Main.cs 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  1. using CCWin;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using SufeiUtil;
  5. using SXLibrary;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Data.SQLite;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.IO.Ports;
  13. using System.Linq;
  14. using System.Net;
  15. using System.Threading;
  16. using System.Threading.Tasks;
  17. using System.Windows.Forms;
  18. namespace MOKA_Factory_Tools
  19. {
  20. public delegate void MoveHandler(Point XY, ArrayList formlocationmsg, int num);
  21. public delegate void KeyDownHandler(ArrayList formlocationmsg, IntPtr intPtr);
  22. public partial class Main : Skin_Color
  23. {
  24. MidList midList1 = new MidList();
  25. UpgradeMsgList UpgradeMsgList1 = new UpgradeMsgList();
  26. MidAddress midAddress1 = new MidAddress();
  27. ReadCheck ReadCheck1 = new ReadCheck();
  28. WriteCheck WriteCheck1 = new WriteCheck();
  29. WriteDone WriteDone1 = new WriteDone();
  30. FunctionSetting functionSetting1 = new FunctionSetting();
  31. SQLiteConnection LocalDB = null;
  32. SQLiteConnection ErrorDB = null;
  33. Dictionary<string, string> ChannelMapList = new Dictionary<string, string>();
  34. Dictionary<string, string> LanguageMapList = new Dictionary<string, string>();
  35. string Custom_ProjectID = "";
  36. ArrayList formlocationmsg = new ArrayList();
  37. string ErrorDBPath = AppDomain.CurrentDomain.BaseDirectory + "\\Error.db";
  38. Thread uploadbackground;
  39. bool LocalWrite = false;//离线抄写开关
  40. bool LocationMark = true;//操作窗体换行点
  41. int LocationNum = 0;//一行操作窗体数
  42. public event KeyDownHandler KeyDownEvent;
  43. public event MoveHandler MoveEvent;
  44. public Main(int enable)
  45. {
  46. InitializeComponent();
  47. LockSettingFunction(enable == 0 || enable == 3);
  48. CreateKeyManually.Visible = enable == 1;
  49. LocalWrite = enable == 3;
  50. }
  51. private void Form1_Load(object sender, EventArgs e)
  52. {
  53. uploadbackground = new Thread(UploadBackGround);
  54. uploadbackground.IsBackground = true;
  55. TVCOM.Items.AddRange(SerialPort.GetPortNames());
  56. LoadJsonConfig();
  57. this.StartPosition = FormStartPosition.Manual;
  58. this.Location = new Point(0, 0);
  59. this.Text = CommonMethod.FactoryName + " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
  60. if (!File.Exists(ErrorDBPath))
  61. {
  62. if (SQLiteHelper.NewDbFile(ErrorDBPath))
  63. {
  64. SQLiteHelper.NewTable(ErrorDBPath, "ErrorReport", "(ID INTEGER PRIMARY KEY AUTOINCREMENT,url varchar,content varvhar,gener_date DATETIME DEFAULT (datetime(CURRENT_TIMESTAMP,'localtime')),report_date DATETIME)");
  65. SQLiteHelper.NewTable(ErrorDBPath, "CopyDelayReport", "(ID INTEGER PRIMARY KEY AUTOINCREMENT,bid varchar,url varchar,content varvhar,copy_date DATETIME DEFAULT (datetime(CURRENT_TIMESTAMP,'localtime')),report_date DATETIME)");
  66. SQLiteHelper.NewTable(ErrorDBPath, "ProductionCount", "(bid varchar,count varchar)");
  67. }
  68. }
  69. if (ErrorDB == null)
  70. {
  71. ErrorDB = new SQLiteConnection("data source=" + ErrorDBPath);
  72. ErrorDB.Open();
  73. }
  74. }
  75. private void SetDSNLimit()
  76. {
  77. // 如果抄写PSN,不自动赋值条码限制;
  78. if (BarcodeWrite.Checked)
  79. return;
  80. // 设置条码限制默认打上勾;
  81. if (midList1.keytype != null && midList1.keytype.ContainsKey("DSN"))
  82. {
  83. BarcodeLimit.Checked = true;
  84. BarCodeKeyCodeText.Text = OrderText.Text;
  85. }
  86. }
  87. private void OrderSubmit_Click(object sender, EventArgs e)
  88. {
  89. SQLiteHelper.DeleteOldData(ErrorDB);//删除30天以前已经上报的数据
  90. if (TestMode.serverurl == Serverurl.Testurl)
  91. {
  92. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  93. DialogResult dr = MessageBox.Show(LResource.TestServerUsingError, LResource.Error, messButton);
  94. if (dr == DialogResult.Yes)
  95. {
  96. //
  97. }
  98. else
  99. {
  100. return;
  101. }
  102. }
  103. if (TVCOM.SelectedItem == null)
  104. {
  105. MessageBox.Show(LResource.TVCOMNullError, LResource.Error);
  106. return;
  107. }
  108. if (OrderText.Text.Trim().Length == 0)
  109. {
  110. MessageBox.Show(LResource.OrderNullError, LResource.Error);
  111. return;
  112. }
  113. if (!SQLiteHelper.CheckProductionNum(ErrorDB, OrderText.Text.Trim()))
  114. {
  115. MessageBox.Show(LResource.CheckProductionNumError, LResource.Error);
  116. return;
  117. }
  118. if (timer1.Enabled == false)
  119. timer1.Start();
  120. OrderSubmit.Text = LResource.Waiting;
  121. SaveJsonConfig("LastOrder", OrderText.Text.ToString());
  122. functionSetting1.TVCOM = TVCOM.SelectedItem.ToString();
  123. functionSetting1.TVBaud = TVBaud.SelectedItem.ToString();
  124. functionSetting1.ChannelList = ChannelList.SelectedItem.ToString();
  125. functionSetting1.WriteChannel = WriteChannel.Checked;
  126. functionSetting1.WriteOSD = WriteOSD.Checked;
  127. functionSetting1.OSDList = OSDList.SelectedItem.ToString();
  128. functionSetting1.WriteSHOP = WriteSHOP.Checked;
  129. functionSetting1.SHOPList = SHOPList.SelectedItem.ToString();
  130. functionSetting1.WriteWB = WriteWB.Checked;
  131. functionSetting1.WBInit = WBInit.Checked;
  132. functionSetting1.WBPath = WBPath.Text;
  133. if (!LocalWrite)
  134. {
  135. if (Preload.Checked)
  136. {
  137. string dbPath = AppDomain.CurrentDomain.BaseDirectory + "\\Keys\\" + OrderText.Text.Trim() + ".db";
  138. if (File.Exists(dbPath))
  139. {
  140. if (LocalDB == null)
  141. {
  142. LocalDB = new SQLiteConnection("data source=" + dbPath);
  143. LocalDB.Open();
  144. }
  145. if (SQLiteHelper.WholeCheckDownloadStatus(LocalDB, OrderText.Text.Trim()))
  146. {
  147. try
  148. {
  149. if (SQLiteHelper.GetDBMidInfo(LocalDB, OrderText.Text.Trim(), out midAddress1))
  150. {
  151. if (UsinglocalIDCheck.Checked)
  152. {
  153. midAddress1.pid = Custom_ProjectID;
  154. MessageBox.Show(LResource.WilluseLocalPID, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  155. }
  156. else if (midAddress1.pid != Custom_ProjectID && Custom_ProjectID.Trim().Length > 0)
  157. {
  158. if (midAddress1.pid != null)
  159. if (midAddress1.pid.Trim().Length > 0)
  160. PID_Num.Value = Convert.ToDecimal(midAddress1.pid);
  161. MessageBox.Show(LResource.WilluseOnlinePID, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
  162. }
  163. if (SQLiteHelper.GetrokuCustomer(LocalDB, OrderText.Text, out RokuCustomer rokuCustomer_1))
  164. {
  165. midList1.rokuCustomer = rokuCustomer_1;
  166. };
  167. if (SQLiteHelper.Getdsn(LocalDB, OrderText.Text, out string firetvdsn))
  168. {
  169. midList1.keytype = new Dictionary<string, string>();
  170. midList1.keytype.Add("DSN", firetvdsn);
  171. };
  172. if (SQLiteHelper.Getwhitebalance(LocalDB, OrderText.Text, out WhiteBalanceInfo whiteBalanceInfo_1))
  173. {
  174. functionSetting1.WBPath = dbPath;
  175. functionSetting1.WriteWB = true;
  176. functionSetting1.NormalRGB = new byte[3];
  177. functionSetting1.CoolRGB = new byte[3];
  178. functionSetting1.WarmRGB = new byte[3];
  179. functionSetting1.NormalRGB[0] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmirgain);
  180. functionSetting1.NormalRGB[1] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmiggain);
  181. functionSetting1.NormalRGB[2] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmibgain);
  182. functionSetting1.CoolRGB[0] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lrgain) + 256);
  183. functionSetting1.CoolRGB[1] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lggain) + 256);
  184. functionSetting1.CoolRGB[2] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lbgain) + 256);
  185. functionSetting1.WarmRGB[0] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nrgain) + 256);
  186. functionSetting1.WarmRGB[1] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nggain) + 256);
  187. functionSetting1.WarmRGB[2] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nbgain) + 256);
  188. };
  189. OperationPanel operationPanel1 = new OperationPanel(this, LocalDB, ErrorDB, midAddress1, functionSetting1, WriteCheck1, ReadCheck1, WriteDone1, Preload.Checked, midList1, OrderText.Text.Trim());
  190. operationPanel1.StartPosition = FormStartPosition.Manual;
  191. if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width && LocationMark)
  192. {
  193. LocationMark = false;
  194. LocationNum = formlocationmsg.Count;
  195. }
  196. if (formlocationmsg.Count == 0)
  197. operationPanel1.Location = (Point)new Size(this.Right, this.Top);
  198. else if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width)
  199. {
  200. Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
  201. operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * (formlocationmsg.Count - LocationNum), this.Top + operationPanel1.Size.Height);
  202. }
  203. else
  204. {
  205. Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
  206. operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * formlocationmsg.Count, this.Top);
  207. }
  208. operationPanel1.DeleteIntptr += new OperationPanel.DisplayUpdateDelegate(DeleteIntptr);
  209. operationPanel1.SNKeyDownEven += new OperationPanel.SNKeyDown(SNKeyDownEven);
  210. operationPanel1.AutoKeyRequire += new OperationPanel.AutoKeyRequireDelegate(AutoKeyRequire);
  211. IntPtr intPtr = operationPanel1.Handle;
  212. Dictionary<IntPtr, Point> part1 = new Dictionary<IntPtr, Point>();
  213. part1.Add(intPtr, (Point)new Size(operationPanel1.Right, operationPanel1.Top));
  214. formlocationmsg.Add(part1);
  215. operationPanel1.Show();
  216. }
  217. else
  218. {
  219. MessageBox.Show("Read LocalDB error,please delete old db file and download a new one");
  220. }
  221. }
  222. catch (Exception ex)
  223. {
  224. Log.WriteErrorLog(ex.Message);
  225. }
  226. // 是否有dsn要抄写;
  227. SetDSNLimit();
  228. }
  229. }
  230. else
  231. {
  232. if (CommonMethod.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, "", "", ErrorDB, out midList1))
  233. {
  234. if (CommonMethod.GetMidAddress2(midList1, OrderText.Text.Trim(), ErrorDB, out List<MidAddress> midAddress2))
  235. {
  236. WhiteBalanceList WhiteBalanceListNow;
  237. // 如果是抄写EDID,则不获取白平衡数据;
  238. if (CommonMethod.IsEDIDCopy(midList1))
  239. midList1.whiteType = "-1";
  240. switch (midList1.whiteType)//订单白平衡预置状态
  241. {
  242. case "0"://旧订单,默认值
  243. {
  244. CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out WhiteBalanceListNow);
  245. break;
  246. }
  247. case "1"://未预置或预置LR数据
  248. {
  249. CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out WhiteBalanceListNow);
  250. if (WhiteBalanceListNow.whiteBalanceInfo == null)
  251. {
  252. MessageBox.Show("White balance info error, please contact factory engineer!");
  253. return;
  254. }
  255. break;
  256. }
  257. case "2"://已预置PR数据
  258. {
  259. CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out WhiteBalanceListNow);
  260. break;
  261. }
  262. default:
  263. {
  264. WhiteBalanceListNow = null;
  265. break;
  266. }
  267. }
  268. foreach (var midAddress1 in midAddress2)
  269. {
  270. string KeyPath = AppDomain.CurrentDomain.BaseDirectory + "\\download\\" + midAddress1.order + ".json";
  271. if (System.IO.File.Exists(KeyPath))
  272. {
  273. if (GetMD5.GetMD5HashFromFile(KeyPath) == midAddress1.pmd5)
  274. {
  275. if (SQLiteHelper.NewDbFile(dbPath))
  276. {
  277. SQLiteHelper.NewTable(dbPath, "keys", "(sn varchar,keys varvhar,copy_date DATETIME,report_date DATETIME)");
  278. SQLiteHelper.NewTable(dbPath, "mid", "(bid varchar,number varchar, pid varchar,ctype varvhar,version varvhar,host varchar,purl varvhar,psize varvhar,pmd5 varvhar,status varvhar,start_date DATETIME DEFAULT (datetime(CURRENT_TIMESTAMP,'localtime')),finish_date DATETIME,desc varvhar)");
  279. SQLiteHelper.NewTable(dbPath, "report", "(url varchar,content varchar,gener_date DATETIME,report_date DATETIME)");
  280. SQLiteHelper.NewTable(dbPath, "rokuCustomer", "(ordernum varchar,region varchar,brand varchar,oemmodel varchar,supporturl varchar,supportphone varchar,productiondate varchar,remotetype varchar)");
  281. SQLiteHelper.NewTable(dbPath, "whitebalance", "(ordernum varchar,hdmirgain varchar,hdmiggain varchar,hdmibgain varchar,nrgain varchar,nggain varchar,nbgain varchar,lrgain varchar,lggain varchar,lbgain varchar,updatetime DATETIME DEFAULT (datetime(CURRENT_TIMESTAMP,'localtime')))");
  282. SQLiteHelper.NewTable(dbPath, "dsn", "(ordernum varchar,dsn varchar,updatetime DATETIME DEFAULT (datetime(CURRENT_TIMESTAMP,'localtime')))");
  283. SQLiteHelper.AddOneLine(dbPath, new object[] { midAddress1.order, midAddress1.number, midAddress1.pid, midAddress1.ctype, midAddress1.version, midList1.host, midAddress1.purl, midAddress1.psize, midAddress1.pmd5, "1" });
  284. if (midList1.rokuCustomer != null)
  285. SQLiteHelper.AddRokuOneLine(dbPath, new object[] { midList1.rokuCustomer.ordernum, midList1.rokuCustomer.region, midList1.rokuCustomer.brand, midList1.rokuCustomer.oemmodel, midList1.rokuCustomer.supporturl, midList1.rokuCustomer.supportphone, midList1.rokuCustomer.productiondate, midList1.rokuCustomer.remotetype });
  286. if (WhiteBalanceListNow != null)
  287. if (WhiteBalanceListNow.whiteBalanceInfo != null)
  288. SQLiteHelper.AddwbOneLine(dbPath, new object[] { WhiteBalanceListNow.whiteBalanceInfo.ordernum,
  289. WhiteBalanceListNow.whiteBalanceInfo.hdmirgain, WhiteBalanceListNow.whiteBalanceInfo.hdmiggain, WhiteBalanceListNow.whiteBalanceInfo.hdmibgain,
  290. WhiteBalanceListNow.whiteBalanceInfo.nrgain, WhiteBalanceListNow.whiteBalanceInfo.nggain, WhiteBalanceListNow.whiteBalanceInfo.nbgain,
  291. WhiteBalanceListNow.whiteBalanceInfo.lrgain, WhiteBalanceListNow.whiteBalanceInfo.lggain, WhiteBalanceListNow.whiteBalanceInfo.lbgain });
  292. if (midList1.keytype.ContainsKey("DSN"))
  293. {
  294. SQLiteHelper.AdddsnOneLine(dbPath, new object[] { midAddress1.order, midList1.keytype["DSN"] });
  295. }
  296. SQLiteHelper.UpdateTime(dbPath, midAddress1.order);
  297. }
  298. if (File.Exists(dbPath))
  299. {
  300. List<object[]> keyDatas = new List<object[]>();
  301. using (System.IO.StreamReader file = System.IO.File.OpenText(KeyPath))
  302. {
  303. using (JsonTextReader reader = new JsonTextReader(file))
  304. {
  305. JArray o = (JArray)JToken.ReadFrom(reader);
  306. foreach (var ss in o) //查找某个字段与值
  307. {
  308. var sn = ((JObject)ss)["sn"];
  309. var data = ((JObject)ss)["key"];
  310. keyDatas.Add(new object[] { sn, data });
  311. }
  312. }
  313. }
  314. SQLiteHelper.InsertKeys(dbPath, keyDatas);
  315. }
  316. try
  317. {
  318. if (LocalDB == null)
  319. {
  320. LocalDB = new SQLiteConnection("data source=" + dbPath);
  321. LocalDB.Open();
  322. }
  323. OperationPanel operationPanel1 = new OperationPanel(this, LocalDB, ErrorDB, midAddress1, functionSetting1, WriteCheck1, ReadCheck1, WriteDone1, Preload.Checked, midList1, OrderText.Text.Trim());
  324. operationPanel1.StartPosition = FormStartPosition.Manual;
  325. if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width && LocationMark)
  326. {
  327. LocationMark = false;
  328. LocationNum = formlocationmsg.Count;
  329. }
  330. if (formlocationmsg.Count == 0)
  331. operationPanel1.Location = (Point)new Size(this.Right, this.Top);
  332. else if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width)
  333. {
  334. Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
  335. operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * (formlocationmsg.Count - LocationNum), this.Top + operationPanel1.Size.Height);
  336. }
  337. else
  338. {
  339. Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
  340. operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * formlocationmsg.Count, this.Top);
  341. }
  342. operationPanel1.DeleteIntptr += new OperationPanel.DisplayUpdateDelegate(DeleteIntptr);
  343. operationPanel1.SNKeyDownEven += new OperationPanel.SNKeyDown(SNKeyDownEven);
  344. operationPanel1.AutoKeyRequire += new OperationPanel.AutoKeyRequireDelegate(AutoKeyRequire);
  345. IntPtr intPtr = operationPanel1.Handle;
  346. Dictionary<IntPtr, Point> part1 = new Dictionary<IntPtr, Point>();
  347. part1.Add(intPtr, (Point)new Size(operationPanel1.Right, operationPanel1.Top));
  348. formlocationmsg.Add(part1);
  349. operationPanel1.Show();
  350. }
  351. catch (Exception ex)
  352. {
  353. Log.WriteErrorLog(ex.Message);
  354. }
  355. }
  356. else
  357. {
  358. Download DownloadPage = new Download(ErrorDB, midAddress1, -1, midList1, WhiteBalanceListNow);
  359. DownloadPage.ShowDialog();
  360. int gid = GC.GetGeneration(DownloadPage);
  361. DownloadPage = null;
  362. GC.Collect(gid);
  363. }
  364. }
  365. else
  366. {
  367. Download DownloadPage = new Download(ErrorDB, midAddress1, -1, midList1, WhiteBalanceListNow);
  368. DownloadPage.ShowDialog();
  369. int gid = GC.GetGeneration(DownloadPage);
  370. DownloadPage = null;
  371. GC.Collect(gid);
  372. }
  373. }
  374. if (File.Exists(dbPath))
  375. {
  376. if (LocalDB == null)
  377. {
  378. LocalDB = new SQLiteConnection("data source=" + dbPath);
  379. LocalDB.Open();
  380. }
  381. if (SQLiteHelper.WholeCheckDownloadStatus(LocalDB, OrderText.Text.Trim()))
  382. {
  383. if (CommonMethod.ReportDownloadStatus(midList1.host, OrderText.Text.Trim(), ErrorDB))
  384. MessageBox.Show(LResource.DownloadSuccess);
  385. else
  386. MessageBox.Show(LResource.DownloadReportFail);
  387. }
  388. }
  389. }
  390. else
  391. {
  392. MessageBox.Show(LResource.GetMidAdresserror);
  393. }
  394. }
  395. else
  396. {
  397. MessageBox.Show(LResource.GetMidInfoerror);
  398. }
  399. // 是否有dsn要抄写;
  400. SetDSNLimit();
  401. }
  402. }
  403. else
  404. {
  405. if (CommonMethod.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, "", "", ErrorDB, out midList1))
  406. {
  407. //CommonMethod.UpgradeCheck(UpgradeUrl.Officialurl, midList1.factoryNum, ErrorDB, out UpgradeMsgList1);
  408. if (UsinglocalIDCheck.Checked)
  409. {
  410. midList1.projectid = Custom_ProjectID;
  411. MessageBox.Show(LResource.WilluseLocalPID, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  412. }
  413. else if (midList1.projectid != Custom_ProjectID && Custom_ProjectID.Trim().Length > 0)
  414. {
  415. if (midList1.projectid != null)
  416. if (midList1.projectid.Trim().Length > 0)
  417. PID_Num.Value = Convert.ToDecimal(midList1.projectid);
  418. MessageBox.Show(LResource.WilluseOnlinePID, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
  419. }
  420. try
  421. {
  422. OperationPanel operationPanel1 = new OperationPanel(this, LocalDB, ErrorDB, midAddress1, functionSetting1, WriteCheck1, ReadCheck1, WriteDone1, Preload.Checked, midList1, OrderText.Text.Trim());
  423. operationPanel1.StartPosition = FormStartPosition.Manual;
  424. if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width && LocationMark)
  425. {
  426. LocationMark = false;
  427. LocationNum = formlocationmsg.Count;
  428. }
  429. if (formlocationmsg.Count == 0)
  430. operationPanel1.Location = (Point)new Size(this.Right, this.Top);
  431. else if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width)
  432. {
  433. Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
  434. operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * (formlocationmsg.Count - LocationNum), this.Top + operationPanel1.Size.Height);
  435. }
  436. else
  437. {
  438. Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
  439. operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * formlocationmsg.Count, this.Top);
  440. }
  441. operationPanel1.DeleteIntptr += new OperationPanel.DisplayUpdateDelegate(DeleteIntptr);
  442. operationPanel1.SNKeyDownEven += new OperationPanel.SNKeyDown(SNKeyDownEven);
  443. operationPanel1.AutoKeyRequire += new OperationPanel.AutoKeyRequireDelegate(AutoKeyRequire);
  444. IntPtr intPtr = operationPanel1.Handle;
  445. Dictionary<IntPtr, Point> part1 = new Dictionary<IntPtr, Point>();
  446. part1.Add(intPtr, (Point)new Size(operationPanel1.Right, operationPanel1.Top));
  447. formlocationmsg.Add(part1);
  448. operationPanel1.Show();
  449. }
  450. catch (Exception ex)
  451. {
  452. Log.WriteErrorLog(ex.Message);
  453. }
  454. // 是否有dsn要抄写;
  455. SetDSNLimit();
  456. }
  457. else
  458. {
  459. MessageBox.Show(LResource.GetMidInfoerror);
  460. }
  461. }
  462. }
  463. else
  464. {
  465. MessageBox.Show(LResource.LocalKeyMode);
  466. try
  467. {
  468. if (Preload.Checked)
  469. {
  470. string dbPath = AppDomain.CurrentDomain.BaseDirectory + "\\Keys\\" + OrderText.Text.Trim() + ".db";
  471. if (File.Exists(dbPath))
  472. {
  473. if (LocalDB == null)
  474. {
  475. LocalDB = new SQLiteConnection("data source=" + dbPath);
  476. LocalDB.Open();
  477. }
  478. if (SQLiteHelper.WholeCheckDownloadStatus(LocalDB, OrderText.Text.Trim()))
  479. {
  480. if (SQLiteHelper.GetDBMidInfo(LocalDB, OrderText.Text.Trim(), out midAddress1))
  481. {
  482. if (UsinglocalIDCheck.Checked)
  483. {
  484. midAddress1.pid = Custom_ProjectID;
  485. MessageBox.Show(LResource.WilluseLocalPID, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  486. }
  487. else if (midAddress1.pid != Custom_ProjectID && Custom_ProjectID.Trim().Length > 0)
  488. {
  489. if (midAddress1.pid != null)
  490. if (midAddress1.pid.Trim().Length > 0)
  491. PID_Num.Value = Convert.ToDecimal(midAddress1.pid);
  492. MessageBox.Show(LResource.WilluseOnlinePID, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
  493. }
  494. midList1 = new MidList()
  495. {
  496. keytype = new Dictionary<string, string>(),
  497. clienttype = midAddress1.ctype,
  498. version = midAddress1.version,
  499. projectid = midAddress1.pid,
  500. host = "LocalPC"
  501. };
  502. if (SQLiteHelper.GetrokuCustomer(LocalDB, OrderText.Text, out RokuCustomer rokuCustomer_1))
  503. {
  504. midList1.rokuCustomer = rokuCustomer_1;
  505. };
  506. if (SQLiteHelper.Getdsn(LocalDB, OrderText.Text, out string firetvdsn))
  507. {
  508. midList1.keytype = new Dictionary<string, string>();
  509. midList1.keytype.Add("DSN", firetvdsn);
  510. };
  511. if (SQLiteHelper.Getwhitebalance(LocalDB, OrderText.Text, out WhiteBalanceInfo whiteBalanceInfo_1))
  512. {
  513. functionSetting1.WBPath = dbPath;
  514. functionSetting1.WriteWB = true;
  515. functionSetting1.NormalRGB = new byte[3];
  516. functionSetting1.CoolRGB = new byte[3];
  517. functionSetting1.WarmRGB = new byte[3];
  518. functionSetting1.NormalRGB[0] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmirgain);
  519. functionSetting1.NormalRGB[1] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmiggain);
  520. functionSetting1.NormalRGB[2] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmibgain);
  521. functionSetting1.CoolRGB[0] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lrgain) + 256);
  522. functionSetting1.CoolRGB[1] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lggain) + 256);
  523. functionSetting1.CoolRGB[2] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lbgain) + 256);
  524. functionSetting1.WarmRGB[0] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nrgain) + 256);
  525. functionSetting1.WarmRGB[1] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nggain) + 256);
  526. functionSetting1.WarmRGB[2] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nbgain) + 256);
  527. };
  528. }
  529. else
  530. {
  531. MessageBox.Show(LResource.FailtoReadLocalDB);
  532. return;
  533. }
  534. }
  535. else
  536. {
  537. MessageBox.Show(LResource.LocalDBIncomplete);
  538. return;
  539. }
  540. }
  541. else
  542. {
  543. MessageBox.Show(LResource.NofoundLocalDB);
  544. return;
  545. }
  546. }
  547. else
  548. {
  549. midList1 = new MidList()
  550. {
  551. keytype = new Dictionary<string, string>(),
  552. projectid = Custom_ProjectID,
  553. host = "LocalPC"
  554. };
  555. }
  556. OperationPanel operationPanel1 = new OperationPanel(this, LocalDB, ErrorDB, null, functionSetting1, WriteCheck1, ReadCheck1, WriteDone1, Preload.Checked, midList1, OrderText.Text.Trim());
  557. operationPanel1.StartPosition = FormStartPosition.Manual;
  558. if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width && LocationMark)
  559. {
  560. LocationMark = false;
  561. LocationNum = formlocationmsg.Count;
  562. }
  563. if (formlocationmsg.Count == 0)
  564. operationPanel1.Location = (Point)new Size(this.Right, this.Top);
  565. else if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width)
  566. {
  567. Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
  568. operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * (formlocationmsg.Count - LocationNum), this.Top + operationPanel1.Size.Height);
  569. }
  570. else
  571. {
  572. Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
  573. operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * formlocationmsg.Count, this.Top);
  574. }
  575. operationPanel1.DeleteIntptr += new OperationPanel.DisplayUpdateDelegate(DeleteIntptr);
  576. operationPanel1.SNKeyDownEven += new OperationPanel.SNKeyDown(SNKeyDownEven);
  577. operationPanel1.AutoKeyRequire += new OperationPanel.AutoKeyRequireDelegate(AutoKeyRequire);
  578. IntPtr intPtr = operationPanel1.Handle;
  579. Dictionary<IntPtr, Point> part1 = new Dictionary<IntPtr, Point>();
  580. part1.Add(intPtr, (Point)new Size(operationPanel1.Right, operationPanel1.Top));
  581. formlocationmsg.Add(part1);
  582. operationPanel1.Show();
  583. }
  584. catch
  585. {
  586. //
  587. }
  588. }
  589. OrderSubmit.Text = LResource.submitbutton;
  590. #if DEBUG
  591. #else
  592. LockSettingFunction(false);
  593. #endif
  594. if (!LocalWrite)
  595. {
  596. if (!uploadbackground.IsAlive)
  597. if (!Preload.Checked || LocalDB != null)
  598. uploadbackground.Start();
  599. }
  600. }
  601. /// <summary>
  602. /// 加载配置
  603. /// </summary>
  604. public void LoadJsonConfig()
  605. {
  606. StreamReader file = File.OpenText(LocalPath.localpath + "\\Config.json");
  607. using (JsonTextReader reader = new JsonTextReader(file))
  608. {
  609. JObject jObject = (JObject)JToken.ReadFrom(reader);
  610. reader.Close();
  611. var COM = jObject["COM"].Value<string>();
  612. var Baudrate = jObject["Baudrate"].Value<string>();
  613. var WriteChannelConfig = jObject["WriteChannel"].Value<string>();
  614. var ChannelSelect = jObject["ChannelSelect"].Value<string>();
  615. var WriteOSDLanguageConfig = jObject["WriteOSDLanguage"].Value<string>();
  616. var OSDLanguageSelect = jObject["OSDLanguageSelect"].Value<string>();
  617. var WriteSHOPLanguageConfig = jObject["WriteSHOPLanguage"].Value<string>();
  618. var SHOPLanguageSelect = jObject["SHOPLanguageSelect"].Value<string>();
  619. var WriteWhiteBalanceConfig = jObject["WriteWhiteBalance"].Value<string>();
  620. var WhiteBalanceInitConfig = jObject["WhiteBalanceInit"].Value<string>();
  621. var WhiteBalancePath = jObject["WhiteBalancePath"].Value<string>();
  622. var LastOrder = jObject["LastOrder"].Value<string>();
  623. var Preloadmode = jObject["Preload"].Value<string>();
  624. var UsingLocalPID = jObject["UsingLocalPID"].Value<string>();
  625. Custom_ProjectID = jObject["Custom_ProjectID"].Value<string>();
  626. functionSetting1.Wait_after_completion = jObject["Wait_after_completion"].Value<int>();
  627. functionSetting1.EnterFactoryRetry = jObject["EnterFactoryRetry"].Value<int>();
  628. functionSetting1.AllowNoScanning = jObject["AllowNoScanning"].Value<bool>();
  629. functionSetting1.ReportTimeOut = jObject["ReportTimeOut"].Value<int>();
  630. //本地离线抄写时key长度设置获取
  631. functionSetting1.LocalDidSize = jObject["LocalSize"]["DID"].Value<int>();
  632. functionSetting1.LocalMacSize = jObject["LocalSize"]["MAC"].Value<int>();
  633. functionSetting1.LocalHdcpSize = jObject["LocalSize"]["HDCP"].Value<int>();
  634. functionSetting1.LocalWidiSize = jObject["LocalSize"]["WIDI"].Value<int>();
  635. functionSetting1.LocalHdcp22Size = jObject["LocalSize"]["HDCP22"].Value<int>();
  636. functionSetting1.LocalEsnSize = jObject["LocalSize"]["ESN"].Value<int>();
  637. functionSetting1.LocalWidevineSize = jObject["LocalSize"]["WIDEVINE"].Value<int>();
  638. functionSetting1.LocalCiSize = jObject["LocalSize"]["CI"].Value<int>();
  639. functionSetting1.LocalMGKSize = jObject["LocalSize"]["MGK"].Value<int>();
  640. functionSetting1.LocalFairplaySize = jObject["LocalSize"]["Fairplay"] == null ? (CommonMethod.InsertJsonConfig("LocalSize", "Fairplay") ? -1 : 0) : jObject["LocalSize"]["Fairplay"].Value<int>();
  641. functionSetting1.LocalECPSize = jObject["LocalSize"]["ECP"] == null ? (CommonMethod.InsertJsonConfig("LocalSize", "ECP") ? -1 : 0) : jObject["LocalSize"]["ECP"].Value<int>();
  642. functionSetting1.LocalWifiMacSize = jObject["LocalSize"]["WifiMac"] == null ? (CommonMethod.InsertJsonConfig("LocalSize", "WifiMac") ? -1 : 0) : jObject["LocalSize"]["WifiMac"].Value<int>();
  643. functionSetting1.LocalBTMacSize = jObject["LocalSize"]["BTMac"] == null ? (CommonMethod.InsertJsonConfig("LocalSize", "BTMac") ? -1 : 0) : jObject["LocalSize"]["BTMac"].Value<int>();
  644. //本地DB离线抄写时是否不允许重复抄写
  645. functionSetting1.NoDoublewrite = jObject["NodoubleWrite"].Value<bool>();
  646. //条码限制
  647. functionSetting1.BarcodeLimit = jObject["BarcodeLimit"].Value<bool>();
  648. functionSetting1.BarcodeWrite = jObject["BarcodeWrite"] == null ? CommonMethod.AddJsonConfig("BarcodeWrite", false) : jObject["BarcodeWrite"].Value<bool>();
  649. functionSetting1.BarcodeLength = jObject["BarcodeLength"].Value<int>();
  650. functionSetting1.BarcodeKeyword = jObject["BarcodeKeyword"].Value<string>();
  651. //串口延迟
  652. //functionSetting1.SerailDelay = jObject["SerailDelay"].Value<int>(); // 名字不易理解,使用NextCommandWaitTime代替;
  653. //SerialCMD.SerialTimeout = jObject["SerialTimeout"].Value<int>(); // 名字不易理解,目前不再使用;
  654. // G客户防呆措施;
  655. functionSetting1.UsingGFoolProofing = jObject["UsingGFoolProofing"] == null ? false : jObject["UsingGFoolProofing"].Value<bool>();
  656. functionSetting1.GFoolProofingCount = jObject["GFoolProofingCount"] == null ? 2 : jObject["GFoolProofingCount"].Value<int>();
  657. // 导出日规acas与sn;
  658. if (jObject["ExportSNACASID"] == null)
  659. {
  660. SaveJsonConfig("ExportSNACASID", functionSetting1.ExportSNACASID);
  661. }
  662. else
  663. {
  664. functionSetting1.ExportSNACASID = jObject["ExportSNACASID"].Value<bool>();
  665. }
  666. // 获取ReadTimeout值;
  667. if (jObject["ReadTimeout"] == null)
  668. {
  669. SaveJsonConfig("ReadTimeout", SerialCMD.ReadTimeout);
  670. }
  671. else
  672. {
  673. functionSetting1.ReadTimeout = SerialCMD.ReadTimeout = jObject["ReadTimeout"].Value<int>();
  674. }
  675. // 获取NextCommandWaitTime值;
  676. if (jObject["NextCommandWaitTime"] == null)
  677. {
  678. SaveJsonConfig("NextCommandWaitTime", SerialCMD.NextCommandWaitTime);
  679. }
  680. else
  681. {
  682. functionSetting1.NextCommandWaitTime = SerialCMD.NextCommandWaitTime = jObject["NextCommandWaitTime"].Value<int>();
  683. }
  684. #region G客户NTF功能;
  685. if ( jObject["NTF"] != null )
  686. {
  687. functionSetting1.NTF = jObject["NTF"].Value<bool>();
  688. }
  689. if (jObject["Line"] != null)
  690. {
  691. functionSetting1.Line = jObject["Line"].Value<string>();
  692. }
  693. if (jObject["Station"] != null)
  694. {
  695. functionSetting1.Station = jObject["Station"].Value<string>();
  696. }
  697. #endregion
  698. foreach (var ss in jObject["Channel"]) //遍历Channel
  699. {
  700. Dictionary<string, string> ChannelValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(ss.ToString());
  701. foreach (string key in ChannelValues.Keys)
  702. {
  703. ChannelMapList.Add(key, ChannelValues[key]);
  704. ChannelList.Items.Add(key);
  705. }
  706. }
  707. foreach (var ss in jObject["Language"]) //遍历Language
  708. {
  709. Dictionary<string, string> LanguageValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(ss.ToString());
  710. foreach (string key in LanguageValues.Keys)
  711. {
  712. OSDList.Items.Add(key);
  713. SHOPList.Items.Add(key);
  714. LanguageMapList.Add(key, LanguageValues[key]);
  715. }
  716. }
  717. foreach (var ss in jObject["CustomCMD"]) //遍历自定义命令表
  718. {
  719. functionSetting1.CustomCMD = JsonConvert.DeserializeObject<Dictionary<string, string>>(ss.ToString());
  720. }
  721. //ReadCheck配置读取
  722. ReadCheck1.PIDReadcheck = jObject["ReadCheck"]["PID"].Value<bool>();
  723. ReadCheck1.OSDReadcheck = jObject["ReadCheck"]["OSD"].Value<bool>();
  724. ReadCheck1.SHOPReadcheck = jObject["ReadCheck"]["SHOP"].Value<bool>();
  725. ReadCheck1.DIDReadcheck = jObject["ReadCheck"]["DID"].Value<bool>();
  726. ReadCheck1.MacReadcheck = jObject["ReadCheck"]["MAC"].Value<bool>();
  727. ReadCheck1.HDCPReadcheck = jObject["ReadCheck"]["HDCP"].Value<bool>();
  728. ReadCheck1.HDCP22Readcheck = jObject["ReadCheck"]["HDCP22"].Value<bool>();
  729. ReadCheck1.WiDiReadcheck = jObject["ReadCheck"]["WIDI"].Value<bool>();
  730. ReadCheck1.WidevineReadcheck = jObject["ReadCheck"]["WIDEVINE"].Value<bool>();
  731. ReadCheck1.ESNReadcheck = jObject["ReadCheck"]["ESN"].Value<bool>();
  732. ReadCheck1.CI_plusReadcheck = jObject["ReadCheck"]["CI"].Value<bool>();
  733. ReadCheck1.AttestationReadcheck = jObject["ReadCheck"]["Attestation"].Value<bool>();
  734. ReadCheck1.MGKReadcheck = jObject["ReadCheck"]["MGK"].Value<bool>();
  735. ReadCheck1.FairplayReadcheck = jObject["ReadCheck"]["Fairplay"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "Fairplay") : jObject["ReadCheck"]["Fairplay"].Value<bool>();
  736. ReadCheck1.ECPReadcheck = jObject["ReadCheck"]["ECP"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "ECP") : jObject["ReadCheck"]["ECP"].Value<bool>();
  737. ReadCheck1.WifiMacReadcheck = jObject["ReadCheck"]["WifiMac"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "WifiMac") : jObject["ReadCheck"]["WifiMac"].Value<bool>();
  738. ReadCheck1.BTMacReadcheck = jObject["ReadCheck"]["BTMac"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "BTMac") : jObject["ReadCheck"]["BTMac"].Value<bool>();
  739. ReadCheck1.LEKReadcheck = jObject["ReadCheck"]["LEK"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "LEK") : jObject["ReadCheck"]["LEK"].Value<bool>();
  740. ReadCheck1.PEKReadcheck = jObject["ReadCheck"]["PEK"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "PEK") : jObject["ReadCheck"]["PEK"].Value<bool>();
  741. ReadCheck1.PlayreadyReadcheck = jObject["ReadCheck"]["Playready"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "Playready") : jObject["ReadCheck"]["Playready"].Value<bool>();
  742. ReadCheck1.HashReadcheck = jObject["ReadCheck"]["Hash"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "Hash") : jObject["ReadCheck"]["Hash"].Value<bool>();
  743. ReadCheck1.DSNReadcheck = jObject["ReadCheck"]["DSN"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "DSN") : jObject["ReadCheck"]["DSN"].Value<bool>();
  744. ReadCheck1.YouTubeReadcheck = jObject["ReadCheck"]["YouTube"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "YouTube") : jObject["ReadCheck"]["YouTube"].Value<bool>();
  745. ReadCheck1.EDIDPIDReadcheck = jObject["ReadCheck"]["EDIDPID"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "EDIDPID") : jObject["ReadCheck"]["EDIDPID"].Value<bool>();
  746. ReadCheck1.EDIDModeNameReadcheck = jObject["ReadCheck"]["EDIDModeName"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "EDIDModeName") : jObject["ReadCheck"]["EDIDModeName"].Value<bool>();
  747. ReadCheck1.ACASKeyReadcheck = jObject["ReadCheck"]["ACASKey"] == null ? CommonMethod.InsertJsonConfig("ReadCheck", "ACASKey") : jObject["ReadCheck"]["ACASKey"].Value<bool>();
  748. //WriteCheck配置读取
  749. WriteCheck1.DIDCheckcheck = jObject["WriteCheck"]["DID"].Value<bool>();
  750. WriteCheck1.MacCheckcheck = jObject["WriteCheck"]["MAC"].Value<bool>();
  751. WriteCheck1.HDCPCheckcheck = jObject["WriteCheck"]["HDCP"].Value<bool>();
  752. WriteCheck1.HDCP22Checkcheck = jObject["WriteCheck"]["HDCP22"].Value<bool>();
  753. WriteCheck1.WiDiCheckcheck = jObject["WriteCheck"]["WIDI"].Value<bool>();
  754. WriteCheck1.WidevineCheckcheck = jObject["WriteCheck"]["WIDEVINE"].Value<bool>();
  755. WriteCheck1.ESNCheckcheck = jObject["WriteCheck"]["ESN"].Value<bool>();
  756. WriteCheck1.CI_plusCheckcheck = jObject["WriteCheck"]["CI"].Value<bool>();
  757. WriteCheck1.AttestationCheckcheck = jObject["WriteCheck"]["Attestation"].Value<bool>();
  758. WriteCheck1.MGKCheckcheck = jObject["WriteCheck"]["MGK"].Value<bool>();
  759. WriteCheck1.FairplayCheckcheck = jObject["WriteCheck"]["Fairplay"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "Fairplay") : jObject["WriteCheck"]["Fairplay"].Value<bool>();
  760. WriteCheck1.ECPCheckcheck = jObject["WriteCheck"]["ECP"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "ECP") : jObject["WriteCheck"]["ECP"].Value<bool>();
  761. WriteCheck1.WifiMacCheckcheck = jObject["WriteCheck"]["WifiMac"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "WifiMac") : jObject["WriteCheck"]["WifiMac"].Value<bool>();
  762. WriteCheck1.BTMacCheckcheck = jObject["WriteCheck"]["BTMac"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "BTMac") : jObject["WriteCheck"]["BTMac"].Value<bool>();
  763. WriteCheck1.LEKCheckcheck = jObject["WriteCheck"]["LEK"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "LEK") : jObject["WriteCheck"]["LEK"].Value<bool>();
  764. WriteCheck1.PEKCheckcheck = jObject["WriteCheck"]["PEK"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "PEK") : jObject["WriteCheck"]["PEK"].Value<bool>();
  765. WriteCheck1.PlayreadyCheckcheck = jObject["WriteCheck"]["Playready"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "Playready") : jObject["WriteCheck"]["Playready"].Value<bool>();
  766. WriteCheck1.HashCheckcheck = jObject["WriteCheck"]["Hash"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "Hash") : jObject["WriteCheck"]["Hash"].Value<bool>();
  767. WriteCheck1.DSNCheckcheck = jObject["WriteCheck"]["DSN"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "DSN") : jObject["WriteCheck"]["DSN"].Value<bool>();
  768. WriteCheck1.YouTubeCheckcheck = jObject["WriteCheck"]["YouTube"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "YouTube") : jObject["WriteCheck"]["YouTube"].Value<bool>();
  769. WriteCheck1.ACASKeyCheckcheck = jObject["WriteCheck"]["ACASKey"] == null ? CommonMethod.InsertJsonConfig("WriteCheck", "ACASKey") : jObject["WriteCheck"]["ACASKey"].Value<bool>();
  770. //WriteDone配置读取
  771. WriteDone1.PIDWrite_YesNo = jObject["WriteDone"]["PID"].Value<bool>();
  772. WriteDone1.PIDWriteDelay = jObject["WriteDone"]["PIDWirteDelay"].Value<int>();
  773. WriteDone1.ClientTypeCheck_YesNo = jObject["WriteDone"]["ClientType"].Value<bool>();
  774. WriteDone1.SoftwareVersionCheck_YesNo = jObject["WriteDone"]["SoftwareVersion"].Value<bool>();
  775. WriteDone1.DIDWrite_YesNo = jObject["WriteDone"]["DID"].Value<bool>();
  776. WriteDone1.MacWrite_YesNo = jObject["WriteDone"]["MAC"].Value<bool>();
  777. WriteDone1.HDCPWrite_YesNo = jObject["WriteDone"]["HDCP"].Value<bool>();
  778. WriteDone1.HDCP22Write_YesNo = jObject["WriteDone"]["HDCP22"].Value<bool>();
  779. WriteDone1.WiDiWrite_YesNo = jObject["WriteDone"]["WIDI"].Value<bool>();
  780. WriteDone1.WidevineWrite_YesNo = jObject["WriteDone"]["WIDEVINE"].Value<bool>();
  781. WriteDone1.ESNWrite_YesNo = jObject["WriteDone"]["ESN"].Value<bool>();
  782. WriteDone1.CI_plusWrite_YesNo = jObject["WriteDone"]["CI"].Value<bool>();
  783. WriteDone1.AttestationWrite_YesNo = jObject["WriteDone"]["Attestation"].Value<bool>();
  784. WriteDone1.MGKWrite_YesNo = jObject["WriteDone"]["MGK"].Value<bool>();
  785. WriteDone1.FairplayWrite_YesNo = jObject["WriteDone"]["Fairplay"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "Fairplay") : jObject["WriteDone"]["Fairplay"].Value<bool>();
  786. WriteDone1.ECPWrite_YesNo = jObject["WriteDone"]["ECP"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "ECP") : jObject["WriteDone"]["ECP"].Value<bool>();
  787. WriteDone1.WifiMacWrite_YesNo = jObject["WriteDone"]["WifiMac"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "WifiMac") : jObject["WriteDone"]["WifiMac"].Value<bool>();
  788. WriteDone1.BTMacWrite_YesNo = jObject["WriteDone"]["BTMac"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "BTMac") : jObject["WriteDone"]["BTMac"].Value<bool>();
  789. WriteDone1.LEKWrite_YesNo = jObject["WriteDone"]["LEK"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "LEK") : jObject["WriteDone"]["LEK"].Value<bool>();
  790. WriteDone1.PEKWrite_YesNo = jObject["WriteDone"]["PEK"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "PEK") : jObject["WriteDone"]["PEK"].Value<bool>();
  791. WriteDone1.PlayreadyWrite_YesNo = jObject["WriteDone"]["Playready"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "Playready") : jObject["WriteDone"]["Playready"].Value<bool>();
  792. WriteDone1.HashWrite_YesNo = jObject["WriteDone"]["Hash"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "Hash") : jObject["WriteDone"]["Hash"].Value<bool>();
  793. WriteDone1.DSNWrite_YesNo = jObject["WriteDone"]["DSN"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "DSN") : jObject["WriteDone"]["DSN"].Value<bool>();
  794. WriteDone1.AutoWhiteBalance = jObject["WriteDone"]["AutoWhiteBalance"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "AutoWhiteBalance") : jObject["WriteDone"]["AutoWhiteBalance"].Value<bool>();
  795. WriteDone1.YouTubeWrite_YesNo = jObject["WriteDone"]["YouTube"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "YouTube") : jObject["WriteDone"]["YouTube"].Value<bool>();
  796. WriteDone1.EDIDPIDWrite_YesNo = jObject["WriteDone"]["EDIDPID"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "EDIDPID") : jObject["WriteDone"]["EDIDPID"].Value<bool>();
  797. WriteDone1.EDIDModeNameWrite_YesNo = jObject["WriteDone"]["EDIDModeName"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "EDIDModeName") : jObject["WriteDone"]["EDIDModeName"].Value<bool>();
  798. WriteDone1.ACASKeyWrite_YesNo = jObject["WriteDone"]["ACASKey"] == null ? CommonMethod.InsertJsonConfig("WriteDone", "ACASKey") : jObject["WriteDone"]["ACASKey"].Value<bool>();
  799. file.Close();
  800. if (Custom_ProjectID != null)
  801. if (Custom_ProjectID.Trim().Length > 0)
  802. PID_Num.Value = Convert.ToDecimal(Custom_ProjectID);
  803. if (TVCOM.Items.Contains(COM))
  804. TVCOM.SelectedItem = COM;
  805. if (TVBaud.Items.Contains(Baudrate))
  806. TVBaud.SelectedItem = Baudrate;
  807. if (ChannelList.Items.Contains(ChannelSelect))
  808. {
  809. ChannelList.SelectedItem = ChannelSelect;
  810. functionSetting1.ChannelCode = SerialInit.HexToByte(ChannelMapList[ChannelSelect]);
  811. }
  812. if (OSDList.Items.Contains(OSDLanguageSelect))
  813. {
  814. OSDList.SelectedItem = OSDLanguageSelect;
  815. functionSetting1.OSDLCode = SerialInit.HexToByte(LanguageMapList[OSDLanguageSelect]);
  816. }
  817. if (SHOPList.Items.Contains(SHOPLanguageSelect))
  818. {
  819. SHOPList.SelectedItem = SHOPLanguageSelect;
  820. functionSetting1.ShopLCode = SerialInit.HexToByte(LanguageMapList[SHOPLanguageSelect]);
  821. }
  822. BarcodeLimit.Checked = functionSetting1.BarcodeLimit;
  823. BarcodeWrite.Checked = functionSetting1.BarcodeWrite;
  824. BarCodeKeyCodeText.Text = functionSetting1.BarcodeKeyword;
  825. BarCodeLengthText.Value = functionSetting1.BarcodeLength;
  826. Preload.Checked = Preloadmode == "True";
  827. WriteChannel.Checked = WriteChannelConfig == "True";
  828. WriteOSD.Checked = WriteOSDLanguageConfig == "True";
  829. WriteSHOP.Checked = WriteSHOPLanguageConfig == "True";
  830. WBInit.Checked = WhiteBalanceInitConfig == "True";
  831. UsinglocalIDCheck.Checked = UsingLocalPID == "True";
  832. OrderText.Text = LastOrder;
  833. if (File.Exists(WhiteBalancePath))
  834. {
  835. if (!LoadWBConfig(WhiteBalancePath))
  836. {
  837. MessageBox.Show(LResource.ReadWBError);
  838. WriteWB.Checked = false;
  839. }
  840. else
  841. {
  842. WBPath.Text = WhiteBalancePath;
  843. WriteWB.Checked = WriteWhiteBalanceConfig == "True";
  844. }
  845. }
  846. else
  847. WriteWB.Checked = false;
  848. }
  849. }
  850. /// <summary>
  851. /// 加载本地白平衡配置
  852. /// </summary>
  853. /// <param name="filepath"></param>
  854. /// <returns></returns>
  855. public bool LoadWBConfig(string filepath)
  856. {
  857. try
  858. {
  859. functionSetting1.NormalRGB = new byte[3];
  860. functionSetting1.CoolRGB = new byte[3];
  861. functionSetting1.WarmRGB = new byte[3];
  862. functionSetting1.NormalRGB[0] = (byte)Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "HDMI white R:", null, filepath));
  863. functionSetting1.NormalRGB[1] = (byte)Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "HDMI white G:", null, filepath));
  864. functionSetting1.NormalRGB[2] = (byte)Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "HDMI white B:", null, filepath));
  865. functionSetting1.CoolRGB[0] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Cool white R:", null, filepath)) + 256);
  866. functionSetting1.CoolRGB[1] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Cool white G:", null, filepath)) + 256);
  867. functionSetting1.CoolRGB[2] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Cool white B:", null, filepath)) + 256);
  868. functionSetting1.WarmRGB[0] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Warm white R:", null, filepath)) + 256);
  869. functionSetting1.WarmRGB[1] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Warm white G:", null, filepath)) + 256);
  870. functionSetting1.WarmRGB[2] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Warm white B:", null, filepath)) + 256);
  871. return true;
  872. }
  873. catch (Exception ex)
  874. {
  875. MessageBox.Show(ex.Message);
  876. return false;
  877. }
  878. }
  879. private void ChannelList_SelectedIndexChanged(object sender, EventArgs e)
  880. {
  881. string ChannelSelect = ChannelList.SelectedItem.ToString();
  882. string channelcode = ChannelMapList[ChannelSelect];
  883. functionSetting1.ChannelCode = SerialInit.HexToByte(channelcode);
  884. SaveJsonConfig("ChannelSelect", ChannelSelect);
  885. Log.WriteInfoLog("\r\nSet channel setting to " + ChannelSelect + "\r\nchannel code is " + channelcode);
  886. }
  887. private void OSDList_SelectedIndexChanged(object sender, EventArgs e)
  888. {
  889. string OSDLanguageSelect = OSDList.SelectedItem.ToString();
  890. string OSDLcode = LanguageMapList[OSDLanguageSelect];
  891. functionSetting1.OSDLCode = SerialInit.HexToByte(OSDLcode);
  892. SaveJsonConfig("OSDLanguageSelect", OSDLanguageSelect);
  893. Log.WriteInfoLog("\r\nSet channel setting to " + OSDLanguageSelect + "\r\nchannel code is " + OSDLcode);
  894. }
  895. private void SHOPList_SelectedIndexChanged(object sender, EventArgs e)
  896. {
  897. string SHOPLanguageSelect = SHOPList.SelectedItem.ToString();
  898. string SHOPLcode = LanguageMapList[SHOPLanguageSelect];
  899. functionSetting1.ShopLCode = SerialInit.HexToByte(SHOPLcode);
  900. SaveJsonConfig("SHOPLanguageSelect", SHOPLanguageSelect);
  901. Log.WriteInfoLog("\r\nSet channel setting to " + SHOPLanguageSelect + "\r\nchannel code is " + SHOPLcode);
  902. }
  903. private void skinButton1_Click(object sender, EventArgs e)
  904. {
  905. SaveJsonConfig("COM", "COM3");
  906. string strFileName = null;
  907. openFileDialog1.Filter = "WBConfig file|*.wba";
  908. openFileDialog1.FileName = "";
  909. openFileDialog1.Title = "Please select the WB config file";
  910. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  911. {
  912. strFileName = System.IO.Path.GetFullPath(openFileDialog1.FileName);
  913. WBPath.Text = strFileName;
  914. if (LoadWBConfig(strFileName))
  915. {
  916. functionSetting1.WBFileName = Path.GetFileName(openFileDialog1.FileName);
  917. SaveJsonConfig("WhiteBalancePath", strFileName);
  918. MessageBox.Show(LResource.LoadWBsuccess);
  919. }
  920. }
  921. }
  922. private void WriteWB_CheckedChanged(object sender, EventArgs e)
  923. {
  924. if (WriteWB.Checked == true)
  925. {
  926. if (WBPath.Text.Trim().Length > 0)
  927. {
  928. LoadWBConfig(WBPath.Text.Trim());
  929. SaveJsonConfig("WriteWhiteBalance", true);
  930. }
  931. else
  932. {
  933. MessageBox.Show(LResource.SelectWBfirst);
  934. WriteWB.Checked = false;
  935. }
  936. }
  937. else
  938. {
  939. SaveJsonConfig("WriteWhiteBalance", false);
  940. }
  941. }
  942. public void SaveJsonConfig(string node, object value)
  943. {
  944. StreamReader file = File.OpenText(LocalPath.localpath + "\\Config.json");
  945. using (JsonTextReader reader = new JsonTextReader(file))
  946. {
  947. JObject jObject = (JObject)JToken.ReadFrom(reader);
  948. jObject[node] = value.ToString();
  949. file.Close();
  950. using (StreamWriter writer = new StreamWriter(LocalPath.localpath + "\\Config.json"))
  951. {
  952. writer.Write(jObject.ToString()); //将JToken.ReadFrom(reader)的数据写入文件,这样的数据有空行。
  953. }
  954. }
  955. }
  956. private void WBInit_CheckedChanged(object sender, EventArgs e)
  957. {
  958. if (WBInit.Checked)
  959. {
  960. SaveJsonConfig("WhiteBalanceInit", true);
  961. }
  962. else
  963. SaveJsonConfig("WhiteBalanceInit", false);
  964. }
  965. private void WriteChannel_CheckedChanged(object sender, EventArgs e)
  966. {
  967. if (WriteChannel.Checked)
  968. {
  969. SaveJsonConfig("WriteChannel", true);
  970. }
  971. else
  972. SaveJsonConfig("WriteChannel", false);
  973. }
  974. private void WriteOSD_CheckedChanged(object sender, EventArgs e)
  975. {
  976. if (WriteOSD.Checked)
  977. {
  978. SaveJsonConfig("WriteOSDLanguage", true);
  979. }
  980. else
  981. SaveJsonConfig("WriteOSDLanguage", false);
  982. }
  983. private void WriteSHOP_CheckedChanged(object sender, EventArgs e)
  984. {
  985. if (WriteSHOP.Checked)
  986. {
  987. SaveJsonConfig("WriteSHOPLanguage", true);
  988. }
  989. else
  990. SaveJsonConfig("WriteSHOPLanguage", false);
  991. }
  992. private void TVCOM_SelectedIndexChanged(object sender, EventArgs e)
  993. {
  994. SaveJsonConfig("COM", TVCOM.SelectedItem.ToString());
  995. }
  996. private void TVBaud_SelectedIndexChanged(object sender, EventArgs e)
  997. {
  998. SaveJsonConfig("Baudrate", TVBaud.SelectedItem.ToString());
  999. }
  1000. private void Form1_FormClosed(object sender, FormClosedEventArgs e)
  1001. {
  1002. Environment.Exit(0);
  1003. }
  1004. public void LockSettingFunction(bool locksetting)
  1005. {
  1006. ChannelList.Enabled = locksetting;
  1007. WriteOSD.Enabled = locksetting;
  1008. WriteSHOP.Enabled = locksetting;
  1009. WriteChannel.Enabled = locksetting;
  1010. OSDList.Enabled = locksetting;
  1011. SHOPList.Enabled = locksetting;
  1012. skinButton1.Enabled = locksetting;
  1013. WriteOSD.Enabled = locksetting;
  1014. WBInit.Enabled = locksetting;
  1015. WriteWB.Enabled = locksetting;
  1016. OrderText.Enabled = locksetting;
  1017. Preload.Enabled = locksetting;
  1018. PID_Num.Enabled = locksetting;
  1019. BarcodeLimit.Enabled = locksetting;
  1020. BarCodeLengthText.Enabled = locksetting;
  1021. BarCodeKeyCodeText.Enabled = locksetting;
  1022. }
  1023. private void TVCOM_MouseClick(object sender, MouseEventArgs e)
  1024. {
  1025. TVCOM.Items.Clear();
  1026. TVCOM.Items.AddRange(SerialPort.GetPortNames());
  1027. }
  1028. private void CreateKeyManually_Click(object sender, EventArgs e)
  1029. {
  1030. CreateDBManually CreateDBManually1 = new CreateDBManually(TestMode.serverurl, ErrorDB);
  1031. CreateDBManually1.ShowDialog();
  1032. }
  1033. private void Preload_CheckedChanged(object sender, EventArgs e)
  1034. {
  1035. SaveJsonConfig("Preload", Preload.Checked.ToString());
  1036. }
  1037. private void Form1_Move(object sender, EventArgs e)
  1038. {
  1039. if (this.MoveEvent != null)
  1040. {
  1041. Point XY = this.Location;
  1042. XY.X = this.Right;
  1043. XY.Y = this.Top;
  1044. this.MoveEvent(XY, formlocationmsg, LocationNum);
  1045. }
  1046. }
  1047. private void DeleteIntptr(IntPtr intPtr)
  1048. {
  1049. foreach (Dictionary<IntPtr, Point> pairs in formlocationmsg)
  1050. {
  1051. if (pairs.ContainsKey(intPtr))
  1052. {
  1053. formlocationmsg.Remove(pairs);
  1054. if (this.MoveEvent != null)
  1055. {
  1056. Point XY = this.Location;
  1057. XY.X = this.Right;
  1058. XY.Y = this.Top;
  1059. this.MoveEvent(XY, formlocationmsg, LocationNum);
  1060. }
  1061. break;
  1062. }
  1063. }
  1064. }
  1065. private void AutoKeyRequire(IntPtr intPtr, string key, string keytype)
  1066. {
  1067. Task.Run(() =>
  1068. {
  1069. var a = ((Dictionary<IntPtr, Point>)formlocationmsg[0]).First();
  1070. if (a.Key == intPtr)
  1071. {
  1072. ;//start autokey require
  1073. if (CommonMethod.AutoGetKeyStatus(midList1.host, key, keytype, ErrorDB))
  1074. {
  1075. CommonMethod.AutoGetKey(midList1.host, OrderText.Text.Trim(), key, keytype, ErrorDB);
  1076. }
  1077. }
  1078. });
  1079. }
  1080. private void SNKeyDownEven(IntPtr intPtr)
  1081. {
  1082. this.KeyDownEvent(formlocationmsg, intPtr);
  1083. }
  1084. private void timer1_Tick(object sender, EventArgs e)
  1085. {
  1086. string count = SQLiteHelper.GetProductionNum(ErrorDB, OrderText.Text.Trim());
  1087. UpdateCountLabel(ProductionNum_Text, count);
  1088. }
  1089. /// <summary>
  1090. /// 刷新订单数量
  1091. /// </summary>
  1092. /// <param name="label"></param>
  1093. /// <param name="str"></param>
  1094. public void UpdateCountLabel(Label label, string str)
  1095. {
  1096. if (label.InvokeRequired)
  1097. {
  1098. BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), str);
  1099. }
  1100. else
  1101. {
  1102. label.Text = str;
  1103. }
  1104. }
  1105. /// <summary>
  1106. /// 后台上报
  1107. /// </summary>
  1108. public void UploadBackGround()
  1109. {
  1110. while (true)
  1111. {
  1112. if (CommonMethod.HTTPChecker(StructList.CheckServerConnectionUrl))
  1113. {
  1114. try
  1115. {
  1116. string url;
  1117. string content;
  1118. string id;
  1119. if (SQLiteHelper.GetDelayReportData(ErrorDB, out url, out content, out id))
  1120. if (content.Contains("@"))
  1121. {
  1122. string[] data = content.Split('@');
  1123. if (CommonMethod.UploadPreloadCopyResult(url, data[1], data[0], LocalDB, ErrorDB, true, id, 30000))
  1124. {
  1125. SQLiteHelper.UpdateReportData(ErrorDB, "CopyDelayReport", "ID", id);
  1126. }
  1127. }
  1128. else
  1129. if (CommonMethod.UploadCopyResult(content, url, ErrorDB, OrderText.Text.Trim(), true, id, functionSetting1.ReportTimeOut))
  1130. {
  1131. SQLiteHelper.UpdateReportData(ErrorDB, "CopyDelayReport", "ID", id);
  1132. }
  1133. }
  1134. catch (Exception ex)
  1135. {
  1136. Log.WriteErrorLog(ex.Message);
  1137. }
  1138. try
  1139. {
  1140. string url;
  1141. string content;
  1142. string id;
  1143. if (SQLiteHelper.GetErrorReportData(ErrorDB, out url, out content, out id))
  1144. {
  1145. CommonMethod.ReportErrormsg2(url, content, out bool mark);
  1146. if (mark)
  1147. {
  1148. SQLiteHelper.UpdateReportData(ErrorDB, "ErrorReport", "ID", id);
  1149. }
  1150. }
  1151. }
  1152. catch (Exception ex)
  1153. {
  1154. Log.WriteErrorLog(ex.Message);
  1155. }
  1156. Thread.Sleep(5000);
  1157. }
  1158. else
  1159. Thread.Sleep(20000);
  1160. }
  1161. }
  1162. private void PID_Num_ValueChanged(object sender, EventArgs e)
  1163. {
  1164. Custom_ProjectID = PID_Num.Value.ToString();
  1165. SaveJsonConfig("Custom_ProjectID", Custom_ProjectID);
  1166. }
  1167. private void BarCodeLengthText_ValueChanged(object sender, EventArgs e)
  1168. {
  1169. functionSetting1.BarcodeLength = Convert.ToInt32(BarCodeLengthText.Value);
  1170. SaveJsonConfig("BarcodeLength", functionSetting1.BarcodeLength);
  1171. }
  1172. private void BarcodeLimit_CheckedChanged(object sender, EventArgs e)
  1173. {
  1174. functionSetting1.BarcodeLimit = BarcodeLimit.Checked;
  1175. SaveJsonConfig("BarcodeLimit", BarcodeLimit.Checked);
  1176. }
  1177. private void BarCodeKeyCodeText_TextChanged(object sender, EventArgs e)
  1178. {
  1179. functionSetting1.BarcodeKeyword = BarCodeKeyCodeText.Text;
  1180. SaveJsonConfig("BarcodeKeyword", BarCodeKeyCodeText.Text);
  1181. }
  1182. private void UsinglocalIDCheck_CheckedChanged(object sender, EventArgs e)
  1183. {
  1184. SaveJsonConfig("UsingLocalPID", UsinglocalIDCheck.Checked);
  1185. }
  1186. private void BarcodeWrite_CheckedChanged(object sender, EventArgs e)
  1187. {
  1188. functionSetting1.BarcodeWrite = BarcodeWrite.Checked;
  1189. SaveJsonConfig("BarcodeWrite", BarcodeWrite.Checked);
  1190. }
  1191. }
  1192. }