Ver Fonte

设备对接

yhluo há 5 meses atrás
pai
commit
66853c4e01

+ 117 - 14
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.Designer.cs

@@ -39,8 +39,15 @@
             this.time = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.fileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.panel1 = new System.Windows.Forms.Panel();
+            this.LockMakeCode = new UAS_MES_NEW.CustomControl.CustomCheckBox.LockCheckBox();
+            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
+            this.allParse = new System.Windows.Forms.Button();
+            this.label3 = new System.Windows.Forms.Label();
             this.panel2 = new System.Windows.Forms.Panel();
             this.panel3 = new System.Windows.Forms.Panel();
+            this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog();
+            this.lstFiles = new System.Windows.Forms.ListBox();
+            this.claerBtn = new System.Windows.Forms.Button();
             this.panel1.SuspendLayout();
             this.panel2.SuspendLayout();
             this.panel3.SuspendLayout();
@@ -55,17 +62,17 @@
             "SPI设备",
             "AOI设备",
             "印刷机"});
-            this.Device.Location = new System.Drawing.Point(192, 59);
+            this.Device.Location = new System.Drawing.Point(193, 88);
             this.Device.Name = "Device";
             this.Device.Size = new System.Drawing.Size(328, 32);
-            this.Device.TabIndex = 1;
+            this.Device.TabIndex = 2;
             this.Device.SelectedIndexChanged += new System.EventHandler(this.Device_SelectedIndexChanged);
             // 
             // label1
             // 
             this.label1.AutoSize = true;
             this.label1.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label1.Location = new System.Drawing.Point(60, 57);
+            this.label1.Location = new System.Drawing.Point(61, 86);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(101, 30);
             this.label1.TabIndex = 0;
@@ -75,28 +82,28 @@
             // 
             this.label2.AutoSize = true;
             this.label2.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label2.Location = new System.Drawing.Point(60, 137);
+            this.label2.Location = new System.Drawing.Point(61, 159);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(101, 30);
+            this.label2.Size = new System.Drawing.Size(123, 30);
             this.label2.TabIndex = 4;
-            this.label2.Text = "路径选择";
+            this.label2.Text = "文件夹选择";
             // 
             // txtPath
             // 
             this.txtPath.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.txtPath.Location = new System.Drawing.Point(192, 132);
+            this.txtPath.Location = new System.Drawing.Point(193, 154);
             this.txtPath.Name = "txtPath";
             this.txtPath.Size = new System.Drawing.Size(474, 39);
-            this.txtPath.TabIndex = 2;
+            this.txtPath.TabIndex = 3;
             // 
             // Choose
             // 
             this.Choose.Cursor = System.Windows.Forms.Cursors.Hand;
             this.Choose.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Choose.Location = new System.Drawing.Point(692, 130);
+            this.Choose.Location = new System.Drawing.Point(693, 152);
             this.Choose.Name = "Choose";
             this.Choose.Size = new System.Drawing.Size(122, 38);
-            this.Choose.TabIndex = 5;
+            this.Choose.TabIndex = 4;
             this.Choose.Text = "选择";
             this.Choose.UseVisualStyleBackColor = true;
             this.Choose.Click += new System.EventHandler(this.Choose_Click);
@@ -115,12 +122,13 @@
             this.logList.Dock = System.Windows.Forms.DockStyle.Fill;
             this.logList.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.logList.HideSelection = false;
-            this.logList.Location = new System.Drawing.Point(0, 0);
+            this.logList.Location = new System.Drawing.Point(958, 0);
             this.logList.Name = "logList";
-            this.logList.Size = new System.Drawing.Size(814, 492);
+            this.logList.Size = new System.Drawing.Size(346, 492);
             this.logList.TabIndex = 6;
             this.logList.UseCompatibleStateImageBehavior = false;
             this.logList.View = System.Windows.Forms.View.Details;
+            this.logList.Visible = false;
             // 
             // sn
             // 
@@ -139,6 +147,12 @@
             // 
             // panel1
             // 
+            this.panel1.BackColor = System.Drawing.SystemColors.Control;
+            this.panel1.Controls.Add(this.claerBtn);
+            this.panel1.Controls.Add(this.LockMakeCode);
+            this.panel1.Controls.Add(this.ma_code);
+            this.panel1.Controls.Add(this.allParse);
+            this.panel1.Controls.Add(this.label3);
             this.panel1.Controls.Add(this.Device);
             this.panel1.Controls.Add(this.label1);
             this.panel1.Controls.Add(this.Choose);
@@ -150,8 +164,64 @@
             this.panel1.Size = new System.Drawing.Size(1304, 334);
             this.panel1.TabIndex = 7;
             // 
