Make_ParseLog.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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. }
  257. else if (Device.SelectedIndex == 2) // 印刷机
  258. {
  259. PrinterData xmlData = ReadWithXmlReader(file);
  260. Console.WriteLine();
  261. }
  262. else if (Device.SelectedIndex == 3) // 贴片机
  263. {
  264. if (!File.Exists(file))
  265. {
  266. LogMessage($"文件不存在: {file}");
  267. }
  268. string xmlContent = File.ReadAllText(file);
  269. var xmlList = ParseXml(xmlContent);
  270. if (ConsoleLog(xmlContent, file))
  271. {
  272. File.Delete(file);
  273. }
  274. List<string> param = new List<string>() { };
  275. string PS_CODE = "";
  276. LogicHandler.GetSerialNumByCaller("Make!ParseLog", out PS_CODE);
  277. List<string> MachineName = new List<string>();
  278. List<string> Part = new List<string>();
  279. List<string> Station = new List<string>();
  280. List<string> ReelNo = new List<string>();
  281. List<string> letNo = new List<string>();
  282. string Part_ = "";
  283. int letNoNum = 0;
  284. foreach (var item in xmlList)
  285. {
  286. MachineName.Add(item.MachineName);
  287. Part_ = item.Part.Split('.')[0];
  288. Station.Add(item.Station);
  289. ReelNo.Add(item.ReelNo);
  290. letNo.Add((++letNoNum).ToString());
  291. }
  292. string ps_id = "";
  293. string lineId = dh.getFieldDataByCondition("smtlocationinto", "SLI_LANE", "SLI_MCNO='" + MachineName[0] + "'").ToString();
  294. if (!dh.CheckExist("productsmt", "ps_prodcode='" + Part_ + "'"))
  295. {
  296. ps_id = dh.GetSEQ("productsmt_seq");
  297. dh.ExecuteSql("insert into productsmt(ps_id,ps_prodcode,ps_status,ps_statuscode,PS_LINECODE,PS_CODE)" +
  298. "values('" + ps_id + "','" + Part_ + "','在录入','ENTERING','"+ lineId + "','"+ PS_CODE + "')", "insert");
  299. }
  300. else
  301. {
  302. ps_id = dh.getFieldDataByCondition("productsmt", "ps_id", "ps_prodcode='"+Part_+"'").ToString();
  303. }
  304. if (dh.getRowCount("productsmtlocation", "PSL_PSID=" + ps_id) > 0)
  305. {
  306. dh.ExecuteSql("delete from productsmtlocation where PSL_PSID" + ps_id, "delete");
  307. }
  308. sql.Clear();
  309. sql.Append("insert into productsmtlocation(PSL_ID, PSL_PSID, PSL_DETNO, PSL_PRODCODE, PSL_REPCODE, PSL_LOCATION, PSL_BASEQTY, PSL_TABLE)" +
  310. "select productsmtlocation_seq.nextval," + ps_id + ",:letArr, :ReelNo,:ReelNo,:Station,BD_BASEQTY,'' from bom@ERP " +
  311. "left join bomdetail@ERP on bo_id=bd_bomid where bo_mothercode='" + Part_ + "' and BD_SONCODE=:ReelNo");
  312. dh.BatchInsert(sql.GetString(), new string[] {"letArr", "ReelNo", "ReelNo", "Station", "ReelNo" },
  313. letNo.ToArray(),ReelNo.ToArray(), ReelNo.ToArray(), Station.ToArray(), ReelNo.ToArray());
  314. Console.WriteLine();
  315. }
  316. }
  317. LogMessage($"共找到{txtFiles.Length}个{currFileType.ToUpper()}文件");
  318. }
  319. }
  320. catch (Exception ex)
  321. {
  322. LogMessage($"刷新文件列表时出错: {ex.Message}");
  323. }
  324. }
  325. private void ParseLogInsert(string PathName)
  326. {
  327. try
  328. {
  329. StreamReader SR = File.OpenText(PathName);
  330. string restOfStream = SR.ReadToEnd();
  331. SR.Close();
  332. SR.Dispose();
  333. List<Log> logArr = new List<Log>() { };
  334. string[] lines = restOfStream.Split(new string[] { "\r\n" }, StringSplitOptions.None);
  335. LogMessage($"文件夹{PathName},共{lines.Length}条记录");
  336. foreach (var item in lines)
  337. {
  338. if (string.IsNullOrEmpty(item)) continue;
  339. string[] currItem = item.Split(',');
  340. string res = "";
  341. /*List<NgData> data = new List<NgData>();*/
  342. if (currItem[1] != "PASS")
  343. {
  344. res = "NG";
  345. #region
  346. /*string[] NgArr = currItem[1].Split(';');
  347. foreach (var ngItem in NgArr)
  348. {
  349. string[] ngItemArr = ngItem.Split('*');
  350. List<string> ngItemLocal = ngItemArr[1].Split('&').ToList();
  351. NgData ngData = new NgData {
  352. Code = ngItemArr[0],
  353. Local = ngItemLocal
  354. };
  355. data.Add(ngData);
  356. }*/
  357. #endregion
  358. }
  359. else
  360. {
  361. res = "PASS";
  362. }
  363. Log itemLog = new Log()
  364. {
  365. SN = currItem[0],
  366. Result = res,
  367. Details = currItem[1]
  368. };
  369. logArr.Add(itemLog);
  370. LogMessage($"已解析: {currItem[0]}");
  371. }
  372. InsertDb(logArr, PathName);
  373. File.WriteAllText(PathName, string.Empty);
  374. if (ConsoleLog(restOfStream, PathName))
  375. {
  376. File.Delete(PathName);
  377. }
  378. }
  379. catch (Exception ex)
  380. {
  381. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  382. }
  383. }
  384. private void InsertDb(List<Log> logs, string PathName)
  385. {
  386. try
  387. {
  388. int type = Device.SelectedIndex;
  389. StringBuilder sql = new StringBuilder();
  390. List<string> param = new List<string>() { };
  391. foreach (var item in logs)
  392. {
  393. param.Add(item.SN);
  394. param.Add(ma_code.Text);
  395. if (item.Result == "PASS")
  396. {
  397. param.Add(item.Result);
  398. }
  399. else
  400. {
  401. param.Add(item.Result);
  402. }
  403. param.Add(equiType);
  404. param.Add(item.Details);
  405. param.Add(User.UserCode);
  406. param.Add(User.UserSourceCode);
  407. param.Add(User.UserLineCode);
  408. string res = "";
  409. param.Add(res);
  410. string[] paramList = param.ToArray();
  411. dh.CallProcedure("cs_insert_testrejects", ref paramList);
  412. param.Clear();
  413. if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, item.SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  414. {
  415. if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, item.SN, "日志解析", "OK", User.UserCode, out oErrorMessage))
  416. {
  417. if (oErrorMessage.Contains("AFTERSUCCESS")) LogMessage(">>" + oErrorMessage + "\n");
  418. sql.Clear();
  419. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  420. sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  421. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  422. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  423. BaseUtil.SetFormValue(Controls, dt);
  424. //记录日志
  425. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析成功", item.SN, "");
  426. LogMessage("<<解析成功\n");
  427. }
  428. else
  429. {
  430. LogMessage(">>" + oErrorMessage + "\n");
  431. }
  432. }
  433. else
  434. {
  435. LogMessage(">>" + oErrorMessage + "\n");
  436. }
  437. }
  438. }
  439. catch (Exception ex)
  440. {
  441. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  442. }
  443. }
  444. private bool ConsoleLog(string Content, string PathName)
  445. {
  446. try
  447. {
  448. string sourceDir = Path.GetDirectoryName(PathName);
  449. string newFolderName = "Logs";
  450. string newFolderPath = Path.Combine(sourceDir, newFolderName);
  451. if (!Directory.Exists(newFolderPath))
  452. {
  453. Directory.CreateDirectory(newFolderPath);
  454. }
  455. string newFileName = "Log_" + Path.GetFileName(PathName);
  456. string newFilePath = Path.Combine(newFolderPath, newFileName);
  457. File.AppendAllText(newFilePath, Content + Environment.NewLine);
  458. return true;
  459. }
  460. catch (Exception ex)
  461. {
  462. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  463. return false;
  464. }
  465. }
  466. private void LogMessage(string message)
  467. {
  468. if (lstFiles.InvokeRequired)
  469. {
  470. lstFiles.Invoke(new Action<string>(LogMessage), message);
  471. return;
  472. }
  473. lstFiles.Items.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
  474. lstFiles.TopIndex = lstFiles.Items.Count - 1;
  475. }
  476. private PrinterData ReadWithXmlReader(string filePath)
  477. {
  478. PrinterData data = new PrinterData();
  479. using (XmlReader reader = XmlReader.Create(filePath))
  480. {
  481. while (reader.Read())
  482. {
  483. if (reader.NodeType == XmlNodeType.Element)
  484. {
  485. switch (reader.Name)
  486. {
  487. case "SN":
  488. data.SN = reader.ReadElementContentAsString();
  489. break;
  490. case "Barcode":
  491. data.Barcode = reader.ReadElementContentAsString();
  492. break;
  493. case "Direction":
  494. data.Direction = reader.ReadElementContentAsString();
  495. break;
  496. case "PrintTime":
  497. data.PrintTime = reader.ReadElementContentAsString();
  498. break;
  499. case "PANEL":
  500. ReadPanelData(reader, data.Panel);
  501. break;
  502. case "PROCESS":
  503. ReadProcessData(reader, data.Process);
  504. break;
  505. }
  506. }
  507. }
  508. }
  509. return data;
  510. }
  511. private void ReadPanelData(XmlReader reader, Panel panel)
  512. {
  513. while (reader.Read())
  514. {
  515. if (reader.NodeType == XmlNodeType.Element)
  516. {
  517. switch (reader.Name)
  518. {
  519. case "PanelID":
  520. panel.PanelID = reader.ReadElementContentAsString();
  521. break;
  522. case "PanelName":
  523. panel.PanelName = reader.ReadElementContentAsString();
  524. break;
  525. case "PanelFirm":
  526. panel.PanelFirm = reader.ReadElementContentAsString();
  527. break;
  528. case "PanelLength":
  529. panel.PanelLength = reader.ReadElementContentAsDouble();
  530. break;
  531. case "PanelWide":
  532. panel.PanelWide = reader.ReadElementContentAsDouble();
  533. break;
  534. case "PanelThickness":
  535. panel.PanelThickness = reader.ReadElementContentAsDouble();
  536. break;
  537. }
  538. }
  539. else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "PANEL")
  540. {
  541. break;
  542. }
  543. }
  544. }
  545. private void ReadProcessData(XmlReader reader, Process process)
  546. {
  547. while (reader.Read())
  548. {
  549. if (reader.NodeType == XmlNodeType.Element)
  550. {
  551. switch (reader.Name)
  552. {
  553. case "ProcessName":
  554. process.ProcessName = reader.ReadElementContentAsString();
  555. break;
  556. case "LineNumber":
  557. process.LineNumber = reader.ReadElementContentAsString();
  558. break;
  559. case "StencilNum":
  560. process.StencilNum = reader.ReadElementContentAsString();
  561. break;
  562. }
  563. }
  564. else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "PROCESS")
  565. {
  566. break;
  567. }
  568. }
  569. }
  570. public List<MachineList> ParseXml(string xmlContent)
  571. {
  572. List<MachineList> result = new List<MachineList>();
  573. try
  574. {
  575. XmlDocument xmlDoc = new XmlDocument();
  576. xmlDoc.LoadXml(xmlContent);
  577. XmlNode machineNode = xmlDoc.SelectSingleNode("//TotalProductionInfo");
  578. string machineName = machineNode?.Attributes["MachineName"]?.Value ?? "Unknown";
  579. string part = machineNode?.Attributes["ProductionProgramName"]?.Value ?? "Unknown";
  580. XmlNodeList feederNodes = xmlDoc.SelectNodes("//FeederProductionManageInfo");
  581. foreach (XmlNode feederNode in feederNodes)
  582. {
  583. MachineList machineList = new MachineList();
  584. string feederBankPosition = feederNode.Attributes["FeederBankPosition"]?.Value ?? "Unknown";
  585. string holeNo = feederNode.Attributes["HoleNo"]?.Value ?? "Unknown";
  586. string componentName = feederNode.Attributes["ComponentName"]?.Value ?? "Unknown";
  587. machineList.MachineName = machineName;
  588. machineList.Part = part;
  589. machineList.ReelNo = componentName;
  590. machineList.Station = $"{machineName}-{feederBankPosition[0]}-{holeNo}";
  591. result.Add(machineList);
  592. }
  593. }
  594. catch (Exception ex)
  595. {
  596. LogMessage($"Error parsing XML: {ex.Message}");
  597. }
  598. return result;
  599. }
  600. private class Log
  601. {
  602. public string SN { set; get; }
  603. public string Result { set; get; }
  604. /*public List<NgData> Details { set; get; }*/
  605. public string Details { set; get; }
  606. }
  607. public class MachineList
  608. {
  609. public string MachineName { set; get; }
  610. public string Part { set; get; }
  611. public string Station { set; get; }
  612. public string ReelNo { set; get; }
  613. }
  614. private class NgData
  615. {
  616. public string Code { set; get; }
  617. public List<string> Local { set; get; }
  618. }
  619. private class PrinterData
  620. {
  621. public string SN { get; set; }
  622. public string Barcode { get; set; }
  623. public string Direction { get; set; }
  624. public string PrintTime { get; set; }
  625. public Panel Panel { get; set; } = new Panel();
  626. public Process Process { get; set; } = new Process();
  627. }
  628. private class Panel
  629. {
  630. public string PanelID { get; set; }
  631. public string PanelName { get; set; }
  632. public string PanelFirm { get; set; }
  633. public double PanelLength { get; set; }
  634. public double PanelWide { get; set; }
  635. public double PanelThickness { get; set; }
  636. }
  637. private class Process
  638. {
  639. public string ProcessName { get; set; }
  640. public string LineNumber { get; set; }
  641. public string StencilNum { get; set; }
  642. }
  643. private void claerBtn_Click(object sender, EventArgs e)
  644. {
  645. lstFiles.Items.Clear();
  646. }
  647. }
  648. }