Main.cs 84 KB

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