CreateDBManually.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using CCWin;
  2. using Newtonsoft.Json.Linq;
  3. using SufeiUtil;
  4. using SXLibrary;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Data.SQLite;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Management;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. namespace MOKA_Factory_Tools
  17. {
  18. public partial class CreateDBManually : Skin_Color
  19. {
  20. string url;
  21. string order;
  22. MidList midList1 = new MidList();
  23. MidAddress midAddress1 = new MidAddress();
  24. SQLiteConnection errorDBNow;
  25. SQLiteConnection ReportDB;
  26. string dbPath;
  27. public CreateDBManually(string getMidInfoUrl_Test, System.Data.SQLite.SQLiteConnection errorDB)
  28. {
  29. InitializeComponent();
  30. url = getMidInfoUrl_Test;
  31. errorDBNow = errorDB;
  32. }
  33. private void SubmitMIDInfo_Click(object sender, EventArgs e)
  34. {
  35. if (Order_Text.Text.Trim().Length > 0)
  36. {
  37. dbPath = AppDomain.CurrentDomain.BaseDirectory + "\\Keys\\" + Order_Text.Text.Trim() + ".db";
  38. order = Order_Text.Text.Trim();
  39. if (CommonMethod.GetMidInfo(url, order, TestMode.MAC, "", "", errorDBNow, out midList1))
  40. {
  41. if (CommonMethod.GetMidAddress2(midList1, order, errorDBNow, out List<MidAddress> midAddress2))
  42. {
  43. foreach(var midAddress1 in midAddress2)
  44. {
  45. SoftwareVersion_Text.Text = midAddress1.version;
  46. ClientType_Text.Text = midAddress1.ctype;
  47. OrderQuantity.Text = midAddress1.number;
  48. ProjectID_Text.Text = midAddress1.pid;
  49. Download DownloadPage = new Download(errorDBNow, midAddress1, comboBox1.SelectedIndex, null, null);
  50. DownloadPage.ShowDialog();
  51. }
  52. if(File.Exists(dbPath))
  53. {
  54. ReportDB = new SQLiteConnection("data source=" + dbPath);
  55. ReportDB.Open();
  56. if (SQLiteHelper.WholeCheckDownloadStatus(ReportDB, order))
  57. {
  58. if (CommonMethod.ReportDownloadStatus(midList1.host, order, errorDBNow))
  59. MessageBox.Show(LResource.DownloadSuccess);
  60. else
  61. MessageBox.Show(LResource.DownloadReportFail);
  62. }
  63. ReportDB.Close();
  64. }
  65. }
  66. else
  67. MessageBox.Show(LResource.GetMidAdresserror);
  68. }
  69. else
  70. MessageBox.Show(LResource.GetMidInfoerror);
  71. }
  72. else
  73. MessageBox.Show("请输入订单号!");
  74. }
  75. private void skinButton1_Click(object sender, EventArgs e)
  76. {
  77. dbPath = AppDomain.CurrentDomain.BaseDirectory + "\\Keys\\" + Order_Text.Text.Trim() + ".db";
  78. ReportDB = new SQLiteConnection("data source=" + dbPath);
  79. bool result = true;
  80. try
  81. {
  82. ReportDB.Open();
  83. string count;
  84. if (SQLiteHelper.GetEppormDataCount(ReportDB, out count))
  85. progressBar1.Maximum = Convert.ToInt32(count) + 1;
  86. else
  87. goto end;
  88. if(SQLiteHelper.GetEppormUploadedDataCount(ReportDB, out count))
  89. progressBar1.Value= Convert.ToInt32(count);
  90. else
  91. goto end;
  92. List<string> SNs = new List<string>();
  93. do
  94. {
  95. //int n = 0;
  96. List<PostDateClass> postList = new List<PostDateClass>();
  97. if (!SQLiteHelper.GetEppormDataList(ReportDB, out postList,out SNs))
  98. {
  99. goto end;
  100. }
  101. if (SNs.Count==0)
  102. {
  103. break;
  104. }
  105. if (!CommonMethod.UploadPreloadCopyResultList(midAddress1.host, postList, ReportDB, errorDBNow, false, ""))//
  106. {
  107. MessageBox.Show("上报异常!");
  108. goto end;
  109. }
  110. else
  111. {
  112. SQLiteHelper.UpdateReportListStatus(ReportDB, SNs);
  113. }
  114. } while (SNs.Count>0);
  115. MessageBox.Show("上报成功!");
  116. result = false;
  117. end:
  118. if(result)
  119. MessageBox.Show("error!");
  120. }
  121. catch(Exception ex)
  122. {
  123. MessageBox.Show(ex.Message);
  124. }
  125. }
  126. private void CreateDBManually_FormClosing(object sender, FormClosingEventArgs e)
  127. {
  128. errorDBNow.Close();
  129. GC.Collect();
  130. }
  131. private void CreateDBManually_Load(object sender, EventArgs e)
  132. {
  133. comboBox1.SelectedIndex = 0;
  134. }
  135. }
  136. }