How to know the status of my print job?

Posted by Laghaterohan under C# on 10/9/2010 | Points: 10 | Views : 7972 | Status : [Member] | Replies : 3
Hello!
I am developing ASP.NET 3.5 & C# application. Following is the scenario:

I have two textboxes on my screen where in i enter Sr.No from and Sr. No To numbers . Suppose i enter 1 to 100 and then click on print. In this case my printing should start. However, if suddenly there is some internal error or if there is printer failure i should know the current status ie. how many Sr.No print was successful. And from which number i should start next. etc...

May i know how to achieve this??

Please do let me know..


Thanks! Regards,
Rohan Laghate.

Best Regards,
Rohan Laghate



Responses

Posted by: Lalji_mer on: 10/11/2010 [Member] Bronze | Points: 25

Up
0
Down
you can use below code

public enum PrintJobStatus
// Check for possible trouble states of a print job using the flags of the JobStatus property
internal static void SpotTroubleUsingJobAttributes(PrintSystemJobInfo theJob)
{
if ((theJob.JobStatus & PrintJobStatus.Blocked) == PrintJobStatus.Blocked)
{
Console.WriteLine("The job is blocked.");
}
if (((theJob.JobStatus & PrintJobStatus.Completed) == PrintJobStatus.Completed)
||
((theJob.JobStatus & PrintJobStatus.Printed) == PrintJobStatus.Printed))
{
Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
}
if (((theJob.JobStatus & PrintJobStatus.Deleted) == PrintJobStatus.Deleted)
||
((theJob.JobStatus & PrintJobStatus.Deleting) == PrintJobStatus.Deleting))
{
Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
}
if ((theJob.JobStatus & PrintJobStatus.Error) == PrintJobStatus.Error)
{
Console.WriteLine("The job has errored.");
}
if ((theJob.JobStatus & PrintJobStatus.Offline) == PrintJobStatus.Offline)
{
Console.WriteLine("The printer is offline. Have user put it online with printer front panel.");
}
if ((theJob.JobStatus & PrintJobStatus.PaperOut) == PrintJobStatus.PaperOut)
{
Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
}

if (((theJob.JobStatus & PrintJobStatus.Paused) == PrintJobStatus.Paused)
||
((theJob.HostingPrintQueue.QueueStatus & PrintQueueStatus.Paused) == PrintQueueStatus.Paused))
{
HandlePausedJob(theJob);
//HandlePausedJob is defined in the complete example.
}

if ((theJob.JobStatus & PrintJobStatus.Printing) == PrintJobStatus.Printing)
{
Console.WriteLine("The job is printing now.");
}
if ((theJob.JobStatus & PrintJobStatus.Spooling) == PrintJobStatus.Spooling)
{
Console.WriteLine("The job is spooling now.");
}
if ((theJob.JobStatus & PrintJobStatus.UserIntervention) == PrintJobStatus.UserIntervention)
{
Console.WriteLine("The printer needs human intervention.");
}

}//end SpotTroubleUsingJobAttributes
Reference link
----------
http://www.eggheadcafe.com/sample-code/csharp.NET/e41513e1-dbef-4bf2-96f9-0ba954f3d31b/specifies-the-current-status-of-a-print-job-in-a-print-queue.aspx

If you want to use script then you will get source code from below link
------------------------------------------------------------------------------------------------
http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/printing/servers/#MonPrintJobStatus.htm

LP MER

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 10/11/2010 [Member] Starter | Points: 25

Up
0
Down
Hello LP MER,

Can you please simply the code for me...:)

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prasham on: 10/11/2010 [Member] Starter | Points: 25

Up
0
Down
Hello,

Please check following link whether it could help you :
http://www.codeproject.com/KB/printing/prntjobcontrollerusingwmi.aspx

Thanks
Prasham

Thanks and Best Regards
Prasham

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response