码迷,mamicode.com
首页 > 其他好文 > 详细

Printer Print Queue

时间:2014-09-05 18:07:31      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   ar   for   art   

  1. PrinterServer:在打印服务器上管理打印队列。
    bubuko.com,布布扣
     1 // Create a PrintServer
     2 // "theServer" must be a print server to which the user has full print access.
     3 PrintServer myPrintServer = new PrintServer(@"\\theServer");
     4 
     5 // List the print server‘s queues
     6 PrintQueueCollection myPrintQueues = myPrintServer.GetPrintQueues();
     7 String printQueueNames = "My Print Queues:\n\n";
     8 foreach (PrintQueue pq in myPrintQueues)
     9 {
    10     printQueueNames += "\t" + pq.Name + "\n";
    11 }
    12 Console.WriteLine(printQueueNames);
    13 Console.WriteLine("\nPress Return to continue.");
    14 Console.ReadLine();
    View Code
  2. PrintQueue:管理打印机与打印作业
  3. PrintSystemJobInfo:详细定义打印作业
  4. PrintJobStatus:指定打印队列中打印作业的当前状态。
  5. PrintQueueStatus:指定打印队列或其打印机的状态。
  6. PrintQueue.QueueStatus:获取用于表示打印机状态的值。 这些状态包括“正在预热”、“正在初始化”、“正在打印”等。

 

 

     示例:

 1   public class SystemPrintQueue
 2     {
 3         private string _printerName;
 4         private string _owner;
 5         private PrintQueue _printQueue;
 6 
 7         public SystemPrintQueue(string printerName)
 8         {
 9             _printerName = printerName;
10             _owner = System.Environment.UserName;
11             PrintServer server = new PrintServer(printerName);
12             foreach (PrintQueue pq in server.GetPrintQueues())
13             {
14                 if (pq.FullName.Equals(printerName))
15                 {
16                     _printQueue = pq;
17                 }
18             }
19         }
20 
21         public bool IsPrinted
22         {
23             get
24             {
25                 return CheckIsPrinted(_printQueue);
26             }
27         }
28 
29         /// <summary>
30         /// 检测打印队列是否打印完成
31         /// </summary>
32         /// <param name="pq">打印队列</param>
33         /// <returns></returns>
34         private bool CheckIsPrinted(PrintQueue pq)
35         {
36             bool isPrinted = false;
37             if (pq != null)
38             {
39                 pq.Refresh();
40                 PrintJobInfoCollection jobs = pq.GetPrintJobInfoCollection();
41                 if (jobs != null && jobs.Count() > 0)
42                 {
43                     isPrinted = jobs.All<PrintSystemJobInfo>(job => job.Submitter == System.Environment.UserName && (job.JobStatus & PrintJobStatus.Paused) == PrintJobStatus.Paused);
44                 }
45                 else
46                 {
47                     isPrinted = true;
48                 }
49             }
50             return isPrinted;
51         }
52     }

 

Printer Print Queue

标签:style   blog   http   color   os   io   ar   for   art   

原文地址:http://www.cnblogs.com/JustYong/p/3958423.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!