1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101 |
- 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;
- // 读取指定订单号的SN和ACAS值;
- if (functionSetting1.ExportSNACASID)
- {
- CommonMethod.ReadSNACASID(OrderText.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
- #region 波兰G客户接口变更
- if (jObject["UsePolandGInterface"] != null)
- {
- functionSetting1.UsePolandGInterface = jObject["UsePolandGInterface"].Value<bool>();
- }
- else
- {
- SaveJsonConfig("UsePolandGInterface", functionSetting1.UsePolandGInterface);
- }
- GMethod.SetPolandConfig(functionSetting1.UsePolandGInterface);
- #endregion
- #region
- if (jObject["Poland_NTF"] != null)
- {
- functionSetting1.Poland_NTF = jObject["Poland_NTF"].Value<bool>();
- }
- else
- {
- SaveJsonConfig("Poland_NTF", functionSetting1.Poland_NTF);
- }
- #endregion
- #region 预绑定抄写是否上报离线数据;
- if (jObject["ReportOfflineData"] != null)
- {
- functionSetting1.ReportOfflineData = jObject["ReportOfflineData"].Value<bool>();
- }
- else
- {
- SaveJsonConfig("ReportOfflineData", functionSetting1.ReportOfflineData);
- }
- #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>();
- }
- if (jObject["ReadCheck"]["RMCA"] == null)
- {
- CommonMethod.InsertJsonConfig("ReadCheck", "RMCA");
- cfg_readcheck.RMCAReadcheck = false;
- }
- else
- {
- cfg_readcheck.RMCAReadcheck = jObject["ReadCheck"]["RMCA"].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>();
- }
- if (jObject["WriteCheck"]["RMCA"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteCheck", "RMCA");
- cfg_writecheck.RMCACheckcheck = false;
- }
- else
- {
- cfg_writecheck.RMCACheckcheck = jObject["WriteCheck"]["RMCA"].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>();
- }
- if (jObject["WriteDone"]["RMCA"] == null)
- {
- CommonMethod.InsertJsonConfig("WriteDone", "RMCA");
- cfg_writedone.RMCAWrite_YesNo = false;
- }
- else
- {
- cfg_writedone.RMCAWrite_YesNo = jObject["WriteDone"]["RMCA"].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("@"))
- {
- // 不上报离线数据;
- if (!functionSetting1.ReportOfflineData)
- continue;
- 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);
- }
- }
- }
|