private bool PrintDoc(FileSendOnNet file)
        {
            String FilePath = file.mFileFullPath;
            int    flag     = 0;

            PCLConvertCS.PCLConvert pc    = new PCLConvertCS.PCLConvert();
            PCLConvertCS.PDFConvert pcpdf = new PCLConvertCS.PDFConvert();
            string fileOut = file.GetPCLprnfullPath();
            string printer;
            string result = null;

            if (file.GetPrinterName().Equals(""))
            {
                printer = PrintLocal.GetPCLPrinter();
            }
            else
            {
                printer = file.GetPrinterName();
            }

            if (FilePath.ToLower().EndsWith("doc") || FilePath.ToLower().EndsWith("docx"))
            {
                //Step 1
                try{
                    result = pc.WordToPCL(readArgs(FilePath), fileOut, printer);
                    if (result != null)
                    {
                        LogHelper.WriteLog(this.GetType(), "WORD2PCL 转换失败" + result);
                        result = pc.Word2PDFToPCL(readArgs(FilePath), fileOut, printer);
                    }
                }catch (Exception e) {
                    LogHelper.WriteLog(this.GetType(), e.Message);
                }
                finally {
                    if (result == null)
                    {
                        flag = 1;    //转换成功
                    }
                }
            }
            if (FilePath.ToLower().EndsWith("pdf"))
            {
                try
                {
                    result = pcpdf.ConvertPdf2pcl(readArgs(FilePath), fileOut);
                    if (result == null)
                    {
                        flag = 1;     //装换成功
                    }
                    else
                    {
                        //转换失败
                    }
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(this.GetType(), e.Message);
                }
            }
            if (FilePath.ToLower().EndsWith("jpg") || FilePath.ToLower().EndsWith("jpeg") || FilePath.ToLower().EndsWith("JPEG"))
            {
                result = pc.JPGToPCL(FilePath, fileOut);
                if (result == null)
                {
                    flag = 1;
                }
            }
            if (FilePath.ToLower().EndsWith("xlsx") || FilePath.ToLower().EndsWith("xlsm") || FilePath.ToLower().EndsWith("xls"))
            {
#if false
                string sPath = System.IO.Path.GetTempPath() + System.IO.Path.GetFileName(FilePath).Replace(".", "_") + ".pdf";
                Method m     = new Method();

                if (m.Convert2PDF(FilePath, sPath, Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF))
                {
                    string result = pcpdf.ConvertPdf2pcl(readArgs(sPath), fileOut);
                    if (result == null)
                    {
                        flag = 1;
                    }
                }
#else
                string sPath = System.IO.Path.GetTempPath() + System.IO.Path.GetFileNameWithoutExtension(FilePath) + Guid.NewGuid().ToString() + ".pdf";
                Method m     = new Method();

                if (m.Convert2PDF(FilePath, sPath, Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF))
                {
#if true
                    result = pcpdf.ConvertPdf2pcl(readArgs(sPath), fileOut);
#else
                    string result = "测试";
#endif
                    if (result == null)
                    {
                        flag = 1;
                    }
                }
#endif
            }
            if (flag == 1)
            {
                //文件转换成功-发送到打印机
                LogHelper.WriteLog(this.GetType(), "文件转换成功");
                SendPCL2Printer s2p = new SendPCL2Printer();
                return(s2p.SendFile2Printer(fileOut, printer));
            }
            else
            {
                LogHelper.WriteLog(this.GetType(), "文件转换:" + result + "&&&" + FilePath);
                //文件转换失败
                return(false);
            }
            //return false;
        }
        private bool PrintDoc(FileSendOnNet file)
        {
            String FilePath = file.mFileFullPath;
            int    flag     = 0;

            PCLConvertCS.PCLConvert pc    = new PCLConvertCS.PCLConvert();
            PCLConvertCS.PDFConvert pcpdf = new PCLConvertCS.PDFConvert();
            string fileOut = file.GetPCLprnfullPath();
            string printer;

            if (file.GetPrinterName().Equals(""))
            {
                printer = PrintLocalPrint.LocalPrinter.DefaultPrinter();
            }
            else
            {
                printer = file.GetPrinterName();
            }

            if (FilePath.ToLower().EndsWith("doc") || FilePath.ToLower().EndsWith("docx"))
            {
                string result = pc.WordToPCL(readArgs(FilePath), fileOut, printer);
                if (result == null)
                {
                    flag = 1;
                }
            }
            if (FilePath.ToLower().EndsWith("pdf"))
            {
                string result = pcpdf.ConvertPdf2pcl(readArgs(FilePath), fileOut);
                if (result == null)
                {
                    flag = 1;
                }
            }
            if (FilePath.ToLower().EndsWith("jpg") || FilePath.ToLower().EndsWith("jpeg") || FilePath.ToLower().EndsWith("JPEG"))
            {
                string result = pc.JPGToPCL(FilePath, fileOut);
                if (result == null)
                {
                    flag = 1;
                }
            }
            if (FilePath.ToLower().EndsWith("xlsx") || FilePath.ToLower().EndsWith("xlsm") || FilePath.ToLower().EndsWith("xls"))
            {
#if false
                string sPath = System.IO.Path.GetTempPath() + System.IO.Path.GetFileName(FilePath).Replace(".", "_") + ".pdf";
                Method m     = new Method();

                if (m.Convert2PDF(FilePath, sPath, Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF))
                {
                    string result = pcpdf.ConvertPdf2pcl(readArgs(sPath), fileOut);
                    if (result == null)
                    {
                        flag = 1;
                    }
                }
#else
                string sPath = System.IO.Path.GetTempPath() + System.IO.Path.GetFileNameWithoutExtension(FilePath) + Guid.NewGuid().ToString() + ".pdf";
                Method m     = new Method();

                if (m.Convert2PDF(FilePath, sPath, Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF))
                {
#if true
                    string result = pcpdf.ConvertPdf2pcl(readArgs(sPath), fileOut);
#else
                    string result = "测试";
#endif
                    if (result == null)
                    {
                        flag = 1;
                    }
                }
#endif
            }
            if (flag == 1)
            {
                //文件转换成功-发送到打印机
                SendPCL2Printer s2p = new SendPCL2Printer();

                return(s2p.SendFile2Printer(fileOut, printer));
            }
            else
            {
                Debug.Assert(false);
                //文件转换失败
                return(false);
            }
        }
        public void  GetPrintTaskInfo()
        {
            string       orderid        = "";
            string       copies         = "";
            string       fileid         = "";
            string       filetype       = "";
            string       filename       = "";
            string       printer        = "";
            string       page           = "";
            string       peisong        = "";
            string       time           = "";
            bool         isdouble       = false;
            bool         iscolor        = false;
            int          flag           = 0;
            String       post_send_data = "userID=" + c_userID + "&" + "licenseCode=" + c_licenseCode;
            HttpRsepData RespData       = Post2ReceiveData(this.url_GetTask, post_send_data);

            if (Jsontext != "" && Jsontext != null)
            {
                GetPrintTask  obj       = new GetPrintTask();
                List <Object> orderlist = obj.getTaskFromCloud(Jsontext);//获得云中任务
                List <report> r         = new List <report>();
                if (orderlist.Count != 0)
                {
                    for (int i = 0; i < orderlist.Count; i++)
                    {
                        Orders order = (Orders)orderlist[i];


                        if (order.IsDuplex == "1")
                        {
                            isdouble = false;
                        }
                        if (order.IsDuplex == "2")
                        {
                            isdouble = true;
                        }
                        if (order.Iscolor == "黑白")
                        {
                            iscolor = false;
                        }
                        else
                        {
                            iscolor = true;
                        }
                        copies   = order.Printcopies;
                        fileid   = order.FileID;
                        filetype = order.Filetype;
                        page     = order.Prtpage;
                        filename = order.Filename;
                        peisong  = order.Peisong;
                        printer  = order.Printer;

                        string   printers = PCLConvertCS.PCLToPrinter.GetAllPrinter();
                        string[] all      = printers.Split(';');
                        string   x        = "";
                        string   murl     = url;
                        murl += "/machine/privateDownloadFileHandler.ashx";
                        DownLoadFile obj2 = new DownLoadFile(@murl);
                        obj2.getFileFromCloud(orderlist);
                        string FilePath = System.IO.Directory.GetCurrentDirectory() + @"\下载文档\";
                        FilePath += fileid + "." + filetype;
                        string fileOut                = System.IO.Directory.GetCurrentDirectory() + @"\PCL\" + fileid + ".prn";//移动到哪里
                        PCLConvertCS.PCLConvert pc    = new PCLConvertCS.PCLConvert();
                        PCLConvertCS.PDFConvert pcpdf = new PCLConvertCS.PDFConvert();
                        string fileOutFJ              = System.IO.Directory.GetCurrentDirectory() + @"\PCL\" + fileid + "FJ" + ".prn";

                        if (FilePath.ToLower().EndsWith("doc") || FilePath.ToLower().EndsWith("docx"))
                        {
                            string result = pc.WordToPCL(readArgs(FilePath, copies, iscolor, isdouble, page), fileOut, printer);
                            if (result == null)
                            {
                                flag = 1;
                            }
                        }
                        if (FilePath.ToLower().EndsWith("pdf"))
                        {
                            string result = pcpdf.ConvertPdf2pcl(readArgs(FilePath, copies, iscolor, isdouble, page), fileOut);
                            if (result == null)
                            {
                                flag = 1;
                            }
                        }
                        if (FilePath.ToLower().EndsWith("jpg") || FilePath.ToLower().EndsWith("jpeg") || FilePath.ToLower().EndsWith("JPEG"))
                        {
                            string result = pc.JPGToPCL(FilePath, fileOut);
                            if (result == null)
                            {
                                flag = 1;
                            }
                        }
                        if (FilePath.ToLower().EndsWith("xlsx") || FilePath.ToLower().EndsWith("xlsm"))
                        {
                            string sPath = System.IO.Directory.GetCurrentDirectory() + @"\下载文档\" + "\\" + orderid + "\\" + fileid;
                            if (XLSConvertToPDF(FilePath, sPath))
                            {
                                FilePath = sPath + ".pdf";
                                string result = pcpdf.ConvertPdf2pcl(readArgs(FilePath, copies, iscolor, isdouble, page), fileOut);
                                if (result == null)
                                {
                                    flag = 1;
                                }
                            }
                        }
                        if (flag == 1)
                        {
                            string fileOut1 = System.IO.Directory.GetCurrentDirectory() + @"\PCL\" + fileid + ".prn";
                            PCLConvertCS.PCLToPrinter pcl = new PCLConvertCS.PCLToPrinter();
                            // 设置事件触发间隔
                            pcl.SetEventTimeout(2000);
                            // 添加打印监控事件处理handler
                            pcl.OnPCLResult += new PCLConvertCS.PCLToPrinter.PCLResult(pcl_OnPCLResult);
                            string result1 = pcl.SendFileToPrinter(printer, fileOut1);
                            string userid  = order.OrderID;
                            countpage(FilePath);
                            int xpage = 0;
                            if (page == "全部")
                            {
                                xpage = mnum;
                            }
                            else
                            {
                                xpage = m_lastPage - m_firstPage + 1;
                            }
                            int    totalPage = Convert.ToInt32(copies) * xpage;
                            report a         = new report();
                            a.Orderid = order.OrderID;
                            a.Pagenum = totalPage;
                            DirectoryInfo dirInfo = new DirectoryInfo(System.IO.Directory.GetCurrentDirectory() + @"\PCL\");
                            FileInfo[]    files   = dirInfo.GetFiles(); // 获取该目录下的所有文件
                            foreach (FileInfo file in files)
                            {
                                file.Delete();
                            }

                            r.Add(a);
                        }
                    }

                    ReportData R = new ReportData();
                    R.ReportCloud(CreateJsonParameters(r), @url);
                }
            }
        }