123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028 |
- using CCWin;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using SufeiUtil;
- using SXLibrary;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data.SQLite;
- using System.Drawing;
- using System.IO;
- using System.IO.Ports;
- using System.Linq;
- using System.Net;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Web.Configuration;
- using System.Windows.Forms;
- namespace MOKA_Factory_Tools
- {
- public delegate void MoveHandler(Point XY, ArrayList formlocationmsg, int num);
- public delegate void KeyDownHandler(ArrayList formlocationmsg, IntPtr intPtr);
- public partial class Main : Skin_Color
- {
- public static string Is_Smt { get; set; }
- MidList midList1 = new MidList();
- UpgradeMsgList UpgradeMsgList1 = new UpgradeMsgList();
- MidAddress midAddress1 = new MidAddress();
- Config_ReadCheck cfg_readcheck = new Config_ReadCheck();
- Config_WriteCheck cfg_writecheck = new Config_WriteCheck();
- Config_WriteDone cfg_writedone = new Config_WriteDone();
- FunctionSetting functionSetting1 = new FunctionSetting();
- SQLiteConnection LocalDB = null;
- SQLiteConnection ErrorDB = null;
- SQLiteConnection ReportDB = null;
- Dictionary<string, string> ChannelMapList = new Dictionary<string, string>();
- Dictionary<string, string> LanguageMapList = new Dictionary<string, string>();
- List<KeyType> key2Write = null;
- string Custom_ProjectID = "";
- ArrayList formlocationmsg = new ArrayList();
- string ErrorDBPath = AppDomain.CurrentDomain.BaseDirectory + "\\Error.db";
- string ReportDBPath = AppDomain.CurrentDomain.BaseDirectory + "\\DB\\ReportData.db";
- Thread uploadbackground;
- bool LocalWrite = false;//离线抄写开关
- bool LocationMark = true;//操作窗体换行点
- int LocationNum = 0;//一行操作窗体数
- public event KeyDownHandler KeyDownEvent;
- public event MoveHandler MoveEvent;
- public Main(int enable)
- {
- InitializeComponent();
- LockSettingFunction(enable == 0 || enable == 3);
- CreateKeyManually.Visible = enable == 1;
- LocalWrite = enable == 3;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- uploadbackground = new Thread(UploadBackGround);
- uploadbackground.IsBackground = true;
- TVCOM.Items.AddRange(SerialPort.GetPortNames());
- LoadJsonConfig();
- this.StartPosition = FormStartPosition.Manual;
- this.Location = new Point(0, 0);
- //增加整机抄写和板卡抄写文字提示,界面颜色随之修改
- //根据配置文件,这个是整机抄写模式
- if(functionSetting1.IsSmt == "0")
- {
- this.Text = CommonMethod.FactoryName + " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()+" " + "整机抄写";
- }
- else
- {
- this.Text = CommonMethod.FactoryName + " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " " + "板卡抄写";
- // 修改底色;
- this.CaptionBackColorTop = Color.Red;
- this.CaptionBackColorBottom = Color.Goldenrod;
- this.BackColor = Color.AliceBlue;
- }
-
- if (!File.Exists(ErrorDBPath))
- {
- if (SQLiteHelper.NewDbFile(ErrorDBPath))
- {
- SQLiteHelper.NewTable(ErrorDBPath, "ErrorReport", "(ID INTEGER PRIMARY KEY AUTOINCREMENT,url varchar,content varvhar,gener_date DATETIME DEFAULT (datetime(CURRENT_TIMESTAMP,'localtime')),report_date DATETIME)");
- 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)");
- SQLiteHelper.NewTable(ErrorDBPath, "ProductionCount", "(bid varchar,count varchar)");
- }
- }
- if (ErrorDB == null)
- {
- ErrorDB = new SQLiteConnection("data source=" + ErrorDBPath);
- ErrorDB.Open();
- }
- if (ReportDB == null)
- {
- ReportDB = new SQLiteConnection("data source=" + ReportDBPath);
- ReportDB.Open();
- }
- #region 研发账号
- if (CommonMethod.GetLoginAccout().Equals("RD", StringComparison.OrdinalIgnoreCase))
- {
- if(functionSetting1.IsSmt == "0")
- {
- // 修改标题;
- this.Text = "研发抄写专用版" + " " +"整机抄写";
- // 修改底色;
- this.CaptionBackColorTop = Color.AntiqueWhite;
- this.CaptionBackColorBottom = Color.Beige;
- this.BackColor = Color.AliceBlue;
- }
- else
- {
- // 修改标题;
- this.Text = "研发抄写专用版" + " " + "板卡抄写";
- // 修改底色;
- this.CaptionBackColorTop = Color.Aqua;
- this.CaptionBackColorBottom = Color.Azure;
- this.BackColor = Color.AliceBlue;
- }
-
- }
- #endregion
- }
- private void SetDSNLimit()
- {
- #region 试产订单,不需要自动限制条码;
- string strValue = CommonMethod.ReadProfileString("MOKAFactoryTools", "OrderType", "");
- if (strValue.Equals("TR", StringComparison.OrdinalIgnoreCase))
- {
- return;
- }
- #endregion
- // 如果抄写PSN,不自动赋值条码限制;
- if (BarcodeWrite.Checked)
- return;
- // 设置条码限制默认打上勾;
- if (midList1.keytype != null && !functionSetting1.MITVEnable && !functionSetting1.IndiaMITVEnable && midList1.keytype.ContainsKey("DSN"))
- {
- BarcodeLimit.Checked = true;
- BarCodeKeyCodeText.Text = OrderText.Text;
- }
- }
- private void OrderSubmit_Click(object sender, EventArgs e)
- {
- SQLiteHelper.DeleteOldData(ErrorDB);//删除30天以前已经上报的数据
- if (TestMode.serverurl == Serverurl.Testurl)
- {// 此软件连接测试服务器,请勿用于生产
- MessageBoxButtons messButton = MessageBoxButtons.YesNo;
- DialogResult dr = MessageBox.Show(LResource.TestServerUsingError, LResource.Error, messButton);
- if (dr == DialogResult.Yes)
- {
- //
- }
- else
- {
- return;
- }
- }
- if (TVCOM.SelectedItem == null)
- {
- MessageBox.Show(LResource.TVCOMNullError, LResource.Error);
- return;
- }
- if (OrderText.Text.Trim().Length == 0)
- {
- MessageBox.Show(LResource.OrderNullError, LResource.Error);
- return;
- }
- if (!SQLiteHelper.CheckProductionNum(ErrorDB, OrderText.Text.Trim()))
- {
- MessageBox.Show(LResource.CheckProductionNumError, LResource.Error);
- return;
- }
- if (timer1.Enabled == false)
- timer1.Start();
- OrderSubmit.Text = LResource.Waiting;
- SaveJsonConfig("LastOrder", OrderText.Text.ToString());
- functionSetting1.TVCOM = TVCOM.SelectedItem.ToString();
- functionSetting1.TVBaud = TVBaud.SelectedItem.ToString();
- functionSetting1.ChannelList = ChannelList.SelectedItem.ToString();
- functionSetting1.WriteChannel = WriteChannel.Checked;
- functionSetting1.WriteOSD = WriteOSD.Checked;
- functionSetting1.OSDList = OSDList.SelectedItem.ToString();
- functionSetting1.WriteSHOP = WriteSHOP.Checked;
- functionSetting1.SHOPList = SHOPList.SelectedItem.ToString();
- functionSetting1.WriteWB = WriteWB.Checked;
- functionSetting1.WBInit = WBInit.Checked;
- functionSetting1.WBPath = WBPath.Text;
- if (!LocalWrite)
- {
- if (Preload.Checked)
- {
- string dbPath = AppDomain.CurrentDomain.BaseDirectory + "\\Keys\\" + OrderText.Text.Trim() + ".db";
- if (File.Exists(dbPath))
- {
- if (LocalDB == null)
- {
- LocalDB = new SQLiteConnection("data source=" + dbPath);
- LocalDB.Open();
- }
- if (SQLiteHelper.WholeCheckDownloadStatus(LocalDB, OrderText.Text.Trim()))
- {
- try
- {
- if (SQLiteHelper.GetDBMidInfo(LocalDB, OrderText.Text.Trim(), out midAddress1))
- {
- if (UsinglocalIDCheck.Checked)
- {
- midAddress1.pid = Custom_ProjectID;
- MessageBox.Show(LResource.WilluseLocalPID, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else if (midAddress1.pid != Custom_ProjectID && Custom_ProjectID.Trim().Length > 0)
- {
- if (midAddress1.pid != null)
- if (midAddress1.pid.Trim().Length > 0)
- PID_Num.Value = Convert.ToDecimal(midAddress1.pid);
- MessageBox.Show(LResource.WilluseOnlinePID, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- if (SQLiteHelper.GetrokuCustomer(LocalDB, OrderText.Text, out RokuCustomer rokuCustomer_1))
- {
- midList1.rokuCustomer = rokuCustomer_1;
- };
- if (SQLiteHelper.Getdsn(LocalDB, OrderText.Text, out string firetvdsn))
- {
- midList1.keytype = new Dictionary<string, string>();
- midList1.keytype.Add("DSN", firetvdsn);
- };
- if (SQLiteHelper.Getwhitebalance(LocalDB, OrderText.Text, out WhiteBalanceInfo whiteBalanceInfo_1))
- {
- functionSetting1.WBPath = dbPath;
- functionSetting1.WriteWB = true;
- functionSetting1.NormalRGB = new byte[3];
- functionSetting1.CoolRGB = new byte[3];
- functionSetting1.WarmRGB = new byte[3];
- functionSetting1.NormalRGB[0] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmirgain);
- functionSetting1.NormalRGB[1] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmiggain);
- functionSetting1.NormalRGB[2] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmibgain);
- functionSetting1.CoolRGB[0] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lrgain) + 256);
- functionSetting1.CoolRGB[1] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lggain) + 256);
- functionSetting1.CoolRGB[2] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lbgain) + 256);
- functionSetting1.WarmRGB[0] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nrgain) + 256);
- functionSetting1.WarmRGB[1] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nggain) + 256);
- functionSetting1.WarmRGB[2] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nbgain) + 256);
- };
- OperationPanel operationPanel1 = new OperationPanel(this, LocalDB, ErrorDB, midAddress1, functionSetting1, cfg_writecheck, cfg_readcheck, cfg_writedone, Preload.Checked, midList1, OrderText.Text.Trim());
- operationPanel1.StartPosition = FormStartPosition.Manual;
- if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width && LocationMark)
- {
- LocationMark = false;
- LocationNum = formlocationmsg.Count;
- }
- if (formlocationmsg.Count == 0)
- operationPanel1.Location = (Point)new Size(this.Right, this.Top);
- else if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width)
- {
- Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
- operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * (formlocationmsg.Count - LocationNum), this.Top + operationPanel1.Size.Height);
- }
- else
- {
- Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
- operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * formlocationmsg.Count, this.Top);
- }
- operationPanel1.DeleteIntptr += new OperationPanel.DisplayUpdateDelegate(DeleteIntptr);
- operationPanel1.SNKeyDownEven += new OperationPanel.SNKeyDown(SNKeyDownEven);
- IntPtr intPtr = operationPanel1.Handle;
- Dictionary<IntPtr, Point> part1 = new Dictionary<IntPtr, Point>();
- part1.Add(intPtr, (Point)new Size(operationPanel1.Right, operationPanel1.Top));
- formlocationmsg.Add(part1);
- operationPanel1.Show();
- }
- else
- {
- MessageBox.Show("Read LocalDB error,please delete old db file and download a new one");
- }
- }
- catch (Exception ex)
- {
- Log.WriteErrorLog(ex.Message);
- }
- // 是否有dsn要抄写;
- SetDSNLimit();
- }
- }
- else
- {
- // 预绑定模式下:没有db数据库时需要下载json包;
- if (V2Method.GetMidInfo(OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out midList1))
- {
- CommonMethod.SetCommonsData(functionSetting1, midList1);
- if (V2Method.GetOfflineData(midList1.host, OrderText.Text.Trim(), ErrorDB, out List<MidAddress> midAddress2))
- {
- WhiteBalanceList WhiteBalanceListNow;
- // 如果是抄写EDID,则不获取白平衡数据;
- if (CommonMethod.IsEDIDCopy(midList1))
- midList1.whiteType = "-1";
- #if DEBUG
- midList1.whiteType = "-1";
- #endif
- switch (midList1.whiteType)//订单白平衡预置状态
- {
- case "0"://旧订单,默认值
- {
- CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out WhiteBalanceListNow);
- break;
- }
- case "1"://未预置或预置LR数据
- {
- CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out WhiteBalanceListNow);
- if (WhiteBalanceListNow.whiteBalanceInfo == null)
- {
- MessageBox.Show("White balance info error, please contact factory engineer!");
- return;
- }
- break;
- }
- case "2"://已预置PR数据
- {
- CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out WhiteBalanceListNow);
- break;
- }
- default:
- {
- WhiteBalanceListNow = null;
- break;
- }
- }
- foreach (var midAddress1 in midAddress2)
- {
- string KeyPath = AppDomain.CurrentDomain.BaseDirectory + "\\download\\" + midAddress1.order + ".json";
- if (System.IO.File.Exists(KeyPath))
- {
- if (GetMD5.GetMD5HashFromFile(KeyPath) == midAddress1.pmd5)
- {
- if (SQLiteHelper.NewDbFile(dbPath))
- {
- SQLiteHelper.NewTable(dbPath, "keys", "(sn varchar,keys varvhar,copy_date DATETIME,report_date DATETIME)");
- 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)");
- SQLiteHelper.NewTable(dbPath, "report", "(url varchar,content varchar,gener_date DATETIME,report_date DATETIME)");
- SQLiteHelper.NewTable(dbPath, "rokuCustomer", "(ordernum varchar, data varchar)");
- 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')))");
- SQLiteHelper.NewTable(dbPath, "dsn", "(ordernum varchar,dsn varchar,updatetime DATETIME DEFAULT (datetime(CURRENT_TIMESTAMP,'localtime')))");
- SQLiteHelper.AddOneLine(dbPath, new object[] { midAddress1.order, midAddress1.number, midAddress1.pid, midAddress1.ctype, midAddress1.version, midList1.host, midAddress1.purl, midAddress1.psize, midAddress1.pmd5, "1" });
- if (midList1.rokuCustomer != null)
- {
- SQLiteHelper.AddRokuOneLine(dbPath, new object[]{
- midList1.rokuCustomer.ordernum,
- JsonConvert.SerializeObject(midList1.rokuCustomer).ToString()
- });
- }
- if (WhiteBalanceListNow != null)
- if (WhiteBalanceListNow.whiteBalanceInfo != null)
- SQLiteHelper.AddwbOneLine(dbPath, new object[] {
- WhiteBalanceListNow.whiteBalanceInfo.ordernum,
- WhiteBalanceListNow.whiteBalanceInfo.hdmirgain,
- WhiteBalanceListNow.whiteBalanceInfo.hdmiggain,
- WhiteBalanceListNow.whiteBalanceInfo.hdmibgain,
- WhiteBalanceListNow.whiteBalanceInfo.nrgain,
- WhiteBalanceListNow.whiteBalanceInfo.nggain,
- WhiteBalanceListNow.whiteBalanceInfo.nbgain,
- WhiteBalanceListNow.whiteBalanceInfo.lrgain,
- WhiteBalanceListNow.whiteBalanceInfo.lggain,
- WhiteBalanceListNow.whiteBalanceInfo.lbgain
- });
- if (midList1.keytype.ContainsKey("DSN"))
- {
- SQLiteHelper.AdddsnOneLine(dbPath, new object[] { midAddress1.order, midList1.keytype["DSN"] });
- }
- SQLiteHelper.UpdateTime(dbPath, midAddress1.order);
- }
- if (File.Exists(dbPath))
- {
- List<object[]> keyDatas = new List<object[]>();
- using (System.IO.StreamReader file = System.IO.File.OpenText(KeyPath))
- {
- using (JsonTextReader reader = new JsonTextReader(file))
- {
- JArray o = (JArray)JToken.ReadFrom(reader);
- foreach (var ss in o) //查找某个字段与值
- {
- var sn = ((JObject)ss)["sn"];
- var data = ((JObject)ss)["key"];
- keyDatas.Add(new object[] { sn, data });
- }
- }
- }
- SQLiteHelper.InsertKeys(dbPath, keyDatas);
- }
- try
- {
- if (LocalDB == null)
- {
- LocalDB = new SQLiteConnection("data source=" + dbPath);
- LocalDB.Open();
- }
- OperationPanel operationPanel1 = new OperationPanel(this, LocalDB, ErrorDB, midAddress1, functionSetting1, cfg_writecheck, cfg_readcheck, cfg_writedone, Preload.Checked, midList1, OrderText.Text.Trim());
- operationPanel1.StartPosition = FormStartPosition.Manual;
- if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width && LocationMark)
- {
- LocationMark = false;
- LocationNum = formlocationmsg.Count;
- }
- if (formlocationmsg.Count == 0)
- operationPanel1.Location = (Point)new Size(this.Right, this.Top);
- else if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width)
- {
- Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
- operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * (formlocationmsg.Count - LocationNum), this.Top + operationPanel1.Size.Height);
- }
- else
- {
- Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
- operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * formlocationmsg.Count, this.Top);
- }
- operationPanel1.DeleteIntptr += new OperationPanel.DisplayUpdateDelegate(DeleteIntptr);
- operationPanel1.SNKeyDownEven += new OperationPanel.SNKeyDown(SNKeyDownEven);
- IntPtr intPtr = operationPanel1.Handle;
- Dictionary<IntPtr, Point> part1 = new Dictionary<IntPtr, Point>();
- part1.Add(intPtr, (Point)new Size(operationPanel1.Right, operationPanel1.Top));
- formlocationmsg.Add(part1);
- operationPanel1.Show();
- }
- catch (Exception ex)
- {
- Log.WriteErrorLog(ex.Message);
- }
- }
- else
- {
- Download DownloadPage = new Download(ErrorDB, midAddress1, -1, midList1, WhiteBalanceListNow);
- DownloadPage.ShowDialog();
- int gid = GC.GetGeneration(DownloadPage);
- DownloadPage = null;
- GC.Collect(gid);
- }
- }
- else
- {
- Download DownloadPage = new Download(ErrorDB, midAddress1, -1, midList1, WhiteBalanceListNow);
- DownloadPage.ShowDialog();
- int gid = GC.GetGeneration(DownloadPage);
- DownloadPage = null;
- GC.Collect(gid);
- }
- }
- if (File.Exists(dbPath))
- {
- if (LocalDB == null)
- {
- LocalDB = new SQLiteConnection("data source=" + dbPath);
- LocalDB.Open();
- }
- if (SQLiteHelper.WholeCheckDownloadStatus(LocalDB, OrderText.Text.Trim()))
- {
- if (V2Method.ReportDownloadStatus(midList1.host, OrderText.Text.Trim(), ErrorDB))
- MessageBox.Show(LResource.DownloadSuccess);
- else
- MessageBox.Show(LResource.DownloadReportFail);
- }
- }
- }
- else
- {
- MessageBox.Show(LResource.GetMidAdresserror);
- }
- }
- else
- {
- MessageBox.Show(LResource.GetMidInfoerror);
- }
- // 是否有dsn要抄写;
- SetDSNLimit();
- }
- }
- else
- {
- if (V2Method.GetMidInfo(OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out midList1))
- {
- CommonMethod.SetCommonsData(functionSetting1, midList1);
- CommonMethod.CheckKeyType(midList1.keytype, cfg_writedone, out key2Write);
- OperationPanel.key2Write = key2Write;
- if (UsinglocalIDCheck.Checked)
- {
- midList1.projectid = Custom_ProjectID;
- MessageBox.Show(LResource.WilluseLocalPID, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else if (midList1.projectid != Custom_ProjectID && Custom_ProjectID.Trim().Length > 0)
- {
- if (midList1.projectid != null)
- if (midList1.projectid.Trim().Length > 0)
- PID_Num.Value = Convert.ToDecimal(midList1.projectid);
- MessageBox.Show(LResource.WilluseOnlinePID, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- try
- {
- OperationPanel operationPanel1 = new OperationPanel(this, LocalDB, ErrorDB, midAddress1, functionSetting1, cfg_writecheck, cfg_readcheck, cfg_writedone, Preload.Checked, midList1, OrderText.Text.Trim());
- operationPanel1.StartPosition = FormStartPosition.Manual;
- if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width && LocationMark)
- {
- LocationMark = false;
- LocationNum = formlocationmsg.Count;
- }
- if (formlocationmsg.Count == 0)
- operationPanel1.Location = (Point)new Size(this.Right, this.Top);
- else if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width)
- {
- Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
- operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * (formlocationmsg.Count - LocationNum), this.Top + operationPanel1.Size.Height);
- }
- else
- {
- Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
- operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * formlocationmsg.Count, this.Top);
- }
- operationPanel1.DeleteIntptr += new OperationPanel.DisplayUpdateDelegate(DeleteIntptr);
- operationPanel1.SNKeyDownEven += new OperationPanel.SNKeyDown(SNKeyDownEven);
- IntPtr intPtr = operationPanel1.Handle;
- Dictionary<IntPtr, Point> part1 = new Dictionary<IntPtr, Point>();
- part1.Add(intPtr, (Point)new Size(operationPanel1.Right, operationPanel1.Top));
- formlocationmsg.Add(part1);
- operationPanel1.Show();
- }
- catch (Exception ex)
- {
- Log.WriteErrorLog(ex.Message);
- }
- // 是否有dsn要抄写;
- SetDSNLimit();
- }
- else
- {
- MessageBox.Show(LResource.GetMidInfoerror);
- }
- }
- }
- else
- {
- MessageBox.Show(LResource.LocalKeyMode);
- try
- {
- if (Preload.Checked)
- {
- string dbPath = AppDomain.CurrentDomain.BaseDirectory + "\\Keys\\" + OrderText.Text.Trim() + ".db";
- if (File.Exists(dbPath))
- {
- if (LocalDB == null)
- {
- LocalDB = new SQLiteConnection("data source=" + dbPath);
- LocalDB.Open();
- }
- if (SQLiteHelper.WholeCheckDownloadStatus(LocalDB, OrderText.Text.Trim()))
- {
- if (SQLiteHelper.GetDBMidInfo(LocalDB, OrderText.Text.Trim(), out midAddress1))
- {
- if (UsinglocalIDCheck.Checked)
- {
- midAddress1.pid = Custom_ProjectID;
- MessageBox.Show(LResource.WilluseLocalPID, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else if (midAddress1.pid != Custom_ProjectID && Custom_ProjectID.Trim().Length > 0)
- {
- if (midAddress1.pid != null)
- if (midAddress1.pid.Trim().Length > 0)
- PID_Num.Value = Convert.ToDecimal(midAddress1.pid);
- MessageBox.Show(LResource.WilluseOnlinePID, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- midList1 = new MidList()
- {
- keytype = new Dictionary<string, string>(),
- clienttype = midAddress1.ctype,
- version = midAddress1.version,
- projectid = midAddress1.pid,
- host = "LocalPC"
- };
- if (SQLiteHelper.GetrokuCustomer(LocalDB, OrderText.Text, out RokuCustomer rokuCustomer_1))
- {
- midList1.rokuCustomer = rokuCustomer_1;
- };
- if (SQLiteHelper.Getdsn(LocalDB, OrderText.Text, out string firetvdsn))
- {
- midList1.keytype = new Dictionary<string, string>();
- midList1.keytype.Add("DSN", firetvdsn);
- };
- if (SQLiteHelper.Getwhitebalance(LocalDB, OrderText.Text, out WhiteBalanceInfo whiteBalanceInfo_1))
- {
- functionSetting1.WBPath = dbPath;
- functionSetting1.WriteWB = true;
- functionSetting1.NormalRGB = new byte[3];
- functionSetting1.CoolRGB = new byte[3];
- functionSetting1.WarmRGB = new byte[3];
- functionSetting1.NormalRGB[0] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmirgain);
- functionSetting1.NormalRGB[1] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmiggain);
- functionSetting1.NormalRGB[2] = (byte)Convert.ToDouble(whiteBalanceInfo_1.hdmibgain);
- functionSetting1.CoolRGB[0] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lrgain) + 256);
- functionSetting1.CoolRGB[1] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lggain) + 256);
- functionSetting1.CoolRGB[2] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.lbgain) + 256);
- functionSetting1.WarmRGB[0] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nrgain) + 256);
- functionSetting1.WarmRGB[1] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nggain) + 256);
- functionSetting1.WarmRGB[2] = (byte)(Convert.ToDouble(whiteBalanceInfo_1.nbgain) + 256);
- };
- }
- else
- {
- MessageBox.Show(LResource.FailtoReadLocalDB);
- return;
- }
- }
- else
- {
- MessageBox.Show(LResource.LocalDBIncomplete);
- return;
- }
- }
- else
- {
- MessageBox.Show(LResource.NofoundLocalDB);
- return;
- }
- }
- else
- {
- midList1 = new MidList()
- {
- keytype = new Dictionary<string, string>(),
- projectid = Custom_ProjectID,
- host = "LocalPC"
- };
- #region EDID离线模式;
- if (functionSetting1.edid_offline)
- {
- midList1.keytype.Add("edid_pid", functionSetting1.edid_pid);
- midList1.keytype.Add("edid_model_name", functionSetting1.edid_model_name);
- }
- #endregion
- }
- OperationPanel operationPanel1 = new OperationPanel(this, LocalDB, ErrorDB, null, functionSetting1, cfg_writecheck, cfg_readcheck, cfg_writedone, Preload.Checked, midList1, OrderText.Text.Trim());
- operationPanel1.StartPosition = FormStartPosition.Manual;
- if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width && LocationMark)
- {
- LocationMark = false;
- LocationNum = formlocationmsg.Count;
- }
- if (formlocationmsg.Count == 0)
- operationPanel1.Location = (Point)new Size(this.Right, this.Top);
- else if ((this.Right + operationPanel1.Size.Width * formlocationmsg.Count) > Screen.PrimaryScreen.Bounds.Width)
- {
- Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
- operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * (formlocationmsg.Count - LocationNum), this.Top + operationPanel1.Size.Height);
- }
- else
- {
- Point point = ((Dictionary<IntPtr, Point>)formlocationmsg[formlocationmsg.Count - 1]).Last().Value;
- operationPanel1.Location = (Point)new Size(this.Right + operationPanel1.Size.Width * formlocationmsg.Count, this.Top);
- }
- operationPanel1.DeleteIntptr += new OperationPanel.DisplayUpdateDelegate(DeleteIntptr);
- operationPanel1.SNKeyDownEven += new OperationPanel.SNKeyDown(SNKeyDownEven);
- IntPtr intPtr = operationPanel1.Handle;
- Dictionary<IntPtr, Point> part1 = new Dictionary<IntPtr, Point>();
- part1.Add(intPtr, (Point)new Size(operationPanel1.Right, operationPanel1.Top));
- formlocationmsg.Add(part1);
- operationPanel1.Show();
- }
- catch
- {
- //
- }
- }
- OrderSubmit.Text = LResource.submitbutton;
- #if DEBUG
- #else
- LockSettingFunction(false);
- #endif
- if (!LocalWrite)
- {
- if (!uploadbackground.IsAlive)
- if (!Preload.Checked || LocalDB != null)
- uploadbackground.Start();
- }
- }
- /// <summary>
- /// 加载配置
- /// </summary>
- public void LoadJsonConfig()
- {
- StreamReader file = File.OpenText(LocalPath.localpath + "\\Config.json");
- using (JsonTextReader reader = new JsonTextReader(file))
- {
- JObject jObject = (JObject)JToken.ReadFrom(reader);
- reader.Close();
- var COM = jObject["COM"].Value<string>();
- var Baudrate = jObject["Baudrate"].Value<string>();
- var WriteChannelConfig = jObject["WriteChannel"].Value<string>();
- var ChannelSelect = jObject["ChannelSelect"].Value<string>();
- var WriteOSDLanguageConfig = jObject["WriteOSDLanguage"].Value<string>();
- var OSDLanguageSelect = jObject["OSDLanguageSelect"].Value<string>();
- var WriteSHOPLanguageConfig = jObject["WriteSHOPLanguage"].Value<string>();
- var SHOPLanguageSelect = jObject["SHOPLanguageSelect"].Value<string>();
- var WriteWhiteBalanceConfig = jObject["WriteWhiteBalance"].Value<string>();
- var WhiteBalanceInitConfig = jObject["WhiteBalanceInit"].Value<string>();
- var WhiteBalancePath = jObject["WhiteBalancePath"].Value<string>();
- var LastOrder = jObject["LastOrder"].Value<string>();
- var Preloadmode = jObject["Preload"].Value<string>();
- var UsingLocalPID = jObject["UsingLocalPID"].Value<string>();
- Custom_ProjectID = jObject["Custom_ProjectID"].Value<string>();
- functionSetting1.Wait_after_completion = jObject["Wait_after_completion"].Value<int>();
- functionSetting1.EnterFactoryRetry = jObject["EnterFactoryRetry"].Value<int>();
- functionSetting1.AllowNoScanning = jObject["AllowNoScanning"].Value<bool>();
- functionSetting1.ReportTimeOut = jObject["ReportTimeOut"].Value<int>();
- if (jObject["Parity"] == null)
- SaveJsonConfig("Parity", functionSetting1.TVParity);
- functionSetting1.TVParity = jObject["Parity"] != null ? jObject["Parity"].Value<int>() : 0;
- //本地离线抄写时key长度设置获取
- functionSetting1.LocalDidSize = jObject["LocalSize"]["DID"].Value<int>();
- functionSetting1.LocalMacSize = jObject["LocalSize"]["MAC"].Value<int>();
- functionSetting1.LocalHdcpSize = jObject["LocalSize"]["HDCP"].Value<int>();
- functionSetting1.LocalWidiSize = jObject["LocalSize"]["WIDI"].Value<int>();
- functionSetting1.LocalHdcp22Size = jObject["LocalSize"]["HDCP22"].Value<int>();
- functionSetting1.LocalEsnSize = jObject["LocalSize"]["ESN"].Value<int>();
- functionSetting1.LocalWidevineSize = jObject["LocalSize"]["WIDEVINE"].Value<int>();
- functionSetting1.LocalCiSize = jObject["LocalSize"]["CI"].Value<int>();
- functionSetting1.LocalMGKSize = jObject["LocalSize"]["MGK"].Value<int>();
- functionSetting1.LocalFairplaySize = jObject["LocalSize"]["Fairplay"] == null ? (CommonMethod.InsertJsonConfig("LocalSize", "Fairplay") ? -1 : 0) : jObject["LocalSize"]["Fairplay"].Value<int>();
- functionSetting1.LocalECPSize = jObject["LocalSize"]["ECP"] == null ? (CommonMethod.InsertJsonConfig("LocalSize", "ECP") ? -1 : 0) : jObject["LocalSize"]["ECP"].Value<int>();
- functionSetting1.LocalWifiMacSize = jObject["LocalSize"]["WifiMac"] == null ? (CommonMethod.InsertJsonConfig("LocalSize", "WifiMac") ? -1 : 0) : jObject["LocalSize"]["WifiMac"].Value<int>();
- functionSetting1.LocalBTMacSize = jObject["LocalSize"]["BTMac"] == null ? (CommonMethod.InsertJsonConfig("LocalSize", "BTMac") ? -1 : 0) : jObject["LocalSize"]["BTMac"].Value<int>();
- //本地DB离线抄写时是否不允许重复抄写
- functionSetting1.NoDoublewrite = jObject["NodoubleWrite"].Value<bool>();
- //条码限制
- functionSetting1.BarcodeLimit = jObject["BarcodeLimit"].Value<bool>();
- functionSetting1.BarcodeWrite = jObject["BarcodeWrite"] == null ? CommonMethod.AddJsonConfig("BarcodeWrite", false) : jObject["BarcodeWrite"].Value<bool>();
- functionSetting1.BarcodeLength = jObject["BarcodeLength"].Value<int>();
- functionSetting1.BarcodeKeyword = jObject["BarcodeKeyword"].Value<string>();
- //串口延迟
- //functionSetting1.SerailDelay = jObject["SerailDelay"].Value<int>(); // 名字不易理解,使用NextCommandWaitTime代替;
- //SerialCMD.SerialTimeout = jObject["SerialTimeout"].Value<int>(); // 名字不易理解,目前不再使用;
- // G客户防呆措施;
- functionSetting1.UsingGFoolProofing = jObject["UsingGFoolProofing"] == null ? false : jObject["UsingGFoolProofing"].Value<bool>();
- functionSetting1.GFoolProofingCount = jObject["GFoolProofingCount"] == null ? 2 : jObject["GFoolProofingCount"].Value<int>();
- functionSetting1.LeaveFactory = jObject["LeaveFactory"] == null ? false : jObject["LeaveFactory"].Value<bool>();
- functionSetting1.SNDoubleTips = jObject["SNDoubleTips"] == null ? false : jObject["SNDoubleTips"].Value<bool>();
- functionSetting1.EnableSanhuaMES = jObject["EnableSanhuaMES"] == null ? false : jObject["EnableSanhuaMES"].Value<bool>();
- #region 是否启用墨西哥抄写
- if (CommonMethod.GetLoginAccout().Equals("Mexico", StringComparison.OrdinalIgnoreCase) )
- {
- // NTF;
- if (jObject["Mexican_NTF"] == null)
- SaveJsonConfig("Mexican_NTF", functionSetting1.Mexican_NTF);
- else
- functionSetting1.Mexican_NTF = jObject["Mexican_NTF"].Value<bool>();
- GMethod.SetMexicanConfig(functionSetting1.Mexican_NTF);
- // IDM;
- if (jObject["Mexican_IDM"] == null)
- SaveJsonConfig("Mexican_IDM", functionSetting1.Mexican_IDM);
- else
- functionSetting1.Mexican_IDM = jObject["Mexican_IDM"].Value<bool>();
- if (functionSetting1.Mexican_IDM )
- V2Method.SetGetMessageUrl("http://10.138.96.32:81/IDManage/v1/order/getMessage");
- }
- #endregion
- // 导出日规acas与sn;
- if (jObject["ExportSNACASID"] == null)
- {
- SaveJsonConfig("ExportSNACASID", functionSetting1.ExportSNACASID);
- }
- else
- {
- functionSetting1.ExportSNACASID = jObject["ExportSNACASID"].Value<bool>();
- }
- // 获取ReadTimeout值;
- if (jObject["ReadTimeout"] == null)
- {
- SaveJsonConfig("ReadTimeout", SerialCMD.ReadTimeout);
- }
- else
- {
- functionSetting1.ReadTimeout = SerialCMD.ReadTimeout = jObject["ReadTimeout"].Value<int>();
- }
- // 获取NextCommandWaitTime值;
- if (jObject["NextCommandWaitTime"] == null)
- {
- SaveJsonConfig("NextCommandWaitTime", SerialCMD.NextCommandWaitTime);
- }
- else
- {
- functionSetting1.NextCommandWaitTime = SerialCMD.NextCommandWaitTime = jObject["NextCommandWaitTime"].Value<int>();
- }
- // 后台上报数据;
- if (jObject["BackgroudReportData"] == null)
- {
- SaveJsonConfig("BackgroudReportData", false);
- }
- else
- {
- functionSetting1.BackgroudReportData = jObject["BackgroudReportData"].Value<bool>();
- }
- #region EDID离线模式,使用offline账号登录;
- if (jObject["edid_offline"] == null)
- {
- SaveJsonConfig("edid_offline", functionSetting1.edid_offline);
- }
- else
- {
- functionSetting1.edid_offline = jObject["edid_offline"].Value<bool>();
- }
- if (jObject["edid_pid"] == null)
- {
- SaveJsonConfig("edid_pid", functionSetting1.edid_pid);
- }
- else
- {
- functionSetting1.edid_pid = jObject["edid_pid"].Value<string>();
- }
- if (jObject["edid_model_name"] == null)
- {
- SaveJsonConfig("edid_model_name", functionSetting1.edid_model_name);
- }
- else
- {
- functionSetting1.edid_model_name = jObject["edid_model_name"].Value<string>();
- }
- #endregion
- #region 波兰工厂DHA解决方案
- if (jObject["CheckDHAWaitTime"] == null)
- {
- SaveJsonConfig("CheckDHAWaitTime", functionSetting1.CheckDHAWaitTime);
- }
- else
- {
- functionSetting1.CheckDHAWaitTime = jObject["CheckDHAWaitTime"].Value<int>();
- }
- if (jObject["DHA"] == null)
- {
- SaveJsonConfig("DHA", functionSetting1.DHA);
- }
- else
- {
- functionSetting1.DHA = jObject["DHA"].Value<bool>();
- }
- #endregion
- #region G客户NTF功能;
- if ( jObject["NTF"] != null )
- {
- functionSetting1.NTF = jObject["NTF"].Value<bool>();
- if (functionSetting1.NTF == true)
- Log.WriteInfoLog("开启NTF功能");
- }
- else
- {
- SaveJsonConfig("NTF", false);
- }
- if (jObject["Line"] != null)
- {
- functionSetting1.Line = jObject["Line"].Value<string>();
- }
- else
- {
- SaveJsonConfig("Line", "");
- }
- #endregion
- #region 小米FireTV功能模块启用;
- if (jObject["MITVEnable"] != null)
- {
- functionSetting1.MITVEnable = jObject["MITVEnable"].Value<bool>();
- }
- else
- {
- SaveJsonConfig("MITVEnable", false);
- }
- // 获取key的url;
- if (jObject["MIKeyUrl"] != null)
- {
- functionSetting1.MIKeyUrl = jObject["MIKeyUrl"].Value<string>();
- }
- else
- {
- SaveJsonConfig("MIKeyUrl", functionSetting1.MIKeyUrl);
- }
- // 上报key的url;
- if (jObject["MIKeyReportUrl"] != null)
- {
- functionSetting1.MIKeyReportUrl = jObject["MIKeyReportUrl"].Value<string>();
- }
- else
- {
- SaveJsonConfig("MIKeyReportUrl", functionSetting1.MIKeyReportUrl);
- }
- if (jObject["IndiaMITVEnable"] != null)
- {
- functionSetting1.IndiaMITVEnable = jObject["IndiaMITVEnable"].Value<bool>();
- }
- else
- {
- SaveJsonConfig("IndiaMITVEnable", false);
- }
- // 变更接口地址;
- if (functionSetting1.IndiaMITVEnable)
- {
- functionSetting1.MIKeyUrl = "http://10.40.7.61:9006/api/SMESCustomer/GetXMCard";
- functionSetting1.MIKeyReportUrl = "http://10.40.7.61:9006/api/SMESCustomer/UploadXMDataControl";
- V2Method.SetGetMessageUrl("http://10.40.7.93:81/IDManage/v1/order/getMessage ");
- }
- #endregion
- #region 北美DSN的配置项使用SMES里面的
- if (jObject["UserDSNFromSmes"] == null)
- {
- SaveJsonConfig("UserDSNFromSmes", functionSetting1.UserDSNFromSmes);
- }
- else
- {
- functionSetting1.UserDSNFromSmes = jObject["UserDSNFromSmes"].Value<bool>();
- }
- #endregion
- #region 串口重试机制;
- if (jObject["EnableRetry"] != null)
- {
- functionSetting1.EnableRetry = jObject["EnableRetry"].Value<bool>();
- }
- else
- {
- SaveJsonConfig("EnableRetry", false);
- }
- if (jObject["RetryCount"] != null)
- {
- functionSetting1.RetryCount = jObject["RetryCount"].Value<int>();
- }
- else
- {
- SaveJsonConfig("RetryCount", 3);
- }
- #endregion
- #region 是否整机抄写
- if (jObject["IsSmt"] != null)
- {
- functionSetting1.IsSmt = jObject["IsSmt"].Value<string>();
- Is_Smt = functionSetting1.IsSmt;
- }
- else
- {
- SaveJsonConfig("IsSmt", functionSetting1.IsSmt);
- }
- #endregion
- foreach (var ss in jObject["Channel"]) //遍历Channel
- {
- Dictionary<string, string> ChannelValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(ss.ToString());
- foreach (string key in ChannelValues.Keys)
- {
- ChannelMapList.Add(key, ChannelValues[key]);
- ChannelList.Items.Add(key);
- }
- }
- foreach (var ss in jObject["Language"]) //遍历Language
- {
- Dictionary<string, string> LanguageValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(ss.ToString());
- foreach (string key in LanguageValues.Keys)
- {
- OSDList.Items.Add(key);
- SHOPList.Items.Add(key);
- LanguageMapList.Add(key, LanguageValues[key]);
- }
- }
- foreach (var ss in jObject["CustomCMD"]) //遍历自定义命令表
- {
- functionSetting1.CustomCMD = JsonConvert.DeserializeObject<Dictionary<string, string>>(ss.ToString());
- }
- #region ReadCheck配置读取
- cfg_readcheck.PIDReadcheck = jObject["ReadCheck"]["PID"].Value<bool>();
- cfg_readcheck.OSDReadcheck = jObject["ReadCheck"]["OSD"].Value<bool>();
- cfg_readcheck.SHOPReadcheck = jObject["ReadCheck"]["SHOP"].Value<bool>();
- cfg_readcheck.DIDReadcheck = jObject["ReadCheck"]["DID"].Value<bool>();
- cfg_readcheck.MacReadcheck = jObject["ReadCheck"]["MAC"].Value<bool>();
- cfg_readcheck.HDCPReadcheck = jObject["ReadCheck"]["HDCP"].Value<bool>();
- cfg_readcheck.HDCP22Readcheck = jObject["ReadCheck"]["HDCP22"].Value<bool>();
- cfg_readcheck.WidevineReadcheck = jObject["ReadCheck"]["WIDEVINE"].Value<bool>();
- cfg_readcheck.ESNReadcheck = jObject["ReadCheck"]["ESN"].Value<bool>();
- cfg_readcheck.CI_plusReadcheck = jObject["ReadCheck"]["CI"].Value<bool>();
- cfg_readcheck.AttestationReadcheck = jObject["ReadCheck"]["Attestation"].Value<bool>();
- cfg_readcheck.MGKReadcheck = jObject["ReadCheck"]["MGK"].Value<bool>();
-
- if(jObject["ReadCheck"]["Fairplay"] == null )
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "Fairplay");
- cfg_readcheck.FairplayReadcheck = false;
- }
- else
- {
- cfg_readcheck.FairplayReadcheck = jObject["ReadCheck"]["Fairplay"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["ECP"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "ECP");
- cfg_readcheck.ECPReadcheck = false;
- }
- else
- {
- cfg_readcheck.ECPReadcheck = jObject["ReadCheck"]["ECP"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["WifiMac"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "WifiMac");
- cfg_readcheck.WifiMacReadcheck = false;
- }
- else
- {
- cfg_readcheck.WifiMacReadcheck = jObject["ReadCheck"]["WifiMac"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["BTMac"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "BTMac");
- cfg_readcheck.BTMacReadcheck = false;
- }
- else
- {
- cfg_readcheck.BTMacReadcheck = jObject["ReadCheck"]["BTMac"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["LEK"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "LEK");
- cfg_readcheck.LEKReadcheck = false;
- }
- else
- {
- cfg_readcheck.LEKReadcheck = jObject["ReadCheck"]["LEK"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["PEK"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "PEK");
- cfg_readcheck.PEKReadcheck = false;
- }
- else
- {
- cfg_readcheck.PEKReadcheck = jObject["ReadCheck"]["PEK"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["Playready"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "Playready");
- cfg_readcheck.PlayreadyReadcheck = false ;
- }
- else
- {
- cfg_readcheck.PlayreadyReadcheck = jObject["ReadCheck"]["Playready"].Value<bool>();
- }
-
- if (jObject["ReadCheck"]["Hash"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "Hash");
- cfg_readcheck.HashReadcheck = false ;
- }
- else
- {
- cfg_readcheck.HashReadcheck = jObject["ReadCheck"]["Hash"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["DSN"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "DSN");
- cfg_readcheck.DSNReadcheck = false;
- }
- else
- {
- cfg_readcheck.DSNReadcheck = jObject["ReadCheck"]["DSN"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["YouTube"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "YouTube");
- cfg_readcheck.YouTubeReadcheck = false;
- }
- else
- {
- cfg_readcheck.YouTubeReadcheck = jObject["ReadCheck"]["YouTube"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["EDIDPID"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "EDIDPID");
- cfg_readcheck.EDIDPIDReadcheck = false;
- }
- else
- {
- cfg_readcheck.EDIDPIDReadcheck = jObject["ReadCheck"]["EDIDPID"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["EDIDModeName"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "EDIDModeName");
- cfg_readcheck.EDIDModeNameReadcheck = false;
- }
- else
- {
- cfg_readcheck.EDIDModeNameReadcheck = jObject["ReadCheck"]["EDIDModeName"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["ACASKey"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "ACASKey");
- cfg_readcheck.ACASKeyReadcheck = false;
- }
- else
- {
- cfg_readcheck.ACASKeyReadcheck = jObject["ReadCheck"]["ACASKey"].Value<bool>();
- }
-
- if(jObject["ReadCheck"]["FVP"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "FVP");
- cfg_readcheck.FVPReadcheck = false;
- }
- else
- {
- cfg_readcheck.FVPReadcheck = jObject["ReadCheck"]["FVP"].Value<bool>();
- }
-
- if (jObject["ReadCheck"]["DAK"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "DAK");
- cfg_readcheck.DAKReadcheck = false;
- }
- else
- {
- cfg_readcheck.DAKReadcheck = jObject["ReadCheck"]["DAK"].Value<bool>();
- }
- if (jObject["ReadCheck"]["Dolby"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "Dolby");
- cfg_readcheck.DolbyReadcheck = false;
- }
- else
- {
- cfg_readcheck.DolbyReadcheck=jObject["ReadCheck"]["Dolby"].Value<bool>();
- }
-
- if (jObject["ReadCheck"]["KFP"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "KFP");
- cfg_readcheck.KFPReadcheck = false;
- }
- else
- {
- cfg_readcheck.KFPReadcheck = jObject["ReadCheck"]["KFP"].Value<bool>();
- }
- #endregion
- #region WriteCheck配置读取
- cfg_writecheck.DIDCheckcheck = jObject["WriteCheck"]["DID"].Value<bool>();
- cfg_writecheck.MacCheckcheck = jObject["WriteCheck"]["MAC"].Value<bool>();
- cfg_writecheck.HDCPCheckcheck = jObject["WriteCheck"]["HDCP"].Value<bool>();
- cfg_writecheck.HDCP22Checkcheck = jObject["WriteCheck"]["HDCP22"].Value<bool>();
- cfg_writecheck.WidevineCheckcheck = jObject["WriteCheck"]["WIDEVINE"].Value<bool>();
- cfg_writecheck.ESNCheckcheck = jObject["WriteCheck"]["ESN"].Value<bool>();
- cfg_writecheck.CI_plusCheckcheck = jObject["WriteCheck"]["CI"].Value<bool>();
- cfg_writecheck.AttestationCheckcheck = jObject["WriteCheck"]["Attestation"].Value<bool>();
- cfg_writecheck.MGKCheckcheck = jObject["WriteCheck"]["MGK"].Value<bool>();
-
- if (jObject["WriteCheck"]["Fairplay"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "Fairplay");
- cfg_writecheck.FairplayCheckcheck = false;
- }
- else
- {
- cfg_writecheck.FairplayCheckcheck = jObject["WriteCheck"]["Fairplay"].Value<bool>();
- }
- if (jObject["WriteCheck"]["ECP"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "ECP");
- cfg_writecheck.ECPCheckcheck = false;
- }
- else
- {
- cfg_writecheck.ECPCheckcheck = jObject["WriteCheck"]["ECP"].Value<bool>();
- }
- if (jObject["WriteCheck"]["WifiMac"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "WifiMac");
- cfg_writecheck.WifiMacCheckcheck = false;
- }
- else
- {
- cfg_writecheck.WifiMacCheckcheck = jObject["WriteCheck"]["WifiMac"].Value<bool>();
- }
- if (jObject["WriteCheck"]["BTMac"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "BTMac");
- cfg_writecheck.BTMacCheckcheck = false;
- }
- else
- {
- cfg_writecheck.BTMacCheckcheck = jObject["WriteCheck"]["BTMac"].Value<bool>();
- }
- if (jObject["WriteCheck"]["LEK"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "LEK");
- cfg_writecheck.LEKCheckcheck = false;
- }
- else
- {
- cfg_writecheck.LEKCheckcheck = jObject["WriteCheck"]["LEK"].Value<bool>();
- }
- if (jObject["WriteCheck"]["PEK"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "PEK");
- cfg_writecheck.PEKCheckcheck = false;
- }
- else
- {
- cfg_writecheck.PEKCheckcheck = jObject["WriteCheck"]["PEK"].Value<bool>();
- }
- if (jObject["WriteCheck"]["Playready"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "Playready");
- cfg_writecheck.PlayreadyCheckcheck = false;
- }
- else
- {
- cfg_writecheck.PlayreadyCheckcheck = jObject["WriteCheck"]["Playready"].Value<bool>();
- }
- if (jObject["WriteCheck"]["Hash"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "Hash");
- cfg_writecheck.HashCheckcheck = false;
- }
- else
- {
- cfg_writecheck.HashCheckcheck = jObject["WriteCheck"]["Hash"].Value<bool>();
- }
- if (jObject["WriteCheck"]["DSN"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "DSN");
- cfg_writecheck.DSNCheckcheck = false;
- }
- else
- {
- cfg_writecheck.DSNCheckcheck = jObject["WriteCheck"]["DSN"].Value<bool>();
- }
- if (jObject["WriteCheck"]["YouTube"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "YouTube");
- cfg_writecheck.YouTubeCheckcheck = false;
- }
- else
- {
- cfg_writecheck.YouTubeCheckcheck = jObject["WriteCheck"]["YouTube"].Value<bool>();
- }
-
- if (jObject["WriteCheck"]["ACASKey"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "ACASKey");
- cfg_writecheck.ACASKeyCheckcheck = false;
- }
- else
- {
- cfg_writecheck.ACASKeyCheckcheck = jObject["WriteCheck"]["ACASKey"].Value<bool>();
- }
- if (jObject["WriteCheck"]["FVP"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "FVP");
- cfg_writecheck.FVPCheckcheck = false;
- }
- else
- {
- cfg_writecheck.FVPCheckcheck = jObject["WriteCheck"]["FVP"].Value<bool>();
- }
- if (jObject["WriteCheck"]["DAK"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "DAK");
- cfg_writecheck.DAKCheckcheck = false;
- }
- else
- {
- cfg_writecheck.DAKCheckcheck = jObject["WriteCheck"]["DAK"].Value<bool>();
- }
- if (jObject["WriteCheck"]["Dolby"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "Dolby");
- cfg_writecheck.DolbyCheckcheck = false;
- }
- else
- {
- cfg_writecheck.DolbyCheckcheck = jObject["WriteCheck"]["Dolby"].Value<bool>();
- }
- if (jObject["WriteCheck"]["KFP"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "KFP");
- cfg_writecheck.KFPCheckcheck = false;
- }
- else
- {
- cfg_writecheck.KFPCheckcheck = jObject["WriteCheck"]["KFP"].Value<bool>();
- }
- #endregion
- #region WriteDone配置读取
- cfg_writedone.PIDWrite_YesNo = jObject["WriteDone"]["PID"].Value<bool>();
- cfg_writedone.PIDWriteDelay = jObject["WriteDone"]["PIDWirteDelay"].Value<int>();
- cfg_writedone.ClientTypeCheck_YesNo = jObject["WriteDone"]["ClientType"].Value<bool>();
- cfg_writedone.SoftwareVersionCheck_YesNo = jObject["WriteDone"]["SoftwareVersion"].Value<bool>();
- cfg_writedone.DIDWrite_YesNo = jObject["WriteDone"]["DID"].Value<bool>();
- cfg_writedone.MacWrite_YesNo = jObject["WriteDone"]["MAC"].Value<bool>();
- cfg_writedone.HDCPWrite_YesNo = jObject["WriteDone"]["HDCP"].Value<bool>();
- cfg_writedone.HDCP22Write_YesNo = jObject["WriteDone"]["HDCP22"].Value<bool>();
- cfg_writedone.WidevineWrite_YesNo = jObject["WriteDone"]["WIDEVINE"].Value<bool>();
- cfg_writedone.ESNWrite_YesNo = jObject["WriteDone"]["ESN"].Value<bool>();
- cfg_writedone.CI_plusWrite_YesNo = jObject["WriteDone"]["CI"].Value<bool>();
- cfg_writedone.AttestationWrite_YesNo = jObject["WriteDone"]["Attestation"].Value<bool>();
- cfg_writedone.MGKWrite_YesNo = jObject["WriteDone"]["MGK"].Value<bool>();
-
- if (jObject["WriteDone"]["Fairplay"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "Fairplay");
- cfg_writedone.FairplayWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.FairplayWrite_YesNo = jObject["WriteDone"]["Fairplay"].Value<bool>();
- }
- if (jObject["WriteDone"]["ECP"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "ECP");
- cfg_writedone.ECPWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.ECPWrite_YesNo = jObject["WriteDone"]["ECP"].Value<bool>();
- }
- if (jObject["WriteDone"]["WifiMac"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "WifiMac");
- cfg_writedone.WifiMacWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.WifiMacWrite_YesNo = jObject["WriteDone"]["WifiMac"].Value<bool>();
- }
- if (jObject["WriteDone"]["BTMac"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "BTMac");
- cfg_writedone.BTMacWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.BTMacWrite_YesNo = jObject["WriteDone"]["BTMac"].Value<bool>();
- }
- if (jObject["WriteDone"]["LEK"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "LEK");
- cfg_writedone.LEKWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.LEKWrite_YesNo = jObject["WriteDone"]["LEK"].Value<bool>();
- }
- if (jObject["WriteDone"]["PEK"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "PEK");
- cfg_writedone.PEKWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.PEKWrite_YesNo = jObject["WriteDone"]["PEK"].Value<bool>();
- }
- if (jObject["WriteDone"]["Playready"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "Playready");
- cfg_writedone.PlayreadyWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.PlayreadyWrite_YesNo = jObject["WriteDone"]["Playready"].Value<bool>();
- }
- if (jObject["WriteDone"]["Hash"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "Hash");
- cfg_writedone.HashWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.HashWrite_YesNo = jObject["WriteDone"]["Hash"].Value<bool>();
- }
- if (jObject["WriteDone"]["DSN"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "DSN");
- cfg_writedone.DSNWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.DSNWrite_YesNo = jObject["WriteDone"]["DSN"].Value<bool>();
- }
-
- if(jObject["WriteDone"]["AutoWhiteBalance"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "AutoWhiteBalance");
- cfg_writedone.AutoWhiteBalance = false;
- }
- else
- {
- cfg_writedone.AutoWhiteBalance = jObject["WriteDone"]["AutoWhiteBalance"].Value<bool>();
- }
- ///
- if (jObject["WriteDone"]["YouTube"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "YouTube");
- cfg_writedone.YouTubeWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.YouTubeWrite_YesNo = jObject["WriteDone"]["YouTube"].Value<bool>();
- }
- if (jObject["WriteDone"]["EDIDPID"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "EDIDPID");
- cfg_writedone.EDIDPIDWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.EDIDPIDWrite_YesNo = jObject["WriteDone"]["EDIDPID"].Value<bool>();
- }
- if (jObject["WriteDone"]["EDIDModeName"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "EDIDModeName");
- cfg_writedone.EDIDModeNameWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.EDIDModeNameWrite_YesNo = jObject["WriteDone"]["EDIDModeName"].Value<bool>();
- }
- if (jObject["WriteDone"]["ACASKey"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "ACASKey");
- cfg_writedone.ACASKeyWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.ACASKeyWrite_YesNo = jObject["WriteDone"]["ACASKey"].Value<bool>();
- }
- if (jObject["WriteDone"]["FVP"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "FVP");
- cfg_writedone.FVPWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.FVPWrite_YesNo = jObject["WriteDone"]["FVP"].Value<bool>();
- }
- if (jObject["WriteDone"]["DAK"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "DAK");
- cfg_writedone.DAKWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.DAKWrite_YesNo = jObject["WriteDone"]["DAK"].Value<bool>();
- }
- if (jObject["WriteDone"]["Dolby"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "Dolby");
- cfg_writedone.DolbyWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.DolbyWrite_YesNo = jObject["WriteDone"]["Dolby"].Value<bool>();
- }
- if (jObject["WriteDone"]["KFP"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "KFP");
- cfg_writedone.KFPWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.KFPWrite_YesNo = jObject["WriteDone"]["KFP"].Value<bool>();
- }
- #endregion
- file.Close();
- if (Custom_ProjectID != null)
- if (Custom_ProjectID.Trim().Length > 0)
- PID_Num.Value = Convert.ToDecimal(Custom_ProjectID);
- if (TVCOM.Items.Contains(COM))
- TVCOM.SelectedItem = COM;
- if (TVBaud.Items.Contains(Baudrate))
- TVBaud.SelectedItem = Baudrate;
- if (ChannelList.Items.Contains(ChannelSelect))
- {
- ChannelList.SelectedItem = ChannelSelect;
- functionSetting1.ChannelCode = SerialInit.HexToByte(ChannelMapList[ChannelSelect]);
- }
- if (OSDList.Items.Contains(OSDLanguageSelect))
- {
- OSDList.SelectedItem = OSDLanguageSelect;
- functionSetting1.OSDLCode = SerialInit.HexToByte(LanguageMapList[OSDLanguageSelect]);
- }
- if (SHOPList.Items.Contains(SHOPLanguageSelect))
- {
- SHOPList.SelectedItem = SHOPLanguageSelect;
- functionSetting1.ShopLCode = SerialInit.HexToByte(LanguageMapList[SHOPLanguageSelect]);
- }
- BarcodeLimit.Checked = functionSetting1.BarcodeLimit;
- BarcodeWrite.Checked = functionSetting1.BarcodeWrite;
- BarCodeKeyCodeText.Text = functionSetting1.BarcodeKeyword;
- BarCodeLengthText.Value = functionSetting1.BarcodeLength;
- Preload.Checked = Preloadmode == "True";
- WriteChannel.Checked = WriteChannelConfig == "True";
- WriteOSD.Checked = WriteOSDLanguageConfig == "True";
- WriteSHOP.Checked = WriteSHOPLanguageConfig == "True";
- WBInit.Checked = WhiteBalanceInitConfig == "True";
- UsinglocalIDCheck.Checked = UsingLocalPID == "True";
- OrderText.Text = LastOrder;
- if (File.Exists(WhiteBalancePath))
- {
- if (!LoadWBConfig(WhiteBalancePath))
- {
- MessageBox.Show(LResource.ReadWBError);
- WriteWB.Checked = false;
- }
- else
- {
- WBPath.Text = WhiteBalancePath;
- WriteWB.Checked = WriteWhiteBalanceConfig == "True";
- }
- }
- else
- WriteWB.Checked = false;
- }
- }
- /// <summary>
- /// 加载本地白平衡配置
- /// </summary>
- /// <param name="filepath"></param>
- /// <returns></returns>
- public bool LoadWBConfig(string filepath)
- {
- try
- {
- functionSetting1.NormalRGB = new byte[3];
- functionSetting1.CoolRGB = new byte[3];
- functionSetting1.WarmRGB = new byte[3];
- functionSetting1.NormalRGB[0] = (byte)Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "HDMI white R:", null, filepath));
- functionSetting1.NormalRGB[1] = (byte)Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "HDMI white G:", null, filepath));
- functionSetting1.NormalRGB[2] = (byte)Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "HDMI white B:", null, filepath));
- functionSetting1.CoolRGB[0] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Cool white R:", null, filepath)) + 256);
- functionSetting1.CoolRGB[1] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Cool white G:", null, filepath)) + 256);
- functionSetting1.CoolRGB[2] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Cool white B:", null, filepath)) + 256);
- functionSetting1.WarmRGB[0] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Warm white R:", null, filepath)) + 256);
- functionSetting1.WarmRGB[1] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Warm white G:", null, filepath)) + 256);
- functionSetting1.WarmRGB[2] = (byte)(Convert.ToDouble(Iniconfig.OperateIniFile.ReadIniData("WBA value:", "Warm white B:", null, filepath)) + 256);
- return true;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- return false;
- }
- }
- private void ChannelList_SelectedIndexChanged(object sender, EventArgs e)
- {
- string ChannelSelect = ChannelList.SelectedItem.ToString();
- string channelcode = ChannelMapList[ChannelSelect];
- functionSetting1.ChannelCode = SerialInit.HexToByte(channelcode);
- SaveJsonConfig("ChannelSelect", ChannelSelect);
- Log.WriteInfoLog("\r\nSet channel setting to " + ChannelSelect + "\r\nchannel code is " + channelcode);
- }
- private void OSDList_SelectedIndexChanged(object sender, EventArgs e)
- {
- string OSDLanguageSelect = OSDList.SelectedItem.ToString();
- string OSDLcode = LanguageMapList[OSDLanguageSelect];
- functionSetting1.OSDLCode = SerialInit.HexToByte(OSDLcode);
- SaveJsonConfig("OSDLanguageSelect", OSDLanguageSelect);
- Log.WriteInfoLog("\r\nSet channel setting to " + OSDLanguageSelect + "\r\nchannel code is " + OSDLcode);
- }
- private void SHOPList_SelectedIndexChanged(object sender, EventArgs e)
- {
- string SHOPLanguageSelect = SHOPList.SelectedItem.ToString();
- string SHOPLcode = LanguageMapList[SHOPLanguageSelect];
- functionSetting1.ShopLCode = SerialInit.HexToByte(SHOPLcode);
- SaveJsonConfig("SHOPLanguageSelect", SHOPLanguageSelect);
- Log.WriteInfoLog("\r\nSet channel setting to " + SHOPLanguageSelect + "\r\nchannel code is " + SHOPLcode);
- }
- private void skinButton1_Click(object sender, EventArgs e)
- {
- SaveJsonConfig("COM", "COM3");
- string strFileName = null;
- openFileDialog1.Filter = "WBConfig file|*.wba";
- openFileDialog1.FileName = "";
- openFileDialog1.Title = "Please select the WB config file";
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
- strFileName = System.IO.Path.GetFullPath(openFileDialog1.FileName);
- WBPath.Text = strFileName;
- if (LoadWBConfig(strFileName))
- {
- functionSetting1.WBFileName = Path.GetFileName(openFileDialog1.FileName);
- SaveJsonConfig("WhiteBalancePath", strFileName);
- MessageBox.Show(LResource.LoadWBsuccess);
- }
- }
- }
- private void WriteWB_CheckedChanged(object sender, EventArgs e)
- {
- if (WriteWB.Checked == true)
- {
- if (WBPath.Text.Trim().Length > 0)
- {
- LoadWBConfig(WBPath.Text.Trim());
- SaveJsonConfig("WriteWhiteBalance", true);
- }
- else
- {
- MessageBox.Show(LResource.SelectWBfirst);
- WriteWB.Checked = false;
- }
- }
- else
- {
- SaveJsonConfig("WriteWhiteBalance", false);
- }
- }
- public void SaveJsonConfig(string node, object value)
- {
- StreamReader file = File.OpenText(LocalPath.localpath + "\\Config.json");
- using (JsonTextReader reader = new JsonTextReader(file))
- {
- JObject jObject = (JObject)JToken.ReadFrom(reader);
- jObject[node] = value.ToString();
- file.Close();
- using (StreamWriter writer = new StreamWriter(LocalPath.localpath + "\\Config.json"))
- {
- writer.Write(jObject.ToString()); //将JToken.ReadFrom(reader)的数据写入文件,这样的数据有空行。
- }
- }
- }
- private void WBInit_CheckedChanged(object sender, EventArgs e)
- {
- if (WBInit.Checked)
- {
- SaveJsonConfig("WhiteBalanceInit", true);
- }
- else
- SaveJsonConfig("WhiteBalanceInit", false);
- }
- private void WriteChannel_CheckedChanged(object sender, EventArgs e)
- {
- if (WriteChannel.Checked)
- {
- SaveJsonConfig("WriteChannel", true);
- }
- else
- SaveJsonConfig("WriteChannel", false);
- }
- private void WriteOSD_CheckedChanged(object sender, EventArgs e)
- {
- if (WriteOSD.Checked)
- {
- SaveJsonConfig("WriteOSDLanguage", true);
- }
- else
- SaveJsonConfig("WriteOSDLanguage", false);
- }
- private void WriteSHOP_CheckedChanged(object sender, EventArgs e)
- {
- if (WriteSHOP.Checked)
- {
- SaveJsonConfig("WriteSHOPLanguage", true);
- }
- else
- SaveJsonConfig("WriteSHOPLanguage", false);
- }
- private void TVCOM_SelectedIndexChanged(object sender, EventArgs e)
- {
- SaveJsonConfig("COM", TVCOM.SelectedItem.ToString());
- }
- private void TVBaud_SelectedIndexChanged(object sender, EventArgs e)
- {
- SaveJsonConfig("Baudrate", TVBaud.SelectedItem.ToString());
- }
- private void Form1_FormClosed(object sender, FormClosedEventArgs e)
- {
- Environment.Exit(0);
- }
- public void LockSettingFunction(bool locksetting)
- {
- ChannelList.Enabled = locksetting;
- WriteOSD.Enabled = locksetting;
- WriteSHOP.Enabled = locksetting;
- WriteChannel.Enabled = locksetting;
- OSDList.Enabled = locksetting;
- SHOPList.Enabled = locksetting;
- skinButton1.Enabled = locksetting;
- WriteOSD.Enabled = locksetting;
- WBInit.Enabled = locksetting;
- WriteWB.Enabled = locksetting;
- OrderText.Enabled = locksetting;
- Preload.Enabled = locksetting;
- PID_Num.Enabled = locksetting;
- BarcodeLimit.Enabled = locksetting;
- BarCodeLengthText.Enabled = locksetting;
- BarCodeKeyCodeText.Enabled = locksetting;
- }
- private void TVCOM_MouseClick(object sender, MouseEventArgs e)
- {
- TVCOM.Items.Clear();
- TVCOM.Items.AddRange(SerialPort.GetPortNames());
- }
- private void CreateKeyManually_Click(object sender, EventArgs e)
- {
- CreateDBManually CreateDBManually1 = new CreateDBManually(TestMode.serverurl, ErrorDB);
- CreateDBManually1.ShowDialog();
- }
- private void Preload_CheckedChanged(object sender, EventArgs e)
- {
- SaveJsonConfig("Preload", Preload.Checked.ToString());
- }
- private void Form1_Move(object sender, EventArgs e)
- {
- if (this.MoveEvent != null)
- {
- Point XY = this.Location;
- XY.X = this.Right;
- XY.Y = this.Top;
- this.MoveEvent(XY, formlocationmsg, LocationNum);
- }
- }
- private void DeleteIntptr(IntPtr intPtr)
- {
- foreach (Dictionary<IntPtr, Point> pairs in formlocationmsg)
- {
- if (pairs.ContainsKey(intPtr))
- {
- formlocationmsg.Remove(pairs);
- if (this.MoveEvent != null)
- {
- Point XY = this.Location;
- XY.X = this.Right;
- XY.Y = this.Top;
- this.MoveEvent(XY, formlocationmsg, LocationNum);
- }
- break;
- }
- }
- }
- private void SNKeyDownEven(IntPtr intPtr)
- {
- this.KeyDownEvent(formlocationmsg, intPtr);
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- string count = SQLiteHelper.GetProductionNum(ErrorDB, OrderText.Text.Trim());
- UpdateCountLabel(ProductionNum_Text, count);
- }
- /// <summary>
- /// 刷新订单数量
- /// </summary>
- /// <param name="label"></param>
- /// <param name="str"></param>
- public void UpdateCountLabel(Label label, string str)
- {
- if (label.InvokeRequired)
- {
- BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), str);
- }
- else
- {
- label.Text = str;
- }
- }
- /// <summary>
- /// 后台上报
- /// </summary>
- public void UploadBackGround()
- {
- while (true)
- {
- if (!CommonMethod.HTTPChecker(StructList.CheckServerConnectionUrl))
- {
- Thread.Sleep(20000);
- continue;
- }
-
- try
- {
- string url;
- string content;
- string id;
- if (SQLiteHelper.GetDelayReportData(ErrorDB, out url, out content, out id))
- {
- if (content.Contains("@"))
- {
- string[] data = content.Split('@');
- if (V2Method.ReportOfflineData(url, data[1], data[0], LocalDB, ErrorDB, true, id))
- {
- SQLiteHelper.UpdateReportData(ErrorDB, "CopyDelayReport", "ID", id);
- }
- }
- else if (V2Method.ReportOnlineData(url, OrderText.Text.Trim(), content, ErrorDB, true, id, functionSetting1.ReportTimeOut))
- {
- SQLiteHelper.UpdateReportData(ErrorDB, "CopyDelayReport", "ID", id);
- }
- }
- }
- catch (Exception ex)
- {
- Log.WriteErrorLog(ex.Message);
- }
- try
- {
- string url;
- string content;
- string id;
- if (SQLiteHelper.GetErrorReportData(ErrorDB, out url, out content, out id))
- {
- bool mark = false;
- if ( url.EndsWith("smes/RecordKey") )
- {
- GMethod.ReportDataBurningResultToMES(url, content, out mark);
- }
- else
- {
- CommonMethod.ReportErrormsg2(url, content, out mark);
- }
- if (mark)
- {
- SQLiteHelper.UpdateReportData(ErrorDB, "ErrorReport", "ID", id);
- }
- }
- }
- catch (Exception ex)
- {
- Log.WriteErrorLog(ex.Message);
- }
- try
- {
- string url;
- string content;
- string id;
- if (SQLiteHelper.GetReportData(ReportDB, out id, out url, out content))
- {
- if ( V2Method.ReportOnlineDataSQL(url, content, 5000) )
- {
- // 删除该记录;
- SQLiteCommand cmd = new SQLiteCommand();
- cmd.Connection = ReportDB;
- cmd.CommandText = string.Format("delete from ReportData where id = {0}", id);
- cmd.ExecuteNonQuery();
- cmd.Dispose();
- }
- }
- }
- catch (Exception ex)
- {
- Log.WriteErrorLog(ex.Message);
- }
- // 频率5秒一次;
- Thread.Sleep(5000);
- }
- }
- private void PID_Num_ValueChanged(object sender, EventArgs e)
- {
- Custom_ProjectID = PID_Num.Value.ToString();
- SaveJsonConfig("Custom_ProjectID", Custom_ProjectID);
- }
- private void BarCodeLengthText_ValueChanged(object sender, EventArgs e)
- {
- functionSetting1.BarcodeLength = Convert.ToInt32(BarCodeLengthText.Value);
- SaveJsonConfig("BarcodeLength", functionSetting1.BarcodeLength);
- }
- private void BarcodeLimit_CheckedChanged(object sender, EventArgs e)
- {
- functionSetting1.BarcodeLimit = BarcodeLimit.Checked;
- SaveJsonConfig("BarcodeLimit", BarcodeLimit.Checked);
- }
- private void BarCodeKeyCodeText_TextChanged(object sender, EventArgs e)
- {
- functionSetting1.BarcodeKeyword = BarCodeKeyCodeText.Text;
- SaveJsonConfig("BarcodeKeyword", BarCodeKeyCodeText.Text);
- }
- private void UsinglocalIDCheck_CheckedChanged(object sender, EventArgs e)
- {
- SaveJsonConfig("UsingLocalPID", UsinglocalIDCheck.Checked);
- }
- private void BarcodeWrite_CheckedChanged(object sender, EventArgs e)
- {
- functionSetting1.BarcodeWrite = BarcodeWrite.Checked;
- SaveJsonConfig("BarcodeWrite", BarcodeWrite.Checked);
- }
- }
- }
|