소스 검색

Merge commit '32c92f7ab9a14cac19aa285e481893a008fa486e' into zhangxueyang

tags/录制修改前
zhangxueyang 4 년 전
부모
커밋
227d1da0b6
1개의 변경된 파일22개의 추가작업 그리고 7개의 파일을 삭제
  1. 22
    7
      Common/system/LatticeFileHelper.cs

+ 22
- 7
Common/system/LatticeFileHelper.cs 파일 보기

@@ -52,7 +52,10 @@ namespace Common.system
52 52
         /// <param name="PDFPath">PDF文件位置</param>
53 53
         /// <param name="SavePath">保存文件位置 TPF</param>
54 54
         /// <param name="PrintResult">输出结果,非0为失败</param>
55
-        public static void GeneratingPDF(string PDFPath, string SavePath, out int PrintResult, int PointType = 0)
55
+        /// <param name="StandardError">错误信息</param>
56
+        /// <param name="StandardOutput">输出信息["1536.688.35.70","1536.688.35.71","1536.688.35.72"]</param>
57
+        /// <param name="PointType">0 为方点,1 为圆点 默认方点</param>
58
+        public static void GeneratingPDF(string PDFPath, string SavePath, out int PrintResult, out string StandardError, out string StandardOutput, int PointType = 0)
56 59
         {
57 60
             //XML点阵文件位置
58 61
             string XmlFile = FileToolsCommon.GetFileAbsolutePath("/LatticeXML/print_license.xml");
@@ -85,13 +88,18 @@ namespace Common.system
85 88
             PrintProcess.StartInfo.Arguments = ContentParameter;
86 89
             PrintProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
87 90
             PrintProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
91
+            PrintProcess.StartInfo.RedirectStandardOutput = true;
88 92
             PrintProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
89 93
             PrintProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
90 94
             //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
91 95
             PrintProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
92 96
             PrintProcess.Start();                 //启动线程
93
-            PrintProcess.BeginErrorReadLine();    //开始异步读取
94 97
             PrintProcess.WaitForExit();           //阻塞等待进程结束
98
+            StandardError = PrintProcess.StandardError.ReadToEnd();
99
+            StandardOutput = PrintProcess.StandardOutput.ReadToEnd();
100
+            //PrintProcess.BeginErrorReadLine();    //开始异步读取
101
+            Output("【制作点阵文件】错误:" + StandardError);
102
+            Output("【制作点阵文件】返回信息:" + StandardOutput);
95 103
             PrintResult = PrintProcess.ExitCode;     //打印结果 非0则为打印失败
96 104
             Output("【制作点阵文件】" + ContentParameter);//记录打印日志
97 105
             PrintProcess.Close();                 //关闭进程
@@ -144,12 +152,15 @@ namespace Common.system
144 152
         /// <param name="PrinterNum">打印份数</param>
145 153
         /// <param name="PrinterName">打印机名称</param>
146 154
         /// <param name="PrintResult">输出结果,非0为失败</param>
147
-        public static void PrinterTPFFile(string TPFPath, int PrinterNum, string PrinterName, out int PrintResult)
155
+        /// <param name="StandardError">错误信息</param>
156
+        /// <param name="StandardOutput">输出信息</param>
157
+        public static void PrinterTPFFile(string TPFPath, int PrinterNum, string PrinterName, out int PrintResult, out string StandardError, out string StandardOutput)
148 158
         {
159
+            TPFPath = TPFPath.Replace("/", "\\");
149 160
             //XML点阵文件位置
150
-            string XmlFile = FileToolsCommon.GetFileAbsolutePath("/LatticeXML/print_license.xml");
161
+            //string XmlFile = FileToolsCommon.GetFileAbsolutePath("/LatticeXML/print_license.xml");
151 162
             string ContentParameter = null;
152
-            ContentParameter = "-sMode=Print \"-sTPF =" + TPFPath + "\" \"-dCopy= " + PrinterNum + "\" \"-dPaperSize=9\" \"-sPrinter=" + PrinterName + "\"";//[-dPaperSize =] 
163
+            ContentParameter = " -sMode=Print \"-sTPF=" + TPFPath + "\" \"-sPrinter=" + PrinterName + "\" \"-dCopy=" + PrinterNum + "\"";//\"-dPaperSize=9\"
153 164
             #region 打印参数说明
154 165
             //-sMode = Print,参数如下:
155 166
             //PrintTool.exe - sMode = Print - sTPF = [-dCopy =][-dPaperSize =] - sPrinter =
@@ -172,7 +183,7 @@ namespace Common.system
172 183
             }
173 184
             PrintProcess = new Process();
174 185
             LogPath = CreateLog();
175
-            PrintProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath("/PrintTool/PrintTool.exe");   //绝对路径
186
+            PrintProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath("/PrintTool/PrintTool.exe").Replace("/", "\\"); ;   //绝对路径
176 187
             PrintProcess.StartInfo.Arguments = ContentParameter;
177 188
             PrintProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
178 189
             PrintProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
@@ -181,8 +192,12 @@ namespace Common.system
181 192
             //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
182 193
             PrintProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
183 194
             PrintProcess.Start();                 //启动线程
184
-            PrintProcess.BeginErrorReadLine();    //开始异步读取
195
+            //PrintProcess.BeginErrorReadLine();    //开始异步读取
185 196
             PrintProcess.WaitForExit();           //阻塞等待进程结束
197
+            StandardError = PrintProcess.StandardError.ReadToEnd();
198
+            StandardOutput = PrintProcess.StandardOutput.ReadToEnd();
199
+            Output("【制作点阵文件】错误:" + StandardError);
200
+            Output("【制作点阵文件】返回信息:" + StandardOutput);
186 201
             PrintResult = PrintProcess.ExitCode;     //打印结果 非0则为打印失败
187 202
             Output("【打印TPF文件】" + ContentParameter);//记录打印日志
188 203
             PrintProcess.Close();                 //关闭进程

Loading…
취소
저장