+            // LockMakeCode
+            // 
+            this.LockMakeCode.AutoSize = true;
+            this.LockMakeCode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.LockMakeCode.LeaveEvent = false;
+            this.LockMakeCode.Location = new System.Drawing.Point(520, 25);
+            this.LockMakeCode.Margin = new System.Windows.Forms.Padding(4);
+            this.LockMakeCode.Name = "LockMakeCode";
+            this.LockMakeCode.Size = new System.Drawing.Size(72, 28);
+            this.LockMakeCode.TabIndex = 1;
+            this.LockMakeCode.Text = "锁定";
+            this.LockMakeCode.UseVisualStyleBackColor = true;
+            // 
+            // ma_code
+            // 
+            this.ma_code.AllPower = null;
+            this.ma_code.BackColor = System.Drawing.SystemColors.Control;
+            this.ma_code.Caller = null;
+            this.ma_code.Condition = null;
+            this.ma_code.DBTitle = null;
+            this.ma_code.FormName = null;
+            this.ma_code.Location = new System.Drawing.Point(193, 25);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(4);
+            this.ma_code.Name = "ma_code";
+            this.ma_code.Power = null;
+            this.ma_code.ReturnData = null;
+            this.ma_code.SelectField = null;
+            this.ma_code.SetValueField = null;
+            this.ma_code.Size = new System.Drawing.Size(224, 32);
+            this.ma_code.TabIndex = 0;
+            this.ma_code.TableName = null;
+            this.ma_code.TextBoxEnable = true;
+            // 
+            // allParse
+            // 
+            this.allParse.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.allParse.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.allParse.Location = new System.Drawing.Point(836, 152);
+            this.allParse.Name = "allParse";
+            this.allParse.Size = new System.Drawing.Size(122, 38);
+            this.allParse.TabIndex = 5;
+            this.allParse.Text = "批量解析";
+            this.allParse.UseVisualStyleBackColor = true;
+            this.allParse.Click += new System.EventHandler(this.allParse_Click);
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label3.Location = new System.Drawing.Point(61, 23);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(57, 30);
+            this.label3.TabIndex = 6;
+            this.label3.Text = "工单";
+            // 
             // panel2
             // 
+            this.panel2.Controls.Add(this.logList);
             this.panel2.Controls.Add(this.panel3);
             this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
             this.panel2.Location = new System.Drawing.Point(0, 334);
@@ -161,13 +231,39 @@
             // 
             // panel3
             // 
-            this.panel3.Controls.Add(this.logList);
+            this.panel3.Controls.Add(this.lstFiles);
             this.panel3.Dock = System.Windows.Forms.DockStyle.Left;
             this.panel3.Location = new System.Drawing.Point(0, 0);
             this.panel3.Name = "panel3";
-            this.panel3.Size = new System.Drawing.Size(814, 492);
+            this.panel3.Size = new System.Drawing.Size(958, 492);
             this.panel3.TabIndex = 7;
             // 
+            // openFileDialog2
+            // 
+            this.openFileDialog2.FileName = "openFileDialog2";
+            // 
+            // lstFiles
+            // 
+            this.lstFiles.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.lstFiles.FormattingEnabled = true;
+            this.lstFiles.ItemHeight = 18;
+            this.lstFiles.Location = new System.Drawing.Point(0, 0);
+            this.lstFiles.Name = "lstFiles";
+            this.lstFiles.Size = new System.Drawing.Size(958, 492);
+            this.lstFiles.TabIndex = 0;
+            // 
+            // claerBtn
+            // 
+            this.claerBtn.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.claerBtn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.claerBtn.Location = new System.Drawing.Point(978, 151);
+            this.claerBtn.Name = "claerBtn";
+            this.claerBtn.Size = new System.Drawing.Size(122, 38);
+            this.claerBtn.TabIndex = 7;
+            this.claerBtn.Text = "清除";
+            this.claerBtn.UseVisualStyleBackColor = true;
+            this.claerBtn.Click += new System.EventHandler(this.claerBtn_Click);
+            // 
             // Make_ParseLog
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
@@ -203,5 +299,12 @@
         private System.Windows.Forms.ColumnHeader time;
         private System.Windows.Forms.ColumnHeader fileName;
         private System.Windows.Forms.ColumnHeader sn;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Button allParse;
+        private CustomControl.TextBoxWithIcon.MaCodeSearchTextBox ma_code;
+        private CustomControl.CustomCheckBox.LockCheckBox LockMakeCode;
+        private System.Windows.Forms.OpenFileDialog openFileDialog2;
+        private System.Windows.Forms.ListBox lstFiles;
+        private System.Windows.Forms.Button claerBtn;
     }
 }

+ 240 - 20
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs

@@ -1,4 +1,6 @@
-using DevExpress.XtraPrinting;
+using BarTender;
+using DevExpress.Xpo.Logger;
+using DevExpress.XtraPrinting;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -6,11 +8,17 @@ using System.Data;
 using System.Drawing;
 using System.IO;
 using System.Linq;
+using System.Security;
+using System.Security.AccessControl;
+using System.Security.Principal;
 using System.Text;
 using System.Threading.Tasks;
 using System.Web.Services.Description;
+using System.Web.UI.WebControls;
 using System.Windows.Forms;
 using System.Xml;
+using UAS_MES_NEW.CustomControl.ButtonUtil;
+using UAS_MES_NEW.CustomControl.TextBoxWithIcon;
 using UAS_MES_NEW.DataOperate;
 using UAS_MES_NEW.Entity;
 using UAS_MES_NEW.PublicMethod;
@@ -24,19 +32,86 @@ namespace UAS_MES_NEW.Make
         {
             InitializeComponent();
         }
+        LogStringBuilder sql = new LogStringBuilder();
+        DataTable Dbfind;
+        DataTable dt;
+
         DataHelper dh;
+        string currFileType = "";
+
+        string SN,omakeCode, oMsid, oErrorMessage= "";
+        string equiType = "";
         private void Make_ParseLog_Load(object sender, EventArgs e)
         {
             dh = SystemInf.dh;
+
+            //设置锁定工单
+            LockMakeCode.GetMakeCodeCtl(ma_code);
+            ma_code.SetLockCheckBox(LockMakeCode);
+            //工单号放大镜配置
+            ma_code.TableName = "make left join product on ma_prodcode=pr_code";
+            ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称";
+            ma_code.FormName = Name;
+            ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
+            ma_code.Condition = "ma_statuscode='STARTED'";
+            ma_code.DbChange += Ma_code_DbChange;
+        }
+        private void Ma_code_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = ma_code.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
+            //获取工单的其他信息
+            sql.Clear();
+            sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode as pr_code ,pr_detail,");
+            sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty from make left join makecraftdetail on ");
+            sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
+            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+            if (dt.Rows.Count > 0)
+            {
+                BaseUtil.SetFormValue(this.Controls, dt);
+            }
         }
+
         private void Device_SelectedIndexChanged(object sender, EventArgs e)
         {
+            if (string.IsNullOrEmpty(ma_code.Text))
+            {
+                Device.SelectedIndex = -1;
+                MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+                return;
+            }
             txtPath.Focus();
             txtPath.SelectAll();
         }
-
+        private void allParse_Click(object sender, EventArgs e)
+        {
+            if (string.IsNullOrEmpty(ma_code.Text))
+            {
+                MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+                return;
+            }
+            if (Device.SelectedIndex == -1)
+            {
+                Device.Focus();
+                Device.SelectAll();
+                MessageBox.Show(this.ParentForm, "请选择设备", "提示");
+                return;
+            }
+            if (String.IsNullOrEmpty(txtPath.Text))
+            {
+                txtPath.Focus();
+                txtPath.SelectAll();
+                return;
+            }
+            RefreshFileList();
+        }
         private void Choose_Click(object sender, EventArgs e)
         {
+            if (string.IsNullOrEmpty(ma_code.Text))
+            {
+                MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+                return;
+            }
             if (Device.SelectedIndex == -1)
             {
                 Device.Focus();
@@ -50,20 +125,55 @@ namespace UAS_MES_NEW.Make
                 txtPath.SelectAll();
             }
             try {
-                OpenFileDialog dialog = new OpenFileDialog();
-                /*dialog.Multiselect = true;//该值确定是否可以选择多个文件*/
+                FolderBrowserDialog dialog = new FolderBrowserDialog();
                 switch (Device.SelectedIndex)
                 {
                     case 0:
-                        dialog.Title = "请选择读取SPI设备文本文件";
-                        dialog.Filter = "文本文件 (*.txt)|*.txt|All files (*.*)|*.*";
+                        dialog.Description = "请选择读取SPI设备文件夹";
+                        currFileType = "txt";
+                        equiType = "1";
+                        break;
+                    case 1:
+                        dialog.Description = "请选择读取AOI设备文本文件";
+                        currFileType = "txt";
+                        equiType = "2";
+                        break;
+                    case 2:
+                        dialog.Description = "请选择读取印刷机设备的文本文件夹";
+                        currFileType = "xml";
+                        equiType = "3";
+                        break;
+                }
+                if (dialog.ShowDialog() == DialogResult.OK)
+                {
+                    txtPath.Text = dialog.SelectedPath;
+                    txtPath.Enabled = false;
+                    Device.Enabled = false;
+                    var watcher = new FileSystemWatcher(txtPath.Text);
+                    watcher.Filter = $"*.{currFileType}";
+                    watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
+                    watcher.Created += OnFileCreated;
+                    /*watcher.Changed += OnFileChanged;
+                    watcher.Deleted += OnFileChanged;
+                    watcher.Renamed += OnFileChanged;*/
+                    watcher.EnableRaisingEvents = true;
+                }
+                #region
+                /*OpenFileDialog dialog = new OpenFileDialog();
+                dialog.Multiselect = true;//该值确定是否可以选择多个文件
+                dialog.Filter = "文本文件 (*.txt)|*.txt|All files (*.*)|*.*";
+                switch (Device.SelectedIndex)
+                {
+                    case 0:
+                        dialog.Title = "请选择读取SPI设备文件夹";
+                        dialog.Filter = "All files (*.*)|*.*";
                         break;
                     case 1:
                         dialog.Title = "请选择读取AOI设备文本文件";
-                        dialog.Filter = "文本文件 (*.txt)|*.txt|All files (*.*)|*.*";
+                        dialog.Filter = "All files (*.*)|*.*";
                         break;
                     case 2:
-                        dialog.Title = "请选择读取印刷机设备的文本文件";
+                        dialog.Title = "请选择读取印刷机设备的文本文件";
                         dialog.Filter = "文本文件 (*.xml)|*.xml|All files (*.*)|*.*";
                         break;
                 }
@@ -93,13 +203,77 @@ namespace UAS_MES_NEW.Make
                 {
                     PrinterData xmlData = ReadWithXmlReader(txtPath.Text);
                     Console.WriteLine();
-                }
+                }*/
+                #endregion
             }
             catch (Exception ex)
             {
                 MessageBox.Show(this.ParentForm, ex.Message, "警告");
             }
         }
+        private void OnFileCreated(object sender, FileSystemEventArgs e)
+        {
+            RefreshFileList();
+        }
+        private void OnFileChanged(object sender, FileSystemEventArgs e)
+        {
+            if (e.ChangeType == WatcherChangeTypes.Changed)
+            {
+                RefreshFileList();
+            }
+        }
+        private void RefreshFileList()
+        {
+            // 在UI线程上执行更新
+            if (lstFiles.InvokeRequired)
+            {
+                lstFiles.Invoke(new Action(RefreshFileList));
+                return;
+            }
+
+            try
+            {
+                if (!Directory.Exists(txtPath.Text))
+                {
+                    LogMessage($"目录不存在: {txtPath.Text}");
+                    return;
+                }
+
+                string[] txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
+
+                if (txtFiles.Length == 0)
+                {
+                    LogMessage($"当前没有{currFileType.ToUpper()}文件");
+                    return;
+                }
+                else
+                {
+                    foreach (string file in txtFiles)
+                    {
+                        LogMessage(file);
+                        if (Device.SelectedIndex == 0) // SPI
+                        {
+                            ParseLogInsert(file);
+                            Console.WriteLine();
+                        }
+                        else if (Device.SelectedIndex == 1) // AOI
+                        {
+
+                        }
+                        else if (Device.SelectedIndex == 2) // 印刷机
+                        {
+                            PrinterData xmlData = ReadWithXmlReader(file);
+                            Console.WriteLine();
+                        }
+                    }
+                    LogMessage($"共找到{txtFiles.Length}个{currFileType.ToUpper()}文件");
+                }
+            }
+            catch (Exception ex)
+            {
+                LogMessage($"刷新文件列表时出错: {ex.Message}");
+            }
+        }
 
         private void ParseLogInsert(string PathName)
         {
@@ -110,10 +284,14 @@ namespace UAS_MES_NEW.Make
                 SR.Close();
                 SR.Dispose();
 
+                ConsoleLog(restOfStream, PathName);
+
                 List<Log> logArr = new List<Log>() { };
                 string[] lines = restOfStream.Split(new string[] { "\r\n" }, StringSplitOptions.None);
-                foreach(var item in lines)
+                LogMessage($"文件夹{PathName},共{lines.Length}条记录");
+                foreach (var item in lines)
                 {
+                    if (string.IsNullOrEmpty(item)) continue;
                     string[] currItem = item.Split(',');
                     string res = "";
                     /*List<NgData> data = new List<NgData>();*/
@@ -145,15 +323,20 @@ namespace UAS_MES_NEW.Make
                         Details = currItem[1]
                     };
                     logArr.Add(itemLog);
+
+                    LogMessage($"已解析: {currItem[0]}");
                 }
