Main.cs 86 KB

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