批处理图应用程序(PrintServer和PrintQueue问题) [英] Batch plot application (PrintServer & PrintQueue issues)

查看:116
本文介绍了批处理图应用程序(PrintServer和PrintQueue问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿CodeProject成员,

我有一个需要帮助的问题.对于我当前的项目,我需要制作一个批处理图应用程序.此应用程序将需要打印约2000张AutoCAD图形.

该应用程序需要5台打印机,每种格式1台,从A4到A0.到目前为止还没有问题.

现在我们都知道,我们不能在没有某种麻烦的情况下同时排队2000个工程图.我已经在网上进行了研究,并找到了查看当前打印机队列的方法.使用 PrintServer

Hey CodeProject Members,

I have a problem that I need help with. For my current project I need to make a Batch Plot application. This application will have around ~2000 AutoCAD drawings that it will need to print.

The application needs 5 printers, 1 for each format, going from A4 to A0. No problems yet so far.

Now we all understand that we can not queue 2000 drawings simultaneously without some kind of trouble. I''ve did my research online and found methods to look at the current printer Queue. Using PrintServer and PrintQueue.

Here is where the problems begin. Firstly I am not able to find the network printers that I need. The printers are located on this network address: 192.168.0.14 (\\vps01w2k8).

Following the guide from MSDN:

PrintServer m_PrintServer = new PrintServer(@"\\vps01w2k8");
PrintQueueCollection m_PrintQueueCollection = m_PrintServer.GetPrintQueues();

foreach (PrintQueue queue in m_PrintQueueCollection)
{
     cbPrinters.Items.Add(queue.Name.ToString());
}



这没有给我任何打印机.尝试
LocalPrintServer (或者只是不带任何参数的PrintServer).给我我的本地打印机(显然),而不给我我的网络打印机.

我的下一步是找到一种方法来查找所有已安装的打印机,这些打印机使我进入using System.Drawing.Printing;而不是using System.Printing.



This does not give me any printers. Trying LocalPrintServer (or just PrintServer without any parameters passed into it). Gives me my local printers (obviously) and not my network printers.

My next step was to find a method to find all my installed printers which got me into using System.Drawing.Printing; instead of using System.Printing.

foreach (String printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
{
     cbPrinters.Items.Add(printer.ToString());
}



这个简单的代码为我提供了我拥有的所有打印机,包括联网的打印机.但是,现在我陷在.NET 2.0和3.0(及更高版本)之间.类PrinterSettings和PrintServer/PrintQueue没有连接.

最后,我尝试使用 WMI方法访问打印机队列.查询给我结果的Win32_PrintJob.不幸的是,这些附带了10秒钟的锁定来检索这些结果.

我没主意了.我正在寻找一个针对PrintServer的修复程序,以正确返回我的联网打印机,或者有任何建议使用PrinterSettings类进行类似的批处理打印技术.

预先感谢,

Jordy



This simple code gives me all the printers I have, including the networked ones. However, now I am stuck between .NET 2.0 and 3.0 (and onward). The classes PrinterSettings and PrintServer/PrintQueue have no connection.

Lastly I tried to get access to the printer queues using the WMI approach. Querying the Win32_PrintJob which gave me results. Unfortunately these came along with 10 second lock-ups to retrieve these results.

I''m out of ideas. I''m either looking for a fix for the PrintServer to properly return my networked printers or any suggestions to do similar techniques for batch plotting with the PrinterSettings class.

Thanks in advance,

Jordy

推荐答案

找到了它.调用GetPrintQueues时,您必须传递一个EnumeratedPrintQueueTypes数组.现在,它同时返回我的本地和网络打印机(所有已安装的打印机).

Found it. When calling GetPrintQueues you have to pass in an array of EnumeratedPrintQueueTypes. It now returns both my local and network printers (all installed printers).

PrintServer m_PrintServer = new PrintServer(@"\\vps01w2k8");
PrintQueueCollection m_PrintQueueCollection = m_PrintServer.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections });
            
foreach (PrintQueue queue in m_PrintQueueCollection)
{
    cbPrinters.Items.Add(queue.Name.ToString());
}


这篇关于批处理图应用程序(PrintServer和PrintQueue问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