Main.cs 80 KB

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