Main.cs 85 KB

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