Main.cs 79 KB

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