Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 702
  • Last Modified:

Win32_PrintJob not pausing prints in time

Hi,
I am current creating a small print charger for use at my workplace but I have hit a snag, I am testing the system on a computer that does not serve the printers and it seems to work fine, except for hp 2420 printers. The way it works, to prevent jobs "slipping through" is it pauses the job at the very begining of the program to then checks the user has enough credit etc. but for some reason with these 2420's they just disappear.. they don't pause or print. Does anyone know how to prevent this/why it is happening?

Its as if it dosn't process quick Enough
            string query = "SELECT * FROM Win32_PrintJob";
            using (ManagementObjectSearcher jobQuery = new ManagementObjectSearcher(query))
            {
                using (ManagementObjectCollection jobs = jobQuery.Get())
                {
                    foreach (ManagementObject job in jobs)
                    {
                        job.InvokeMethod("Pause", null);
                        string JobID = job.Properties["JobID"].Value.ToString();
                        string JobSize = job.Properties["Size"].Value.ToString();
                        string JobPages = job.Properties["TotalPages"].Value.ToString();
                        string JobOwner = job.Properties["Owner"].Value.ToString();
                        string JobName = job.Properties["Document"].Value.ToString();
                        string PrinterName = job.Properties["Name"].Value.ToString();

Open in new window

0
Guffie
Asked:
Guffie
  • 4
1 Solution
 
GuffieAuthor Commented:
It seems to be the start printing immediately setting, is there a way to catch the print job with this set?
0
 
activephotoCommented:
your code snippet is not showing how/when you trigger that code, but I would look into using a System.Management.ManagementEventWatcher  
to subscribe on events (you can do it with really short intervals to fetch a job when its created and then do your stuff on the job.
please take a look at another question where I suggested this, where you have links to the documentation and also a code snippet how to implement it.
http://www.experts-exchange.com/Programming/Languages/Q_23920826.html?sfQueryTermInfo=1+activephoto+win32_printjob
I am using this already and havnt missed a printjob even when I subscribe on this remotely to a computer on the other side of the globe.
Good luck!
/ Mikael
0
 
GuffieAuthor Commented:
Thanks! I will look into that today!
0
 
GuffieAuthor Commented:
By the way, this solution worked.
0
 
GuffieAuthor Commented:
Hey
That code works great but only if 1 document is printed at a time, I want it so for eg if 10 people print at one time it will catch all 10 documents.. Do you know how I could achieve this?

I have explored threading but all 10 threads get triggered on the event.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now