Main - 压测.cs 74 KB

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