Pārlūkot izejas kodu

打印机进程处理修改

Hcsy 8 gadi atpakaļ
vecāks
revīzija
47f9ed2b2e

+ 3 - 8
UAS-MES/FunctionCode/Make/Make_PalletWeigh.cs

@@ -69,20 +69,15 @@ namespace UAS_MES.Make
             try
             {
                 lbl = new ApplicationClass();
-                String str = SystemInf.ProcessesID + "|" + lbl.PID;
-                string sysdisc = Environment.GetEnvironmentVariable("windir").Substring(0, 1);
-                FileStream fs = new FileStream(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt", FileMode.Append, FileAccess.Write);
-                Console.WriteLine(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt");
-                StreamWriter sw = new StreamWriter(fs);
-                sw.WriteLine(str, Encoding.UTF8);
-                sw.Close();
-                fs.Close();
+                BaseUtil.WriteLbl(lbl);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("未安装codesoft");
             }
         }
+
+
         private void Make_PalletWeigh_SizeChanged(object sender, EventArgs e)
         {
             asc.controlAutoSize(this);

+ 5 - 3
UAS-MES/Main.cs

@@ -113,14 +113,16 @@ namespace UAS_MES
                         {
                         }
                         Console.WriteLine("删除");
+                        FileStream fs = new FileStream(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt", FileMode.Open, FileAccess.Read);
+                        StreamReader sr = new StreamReader(fs);
+                        String s = sr.ReadToEnd();
+                        sr.Close();
+                        fs.Close();
                         FileStream fas = new FileStream(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt", FileMode.Create, FileAccess.ReadWrite);
                         StreamWriter sw = new StreamWriter(fas);
-                        StreamReader sr = new StreamReader(fas);
-                        String s = sr.ReadToEnd();
                         sw.Write(s.Replace(line+"\r\n",""));
                         sw.Flush();
                         sw.Close();
-                        sr.Close();
                         fas.Close();
                     }              
                 }

+ 21 - 2
UAS-MES/PublicMethod/BaseUtil.cs

@@ -1,4 +1,5 @@
-using System;
+using LabelManager2;
+using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -16,6 +17,7 @@ using UAS_MES.CustomControl.DataGrid_View;
 using UAS_MES.CustomControl.GroupBoxWithBorder;
 using UAS_MES.CustomControl.TextBoxWithIcon;
 using UAS_MES.CustomControl.ValueLabel;
+using UAS_MES.Entity;
 using static System.Windows.Forms.Control;
 
 namespace UAS_MES.PublicMethod
@@ -230,7 +232,7 @@ namespace UAS_MES.PublicMethod
         /// <param name="LabelName"></param>
         /// <param name="time"></param>
         /// <returns></returns>
-        public static string GetLabelUrl(string URL, string LabelName, DateTime time)
+        public static string GetLabelUrl(string URL, string LabelName, System.DateTime time)
         {
             //如果是传入的数据是从FTP取的文件
             if (URL.Contains("ftp:"))
@@ -965,5 +967,22 @@ namespace UAS_MES.PublicMethod
             chart1.Legends[0].Title = _title;
             //chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
         }
+
+
+        /// <summary>
+        /// 将新增打印进程信息写入静态文件
+        /// </summary>
+        /// <param name="lbl"></param>
+        public static void WriteLbl(ApplicationClass lbl)
+        {
+            String str = SystemInf.ProcessesID + "|" + lbl.PID;
+            string sysdisc = Environment.GetEnvironmentVariable("windir").Substring(0, 1);
+            FileStream fs = new FileStream(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt", FileMode.Append, FileAccess.Write);
+            Console.WriteLine(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt");
+            StreamWriter sw = new StreamWriter(fs);
+            sw.WriteLine(str, Encoding.UTF8);
+            sw.Close();
+            fs.Close();
+        }
     }
 }