Main.cs 99 KB

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