ExtremumApp.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Management;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using System.Xml;
  13. namespace OTSExtremum
  14. {
  15. public partial class ExtremumApp : Form
  16. {
  17. public ExtremumApp()
  18. {
  19. InitializeComponent();
  20. }
  21. int groupCount = 0;
  22. GroupBox gp;
  23. #region 单组数据操作方法
  24. //分类
  25. int typeIndex = 0;
  26. /// <summary>
  27. /// 添加颗粒直径
  28. /// </summary>
  29. /// <param name="sender"></param>
  30. /// <param name="e"></param>
  31. private void btnAddValue_Click(object sender, EventArgs e)
  32. {
  33. AddVale(panel1);
  34. }
  35. /// <summary>
  36. /// 添加测量结果文件
  37. /// </summary>
  38. /// <param name="sender"></param>
  39. /// <param name="e"></param>
  40. private void btnAddFile_Click(object sender, EventArgs e)
  41. {
  42. DataReadConfigurationForm dialog = new DataReadConfigurationForm();
  43. if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  44. {
  45. this.Cursor = Cursors.WaitCursor;
  46. ScanFile(dialog.Filepath, dialog.LoadCount,panel1);
  47. this.Cursor = Cursors.Default;
  48. }
  49. }
  50. /// <summary>
  51. /// 删除颗粒
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. private void btnDel_Click(object sender, EventArgs e)
  56. {
  57. DialogResult dr = MessageBox.Show("是否确认删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
  58. if (dr == DialogResult.No)
  59. {
  60. return;
  61. }
  62. DelVale(panel1);
  63. }
  64. /// <summary>
  65. /// 检验数据有效性,是否位离群值
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. private void btnCheck_Click(object sender, EventArgs e)
  70. {
  71. CheckVale(panel1);
  72. }
  73. /// <summary>
  74. /// 极值分析
  75. /// </summary>
  76. /// <param name="sender"></param>
  77. /// <param name="e"></param>
  78. private void btnCompute_Click(object sender, EventArgs e)
  79. {
  80. int chkcount = panel1.Controls.Count;
  81. double[] vs = new double[chkcount];
  82. double[] gg = { 140, 240, 532, 205, 150, 110, 200, 180, 220, 300, 70, 390, 100, 90, 320, 190, 250, 150, 280, 250, 490, 120, 500, 200 };
  83. for (int i = 0; i < chkcount; i++)
  84. {
  85. vs[i] = Convert.ToDouble(((CheckBox)panel1.Controls[i]).Text);
  86. }
  87. if (!CheckVale(panel1,1))
  88. {
  89. return;
  90. }
  91. GridForm gridForm = new GridForm(vs, panel1.Controls[0].Text);
  92. gridForm.Show();
  93. }
  94. /// <summary>
  95. /// 选择分类A
  96. /// </summary>
  97. /// <param name="sender"></param>
  98. /// <param name="e"></param>
  99. private void gbflA_Click(object sender, EventArgs e)
  100. {
  101. typeIndex = 0;
  102. this.rbbtntype.Image = Properties.Resources.A1;
  103. ListChangedType();
  104. }
  105. /// <summary>
  106. /// 选择分类B
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. private void gbflB_Click(object sender, EventArgs e)
  111. {
  112. typeIndex = 1;
  113. this.rbbtntype.Image = Properties.Resources.B;
  114. ListChangedType();
  115. }
  116. /// <summary>
  117. /// 选择分类C
  118. /// </summary>
  119. /// <param name="sender"></param>
  120. /// <param name="e"></param>
  121. private void gbflC_Click(object sender, EventArgs e)
  122. {
  123. typeIndex = 2;
  124. this.rbbtntype.Image = Properties.Resources.C1;
  125. ListChangedType();
  126. }
  127. /// <summary>
  128. /// 选择分类D
  129. /// </summary>
  130. /// <param name="sender"></param>
  131. /// <param name="e"></param>
  132. private void gbflD_Click(object sender, EventArgs e)
  133. {
  134. typeIndex = 3;
  135. this.rbbtntype.Image = Properties.Resources.D;
  136. ListChangedType();
  137. }
  138. /// <summary>
  139. /// 选择分类DS
  140. /// </summary>
  141. /// <param name="sender"></param>
  142. /// <param name="e"></param>
  143. private void gbflDS_Click(object sender, EventArgs e)
  144. {
  145. typeIndex = 4;
  146. this.rbbtntype.Image = Properties.Resources.DS;
  147. ListChangedType();
  148. }
  149. /// <summary>
  150. /// 分类改变后测量结果改变
  151. /// </summary>
  152. private void ListChangedType()
  153. {
  154. foreach (var item in panel1.Controls)
  155. {
  156. CheckBox check = (CheckBox)item;
  157. if (check.Tag.GetType().Name == "Double[]")
  158. {
  159. double[] list = (double[])check.Tag;
  160. check.Text = Math.Round(list[typeIndex], 2).ToString();
  161. }
  162. }
  163. }
  164. #endregion
  165. #region 多组数据操作
  166. /// <summary>
  167. /// 添加分组
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void btnGroup_Click(object sender, EventArgs e)
  172. {
  173. string strTemp = string.Empty;
  174. InputText inputDialog = new InputText();
  175. inputDialog.TextHandler = (str) => { strTemp = str; };
  176. inputDialog.StartPosition = FormStartPosition.CenterParent;
  177. DialogResult result = inputDialog.ShowDialog();
  178. if (string.IsNullOrEmpty(strTemp))
  179. {
  180. return;
  181. }
  182. GroupBox group = new GroupBox();
  183. group.Width = panel2.Width - 20;
  184. group.Height = 50;
  185. group.Name = "grp" + groupCount;
  186. group.Location = new Point(0, groupCount * 50 + 5);
  187. group.Text = strTemp;
  188. foreach (GroupBox item in panel2.Controls)
  189. {
  190. ((Panel)item.Controls[0]).BorderStyle = BorderStyle.None;
  191. }
  192. Panel panel = new Panel();
  193. panel.Name = "pan" + groupCount;
  194. panel.Click += panParticles_Click;
  195. panel.Dock = DockStyle.Fill;
  196. panel.BorderStyle = BorderStyle.Fixed3D;
  197. panel.AutoScroll = true;
  198. group.Controls.Add(panel);
  199. panel2.Controls.Add(group);
  200. gp = group;
  201. groupCount++;
  202. }
  203. /// <summary>
  204. /// 选择分组
  205. /// </summary>
  206. /// <param name="sender"></param>
  207. /// <param name="e"></param>
  208. private void panParticles_Click(object sender, EventArgs e)
  209. {
  210. foreach (GroupBox item in panel2.Controls)
  211. {
  212. ((Panel)item.Controls[0]).BorderStyle = BorderStyle.None;
  213. }
  214. ((Panel)sender).BorderStyle = BorderStyle.Fixed3D;
  215. gp = (GroupBox)((Panel)sender).Parent;
  216. }
  217. /// <summary>
  218. /// 删除分组
  219. /// </summary>
  220. /// <param name="sender"></param>
  221. /// <param name="e"></param>
  222. private void btnDelGrp_Click(object sender, EventArgs e)
  223. {
  224. if (panel2.Controls.Count > 0 && gp != null)
  225. {
  226. DialogResult dr = MessageBox.Show("是否确认删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
  227. if (dr == DialogResult.No)
  228. {
  229. return;
  230. }
  231. int height = gp.Location.Y;
  232. panel2.Controls.Remove(gp);
  233. groupCount--;
  234. foreach (GroupBox item in panel2.Controls)
  235. {
  236. if (item.Location.Y > height)
  237. {
  238. item.Location = new Point(item.Location.X, item.Location.Y - 50);
  239. }
  240. }
  241. if (panel2.Controls.Count > 0)
  242. {
  243. int c = panel2.Controls.Count - 1;
  244. gp = (GroupBox)panel2.Controls[c];
  245. ((Panel)gp.Controls[0]).BorderStyle = BorderStyle.Fixed3D;
  246. }
  247. }
  248. }
  249. //分类
  250. int typeIndexGroup = 0;
  251. /// <summary>
  252. /// 添加颗粒直径
  253. /// </summary>
  254. /// <param name="sender"></param>
  255. /// <param name="e"></param>
  256. private void btnAddValueGroup_Click(object sender, EventArgs e)
  257. {
  258. Panel panel = (Panel)gp.Controls[0];
  259. AddVale(panel);
  260. }
  261. /// <summary>
  262. /// 添加测量结果文件
  263. /// </summary>
  264. /// <param name="sender"></param>
  265. /// <param name="e"></param>
  266. private void btnAddFileGroup_Click(object sender, EventArgs e)
  267. {
  268. if (gp == null)
  269. {
  270. MessageBox.Show("请添加分组!");
  271. btnGroup_Click(null, null);
  272. return;
  273. }
  274. Panel panel = (Panel)gp.Controls[0];
  275. DataReadConfigurationForm dialog = new DataReadConfigurationForm();
  276. if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  277. {
  278. this.Cursor = Cursors.WaitCursor;
  279. ScanFile(dialog.Filepath, dialog.LoadCount, panel);
  280. this.Cursor = Cursors.Default;
  281. }
  282. }
  283. /// <summary>
  284. /// 删除颗粒
  285. /// </summary>
  286. /// <param name="sender"></param>
  287. /// <param name="e"></param>
  288. private void btnDelGroup_Click(object sender, EventArgs e)
  289. {
  290. DialogResult dr = MessageBox.Show("是否确认删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
  291. if (dr == DialogResult.No)
  292. {
  293. return;
  294. }
  295. foreach (GroupBox group in panel2.Controls)
  296. {
  297. Panel panel = (Panel)group.Controls[0];
  298. DelVale(panel);
  299. }
  300. }
  301. /// <summary>
  302. /// 检验数据有效性,是否位离群值
  303. /// </summary>
  304. /// <param name="sender"></param>
  305. /// <param name="e"></param>
  306. private void btnCheckGroup_Click(object sender, EventArgs e)
  307. {
  308. foreach (GroupBox group in panel2.Controls)
  309. {
  310. Panel panel = (Panel)group.Controls[0];
  311. if (!CheckVale(panel))
  312. {
  313. break;
  314. }
  315. }
  316. }
  317. /// <summary>
  318. /// 极值分析
  319. /// </summary>
  320. /// <param name="sender"></param>
  321. /// <param name="e"></param>
  322. private void btnComputeGroup_Click(object sender, EventArgs e)
  323. {
  324. if (panel2.Controls.Count > 1)
  325. {
  326. List<Business.groupInfo> list = new List<Business.groupInfo>();
  327. List<Business.groupInfo> list1 = new List<Business.groupInfo>() {
  328. new Business.groupInfo() { values=new double[] {85,25,30,35,40,45,50,55 },groupTitle="DL2" },
  329. new Business.groupInfo() { values=new double[] {30,10,12,14,16,18,20,25 },groupTitle="LF1" },
  330. new Business.groupInfo() { values=new double[] {30,0,5,8,20,25,10,15 },groupTitle="LF2" },
  331. new Business.groupInfo() { values=new double[] {25,10,12,14,18,20,22,24},groupTitle="VD1-2" },
  332. new Business.groupInfo() { values=new double[] {40,10,15,20,35,24,26,30 },groupTitle="VD2-2" },
  333. new Business.groupInfo() { values=new double[] {45,10,15,20,25,30,35,29 },groupTitle="VD3" },
  334. new Business.groupInfo() { values=new double[] {85,10,15,60,55,30,35,40},groupTitle="JZ" }
  335. };
  336. foreach (GroupBox group in panel2.Controls)
  337. {
  338. Panel panel = (Panel)group.Controls[0];
  339. int chkcount = panel.Controls.Count;
  340. double[] vs = new double[chkcount];
  341. for (int i = 0; i < chkcount; i++)
  342. {
  343. vs[i] = Convert.ToDouble(((CheckBox)panel.Controls[i]).Text);
  344. }
  345. if (!CheckVale(panel,1))
  346. {
  347. break;
  348. }
  349. Business.groupInfo groupInfo = new Business.groupInfo();
  350. groupInfo.values = vs;
  351. groupInfo.groupTitle = group.Text;
  352. list.Add(groupInfo);
  353. }
  354. GroupsGridForm groupsGridForm = new GroupsGridForm(list);
  355. groupsGridForm.Show();
  356. }
  357. }
  358. /// <summary>
  359. /// 选择分类A
  360. /// </summary>
  361. /// <param name="sender"></param>
  362. /// <param name="e"></param>
  363. private void fzflA_Click(object sender, EventArgs e)
  364. {
  365. typeIndexGroup = 0;
  366. this.fztype.Image = Properties.Resources.A1;
  367. ListChangedTypeGroup();
  368. }
  369. /// <summary>
  370. /// 选择分类B
  371. /// </summary>
  372. /// <param name="sender"></param>
  373. /// <param name="e"></param>
  374. private void fzflB_Click(object sender, EventArgs e)
  375. {
  376. typeIndexGroup = 1;
  377. this.fztype.Image = Properties.Resources.B;
  378. ListChangedTypeGroup();
  379. }
  380. /// <summary>
  381. /// 选择分类C
  382. /// </summary>
  383. /// <param name="sender"></param>
  384. /// <param name="e"></param>
  385. private void fzflC_Click(object sender, EventArgs e)
  386. {
  387. typeIndexGroup = 2;
  388. this.fztype.Image = Properties.Resources.C1;
  389. ListChangedTypeGroup();
  390. }
  391. /// <summary>
  392. /// 选择分类D
  393. /// </summary>
  394. /// <param name="sender"></param>
  395. /// <param name="e"></param>
  396. private void fzflD_Click(object sender, EventArgs e)
  397. {
  398. typeIndexGroup = 3;
  399. this.fztype.Image = Properties.Resources.D;
  400. ListChangedTypeGroup();
  401. }
  402. /// <summary>
  403. /// 选择分类DS
  404. /// </summary>
  405. /// <param name="sender"></param>
  406. /// <param name="e"></param>
  407. private void fzflDS_Click(object sender, EventArgs e)
  408. {
  409. typeIndexGroup = 4;
  410. this.fztype.Image = Properties.Resources.DS;
  411. ListChangedTypeGroup();
  412. }
  413. /// <summary>
  414. /// 分类改变后测量结果改变
  415. /// </summary>
  416. private void ListChangedTypeGroup()
  417. {
  418. foreach (GroupBox group in panel2.Controls)
  419. {
  420. Panel panel = (Panel)group.Controls[0];
  421. int sel = typeIndexGroup;
  422. foreach (var item in panel.Controls)
  423. {
  424. CheckBox check = (CheckBox)item;
  425. if (check.Tag.GetType().Name == "Double[]")
  426. {
  427. double[] list = (double[])check.Tag;
  428. check.Text = Math.Round(list[sel], 2).ToString();
  429. }
  430. }
  431. }
  432. }
  433. #endregion
  434. #region 全局事件
  435. /// <summary>
  436. /// 选择单组数据
  437. /// </summary>
  438. /// <param name="sender"></param>
  439. /// <param name="e"></param>
  440. private void rbtab1_ActiveChanged(object sender, EventArgs e)
  441. {
  442. if (rbtab1.Active)
  443. {
  444. panel2.Dock = DockStyle.None;
  445. panel2.Visible = false;
  446. panel1.Dock = DockStyle.Fill;
  447. panel1.Visible = true;
  448. }
  449. }
  450. /// <summary>
  451. /// 选择多组数据
  452. /// </summary>
  453. /// <param name="sender"></param>
  454. /// <param name="e"></param>
  455. private void rbtab2_ActiveChanged(object sender, EventArgs e)
  456. {
  457. if (rbtab2.Active)
  458. {
  459. panel1.Dock = DockStyle.None;
  460. panel1.Visible = false;
  461. panel2.Dock = DockStyle.Fill;
  462. panel2.Visible = true;
  463. }
  464. }
  465. /// <summary>
  466. /// 窗体加载
  467. /// </summary>
  468. /// <param name="sender"></param>
  469. /// <param name="e"></param>
  470. private void ExtremumApp_Load(object sender, EventArgs e)
  471. {
  472. panel2.Dock = DockStyle.None;
  473. panel2.Visible = false;
  474. panel1.Dock = DockStyle.Fill;
  475. panel1.Visible = true;
  476. //if (!License())
  477. //{
  478. // this.Close();
  479. //}
  480. }
  481. /// <summary>
  482. /// 扫描文件夹添加测量结果
  483. /// </summary>
  484. /// <param name="path">文件夹路径</param>
  485. /// <param name="panel">添加数据的容器</param>
  486. private void ScanFile(string path,int loadCount,Panel panel)
  487. {
  488. //扫描路径
  489. DirectoryInfo info = new DirectoryInfo(path);
  490. if (!info.Exists) return;
  491. FileSystemInfo[] files = info.GetFileSystemInfos();
  492. for (int i = 0; i < files.Length; i++)
  493. {
  494. FileInfo file = files[i] as FileInfo;
  495. //是文件
  496. if (file != null&& file.Extension== ".rst")
  497. {
  498. //string fpath = System.IO.Path.GetDirectoryName(file.Name);
  499. try
  500. {
  501. var dic = Business.Classify.getClassByGroup(file.DirectoryName);
  502. int sel = typeIndex;
  503. for (int j = 0; j < loadCount; j++)
  504. {
  505. if(j>=dic[sel].Count)
  506. {
  507. break;
  508. }
  509. CheckBox checkBox = new CheckBox();
  510. checkBox.Text = Math.Round(dic[sel][j], 2).ToString();
  511. checkBox.Tag = new double[] {dic[0][j], dic[1][j], dic[2][j], dic[3][j], dic[4][j]};
  512. checkBox.Width = 80;
  513. // checkBox.Font = new Font(checkBox.Font.FontFamily, 8, checkBox.Font.Style);
  514. int chkcount = panel.Controls.Count;
  515. int row = chkcount / 10;
  516. int col = chkcount % 10;
  517. checkBox.Location = new Point(10 + col * 80, row * 35);
  518. panel.Controls.Add(checkBox);
  519. }
  520. }
  521. catch (Exception e)
  522. {
  523. MessageBox.Show(e.Message);
  524. }
  525. }
  526. else ScanFile(files[i].FullName, loadCount, panel);
  527. }
  528. }
  529. /// <summary>
  530. /// 添加颗粒数据
  531. /// </summary>
  532. /// <param name="panel">添加数据的容器</param>
  533. private void AddVale(Panel panel)
  534. {
  535. string strTemp = string.Empty;
  536. InputValue inputDialog = new InputValue();
  537. inputDialog.TextHandler = (str) => { strTemp = str; };
  538. inputDialog.StartPosition = FormStartPosition.CenterParent;
  539. DialogResult result = inputDialog.ShowDialog();
  540. string size = strTemp;
  541. if (!string.IsNullOrEmpty(size))
  542. {
  543. for (int i = 0; i < size.Split(',').Length; i++)
  544. {
  545. string init = size.Split(',')[i];
  546. if (!Business.Tools.IsIntOrDouble(init))
  547. {
  548. MessageBox.Show("不是数字!");
  549. continue;
  550. }
  551. CheckBox checkBox = new CheckBox();
  552. checkBox.Text = init;
  553. checkBox.Tag = Convert.ToDouble(init);
  554. checkBox.Width = 80;
  555. int chkcount = panel.Controls.Count;
  556. int row = chkcount / 10;
  557. int col = chkcount % 10;
  558. checkBox.Location = new Point(10 + col * 80, row * 35);
  559. panel.Controls.Add(checkBox);
  560. }
  561. }
  562. //if (!Business.Tools.IsIntOrDouble(size))
  563. //{
  564. // MessageBox.Show("请输入数字!");
  565. // return;
  566. //}
  567. //CheckBox checkBox = new CheckBox();
  568. //checkBox.Text = size;
  569. //checkBox.Tag = Convert.ToDouble(size);
  570. //checkBox.Width = 80;
  571. //int chkcount = panel.Controls.Count;
  572. //int row = chkcount / 10;
  573. //int col = chkcount % 10;
  574. //checkBox.Location = new Point(10 + col * 80, row * 35);
  575. //panel.Controls.Add(checkBox);
  576. }
  577. /// <summary>
  578. /// 删除颗粒数据
  579. /// </summary>
  580. /// <param name="panel">数据的容器</param>
  581. private void DelVale(Panel panel)
  582. {
  583. for (int i = panel.Controls.Count - 1; i >= 0; i--)
  584. {
  585. CheckBox check = (CheckBox)panel.Controls[i];
  586. if (check.Checked)
  587. {
  588. panel.Controls.RemoveAt(i);
  589. }
  590. }
  591. int chkcount = panel.Controls.Count;
  592. int rows = 0;
  593. int cols = 0;
  594. for (int i = 0; i < chkcount; i++)
  595. {
  596. CheckBox check = (CheckBox)panel.Controls[i];
  597. check.Location = new Point(10 + cols * 80, rows * 35);
  598. cols++;
  599. if (cols == 10)
  600. {
  601. rows++;
  602. cols = 0;
  603. }
  604. }
  605. }
  606. /// <summary>
  607. /// 检测数据有效性
  608. /// </summary>
  609. /// <param name="panel">数据的容器</param>
  610. /// <returns></returns>
  611. private bool CheckVale(Panel panel,int ischeck=0)
  612. {
  613. int chkcount = panel.Controls.Count;
  614. if (chkcount < 3)
  615. {
  616. MessageBox.Show("试验数据过少。");
  617. return false;
  618. }
  619. double[] vs = new double[chkcount];
  620. double[] gg = { 140, 240, 532, 205, 150, 110, 200, 180, 220, 300, 70, 390, 100, 90, 320, 190, 250, 150, 280, 250, 490, 120, 500, 200 };
  621. for (int i = 0; i < chkcount; i++)
  622. {
  623. vs[i] = Convert.ToDouble(((CheckBox)panel.Controls[i]).Text);
  624. }
  625. int ret = Business.Tools.Grubbls(vs);
  626. if (ret == 0&& ischeck==0)
  627. {
  628. MessageBox.Show("试验数据有效。");
  629. return true;
  630. }
  631. else if (ret == 1)
  632. {
  633. MessageBox.Show("最大的夹杂物长度值【"+ vs.Max().ToString() + "】是离群值,试验数据无效。");
  634. return false;
  635. }
  636. else if (ret == 2)
  637. {
  638. MessageBox.Show("最小的夹杂物长度值【" + vs.Min().ToString() + "】是离群值,试验数据无效。");
  639. return false;
  640. }
  641. return true;
  642. }
  643. //检测注册
  644. private bool License()
  645. {
  646. //硬件ID
  647. //string HardwareID = GetLicenseInfo("HardwareID");
  648. ////创建ManagementObjectSearcher对象
  649. //ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
  650. //String strHardDiskID = null;
  651. ////调用ManagementObjectSearcher类的Get方法取主板号
  652. //foreach (ManagementObject mo in searcher.Get())
  653. //{
  654. // strHardDiskID = mo["SerialNumber"].ToString().Trim();//记录获得的磁盘序列号
  655. // break;
  656. //}
  657. //if (Business.Tools.Base64Decrypt(HardwareID) != strHardDiskID)
  658. //{
  659. // MessageBox.Show("未注册!");
  660. // return false;
  661. //}
  662. try
  663. {
  664. //有效期
  665. DateTime ExpireDate = Convert.ToDateTime(Business.Tools.Base64Decrypt(GetLicenseInfo("ExpireDate")));
  666. if (DateTime.Now > ExpireDate)
  667. {
  668. MessageBox.Show("已超过使用期限!");
  669. return false;
  670. }
  671. }
  672. catch (Exception)
  673. {
  674. MessageBox.Show("未注册!");
  675. return false;
  676. }
  677. return true;
  678. }
  679. public static string GetLicenseInfo(string NodeName)
  680. {
  681. string path = Application.StartupPath + "\\LicenseData.xml";
  682. return Business.Tools.GetXMLInformations(path, NodeName);
  683. }
  684. #endregion
  685. }
  686. }