Reputation: 21
I'm new to C# and I have been assigned to control print jobs (pause, authenticate, resume ) on a print server that has almost 50 IP printers connected to it.
Now, I can pause and access details of print jobs of a particular printer on my development PC using printServer class at run time, like:
PrintServer myprintServer = new PrintServer();
foreach (var job in myprintServer.GetPrintQueue("printerA").GetPrintJobInfoCollection())
job.pause();
While my program is running and print job comes for lets say printerB or printerC they dont get controlled. I would have to run separate loops for all which is not possible.
Is there any way to control and pause all print jobs whether they come for printerA, b, c etc which are received on a print server and check for authentication. Either I havent found needed methods in System.Printing
namespace or task cant be achieved.
Upvotes: 2
Views: 2061
Reputation: 152634
GetPrintQueues
should return a collection of all print queues on a printer:
PrintServer myprintServer = new PrintServer();
foreach (var queue in myprintServer.GetPrintQueues)
foreach (var job in queue.GetPrintJobInfoCollection())
job.pause();
Note that there's an overload that takes a list of valid print queue types
Or use SelectMany
from Linq:
foreach (var job in queue.GetPrintQueues.SelectMany(q => GetPrintJobInfoCollection())
job.pause();
Upvotes: 2