版博士V2.0程序
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ProductInfoFrm.cs 25 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. using MaiMuAOI.SysCtrl;
  2. using MaiMuControl.Utils;
  3. using OpenCvSharp;
  4. using ProductionControl.UI;
  5. using ProductionControl.UIExtend;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Diagnostics;
  12. using System.Drawing;
  13. using System.Drawing.Imaging;
  14. using System.IO;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using System.Windows.Forms;
  19. using ToolKits.EnumTool;
  20. using ToolKits.mAPI;
  21. namespace MaiMuAOI.SysUI.ProductAndStep
  22. {
  23. public partial class ProductInfoFrm : Form
  24. {
  25. Service.ClassesService svcClasses = new Service.ClassesService();
  26. Service.ProductService service = new Service.ProductService();
  27. Models.Product model = new Models.Product();
  28. public ProductInfoFrm(Models.Product m = null)
  29. {
  30. InitializeComponent();
  31. UIStyle.SetUIStyle(this);
  32. this.uiTitel1.FatherForm = this;
  33. this.dgvBatchList.AutoGenerateColumns = false;
  34. this.Cursor = Cursors.WaitCursor;
  35. //去除PT线宽等
  36. //tabControl1.TabPages.RemoveAt(2);
  37. //this.cbMarkType.SelectedIndex = -1;
  38. if (m != null)
  39. {
  40. model = m;
  41. this.Text += $" (ID:{m.Id})";
  42. this.txtCode.Text = m.Code;
  43. this.txtName.Text = m.Name;
  44. this.txtSpec.Text = m.Spec;
  45. this.cmbHoleCount.Text = m.HoleCount.ToString();
  46. this.txtBatchId.Text = m.BatchId;
  47. this.numTargetCount.Value = m.TargetCount;
  48. this.toolTip1.SetToolTip(this.numTargetCount, "已完成:" + m.CompleteCount);
  49. this.numTensionBaseValue.Value = (decimal)m.TensionBaseValue;
  50. this.numTensionUpFloatValue.Value = (decimal)m.TensionUpFloatValue;
  51. this.numTensionDownFloatValue.Value = (decimal)m.TensionDownFloatValue;
  52. this.numHeightBaseValue.Value = (decimal)m.HeightBaseValue;
  53. this.numHeightUpFloatValue.Value = (decimal)m.HeightUpFloatValue;
  54. this.numHeightDownFloatValue.Value = (decimal)m.HeightDownFloatValue;
  55. this.txtHeightBaseDec.Text = m.HeightBaseDec;
  56. this.numLineWidthBaseValue.Value = (decimal)m.LineWidthBaseValue;
  57. this.numLineWidthUpFloatValue.Value = (decimal)m.LineWidthUpFloatValue;
  58. this.numLineWidthDownFloatValue.Value = (decimal)m.LineWidthDownFloatValue;
  59. this.numPTBaseValue.Value = (decimal)m.PTBaseValue;
  60. this.numPTUpFloatValue.Value = (decimal)m.PTUpFloatValue;
  61. this.numPTDownFloatValue.Value = (decimal)m.PTDownFloatValue;
  62. this.numPTXBaseValue.Value = (decimal)m.PTXBaseValue;
  63. this.numPTXUpFloatValue.Value = (decimal)m.PTXUpFloatValue;
  64. this.numPTXDownFloatValue.Value = (decimal)m.PTXDownFloatValue;
  65. //if (m.Type > 0)
  66. //{
  67. // this.txtCode.Enabled = false;
  68. // this.txtName.Width = this.txtCode.Width;
  69. // this.txtSpec.Enabled = false;
  70. //}
  71. this.tsbtnAddFile.Enabled = true;
  72. this.tsbtnNewBatchId.Enabled = true;
  73. this.dgvBatchList.DataSource = new BindingSource(m.BatchHistoryList, null);
  74. //2023-11-2 mark
  75. this.cbMarkType.SelectedIndex = m.MarkType;
  76. this.numMarkSize.Value = (decimal)m.MarkSize;
  77. //2023-12-18 主栅
  78. this.cbMarkDisturb.Checked = (m.MarkDisturb == 1);
  79. this.cbMainGrid.Checked = (m.MainGrid == 1);
  80. Models.Attachment attachmentFile = model.AttachmentList.FirstOrDefault(x => x.Type == 0);
  81. if (attachmentFile != null)
  82. {
  83. this.btnOpenFile.Text = attachmentFile.Name;
  84. this.btnOpenFile.Visible = true;
  85. if ((this.groupBox5.Width - this.btnOpenFile.Width) > 0)
  86. {
  87. this.btnOpenFile.Left = (this.groupBox5.Width - this.btnOpenFile.Width) / 2;
  88. }
  89. else
  90. this.btnOpenFile.Left = 20;
  91. this.textBoxPath.Text = ConfMgr.Instance.ProjectDir+ $"\\{model.Id}\\" + attachmentFile.Name;
  92. }
  93. }
  94. else
  95. {
  96. cbMarkType.SelectedIndex = 2;
  97. numMarkSize.Value = (decimal)0.5;
  98. this.textBoxPath.Text = "";
  99. }
  100. InitDataView();
  101. this.Cursor = Cursors.Default;
  102. }
  103. ArrayList GetArrayList<T>()
  104. {
  105. ArrayList list = new ArrayList();
  106. Type type = typeof(T);
  107. //list.Add(new DictionaryEntry("start", "启动按钮"));
  108. foreach (int value in Enum.GetValues(type))
  109. {
  110. string strName = Enum.GetName(type, value);//获取名称
  111. list.Add(new DictionaryEntry(value, strName));
  112. }
  113. return list;
  114. }
  115. private void InitDataView()
  116. {
  117. try
  118. {
  119. //显示的数据
  120. this.cmbClasses.DisplayMember = "Name";
  121. this.cmbClasses.ValueMember = "Id";
  122. var list = svcClasses.GetListNav(0);
  123. this.cmbClasses.DataSource = list;
  124. if (model.ClassesId > 0)
  125. this.cmbClasses.SelectedValue = model.ClassesId;
  126. //缺陷项
  127. //ArrayList lstDefect = new ArrayList();
  128. //List<string> DefectNames = new List<string>();
  129. //foreach (var item in Enum.GetValues(typeof(DefectCodeEnum)))
  130. //{
  131. // DefectCountOfSizeControl userCon = new DefectCountOfSizeControl();
  132. // userCon.Code = item.ToString();
  133. // userCon.Title = EnumExtension.GetEnumDescription((DefectCodeEnum)item);
  134. // if (model != null && model.QualifiedCriterionList != null)
  135. // {
  136. // var qalifiedItem = model.QualifiedCriterionList.FirstOrDefault(m => m.DefectCode == userCon.Code);
  137. // if (qalifiedItem != null)
  138. // {
  139. // userCon.Checked = true;
  140. // userCon.SizeValue = (decimal)qalifiedItem.Size;
  141. // userCon.MaxDefectCount = qalifiedItem.MaxDefectCount;
  142. // }
  143. // }
  144. // this.flpQualifiedPannel.Controls.Add(userCon);
  145. //}
  146. var lstDefect = GetArrayList<DefectCodeEnum>();
  147. foreach (DictionaryEntry item in lstDefect)
  148. {
  149. DefectCountOfSizeControl userCon = new DefectCountOfSizeControl();
  150. userCon.Code = item.Value.ToString();
  151. userCon.Title = ((DefectNameEnum)(int)item.Key).ToString();
  152. if (model != null && model.QualifiedCriterionList != null)
  153. {
  154. var qalifiedItem = model.QualifiedCriterionList.FirstOrDefault(m => m.DefectCode == userCon.Code);
  155. if (qalifiedItem != null)
  156. {
  157. userCon.Checked = true;
  158. userCon.SizeValue = (decimal)qalifiedItem.Size;
  159. userCon.MaxDefectCount = qalifiedItem.MaxDefectCount;
  160. }
  161. }
  162. this.flpQualifiedPannel.Controls.Add(userCon);
  163. }
  164. //模型文件
  165. string strDefectModelFile = ConfMgr.Instance.SysConfigParams.AIModelPath;
  166. string[] onnxFiles = Directory.GetFiles(strDefectModelFile, "*.onnx");
  167. string onlyName;
  168. foreach (string onnxFile in onnxFiles)
  169. {
  170. onlyName = Path.GetFileName(onnxFile);
  171. cmbDefectModelFile.Items.Add(onlyName);
  172. if (!string.IsNullOrWhiteSpace(model.DefectModelFile) && onlyName.ToLower() == model.DefectModelFile.ToLower())
  173. this.cmbDefectModelFile.SelectedItem = model.DefectModelFile;
  174. }
  175. }
  176. catch(Exception e)
  177. {
  178. MessageBox.Show("数据&模型载入出错:"+ e.Message,"报警", MessageBoxButtons.OK,MessageBoxIcon.Error);
  179. }
  180. }
  181. private void ProductInfoFrm_Load(object sender, EventArgs e)
  182. {
  183. }
  184. private void tsbtnSave_Click(object sender, EventArgs e)
  185. {
  186. try
  187. {
  188. string szCode = this.txtCode.Text.Trim();
  189. string szName = this.txtName.Text.Trim();
  190. string szSpec = this.txtSpec.Text.Trim();
  191. string szHoleCount = this.cmbHoleCount.Text.Trim();
  192. string szBatchId = this.txtBatchId.Text.Trim();
  193. int liTargetCount = (int)this.numTargetCount.Value;
  194. string szHeightBaseDec = this.txtHeightBaseDec.Text.Trim().Trim(new char[] { ';', ',' });
  195. if (szCode == "" || szName == "")
  196. throw new Exception("请填写料号和名称!");
  197. if (this.cmbClasses.SelectedIndex < 0)
  198. throw new Exception("请选择产品类型!");
  199. if (szHoleCount == "" || !Util.IsNumber(szHoleCount))
  200. throw new Exception("请正确填写产品目数!");
  201. if (this.cmbDefectModelFile.SelectedIndex < 0)
  202. throw new Exception("请选择检测模型文件!");
  203. if (this.cbMarkType.SelectedIndex < 0)
  204. throw new Exception("请选择Mark!");
  205. //if (szBatchId == "")// || liTargetCount < 1
  206. // throw new Exception("请填写批次号");// 和批次目标数量!");
  207. if (szHeightBaseDec != "")
  208. {
  209. double num;
  210. string[] szs = szHeightBaseDec.Split(new char[] { ';', ',' });
  211. foreach (string s in szs)
  212. {
  213. if (!double.TryParse(s, out num))
  214. throw new Exception(s + " 非数值!");
  215. }
  216. }
  217. model.Code = szCode;
  218. model.Name = szName;
  219. model.Spec = szSpec;
  220. model.ClassesId = (int)this.cmbClasses.SelectedValue;
  221. model.HoleCount = Convert.ToInt32(szHoleCount);
  222. model.DefectModelFile = this.cmbDefectModelFile.Text.Trim();
  223. model.TensionBaseValue = (double)this.numTensionBaseValue.Value;
  224. model.TensionUpFloatValue = (double)this.numTensionUpFloatValue.Value;
  225. model.TensionDownFloatValue = (double)this.numTensionDownFloatValue.Value;
  226. model.HeightBaseValue = (double)this.numHeightBaseValue.Value;
  227. model.HeightUpFloatValue = (double)this.numHeightUpFloatValue.Value;
  228. model.HeightDownFloatValue = (double)this.numHeightDownFloatValue.Value;
  229. model.HeightBaseDec = szHeightBaseDec;
  230. model.LineWidthBaseValue = (double)this.numLineWidthBaseValue.Value;
  231. model.LineWidthUpFloatValue = (double)this.numLineWidthUpFloatValue.Value;
  232. model.LineWidthDownFloatValue = (double)this.numLineWidthDownFloatValue.Value;
  233. model.PTBaseValue = (double)this.numPTBaseValue.Value;
  234. model.PTUpFloatValue = (double)this.numPTUpFloatValue.Value;
  235. model.PTDownFloatValue = (double)this.numPTDownFloatValue.Value;
  236. model.PTXBaseValue = (double)this.numPTXBaseValue.Value;
  237. model.PTXUpFloatValue = (double)this.numPTXUpFloatValue.Value;
  238. model.PTXDownFloatValue = (double)this.numPTXDownFloatValue.Value;
  239. if (model.QualifiedCriterionList == null)
  240. model.QualifiedCriterionList = new List<Models.QualifiedCriterion>();
  241. else
  242. model.QualifiedCriterionList.Clear();
  243. foreach (DefectCountOfSizeControl defectControl in this.flpQualifiedPannel.Controls)
  244. {
  245. if (defectControl.Checked)
  246. {
  247. model.QualifiedCriterionList.Add(
  248. new Models.QualifiedCriterion()
  249. {
  250. DefectCode = defectControl.Code,
  251. Size = (float)defectControl.SizeValue,
  252. MaxDefectCount = (int)defectControl.MaxDefectCount,
  253. ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code,
  254. CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code
  255. });
  256. }
  257. }
  258. model.ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code;
  259. //2023-11-2 mark
  260. model.MarkType = this.cbMarkType.SelectedIndex;
  261. model.MarkSize = (double)this.numMarkSize.Value;
  262. //2023-12-18 主栅
  263. model.MarkDisturb = this.cbMarkDisturb.Checked ? 1 : 0;
  264. model.MainGrid = this.cbMainGrid.Checked ? 1 : 0;
  265. bool result;
  266. if (model.Id == 0)
  267. {
  268. model.BatchId = szBatchId;
  269. model.TargetCount = liTargetCount;
  270. model.CompleteCount = 0;
  271. model.CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code;
  272. result = service.InsertNav(model);
  273. }
  274. else
  275. {
  276. if (model.BatchId != szBatchId && !string.IsNullOrWhiteSpace(model.BatchId))
  277. {
  278. if (model.CompleteCount < model.TargetCount
  279. && MessageBox.Show($"本批次完成数量未达到目标数量,确定更换批次号?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
  280. return;
  281. if (model.BatchHistoryList.FirstOrDefault(m => m.BatchId == szBatchId) != null)
  282. throw new Exception("当前批次号与历史中所用批次号重复,请重新填写!");
  283. model.BatchHistoryList.Add(new Models.BatchHistory()
  284. {
  285. BatchId = model.BatchId,
  286. TargetCount = model.TargetCount,
  287. CompleteCount = model.CompleteCount,
  288. CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code,
  289. ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code
  290. });
  291. model.CompleteCount = 0;
  292. }
  293. model.BatchId = szBatchId;
  294. model.TargetCount = liTargetCount;
  295. result = service.UpdateNav(model);
  296. }
  297. if (!result)
  298. throw new Exception("保存失败!");
  299. this.tsbtnAddFile.Enabled = true;
  300. this.tsbtnNewBatchId.Enabled = true;
  301. MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  302. this.DialogResult = DialogResult.OK;
  303. this.Close();
  304. }
  305. catch (Exception ex)
  306. {
  307. MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  308. }
  309. }
  310. private void tsbtnExit_Click(object sender, EventArgs e)
  311. {
  312. this.Close();
  313. }
  314. private void tsbtnNewBatchId_Click(object sender, EventArgs e)
  315. {
  316. }
  317. private void tsbtnAddFile_Click(object sender, EventArgs e)
  318. {
  319. this.Cursor = Cursors.WaitCursor;
  320. try
  321. {
  322. if (this.cbMarkType.SelectedIndex < 0)
  323. throw new Exception("请选择Mark!");
  324. //.dwg /.dxf /.dws /.dwt
  325. string filePath = ConfMgr.SelectFile("gbx,gbr文件|*.gb?");
  326. if (string.IsNullOrWhiteSpace(filePath))
  327. return;
  328. string fileName = Path.GetFileName(filePath);
  329. string fileExtend = Path.GetExtension(filePath);
  330. string fileOnlyName = fileName.Substring(0, fileName.Length - fileExtend.Length);
  331. //
  332. string targFilePath = ConfMgr.Instance.ProjectDir + $"\\{model.Id}\\";
  333. if (!Directory.Exists(targFilePath))
  334. Directory.CreateDirectory(targFilePath);
  335. else//删除原文件
  336. ConfMgr.DelFilesInFolder(targFilePath);
  337. targFilePath += fileName;
  338. //File.Copy(res.file_path, defectFileName + ".bmp", true);
  339. bool result = API.CopyFile(filePath, targFilePath, false);//更快 //false-覆盖
  340. if (!result)
  341. throw new Exception("移动文件失败!");
  342. //后台线程转BMP与JPG
  343. string tempClass = this.cmbClasses.Text;
  344. int tempIndex = this.cbMarkType.SelectedIndex;
  345. double tempSize = (double)this.numMarkSize.Value;
  346. //2023-12-18
  347. int tMarkDistrub = this.cbMarkDisturb.Checked ? 1 : 0;
  348. int tMainGrid = this.cbMainGrid.Checked ? 1 : 0;
  349. //Task.Run(() =>
  350. {
  351. Yolo5.Yolo_Class yolo = new Yolo5.Yolo_Class();
  352. string bmpPath = targFilePath.Substring(0, targFilePath.Length - 4) + ".bmp";
  353. //2023-11-3 mark
  354. //yolo.gerber2image(targFilePath, bmpPath);
  355. double[] markParam = new double[6];
  356. if (tempClass.Contains("乳剂"))
  357. markParam[0] = 2;
  358. else if (tempClass.Contains("PI"))
  359. markParam[0] = 1;
  360. else
  361. markParam[0] = 0;
  362. if (tempIndex == 0)
  363. {
  364. //默认情况 实心圆,0.5mm
  365. markParam[1] = 2;
  366. markParam[2] = 0.5;
  367. markParam[3] = 1;
  368. markParam[4] = 0;
  369. markParam[5] = 0;
  370. }
  371. else
  372. {
  373. markParam[1] = tempIndex - 1;
  374. markParam[2] = tempSize;
  375. markParam[3] = tempIndex == 1 ? 0 : 1;
  376. markParam[4] = tMarkDistrub;
  377. markParam[5] = tMainGrid;
  378. }
  379. yolo.gerber2image(targFilePath, bmpPath, markParam);
  380. //换背景JPG
  381. Mat mat = Cv2.ImRead(bmpPath);
  382. Cv2.CvtColor(mat, mat, ColorConversionCodes.RGB2GRAY);//转灰度图
  383. for (int i = 0; i < mat.Height; i++)
  384. {
  385. for (int j = 0; j < mat.Width; j++)
  386. {
  387. if (mat.At<byte>(i, j) == 255)//白色
  388. mat.Set<byte>(i, j, 0);
  389. else
  390. mat.Set<byte>(i, j, 255);
  391. }
  392. }
  393. model.MapPath = bmpPath;
  394. //灰转彩
  395. //Cv2.CvtColor(mat, mat, ColorConversionCodes.GRAY2RGB);
  396. //for (int i = 0; i < mat.Height; i++)
  397. //{
  398. // for (int j = 0; j < mat.Width; j++)
  399. // {
  400. // if (mat.At<byte>(i, j) == 255)//白色
  401. // mat.Set<byte>(i, j, 0); //黄色
  402. // }
  403. //}
  404. bmpPath = targFilePath.Substring(0, targFilePath.Length - 4) + ".jpg";
  405. OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat).Save(bmpPath, ImageFormat.Jpeg);
  406. //});//不能加.Start();
  407. }
  408. Models.Attachment attachmentFile = model.AttachmentList.FirstOrDefault(m => m.Type == 0);
  409. if (attachmentFile != null)
  410. {
  411. attachmentFile.Type = 0;//图纸
  412. attachmentFile.NameTimestamp = $"{model.Id}\\{fileOnlyName}";
  413. attachmentFile.Name = fileName;
  414. attachmentFile.ExtendName = fileExtend;
  415. }
  416. else
  417. {
  418. model.AttachmentList.Add(new Models.Attachment()
  419. {
  420. TBName = "product",
  421. Type = 0,
  422. NameTimestamp = $"{model.Id}\\{fileOnlyName}",
  423. Name = fileName,
  424. ExtendName = fileExtend,
  425. CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code,
  426. ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code
  427. });
  428. }
  429. if (!service.UpdateNav(model))
  430. throw new Exception("保存文件失败!");
  431. model = service.GetModelNav(model.Code);
  432. this.btnOpenFile.Text = fileName;
  433. this.btnOpenFile.Visible = true;
  434. }
  435. catch (Exception ex)
  436. {
  437. MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  438. }
  439. finally
  440. {
  441. this.Cursor = Cursors.Default;
  442. }
  443. }
  444. private void btnOpenFile_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  445. {
  446. Models.Attachment attachmentFile = model.AttachmentList.FirstOrDefault(m => m.Type == 0);
  447. if (attachmentFile == null)
  448. MessageBox.Show("还未上传!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  449. string filePath = ConfMgr.Instance.ProjectDir + $"\\{model.Id}\\" + attachmentFile.Name;
  450. if (File.Exists(filePath))
  451. Process.Start(filePath);
  452. }
  453. private void tbtnGetPos_Click(object sender, EventArgs e)
  454. {
  455. if ((model.MapPath == null) || (string.IsNullOrEmpty(model.MapPath)))
  456. {
  457. MessageBox.Show("还未上传图纸!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  458. return;
  459. }
  460. List<double> dList = new List<double>();
  461. if (model.GetPointList != null)
  462. {
  463. var list = model.GetPointList.Split(',');
  464. dList = new List<double>();
  465. if (list.Length < 28)
  466. {
  467. for (int i = 0; i < 28; i++)
  468. {
  469. dList.Add(0);
  470. }
  471. }
  472. else
  473. {
  474. for (int i = 0; i < list.Length; i++)
  475. {
  476. dList.Add(double.Parse(list[i]));
  477. }
  478. }
  479. }
  480. FrmGetPosByPic frm = new FrmGetPosByPic(model, model.MapPath, dList.ToArray());
  481. frm.ShowDialog();
  482. model.GetPointList = string.Join(",", frm.GetPoints()); ;
  483. model.MapPath = frm.GetMapPath();
  484. if (!service.UpdateNav(model))
  485. throw new Exception("保存文件失败!");
  486. model = service.GetModelNav(model.Code);
  487. }
  488. private void textBoxPath_DoubleClick(object sender, EventArgs e)
  489. {
  490. if (File.Exists(this.textBoxPath.Text))
  491. {
  492. Models.Attachment attachmentFile = model.AttachmentList.FirstOrDefault(x => x.Type == 0);
  493. if (attachmentFile != null)
  494. {
  495. System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("Explorer.exe");
  496. psi.Arguments = "/e,/select," + ConfMgr.Instance.ProjectDir + $"\\{model.Id}\\";
  497. System.Diagnostics.Process.Start(psi);
  498. }
  499. }
  500. }
  501. }
  502. }