当前位置: 首页 > 编程语言 > C#

如何使用C#检查打印作业状态Share

时间:2023-04-10 21:44:08 C#

如何使用C#检查打印作业状态现在我想知道何时打印此作业。我希望会有一些我可以订阅并处理的事件。但我找不到它。所以现在我转向民意调查。并检查PrinterSystemJobInfo对象的JobStatus。但在我的例子中,这要么给我JobStatus=None要么JobStatus=Printing。PrinterSystemJobInfo.JobStatus谁能告诉我如何使用C#可靠地检查打印作业状态?Microsoft帮助和支持网站上有一篇关于如何使用VisualC#.NET将原始数据发送到打印机的好文章。http://support.microsoft.com/kb/322091嗯,你可以检查这个例子中的SendBytesToPrinter方法;它返回打印结果。您也可以使用以下代码:publicenumPrintJobStatus//使用JobStatus属性的标志检查打印作业的可能故障状态internalstaticvoidSpotTroubleUsingJobAttributes(PrintSystemJobInfotheJob){if((theJob.JobStatus&PrintJobStatus.Blocked)==PrintJobStatus.Blocked){Console.WriteLine("作业被阻止。");}if(((theJob.JobStatus&PrintJobStatus.Completed)==PrintJobStatus.Completed)||((theJob.JobStatus&PrintJobStatus.Printed)==PrintJobStatus.Printed)){Console.WriteLine("作业已经完成。有用户重新检查所有出纸槽并确保检查的是正确的打印机。");}if(((theJob.JobStatus&PrintJobStatus.Deleted)==PrintJobStatus.Deleted)||((theJob.JobStatus&PrintJobStatus.Deleting)==PrintJobStatus.Deleting)){Console.WriteLine("用户或管理人员队列权限已删除作业。必须重新提交。");}如果((theJob.JobStatus&PrintJobStatus.Error)==PrintJobStatus.Error){Console.WriteLine("作业出错。");}if((theJob.JobStatus&PrintJobStatus.Offline)==PrintJobStatus.Offline){Console.WriteLine("打印机脱机。让用户通过打印机前面板将其联机。");}if((theJob.JobStatus&PrintJobStatus.PaperOut)==PrintJobStatus.PaperOut){Console.WriteLine("打印机用完了作业所需尺寸的纸张。请用户添加纸张。");}if(((theJob.JobStatus&PrintJobStatus.Paused)==PrintJobStatus.Paused)||((theJob.HostingPrintQueue.QueueStatus&PrintQueueStatus.Paused)==PrintQueueStatus.Paused)){HandlePausedJob(theJob);//HandlePausedJob在完整示例中定义。}if((theJob.JobStatus&PrintJobStatus.Printing)==PrintJobStatus.Printing){Console.WriteLine("作业正在打印。");}if((theJob.JobStatus&PrintJobStatus.Spooling)==PrintJobStatus.Spooling){Console.WriteLine("作业正在合并。");}if((theJob.JobStatus&PrintJobStatus.UserIntervention)==PrintJobStatus.UserIntervention){Console.WriteLine("打印机需要人工干预。");}}//endSpotTroubleUsingJobAttributes不过第一个提供的方案比较靠谱以上是C#学习教程:如何使用C#查看打印作业状态分享所有内容,如果对大家有用还需要详细了解的C#学习教程,希望大家多多关注——本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: