Make_ParseLog.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. using BarTender;
  2. using DevExpress.Xpo.Logger;
  3. using DevExpress.XtraPrinting;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Security;
  12. using System.Security.AccessControl;
  13. using System.Security.Principal;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Web.Services.Description;
  17. using System.Web.UI.WebControls;
  18. using System.Windows.Forms;
  19. using System.Xml;
  20. using UAS_MES_NEW.CustomControl.ButtonUtil;
  21. using UAS_MES_NEW.CustomControl.TextBoxWithIcon;
  22. using UAS_MES_NEW.DataOperate;
  23. using UAS_MES_NEW.Entity;
  24. using UAS_MES_NEW.PublicMethod;
  25. using static DevExpress.Xpo.DB.DataStoreLongrunnersWatch;
  26. namespace UAS_MES_NEW.Make
  27. {
  28. public partial class Make_ParseLog : Form
  29. {
  30. public Make_ParseLog()
  31. {
  32. InitializeComponent();
  33. }
  34. LogStringBuilder sql = new LogStringBuilder();
  35. DataTable Dbfind;
  36. DataTable dt;
  37. DataHelper dh;
  38. string currFileType = "";
  39. string SN, omakeCode, oMsid, oErrorMessage = "";
  40. string equiType = "";
  41. private void Make_ParseLog_Load(object sender, EventArgs e)
  42. {
  43. dh = SystemInf.dh;
  44. //设置锁定工单
  45. LockMakeCode.GetMakeCodeCtl(ma_code);
  46. ma_code.SetLockCheckBox(LockMakeCode);
  47. //工单号放大镜配置
  48. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  49. ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称";
  50. ma_code.FormName = Name;
  51. ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
  52. ma_code.Condition = "ma_statuscode='STARTED'";
  53. ma_code.DbChange += Ma_code_DbChange;
  54. }
  55. private void Ma_code_DbChange(object sender, EventArgs e)
  56. {
  57. Dbfind = ma_code.ReturnData;
  58. BaseUtil.SetFormValue(this.Controls, Dbfind);
  59. //获取工单的其他信息
  60. sql.Clear();
  61. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode as pr_code ,pr_detail,");
  62. sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty from make left join makecraftdetail on ");
  63. 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 + "'");
  64. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  65. if (dt.Rows.Count > 0)
  66. {
  67. BaseUtil.SetFormValue(this.Controls, dt);
  68. }
  69. }
  70. private void Device_SelectedIndexChanged(object sender, EventArgs e)
  71. {
  72. if (string.IsNullOrEmpty(ma_code.Text))
  73. {
  74. Device.SelectedIndex = -1;
  75. MessageBox.Show(this.ParentForm, "请选择工单", "提示");
  76. return;
  77. }
  78. txtPath.Focus();
  79. txtPath.SelectAll();
  80. }
  81. private void allParse_Click(object sender, EventArgs e)
  82. {
  83. if (string.IsNullOrEmpty(ma_code.Text))
  84. {
  85. MessageBox.Show(this.ParentForm, "请选择工单", "提示");
  86. return;
  87. }
  88. if (Device.SelectedIndex == -1)
  89. {
  90. Device.Focus();
  91. Device.SelectAll();
  92. MessageBox.Show(this.ParentForm, "请选择设备", "提示");
  93. return;
  94. }
  95. if (String.IsNullOrEmpty(txtPath.Text))
  96. {
  97. txtPath.Focus();
  98. txtPath.SelectAll();
  99. return;
  100. }
  101. RefreshFileList();
  102. }
  103. private void Choose_Click(object sender, EventArgs e)
  104. {
  105. if (string.IsNullOrEmpty(ma_code.Text))
  106. {
  107. MessageBox.Show(this.ParentForm, "请选择工单", "提示");
  108. return;
  109. }
  110. if (Device.SelectedIndex == -1)
  111. {
  112. Device.Focus();
  113. Device.SelectAll();
  114. MessageBox.Show(this.ParentForm, "请选择设备", "提示");
  115. return;
  116. }
  117. if (!String.IsNullOrEmpty(txtPath.Text))
  118. {
  119. txtPath.Focus();
  120. txtPath.SelectAll();
  121. }
  122. try
  123. {
  124. FolderBrowserDialog dialog = new FolderBrowserDialog();
  125. switch (Device.SelectedIndex)
  126. {
  127. case 0:
  128. dialog.Description = "请选择读取SPI设备文件夹";
  129. currFileType = "txt";
  130. equiType = "1";
  131. break;
  132. case 1:
  133. dialog.Description = "请选择读取AOI设备文本文件";
  134. currFileType = "txt";
  135. equiType = "2";
  136. break;
  137. case 2:
  138. dialog.Description = "请选择读取印刷机设备的文本文件夹";
  139. currFileType = "xml";
  140. equiType = "3";
  141. break;
  142. case 3:
  143. dialog.Description = "请选择读取贴片机的文本文件夹";
  144. currFileType = "xml";
  145. equiType = "4";
  146. break;
  147. }
  148. if (dialog.ShowDialog() == DialogResult.OK)
  149. {
  150. txtPath.Text = dialog.SelectedPath;
  151. txtPath.Enabled = false;
  152. Device.Enabled = false;
  153. var watcher = new FileSystemWatcher(txtPath.Text);
  154. watcher.Filter = $"*.{currFileType}";
  155. watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
  156. watcher.Created += OnFileCreated;
  157. /*watcher.Changed += OnFileChanged;
  158. watcher.Deleted += OnFileChanged;
  159. watcher.Renamed += OnFileChanged;*/
  160. watcher.EnableRaisingEvents = true;
  161. }
  162. #region
  163. /*OpenFileDialog dialog = new OpenFileDialog();
  164. dialog.Multiselect = true;//该值确定是否可以选择多个文件
  165. dialog.Filter = "文本文件 (*.txt)|*.txt|All files (*.*)|*.*";
  166. switch (Device.SelectedIndex)
  167. {
  168. case 0:
  169. dialog.Title = "请选择读取SPI设备文件夹";
  170. dialog.Filter = "All files (*.*)|*.*";
  171. break;
  172. case 1:
  173. dialog.Title = "请选择读取AOI设备文本文件";
  174. dialog.Filter = "All files (*.*)|*.*";
  175. break;
  176. case 2:
  177. dialog.Title = "请选择读取印刷机设备的文本文件夹";
  178. dialog.Filter = "文本文件 (*.xml)|*.xml|All files (*.*)|*.*";
  179. break;
  180. }
  181. if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  182. {
  183. txtPath.Text = dialog.FileName;
  184. dialog.Dispose();
  185. ListViewItem item = new ListViewItem();
  186. int count = logList.Items.Count;
  187. item.Text = (++count).ToString();
  188. item.SubItems.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  189. item.SubItems.Add(txtPath.Text);
  190. logList.Items.Add(item);
  191. }
  192. if (Device.SelectedIndex == 0) // SPI
  193. {
  194. ParseLogInsert(txtPath.Text);
  195. Console.WriteLine();
  196. }
  197. else if (Device.SelectedIndex == 1) // AOI
  198. {
  199. }
  200. else if (Device.SelectedIndex == 2) // 印刷机
  201. {
  202. PrinterData xmlData = ReadWithXmlReader(txtPath.Text);
  203. Console.WriteLine();
  204. }*/
  205. #endregion
  206. }
  207. catch (Exception ex)
  208. {
  209. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  210. }
  211. }
  212. private void OnFileCreated(object sender, FileSystemEventArgs e)
  213. {
  214. RefreshFileList();
  215. }
  216. private void OnFileChanged(object sender, FileSystemEventArgs e)
  217. {
  218. if (e.ChangeType == WatcherChangeTypes.Changed)
  219. {
  220. RefreshFileList();
  221. }
  222. }
  223. private void RefreshFileList()
  224. {
  225. // 在UI线程上执行更新
  226. if (lstFiles.InvokeRequired)
  227. {
  228. lstFiles.Invoke(new Action(RefreshFileList));
  229. return;
  230. }
  231. try
  232. {
  233. if (!Directory.Exists(txtPath.Text))
  234. {
  235. LogMessage($"目录不存在: {txtPath.Text}");
  236. return;
  237. }
  238. string[] txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
  239. if (txtFiles.Length == 0)
  240. {
  241. LogMessage($"当前没有{currFileType.ToUpper()}文件");
  242. return;
  243. }
  244. else
  245. {
  246. foreach (string file in txtFiles)
  247. {
  248. LogMessage(file);
  249. if (Device.SelectedIndex == 0) // SPI
  250. {
  251. ParseLogInsert(file);
  252. Console.WriteLine();
  253. }
  254. else if (Device.SelectedIndex == 1) // AOI
  255. {
  256. ParseLogInsert(file);
  257. Console.WriteLine();
  258. }
  259. else if (Device.SelectedIndex == 2) // 印刷机
  260. {
  261. PrinterData xmlData = ReadWithXmlReader(file);
  262. Console.WriteLine();
  263. }
  264. else if (Device.SelectedIndex == 3) // 贴片机
  265. {
  266. if (!File.Exists(file))
  267. {
  268. LogMessage($"文件不存在: {file}");
  269. }
  270. string xmlContent = File.ReadAllText(file);
  271. var xmlList = ParseXml(xmlContent);
  272. if (ConsoleLog(xmlContent, file))
  273. {
  274. File.Delete(file);
  275. }
  276. List<string> param = new List<string>() { };
  277. string PS_CODE = "";
  278. LogicHandler.GetSerialNumByCaller("Make!ParseLog", out PS_CODE);
  279. List<string> MachineName = new List<string>();
  280. List<string> Part = new List<string>();
  281. List<string> Station = new List<string>();
  282. List<string> ReelNo = new List<string>();
  283. List<string> letNo = new List<string>();
  284. string Part_ = "";
  285. int letNoNum = 0;
  286. foreach (var item in xmlList)
  287. {
  288. MachineName.Add(item.MachineName);
  289. Part_ = item.Part.Split('.')[0];
  290. Station.Add(item.Station);
  291. ReelNo.Add(item.ReelNo);
  292. letNo.Add((++letNoNum).ToString());
  293. }
  294. string ps_id = "";
  295. string lineId = dh.getFieldDataByCondition("smtlocationinto", "SLI_LANE", "SLI_MCNO='" + MachineName[0] + "'").ToString();
  296. if (!dh.CheckExist("productsmt", "ps_prodcode='" + Part_ + "'"))
  297. {
  298. ps_id = dh.GetSEQ("productsmt_seq");
  299. dh.ExecuteSql("insert into productsmt(ps_id,ps_prodcode,ps_status,ps_statuscode,PS_LINECODE,PS_CODE)" +
  300. "values('" + ps_id + "','" + Part_ + "','在录入','ENTERING','"+ lineId + "','"+ PS_CODE + "')", "insert");
  301. }
  302. else
  303. {
  304. ps_id = dh.getFieldDataByCondition("productsmt", "ps_id", "ps_prodcode='"+Part_+"'").ToString();
  305. }
  306. if (dh.getRowCount("productsmtlocation", "PSL_PSID=" + ps_id) > 0)
  307. {
  308. dh.ExecuteSql("delete from productsmtlocation where PSL_PSID" + ps_id, "delete");
  309. }
  310. sql.Clear();
  311. sql.Append("insert into productsmtlocation(PSL_ID, PSL_PSID, PSL_DETNO, PSL_PRODCODE, PSL_REPCODE, PSL_LOCATION, PSL_BASEQTY, PSL_TABLE)" +
  312. "select productsmtlocation_seq.nextval," + ps_id + ",:letArr, :ReelNo,:ReelNo,:Station,BD_BASEQTY,'' from bom@ERP " +
  313. "left join bomdetail@ERP on bo_id=bd_bomid where bo_mothercode='" + Part_ + "' and BD_SONCODE=:ReelNo");
  314. dh.BatchInsert(sql.GetString(), new string[] {"letArr", "ReelNo", "ReelNo", "Station", "ReelNo" },
  315. letNo.ToArray(),ReelNo.ToArray(), ReelNo.ToArray(), Station.ToArray(), ReelNo.ToArray());
  316. Console.WriteLine();
  317. }
  318. }
  319. LogMessage($"共找到{txtFiles.Length}个{currFileType.ToUpper()}文件");
  320. }
  321. }
  322. catch (Exception ex)
  323. {
  324. LogMessage($"刷新文件列表时出错: {ex.Message}");
  325. }
  326. }
  327. private void ParseLogInsert(string PathName)
  328. {
  329. try
  330. {
  331. StreamReader SR = File.OpenText(PathName);
  332. string restOfStream = SR.ReadToEnd();
  333. SR.Close();
  334. SR.Dispose();
  335. List<Log> logArr = new List<Log>() { };
  336. string[] lines = restOfStream.Split(new string[] { "\r\n" }, StringSplitOptions.None);
  337. LogMessage($"文件夹{PathName},共{lines.Length}条记录");
  338. foreach (var item in lines)
  339. {
  340. if (string.IsNullOrEmpty(item)) continue;
  341. string[] currItem = item.Split(',');
  342. string res = "";
  343. /*List<NgData> data = new List<NgData>();*/
  344. if (currItem[1] != "PASS")
  345. {
  346. res = "NG";
  347. #region
  348. /*string[] NgArr = currItem[1].Split(';');
  349. foreach (var ngItem in NgArr)
  350. {
  351. string[] ngItemArr = ngItem.Split('*');
  352. List<string> ngItemLocal = ngItemArr[1].Split('&').ToList();
  353. NgData ngData = new NgData {
  354. Code = ngItemArr[0],
  355. Local = ngItemLocal
  356. };
  357. data.Add(ngData);
  358. }*/
  359. #endregion
  360. }
  361. else
  362. {
  363. res = "PASS";
  364. }
  365. Log itemLog = new Log()
  366. {
  367. SN = currItem[0],
  368. Result = res,
  369. Details = equiType == "1" ? currItem[1] : currItem[3]
  370. };
  371. logArr.Add(itemLog);
  372. LogMessage($"已解析: {currItem[0]}");
  373. }
  374. InsertDb(logArr, PathName);
  375. File.WriteAllText(PathName, string.Empty);
  376. if (ConsoleLog(restOfStream, PathName))
  377. {
  378. File.Delete(PathName);
  379. }
  380. }
  381. catch (Exception ex)
  382. {
  383. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  384. }
  385. }
  386. private void InsertDb(List<Log> logs, string PathName)
  387. {
  388. try
  389. {
  390. int type = Device.SelectedIndex;
  391. StringBuilder sql = new StringBuilder();
  392. List<string> param = new List<string>() { };
  393. foreach (var item in logs)
  394. {
  395. param.Add(item.SN);
  396. param.Add(ma_code.Text);
  397. if (item.Result == "PASS")
  398. {
  399. param.Add(item.Result);
  400. }
  401. else
  402. {
  403. param.Add(item.Result);
  404. }
  405. param.Add(equiType);
  406. param.Add(item.Details);
  407. param.Add(User.UserCode);
  408. param.Add(User.UserSourceCode);
  409. param.Add(User.UserLineCode);
  410. string res = "";
  411. param.Add(res);
  412. string[] paramList = param.ToArray();
  413. dh.CallProcedure("cs_insert_testrejects", ref paramList);
  414. param.Clear();
  415. if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, item.SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  416. {
  417. if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, item.SN, "日志解析", "OK", User.UserCode, out oErrorMessage))
  418. {
  419. if (oErrorMessage.Contains("AFTERSUCCESS")) LogMessage(">>" + oErrorMessage + "\n");
  420. sql.Clear();
  421. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  422. sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  423. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  424. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  425. BaseUtil.SetFormValue(Controls, dt);
  426. //记录日志
  427. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析成功", item.SN, "");
  428. LogMessage("<<解析成功\n");
  429. }
  430. else
  431. {
  432. LogMessage(">>" + oErrorMessage + "\n");
  433. }
  434. }
  435. else
  436. {
  437. LogMessage(">>" + oErrorMessage + "\n");
  438. }
  439. }
  440. }
  441. catch (Exception ex)
  442. {
  443. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  444. }
  445. }
  446. private bool ConsoleLog(string Content, string PathName)
  447. {
  448. try
  449. {
  450. string sourceDir = Path.GetDirectoryName(PathName);
  451. string newFolderName = "Logs";
  452. string newFolderPath = Path.Combine(sourceDir, newFolderName);
  453. if (!Directory.Exists(newFolderPath))
  454. {
  455. Directory.CreateDirectory(newFolderPath);
  456. }
  457. string newFileName = "Log_" + Path.GetFileName(PathName);
  458. string newFilePath = Path.Combine(newFolderPath, newFileName);
  459. File.AppendAllText(newFilePath, Content + Environment.NewLine);
  460. return true;
  461. }
  462. catch (Exception ex)
  463. {
  464. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  465. return false;
  466. }
  467. }
  468. private void LogMessage(string message)
  469. {
  470. if (lstFiles.InvokeRequired)
  471. {
  472. lstFiles.Invoke(new Action<string>(LogMessage), message);
  473. return;
  474. }
  475. lstFiles.Items.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
  476. lstFiles.TopIndex = lstFiles.Items.Count - 1;
  477. }
  478. private PrinterData ReadWithXmlReader(string filePath)
  479. {
  480. PrinterData data = new PrinterData();
  481. using (XmlReader reader = XmlReader.Create(filePath))
  482. {
  483. while (reader.Read())
  484. {
  485. if (reader.NodeType == XmlNodeType.Element)
  486. {
  487. switch (reader.Name)
  488. {
  489. case "SN":
  490. data.SN = reader.ReadElementContentAsString();
  491. break;
  492. case "Barcode":
  493. data.Barcode = reader.ReadElementContentAsString();
  494. break;
  495. case "Direction":
  496. data.Direction = reader.ReadElementContentAsString();
  497. break;
  498. case "PrintTime":
  499. data.PrintTime = reader.ReadElementContentAsString();
  500. break;
  501. case "PANEL":
  502. ReadPanelData(reader, data.Panel);
  503. break;
  504. case "PROCESS":
  505. ReadProcessData(reader, data.Process);
  506. break;
  507. }
  508. }
  509. }
  510. }
  511. return data;
  512. }
  513. private void ReadPanelData(XmlReader reader, Panel panel)
  514. {
  515. while (reader.Read())
  516. {
  517. if (reader.NodeType == XmlNodeType.Element)
  518. {
  519. switch (reader.Name)
  520. {
  521. case "PanelID":
  522. panel.PanelID = reader.ReadElementContentAsString();
  523. break;
  524. case "PanelName":
  525. panel.PanelName = reader.ReadElementContentAsString();
  526. break;
  527. case "PanelFirm":
  528. panel.PanelFirm = reader.ReadElementContentAsString();
  529. break;
  530. case "PanelLength":
  531. panel.PanelLength = reader.ReadElementContentAsDouble();
  532. break;
  533. case "PanelWide":
  534. panel.PanelWide = reader.ReadElementContentAsDouble();
  535. break;
  536. case "PanelThickness":
  537. panel.PanelThickness = reader.ReadElementContentAsDouble();
  538. break;
  539. }
  540. }
  541. else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "PANEL")
  542. {
  543. break;
  544. }
  545. }
  546. }
  547. private void ReadProcessData(XmlReader reader, Process process)
  548. {
  549. while (reader.Read())
  550. {
  551. if (reader.NodeType == XmlNodeType.Element)
  552. {
  553. switch (reader.Name)
  554. {
  555. case "ProcessName":
  556. process.ProcessName = reader.ReadElementContentAsString();
  557. break;
  558. case "LineNumber":
  559. process.LineNumber = reader.ReadElementContentAsString();
  560. break;
  561. case "StencilNum":
  562. process.StencilNum = reader.ReadElementContentAsString();
  563. break;
  564. }
  565. }
  566. else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "PROCESS")
  567. {
  568. break;
  569. }
  570. }
  571. }
  572. public List<MachineList> ParseXml(string xmlContent)
  573. {
  574. List<MachineList> result = new List<MachineList>();
  575. try
  576. {
  577. XmlDocument xmlDoc = new XmlDocument();
  578. xmlDoc.LoadXml(xmlContent);
  579. XmlNode machineNode = xmlDoc.SelectSingleNode("//TotalProductionInfo");
  580. string machineName = machineNode?.Attributes["MachineName"]?.Value ?? "Unknown";
  581. string part = machineNode?.Attributes["ProductionProgramName"]?.Value ?? "Unknown";
  582. XmlNodeList feederNodes = xmlDoc.SelectNodes("//FeederProductionManageInfo");
  583. foreach (XmlNode feederNode in feederNodes)
  584. {
  585. MachineList machineList = new MachineList();
  586. string feederBankPosition = feederNode.Attributes["FeederBankPosition"]?.Value ?? "Unknown";
  587. string holeNo = feederNode.Attributes["HoleNo"]?.Value ?? "Unknown";
  588. string componentName = feederNode.Attributes["ComponentName"]?.Value ?? "Unknown";
  589. machineList.MachineName = machineName;
  590. machineList.Part = part;
  591. machineList.ReelNo = componentName;
  592. machineList.Station = $"{machineName}-{feederBankPosition[0]}-{holeNo}";
  593. result.Add(machineList);
  594. }
  595. }
  596. catch (Exception ex)
  597. {
  598. LogMessage($"Error parsing XML: {ex.Message}");
  599. }
  600. return result;
  601. }
  602. private class Log
  603. {
  604. public string SN { set; get; }
  605. public string Result { set; get; }
  606. /*public List<NgData> Details { set; get; }*/
  607. public string Details { set; get; }
  608. }
  609. public class MachineList
  610. {
  611. public string MachineName { set; get; }
  612. public string Part { set; get; }
  613. public string Station { set; get; }
  614. public string ReelNo { set; get; }
  615. }
  616. private class NgData
  617. {
  618. public string Code { set; get; }
  619. public List<string> Local { set; get; }
  620. }
  621. private class PrinterData
  622. {
  623. public string SN { get; set; }
  624. public string Barcode { get; set; }
  625. public string Direction { get; set; }
  626. public string PrintTime { get; set; }
  627. public Panel Panel { get; set; } = new Panel();
  628. public Process Process { get; set; } = new Process();
  629. }
  630. private class Panel
  631. {
  632. public string PanelID { get; set; }
  633. public string PanelName { get; set; }
  634. public string PanelFirm { get; set; }
  635. public double PanelLength { get; set; }
  636. public double PanelWide { get; set; }
  637. public double PanelThickness { get; set; }
  638. }
  639. private class Process
  640. {
  641. public string ProcessName { get; set; }
  642. public string LineNumber { get; set; }
  643. public string StencilNum { get; set; }
  644. }
  645. private void claerBtn_Click(object sender, EventArgs e)
  646. {
  647. lstFiles.Items.Clear();
  648. }
  649. }
  650. }