Main.cs 99 KB

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