Make_ParseLog.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  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(equiType == "1")
  345. {
  346. if (currItem[1] != "PASS")
  347. {
  348. res = "NG";
  349. #region
  350. /*string[] NgArr = currItem[1].Split(';');
  351. foreach (var ngItem in NgArr)
  352. {
  353. string[] ngItemArr = ngItem.Split('*');
  354. List<string> ngItemLocal = ngItemArr[1].Split('&').ToList();
  355. NgData ngData = new NgData {
  356. Code = ngItemArr[0],
  357. Local = ngItemLocal
  358. };
  359. data.Add(ngData);
  360. }*/
  361. #endregion
  362. }
  363. else
  364. {
  365. res = "PASS";
  366. }
  367. }else if (equiType == "2")
  368. {
  369. if (currItem[3] != "PASS")
  370. {
  371. res = "NG";
  372. }
  373. else
  374. {
  375. res = "PASS";
  376. }
  377. }
  378. Log itemLog = new Log()
  379. {
  380. SN = currItem[0],
  381. Result = res,
  382. Details = equiType == "1" ? currItem[1] : currItem[3]
  383. };
  384. logArr.Add(itemLog);
  385. LogMessage($"已解析: {currItem[0]}");
  386. }
  387. InsertDb(logArr, PathName);
  388. File.WriteAllText(PathName, string.Empty);
  389. if (ConsoleLog(restOfStream, PathName))
  390. {
  391. File.Delete(PathName);
  392. }
  393. }
  394. catch (Exception ex)
  395. {
  396. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  397. }
  398. }
  399. private void InsertDb(List<Log> logs, string PathName)
  400. {
  401. try
  402. {
  403. int type = Device.SelectedIndex;
  404. StringBuilder sql = new StringBuilder();
  405. List<string> param = new List<string>() { };
  406. foreach (var item in logs)
  407. {
  408. param.Add(item.SN);
  409. param.Add(ma_code.Text);
  410. if (item.Result == "PASS")
  411. {
  412. param.Add(item.Result);
  413. }
  414. else
  415. {
  416. param.Add(item.Result);
  417. }
  418. param.Add(equiType);
  419. param.Add(item.Details);
  420. param.Add(User.UserCode);
  421. param.Add(User.UserSourceCode);
  422. param.Add(User.UserLineCode);
  423. string res = "";
  424. param.Add(res);
  425. string[] paramList = param.ToArray();
  426. dh.CallProcedure("cs_insert_testrejects", ref paramList);
  427. param.Clear();
  428. if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, item.SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  429. {
  430. if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, item.SN, "日志解析", "OK", User.UserCode, out oErrorMessage))
  431. {
  432. if (oErrorMessage.Contains("AFTERSUCCESS")) LogMessage(">>" + oErrorMessage + "\n");
  433. sql.Clear();
  434. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  435. sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  436. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  437. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  438. BaseUtil.SetFormValue(Controls, dt);
  439. //记录日志
  440. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析成功", item.SN, "");
  441. LogMessage("<<解析成功\n");
  442. }
  443. else
  444. {
  445. LogMessage(">>" + oErrorMessage + "\n");
  446. }
  447. }
  448. else
  449. {
  450. LogMessage(">>" + oErrorMessage + "\n");
  451. }
  452. }
  453. }
  454. catch (Exception ex)
  455. {
  456. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  457. }
  458. }
  459. private bool ConsoleLog(string Content, string PathName)
  460. {
  461. try
  462. {
  463. string sourceDir = Path.GetDirectoryName(PathName);
  464. string newFolderName = "Logs";
  465. string newFolderPath = Path.Combine(sourceDir, newFolderName);
  466. if (!Directory.Exists(newFolderPath))
  467. {
  468. Directory.CreateDirectory(newFolderPath);
  469. }
  470. string newFileName = "Log_" + Path.GetFileName(PathName);
  471. string newFilePath = Path.Combine(newFolderPath, newFileName);
  472. File.AppendAllText(newFilePath, Content + Environment.NewLine);
  473. return true;
  474. }
  475. catch (Exception ex)
  476. {
  477. MessageBox.Show(this.ParentForm, ex.Message, "警告");
  478. return false;
  479. }
  480. }
  481. private void LogMessage(string message)
  482. {
  483. if (lstFiles.InvokeRequired)
  484. {
  485. lstFiles.Invoke(new Action<string>(LogMessage), message);
  486. return;
  487. }
  488. lstFiles.Items.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
  489. lstFiles.TopIndex = lstFiles.Items.Count - 1;
  490. }
  491. private PrinterData ReadWithXmlReader(string filePath)
  492. {
  493. PrinterData data = new PrinterData();
  494. using (XmlReader reader = XmlReader.Create(filePath))
  495. {
  496. while (reader.Read())
  497. {
  498. if (reader.NodeType == XmlNodeType.Element)
  499. {
  500. switch (reader.Name)
  501. {
  502. case "SN":
  503. data.SN = reader.ReadElementContentAsString();
  504. break;
  505. case "Barcode":
  506. data.Barcode = reader.ReadElementContentAsString();
  507. break;
  508. case "Direction":
  509. data.Direction = reader.ReadElementContentAsString();
  510. break;
  511. case "PrintTime":
  512. data.PrintTime = reader.ReadElementContentAsString();
  513. break;
  514. case "PANEL":
  515. ReadPanelData(reader, data.Panel);
  516. break;
  517. case "PROCESS":
  518. ReadProcessData(reader, data.Process);
  519. break;
  520. }
  521. }
  522. }
  523. }
  524. return data;
  525. }
  526. private void ReadPanelData(XmlReader reader, Panel panel)
  527. {
  528. while (reader.Read())
  529. {
  530. if (reader.NodeType == XmlNodeType.Element)
  531. {
  532. switch (reader.Name)
  533. {
  534. case "PanelID":
  535. panel.PanelID = reader.ReadElementContentAsString();
  536. break;
  537. case "PanelName":
  538. panel.PanelName = reader.ReadElementContentAsString();
  539. break;
  540. case "PanelFirm":
  541. panel.PanelFirm = reader.ReadElementContentAsString();
  542. break;
  543. case "PanelLength":
  544. panel.PanelLength = reader.ReadElementContentAsDouble();
  545. break;
  546. case "PanelWide":
  547. panel.PanelWide = reader.ReadElementContentAsDouble();
  548. break;
  549. case "PanelThickness":
  550. panel.PanelThickness = reader.ReadElementContentAsDouble();
  551. break;
  552. }
  553. }
  554. else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "PANEL")
  555. {
  556. break;
  557. }
  558. }
  559. }
  560. private void ReadProcessData(XmlReader reader, Process process)
  561. {
  562. while (reader.Read())
  563. {
  564. if (reader.NodeType == XmlNodeType.Element)
  565. {
  566. switch (reader.Name)
  567. {
  568. case "ProcessName":
  569. process.ProcessName = reader.ReadElementContentAsString();
  570. break;
  571. case "LineNumber":
  572. process.LineNumber = reader.ReadElementContentAsString();
  573. break;
  574. case "StencilNum":
  575. process.StencilNum = reader.ReadElementContentAsString();
  576. break;
  577. }
  578. }
  579. else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "PROCESS")
  580. {
  581. break;
  582. }
  583. }
  584. }
  585. public List<MachineList> ParseXml(string xmlContent)
  586. {
  587. List<MachineList> result = new List<MachineList>();
  588. try
  589. {
  590. XmlDocument xmlDoc = new XmlDocument();
  591. xmlDoc.LoadXml(xmlContent);
  592. XmlNode machineNode = xmlDoc.SelectSingleNode("//TotalProductionInfo");
  593. string machineName = machineNode?.Attributes["MachineName"]?.Value ?? "Unknown";
  594. string part = machineNode?.Attributes["ProductionProgramName"]?.Value ?? "Unknown";
  595. XmlNodeList feederNodes = xmlDoc.SelectNodes("//FeederProductionManageInfo");
  596. foreach (XmlNode feederNode in feederNodes)
  597. {
  598. MachineList machineList = new MachineList();
  599. string feederBankPosition = feederNode.Attributes["FeederBankPosition"]?.Value ?? "Unknown";
  600. string holeNo = feederNode.Attributes["HoleNo"]?.Value ?? "Unknown";
  601. string componentName = feederNode.Attributes["ComponentName"]?.Value ?? "Unknown";
  602. machineList.MachineName = machineName;
  603. machineList.Part = part;
  604. machineList.ReelNo = componentName;
  605. machineList.Station = $"{machineName}-{feederBankPosition[0]}-{holeNo}";
  606. result.Add(machineList);
  607. }
  608. }
  609. catch (Exception ex)
  610. {
  611. LogMessage($"Error parsing XML: {ex.Message}");
  612. }
  613. return result;
  614. }
  615. private class Log
  616. {
  617. public string SN { set; get; }
  618. public string Result { set; get; }
  619. /*public List<NgData> Details { set; get; }*/
  620. public string Details { set; get; }
  621. }
  622. public class MachineList
  623. {
  624. public string MachineName { set; get; }
  625. public string Part { set; get; }
  626. public string Station { set; get; }
  627. public string ReelNo { set; get; }
  628. }
  629. private class NgData
  630. {
  631. public string Code { set; get; }
  632. public List<string> Local { set; get; }
  633. }
  634. private class PrinterData
  635. {
  636. public string SN { get; set; }
  637. public string Barcode { get; set; }
  638. public string Direction { get; set; }
  639. public string PrintTime { get; set; }
  640. public Panel Panel { get; set; } = new Panel();
  641. public Process Process { get; set; } = new Process();
  642. }
  643. private class Panel
  644. {
  645. public string PanelID { get; set; }
  646. public string PanelName { get; set; }
  647. public string PanelFirm { get; set; }
  648. public double PanelLength { get; set; }
  649. public double PanelWide { get; set; }
  650. public double PanelThickness { get; set; }
  651. }
  652. private class Process
  653. {
  654. public string ProcessName { get; set; }
  655. public string LineNumber { get; set; }
  656. public string StencilNum { get; set; }
  657. }
  658. private void claerBtn_Click(object sender, EventArgs e)
  659. {
  660. lstFiles.Items.Clear();
  661. }
  662. }
  663. }