-                InsertDb(logArr);
+                InsertDb(logArr, PathName);
+
+                File.WriteAllText(PathName, string.Empty);
+                File.Delete(PathName);
             }
             catch (Exception ex) 
             {
                 MessageBox.Show(this.ParentForm, ex.Message, "警告");
             }
         }
-        private void InsertDb(List<Log> logs)
+        private void InsertDb(List<Log> logs, string PathName)
         {
             try
             {
@@ -162,8 +345,8 @@ namespace UAS_MES_NEW.Make
                 List<string> param = new List<string>() { };
                 foreach (var item in logs)
                 {
-                    ConsoleLog(item);
                     param.Add(item.SN);
+                    param.Add(ma_code.Text);
                     if (item.Result == "PASS")
                     {
                         param.Add(item.Result);
@@ -172,6 +355,7 @@ namespace UAS_MES_NEW.Make
                     {
                         param.Add(item.Result);
                     }
+                    param.Add(equiType);
                     param.Add(item.Details);
                     param.Add(User.UserCode);
                     param.Add(User.UserSourceCode);
@@ -180,8 +364,32 @@ namespace UAS_MES_NEW.Make
                     param.Add(res);
                     string[] paramList = param.ToArray();
                     dh.CallProcedure("cs_insert_testrejects", ref paramList);
-                    Console.WriteLine(res);
                     param.Clear();
+
+                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, item.SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
+                    {
+                        if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, item.SN, "日志解析", "OK", User.UserCode, out oErrorMessage))
+                        {
+                            if (oErrorMessage.Contains("AFTERSUCCESS")) LogMessage(">>" + oErrorMessage + "\n");
+                            sql.Clear();
+                            sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
+                            sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
+                            sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "'  and mcd_stepcode='" + User.CurrentStepCode + "'");
+                            dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                            BaseUtil.SetFormValue(Controls, dt);
+                            //记录日志
+                            LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析成功", item.SN, "");
+                            LogMessage("<<解析成功\n");
+                        }
+                        else
+                        {
+                            LogMessage(">>" + oErrorMessage + "\n");
+                        }
+                    }
+                    else
+                    {
+                        LogMessage(">>" + oErrorMessage + "\n");
+                    }
                 }
             }
             catch (Exception ex)
@@ -190,11 +398,11 @@ namespace UAS_MES_NEW.Make
             }
         }
 
-        private void ConsoleLog(Log item)
+        private void ConsoleLog(string Content, string PathName)
         {
             try
             {
-                string sourceDir = Path.GetDirectoryName(txtPath.Text);
+                string sourceDir = Path.GetDirectoryName(PathName);
                 string newFolderName = "Logs";
                 string newFolderPath = Path.Combine(sourceDir, newFolderName);
 
@@ -202,18 +410,26 @@ namespace UAS_MES_NEW.Make
                 {
                     Directory.CreateDirectory(newFolderPath);
                 }
-                string newFileName = "Log_" + Path.GetFileName(txtPath.Text);
+                string newFileName = "Log_" + Path.GetFileName(PathName);
                 string newFilePath = Path.Combine(newFolderPath, newFileName);
 
-                string newContent = $"Time: {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} SN:{item.SN},Result:{item.Result},NgDetails:{item.Details}\r\n";
-                File.AppendAllText(newFilePath, newContent);
+                File.AppendAllText(newFilePath, Content + Environment.NewLine);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(this.ParentForm, ex.Message, "警告");
             }
         }
-
+        private void LogMessage(string message)
+        {
+            if (lstFiles.InvokeRequired)
+            {
+                lstFiles.Invoke(new Action<string>(LogMessage), message);
+                return;
+            }
+            lstFiles.Items.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
+            lstFiles.TopIndex = lstFiles.Items.Count - 1;
+        }
         private PrinterData ReadWithXmlReader(string filePath)
         {
             PrinterData data = new PrinterData();
@@ -353,5 +569,9 @@ namespace UAS_MES_NEW.Make
             public string StencilNum { get; set; }
         }
 
+        private void claerBtn_Click(object sender, EventArgs e)
+        {
+            lstFiles.Items.Clear();
+        }
     }
 }

+ 3 - 0
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.resx

@@ -120,4 +120,7 @@
   <metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 23</value>
   </metadata>
+  <metadata name="openFileDialog2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>224, 23</value>
+  </metadata>
 </root>