OperationPanel.cs 243 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347
  1. using CCWin;
  2. using Newtonsoft.Json.Linq;
  3. using SufeiUtil;
  4. using SXLibrary;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.Data.SQLite;
  9. using System.Drawing;
  10. using System.IO;
  11. using System.IO.Ports;
  12. using System.Text;
  13. using System.Threading;
  14. using System.Windows.Forms;
  15. using System.Net;
  16. using System.Net.Sockets;
  17. using System.Linq;
  18. using System.Text.RegularExpressions;
  19. using System.Diagnostics;
  20. using MOKA_Factory_Tools.BLL;
  21. namespace MOKA_Factory_Tools
  22. {
  23. public partial class OperationPanel : Skin_Color
  24. {
  25. //白平衡URL
  26. MidList midListNow = new MidList();
  27. MidList localmidList = new MidList();
  28. MidAddress MidAddressNow = new MidAddress();
  29. FunctionSetting FunctionSettingNow = new FunctionSetting();
  30. WhiteBalanceList WhiteBalanceListNow = new WhiteBalanceList();
  31. Config_WriteCheck cfg_writecheck = new Config_WriteCheck();
  32. Config_ReadCheck cfg_readcheck = new Config_ReadCheck();
  33. Config_WriteDone cfg_writedone = new Config_WriteDone();
  34. SerialPort TVPort = new SerialPort();
  35. SQLiteConnection localDBNow;
  36. SQLiteConnection errorDBNow;
  37. KeyInfo keyInfo = new KeyInfo();
  38. FireTVKey fireTVKey = new FireTVKey();
  39. NTFBLL ntfBLL = null;
  40. bool preloadNow;
  41. string SN;
  42. string orderNow;
  43. Main mainform;
  44. int usingTime = 0;
  45. Thread SNTextFocus;
  46. bool FocusMark = false;
  47. Thread WritekeyThread;
  48. string availableCount = "unknow";
  49. // 只有NTF才用该变量, 0试产, 1=量产;
  50. int nOrderType = -1;
  51. MIKey _MiKey = null;
  52. //删除界面指针委托
  53. public delegate void DisplayUpdateDelegate(IntPtr intPtr);
  54.         //删除界面指针事件
  55.         public event DisplayUpdateDelegate DeleteIntptr;
  56. //扫描回车触发委托
  57. public delegate void SNKeyDown(IntPtr intPtr);
  58.         //扫描回车触发事件
  59.         public event SNKeyDown SNKeyDownEven;
  60. //定义一个委托 调用Verify窗口;
  61. delegate void ShowVerifyCallback(string strMsg);
  62. //委托方法
  63. private void ShowVerifyDailog(string strMsg)
  64. {
  65. //右下角消息框Form
  66. Verify dlg = new Verify(strMsg);
  67. dlg.ShowDialog();
  68. }
  69. //调用委托
  70. private void ShowVerifyDelegate(string strMsg)
  71. {
  72. //创建委托
  73. ShowVerifyCallback wt = new ShowVerifyCallback(ShowVerifyDailog);
  74. //这段代码在主窗体类里面写着,this指主窗体
  75. this.Invoke(wt, new Object[] { strMsg });
  76. }
  77. public OperationPanel(Main form1, SQLiteConnection localDB, SQLiteConnection errorDB, MidAddress midAddress1, FunctionSetting functionSetting, Config_WriteCheck writeCheck1, Config_ReadCheck readCheck1, Config_WriteDone writeDone1, bool preload, MidList midList1, string order)
  78. {
  79. InitializeComponent();
  80. MidAddressNow = midAddress1;
  81. FunctionSettingNow = functionSetting;
  82. cfg_writecheck = writeCheck1;
  83. cfg_readcheck = readCheck1;
  84. cfg_writedone = writeDone1;
  85. localDBNow = localDB;
  86. errorDBNow = errorDB;
  87. preloadNow = preload;
  88. midListNow = midList1;
  89. orderNow = order;
  90. InitPanel();
  91. mainform = form1;
  92. this.mainform.MoveEvent += new MoveHandler(SetFormLocation);
  93. this.mainform.KeyDownEvent += new KeyDownHandler(SetFocus);
  94. if (midListNow.rokuCustomer != null)
  95. ProductMsg_Text.Text = "Roku:";
  96. if (functionSetting.NTF)
  97. ntfBLL = new NTFBLL();
  98. }
  99. /// <summary>
  100. /// 控制界面跟随主界面移动
  101. /// </summary>
  102. /// <param name="XY"></param>
  103. /// <param name="formlocationmsg"></param>
  104. /// <param name="num"></param>
  105. void SetFormLocation(Point XY, ArrayList formlocationmsg, int num)
  106. {
  107. foreach (Dictionary<IntPtr, Point> pairs in formlocationmsg)
  108. {
  109. if (!this.IsDisposed)
  110. {
  111. if (pairs.ContainsKey(this.Handle))
  112. {
  113. if (formlocationmsg.IndexOf(pairs) >= num && num > 0)
  114. {
  115. this.Left = XY.X + this.Size.Width * (formlocationmsg.IndexOf(pairs) - num);
  116. this.Top = XY.Y + this.Size.Height;
  117. }
  118. else
  119. {
  120. this.Left = XY.X + this.Size.Width * formlocationmsg.IndexOf(pairs);
  121. this.Top = XY.Y;
  122. }
  123. break;
  124. }
  125. }
  126. }
  127. }
  128. /// <summary>
  129. /// 按指针设置是否聚焦
  130. /// </summary>
  131. /// <param name="formlocationmsg"></param>
  132. /// <param name="intPtr"></param>
  133. void SetFocus(ArrayList formlocationmsg, IntPtr intPtr)
  134. {
  135. bool mark = false;
  136. bool mark2 = false;
  137. foreach (Dictionary<IntPtr, Point> pairs in formlocationmsg)
  138. {
  139. if (!this.IsDisposed)
  140. {
  141. if (pairs.ContainsKey(this.Handle) && formlocationmsg.IndexOf(pairs) == 0)
  142. {
  143. mark2 = true;
  144. }
  145. if (mark)
  146. {
  147. if (pairs.ContainsKey(this.Handle))
  148. FocusMark = true;
  149. else
  150. mark = false;
  151. }
  152. if (pairs.ContainsKey(intPtr))
  153. {
  154. if (formlocationmsg.IndexOf(pairs) == (formlocationmsg.Count - 1))
  155. {
  156. if (mark2)
  157. FocusMark = true;
  158. }
  159. mark = true;
  160. }
  161. }
  162. }
  163. }
  164. /// <summary>
  165. /// 界面控件初始化
  166. /// </summary>
  167. public void InitPanel()
  168. {
  169. COMText.Text = FunctionSettingNow.TVCOM;
  170. COMText.BackColor = Color.FromArgb(128, 255, 128);
  171. BaudText.Text = FunctionSettingNow.TVBaud;
  172. BaudText.BackColor = Color.FromArgb(128, 255, 128);
  173. WritePSN.Checked = FunctionSettingNow.BarcodeWrite;
  174. #region 设置WriteCheck复选框默认状态;
  175. if (!cfg_writecheck.DIDCheckcheck)
  176. SetspecificText(m_checkdid, LResource.Skip, Color.Yellow);
  177. if (!cfg_writecheck.MacCheckcheck)
  178. SetspecificText(m_checkmac, LResource.Skip, Color.Yellow);
  179. if (!cfg_writecheck.HDCPCheckcheck)
  180. SetspecificText(m_checkhdcp, LResource.Skip, Color.Yellow);
  181. if (!cfg_writecheck.HDCP22Checkcheck)
  182. SetspecificText(m_checkhdcp22, LResource.Skip, Color.Yellow);
  183. if (!cfg_writecheck.WiDiCheckcheck)
  184. SetspecificText(m_checkwidi, LResource.Skip, Color.Yellow);
  185. if (!cfg_writecheck.WidevineCheckcheck)
  186. SetspecificText(m_checkwidevine, LResource.Skip, Color.Yellow);
  187. if (!cfg_writecheck.ESNCheckcheck)
  188. SetspecificText(m_checkesn, LResource.Skip, Color.Yellow);
  189. if (!cfg_writecheck.CI_plusCheckcheck)
  190. SetspecificText(m_checkci, LResource.Skip, Color.Yellow);
  191. if (!cfg_writecheck.AttestationCheckcheck)
  192. SetspecificText(m_checkattestation, LResource.Skip, Color.Yellow);
  193. if (!cfg_writecheck.MGKCheckcheck)
  194. SetspecificText(m_checkMGK, LResource.Skip, Color.Yellow);
  195. if (!cfg_writecheck.FairplayCheckcheck)
  196. SetspecificText(m_checkFairplay, LResource.Skip, Color.Yellow);
  197. if (!cfg_writecheck.ECPCheckcheck)
  198. SetspecificText(m_checkECP, LResource.Skip, Color.Yellow);
  199. if (!cfg_writecheck.WifiMacCheckcheck)
  200. SetspecificText(m_checkWifiMac, LResource.Skip, Color.Yellow);
  201. if (!cfg_writecheck.BTMacCheckcheck)
  202. SetspecificText(m_checkBTMac, LResource.Skip, Color.Yellow);
  203. if (!cfg_writecheck.LEKCheckcheck)
  204. SetspecificText(m_checkLEK, LResource.Skip, Color.Yellow);
  205. if (!cfg_writecheck.PEKCheckcheck)
  206. SetspecificText(m_checkPEK, LResource.Skip, Color.Yellow);
  207. if (!cfg_writecheck.PlayreadyCheckcheck)
  208. SetspecificText(m_checkPlayready, LResource.Skip, Color.Yellow);
  209. if (!cfg_writecheck.HashCheckcheck)
  210. SetspecificText(m_checkHash, LResource.Skip, Color.Yellow);
  211. if (!cfg_writecheck.DSNCheckcheck)
  212. SetspecificText(m_checkDSN, LResource.Skip, Color.Yellow);
  213. if (!cfg_writecheck.YouTubeCheckcheck)
  214. SetspecificText(m_checkYouTube, LResource.Skip, Color.Yellow);
  215. if (!cfg_writecheck.ACASKeyCheckcheck)
  216. SetspecificText(m_checkACASKey, LResource.Skip, Color.Yellow);
  217. if (!cfg_writecheck.FVPCheckcheck)
  218. SetspecificText(m_checkFVP, LResource.Skip, Color.Yellow);
  219. if (!cfg_writecheck.DAKCheckcheck)
  220. SetspecificText(m_checkDAK, LResource.Skip, Color.Yellow);
  221. #endregion
  222. #region 设置ReadCheck复选框默认状态
  223. /////////////////////////////////////////////////////////////////
  224. if (!cfg_readcheck.PIDReadcheck)
  225. SetspecificText(ProjectIDNote, LResource.SkipReadCheck, Color.Yellow);
  226. if (!cfg_readcheck.DIDReadcheck)
  227. SetspecificText(m_readdid, LResource.Skip, Color.Yellow);
  228. if (!cfg_readcheck.MacReadcheck)
  229. SetspecificText(m_readmac, LResource.Skip, Color.Yellow);
  230. if (!cfg_readcheck.HDCPReadcheck)
  231. SetspecificText(m_readhdcp, LResource.Skip, Color.Yellow);
  232. if (!cfg_readcheck.HDCP22Readcheck)
  233. SetspecificText(m_readhdcp22, LResource.Skip, Color.Yellow);
  234. if (!cfg_readcheck.WiDiReadcheck)
  235. SetspecificText(m_readwidi, LResource.Skip, Color.Yellow);
  236. if (!cfg_readcheck.WidevineReadcheck)
  237. SetspecificText(m_readwidevine, LResource.Skip, Color.Yellow);
  238. if (!cfg_readcheck.ESNReadcheck)
  239. SetspecificText(m_readesn, LResource.Skip, Color.Yellow);
  240. if (!cfg_readcheck.CI_plusReadcheck)
  241. SetspecificText(m_readci, LResource.Skip, Color.Yellow);
  242. if (!cfg_readcheck.AttestationReadcheck)
  243. SetspecificText(m_readattestation, LResource.Skip, Color.Yellow);
  244. if (!cfg_readcheck.MGKReadcheck)
  245. SetspecificText(m_readMGK, LResource.Skip, Color.Yellow);
  246. if (!cfg_readcheck.FairplayReadcheck)
  247. SetspecificText(m_readFairplay, LResource.Skip, Color.Yellow);
  248. if (!cfg_readcheck.ECPReadcheck)
  249. SetspecificText(m_readECP, LResource.Skip, Color.Yellow);
  250. if (!cfg_readcheck.WifiMacReadcheck)
  251. SetspecificText(m_readWifiMac, LResource.Skip, Color.Yellow);
  252. if (!cfg_readcheck.BTMacReadcheck)
  253. SetspecificText(m_readBTMac, LResource.Skip, Color.Yellow);
  254. if (!cfg_readcheck.LEKReadcheck)
  255. SetspecificText(m_readLEK, LResource.Skip, Color.Yellow);
  256. if (!cfg_readcheck.PEKReadcheck)
  257. SetspecificText(m_readPEK, LResource.Skip, Color.Yellow);
  258. if (!cfg_readcheck.PlayreadyReadcheck)
  259. SetspecificText(m_readPlayready, LResource.Skip, Color.Yellow);
  260. if (!cfg_readcheck.HashReadcheck)
  261. SetspecificText(m_readHash, LResource.Skip, Color.Yellow);
  262. if (!cfg_readcheck.DSNReadcheck)
  263. SetspecificText(m_readDSN, LResource.Skip, Color.Yellow);
  264. if (!cfg_readcheck.SHOPReadcheck)
  265. SetspecificText(SHOPNote, LResource.SkipChecking, Color.Yellow);
  266. if (!cfg_readcheck.OSDReadcheck)
  267. SetspecificText(OSDNote, LResource.SkipChecking, Color.Yellow);
  268. if (!cfg_readcheck.YouTubeReadcheck)
  269. SetspecificText(m_readYouTube, LResource.SkipChecking, Color.Yellow);
  270. if (!cfg_readcheck.EDIDPIDReadcheck)
  271. SetspecificText(m_readEDIDPID, LResource.SkipChecking, Color.Yellow);
  272. if (!cfg_readcheck.EDIDModeNameReadcheck)
  273. SetspecificText(m_readEDIDName, LResource.SkipChecking, Color.Yellow);
  274. if (!cfg_readcheck.ACASKeyReadcheck)
  275. SetspecificText(m_readACASKey, LResource.SkipChecking, Color.Yellow);
  276. if (FunctionSettingNow.ExportSNACASID)
  277. SetspecificText(m_readACASID, LResource.SkipChecking, Color.Yellow);
  278. if (!cfg_readcheck.FVPReadcheck)
  279. SetspecificText(m_readFVP, LResource.SkipChecking, Color.Yellow);
  280. if (!cfg_readcheck.DAKReadcheck)
  281. SetspecificText(m_readDAK, LResource.SkipChecking, Color.Yellow);
  282. #endregion
  283. #region 设置WriteDone复选框默认状态
  284. /////////////////////////////////////////////////////////////////
  285. if (!cfg_writedone.PIDWrite_YesNo)
  286. SetspecificText(ProjectIDNote, LResource.SkipCovering, Color.Yellow);
  287. if (!cfg_writedone.ClientTypeCheck_YesNo)
  288. SetspecificText(ClientTypeNote, LResource.SkipChecking, Color.Yellow);
  289. if (!cfg_writedone.SoftwareVersionCheck_YesNo)
  290. SetspecificText(SoftwareVersionNote, LResource.SkipChecking, Color.Yellow);
  291. if (!cfg_writedone.DIDWrite_YesNo)
  292. SetspecificText(m_writedid, LResource.Skip, Color.Yellow);
  293. if (!cfg_writedone.MacWrite_YesNo)
  294. SetspecificText(m_writemac, LResource.Skip, Color.Yellow);
  295. if (!cfg_writedone.HDCPWrite_YesNo)
  296. SetspecificText(m_writehdcp, LResource.Skip, Color.Yellow);
  297. if (!cfg_writedone.HDCP22Write_YesNo)
  298. SetspecificText(m_writehdcp22, LResource.Skip, Color.Yellow);
  299. if (!cfg_writedone.WiDiWrite_YesNo)
  300. SetspecificText(m_writewidi, LResource.Skip, Color.Yellow);
  301. if (!cfg_writedone.WidevineWrite_YesNo)
  302. SetspecificText(m_writewidevine, LResource.Skip, Color.Yellow);
  303. if (!cfg_writedone.ESNWrite_YesNo)
  304. SetspecificText(m_writeesn, LResource.Skip, Color.Yellow);
  305. if (!cfg_writedone.CI_plusWrite_YesNo)
  306. SetspecificText(m_writeci, LResource.Skip, Color.Yellow);
  307. if (!cfg_writedone.AttestationWrite_YesNo)
  308. SetspecificText(m_writeattestation, LResource.Skip, Color.Yellow);
  309. if (!cfg_writedone.MGKWrite_YesNo)
  310. SetspecificText(m_writeMGK, LResource.Skip, Color.Yellow);
  311. if (!cfg_writedone.FairplayWrite_YesNo)
  312. SetspecificText(m_writeFairplay, LResource.Skip, Color.Yellow);
  313. if (!cfg_writedone.ECPWrite_YesNo)
  314. SetspecificText(m_writeECP, LResource.Skip, Color.Yellow);
  315. if (!cfg_writedone.WifiMacWrite_YesNo)
  316. SetspecificText(m_writeWifiMac, LResource.Skip, Color.Yellow);
  317. if (!cfg_writedone.BTMacWrite_YesNo)
  318. SetspecificText(m_writeBTMac, LResource.Skip, Color.Yellow);
  319. if (!cfg_writedone.LEKWrite_YesNo)
  320. SetspecificText(m_writeLEK, LResource.Skip, Color.Yellow);
  321. if (!cfg_writedone.PEKWrite_YesNo)
  322. SetspecificText(m_writePEK, LResource.Skip, Color.Yellow);
  323. if (!cfg_writedone.PlayreadyWrite_YesNo)
  324. SetspecificText(m_writePlayready, LResource.Skip, Color.Yellow);
  325. if (!cfg_writedone.HashWrite_YesNo)
  326. SetspecificText(m_writeHash, LResource.Skip, Color.Yellow);
  327. if (!cfg_writedone.DSNWrite_YesNo)
  328. SetspecificText(m_writeDSN, LResource.Skip, Color.Yellow);
  329. if (!cfg_writedone.YouTubeWrite_YesNo)
  330. SetspecificText(m_writeYouTube, LResource.Skip, Color.Yellow);
  331. if (!cfg_writedone.EDIDPIDWrite_YesNo)
  332. SetspecificText(m_writeEDIDPID, LResource.Skip, Color.Yellow);
  333. if (!cfg_writedone.EDIDModeNameWrite_YesNo)
  334. SetspecificText(m_writeEDIDName, LResource.Skip, Color.Yellow);
  335. if (!cfg_writedone.ACASKeyWrite_YesNo)
  336. SetspecificText(m_writeACASKey, LResource.Skip, Color.Yellow);
  337. if (!cfg_writedone.FVPWrite_YesNo)
  338. SetspecificText(m_writeFVP, LResource.Skip, Color.Yellow);
  339. if (!cfg_writedone.DAKWrite_YesNo)
  340. SetspecificText(m_writeDAK, LResource.Skip, Color.Yellow);
  341. if (FunctionSettingNow.WriteChannel)
  342. ChannelText.Text = FunctionSettingNow.ChannelList;
  343. else
  344. {
  345. ChannelText.Text = LResource.Default;
  346. ChannelText.BackColor = Color.Yellow;
  347. }
  348. if (FunctionSettingNow.WriteOSD)
  349. OSDText.Text = FunctionSettingNow.OSDList;
  350. else
  351. {
  352. OSDText.Text = LResource.Default;
  353. OSDText.BackColor = Color.Yellow;
  354. }
  355. if (FunctionSettingNow.WriteSHOP)
  356. SHOPText.Text = FunctionSettingNow.SHOPList;
  357. else
  358. {
  359. SHOPText.Text = LResource.Default;
  360. SHOPText.BackColor = Color.Yellow;
  361. }
  362. #endregion
  363. if (midListNow.host != "LocalPC")
  364. {
  365. if ((!FunctionSettingNow.WriteWB) && (!cfg_writedone.AutoWhiteBalance))
  366. {
  367. WBPathText.Text = LResource.SkipAutoWB;
  368. WBPathText.BackColor = Color.Yellow;
  369. }
  370. else
  371. {
  372. // 如果是抄写EDID,则不获取白平衡数据;
  373. if (CommonMethod.IsEDIDCopy(midListNow))
  374. midListNow.whiteType = "-1";
  375. Log.WriteInfoLog("whiteType=" + midListNow.whiteType);
  376. switch (midListNow.whiteType)//订单白平衡预置状态
  377. {
  378. case "0"://旧订单,默认值
  379. {
  380. if (CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, orderNow, TestMode.MAC, errorDBNow, out WhiteBalanceListNow))
  381. {
  382. if (WhiteBalanceListNow.whiteBalanceInfo != null)
  383. {
  384. if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "0")
  385. {
  386. if (FunctionSettingNow.WriteWB)
  387. {
  388. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  389. DialogResult dr = MessageBox.Show(LResource.HaveWBfromServer, LResource.Error, messButton);
  390. if (dr == DialogResult.Yes)
  391. {
  392. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  393. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  394. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  395. WBPathText.Text = LResource.LoadFromServer;
  396. }
  397. else
  398. {
  399. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  400. }
  401. }
  402. else
  403. {
  404. MessageBox.Show(LResource.FindWBfromServer, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  405. FunctionSettingNow.WriteWB = true;
  406. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  407. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  408. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  409. WBPathText.Text = LResource.LoadFromServer;
  410. }
  411. }
  412. else if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "1")
  413. {
  414. WBPathText.Text = LResource.WBExemptOrder;
  415. WBPathText.BackColor = Color.Yellow;
  416. }
  417. }
  418. else
  419. {
  420. if (FunctionSettingNow.WriteWB)
  421. {
  422. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  423. DialogResult dr = MessageBox.Show(LResource.HaveNoWBfromServer, LResource.Error, messButton);
  424. if (dr == DialogResult.OK)
  425. {
  426. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  427. }
  428. }
  429. else
  430. {
  431. WBPathText.Text = LResource.WBNull;
  432. WBPathText.BackColor = Color.Yellow;
  433. FunctionSettingNow.WriteWB = false;
  434. }
  435. }
  436. }
  437. else
  438. {
  439. MessageBox.Show(LResource.GetWBInfoFail);
  440. if (FunctionSettingNow.WriteWB)
  441. {
  442. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  443. }
  444. else
  445. {
  446. WBPathText.Text = LResource.WBNull;
  447. WBPathText.BackColor = Color.Yellow;
  448. }
  449. }
  450. break;
  451. }
  452. case "1"://未预置或预置LR数据
  453. {
  454. if (CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, orderNow, TestMode.MAC, errorDBNow, out WhiteBalanceListNow))
  455. {
  456. if (WhiteBalanceListNow.whiteBalanceInfo != null)
  457. {
  458. if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "0")//0是正常白平衡绑定订单,1是白平衡豁免订单
  459. {
  460. if (FunctionSettingNow.WriteWB)
  461. {
  462. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  463. DialogResult dr = MessageBox.Show(LResource.HaveWBfromServer, LResource.Error, messButton);
  464. if (dr == DialogResult.Yes)
  465. {
  466. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  467. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  468. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  469. WBPathText.Text = LResource.LoadFromServer;
  470. }
  471. else
  472. {
  473. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  474. }
  475. }
  476. else
  477. {
  478. MessageBox.Show(LResource.FindWBfromServer, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  479. FunctionSettingNow.WriteWB = true;
  480. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  481. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  482. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  483. WBPathText.Text = LResource.LoadFromServer;
  484. }
  485. }
  486. else if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "1")
  487. {
  488. WBPathText.Text = LResource.WBExemptOrder;
  489. WBPathText.BackColor = Color.Yellow;
  490. }
  491. }
  492. else
  493. {
  494. if (FunctionSettingNow.WriteWB)
  495. {
  496. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  497. DialogResult dr = MessageBox.Show(LResource.HaveNoWBfromServer, LResource.Error, messButton);
  498. if (dr == DialogResult.OK)
  499. {
  500. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  501. }
  502. }
  503. else
  504. {
  505. WBPathText.Text = LResource.WBNull;
  506. WBPathText.BackColor = Color.Yellow;
  507. FunctionSettingNow.WriteWB = false;
  508. }
  509. }
  510. }
  511. else
  512. {
  513. if (FunctionSettingNow.WriteWB)
  514. {
  515. MessageBox.Show(LResource.GetWBInfoFail);
  516. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  517. }
  518. else
  519. {
  520. MessageBox.Show(LResource.GetWBInfoFail2);
  521. this.Close();
  522. return;
  523. }
  524. }
  525. break;
  526. }
  527. case "2"://已预置PR数据
  528. {
  529. if (CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, orderNow, TestMode.MAC, errorDBNow, out WhiteBalanceListNow))
  530. {
  531. if (WhiteBalanceListNow.whiteBalanceInfo != null)
  532. {
  533. if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "0")
  534. {
  535. if (FunctionSettingNow.WriteWB)
  536. {
  537. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  538. DialogResult dr = MessageBox.Show(LResource.HaveWBfromServer, LResource.Error, messButton);
  539. if (dr == DialogResult.Yes)
  540. {
  541. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  542. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  543. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  544. WBPathText.Text = LResource.LoadFromServer;
  545. }
  546. else
  547. {
  548. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  549. }
  550. }
  551. else
  552. {
  553. MessageBox.Show(LResource.FindWBfromServer, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  554. FunctionSettingNow.WriteWB = true;
  555. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  556. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  557. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  558. WBPathText.Text = LResource.LoadFromServer;
  559. }
  560. }
  561. else if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "1")
  562. {
  563. WBPathText.Text = LResource.WBExemptOrder;
  564. WBPathText.BackColor = Color.Yellow;
  565. }
  566. }
  567. else
  568. {
  569. if (FunctionSettingNow.WriteWB)
  570. {
  571. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  572. DialogResult dr = MessageBox.Show(LResource.HaveNoWBfromServer, LResource.Error, messButton);
  573. if (dr == DialogResult.OK)
  574. {
  575. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  576. }
  577. }
  578. else
  579. {
  580. WBPathText.Text = LResource.WBNull;
  581. WBPathText.BackColor = Color.Yellow;
  582. FunctionSettingNow.WriteWB = false;
  583. }
  584. }
  585. }
  586. else
  587. {
  588. MessageBox.Show(LResource.GetWBInfoFail);
  589. if (FunctionSettingNow.WriteWB)
  590. {
  591. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  592. }
  593. else
  594. {
  595. WBPathText.Text = LResource.WBNull;
  596. WBPathText.BackColor = Color.Yellow;
  597. }
  598. }
  599. break;
  600. }
  601. case "3"://已预置客户指定数据
  602. {
  603. if (FunctionSettingNow.WriteWB)
  604. {
  605. MessageBox.Show(LResource.PreloadCustomerWB);
  606. this.Close();
  607. return;
  608. }
  609. break;
  610. }
  611. }
  612. }
  613. }
  614. else
  615. {
  616. if (FunctionSettingNow.WriteWB)
  617. {
  618. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  619. }
  620. else
  621. {
  622. WBPathText.Text = LResource.WBNull;
  623. WBPathText.BackColor = Color.Yellow;
  624. }
  625. }
  626. try
  627. {
  628. TVPort.PortName = FunctionSettingNow.TVCOM;
  629. TVPort.BaudRate = Convert.ToInt32(FunctionSettingNow.TVBaud);
  630. TVPort.WriteBufferSize = 20480;
  631. TVPort.ReadBufferSize = 20480;
  632. TVPort.Open();
  633. }
  634. catch (Exception ex)
  635. {
  636. MessageBox.Show(ex.Message);
  637. this.Close();
  638. }
  639. this.Text = FunctionSettingNow.TVCOM;
  640. }
  641. private void OperationPanel_Load(object sender, EventArgs e)
  642. {
  643. if (midListNow.host == "LocalPC")
  644. {
  645. OrderText.Text = orderNow;
  646. ClientTypeText.Text = midListNow.clienttype;
  647. SVText.Text = midListNow.version;
  648. ProjectIDText.Text = midListNow.projectid;
  649. GetLocalKeysCount();
  650. }
  651. else if (!preloadNow)
  652. {
  653. OrderText.Text = orderNow;
  654. ClientTypeText.Text = midListNow.clienttype;
  655. SVText.Text = midListNow.version;
  656. ProjectIDText.Text = midListNow.projectid;
  657. UpdateKeys(midListNow.keytype, false);
  658. }
  659. else
  660. {
  661. OrderText.Text = MidAddressNow.order;
  662. ClientTypeText.Text = MidAddressNow.ctype;
  663. SVText.Text = MidAddressNow.version;
  664. ProjectIDText.Text = MidAddressNow.pid;
  665. }
  666. SNText.Text = "";
  667. SNTextFocus = new Thread(TextBoxFocus);
  668. SNTextFocus.Start();
  669. SNText.Focus();
  670. }
  671. /// <summary>
  672. /// 强制聚焦扫描框
  673. /// </summary>
  674. public void TextBoxFocus()
  675. {
  676. while (true)
  677. {
  678. if (FocusMark)
  679. {
  680. if (this.CaptionBackColorTop != Color.Yellow || this.CaptionBackColorBottom != Color.Orange)
  681. {
  682. if (this.InvokeRequired)
  683. {
  684. this.BeginInvoke(new Action(() =>
  685. {
  686. this.CaptionBackColorTop = Color.Yellow;
  687. this.CaptionBackColorBottom = Color.Orange;
  688. this.Refresh();
  689. }));
  690. }
  691. }
  692. if (SNText.InvokeRequired)
  693. {
  694. SNText.BeginInvoke(new Action(() =>
  695. {
  696. if (!SNText.Focus())
  697. {
  698. SNText.Focus();
  699. }
  700. }));
  701. }
  702. }
  703. Thread.Sleep(500);
  704. }
  705. }
  706. private void OperationPanel_FormClosing(object sender, FormClosingEventArgs e)
  707. {
  708. if (TVPort.IsOpen)
  709. TVPort.Close();
  710. DeleteIntptr(this.Handle);
  711. GC.Collect();
  712. }
  713. /// <summary>
  714. /// 扫描触发抄写,以回车终结触发
  715. /// </summary>
  716. /// <param name="sender"></param>
  717. /// <param name="e"></param>
  718. private void SNText_KeyDown(object sender, KeyEventArgs e)
  719. {
  720. if (e.KeyCode == Keys.Enter)
  721. {
  722. keyInfo = new KeyInfo();
  723. FocusMark = false;
  724. SNKeyDownEven(this.Handle);
  725. SetInitialStatus();
  726. SN = SNText.Text;
  727. SNText.Enabled = false;
  728. if (FunctionSettingNow.BarcodeLimit)
  729. {
  730. if (SN.Length != FunctionSettingNow.BarcodeLength || !SN.StartsWith(FunctionSettingNow.BarcodeKeyword))
  731. {
  732. MessageBox.Show(LResource.WrongBarcode + "\r\n" + SN);
  733. SNText.Enabled = true;
  734. SNText.Text = "";
  735. return;
  736. }
  737. if (!FunctionSettingNow.BarcodeWrite && (midListNow.keytype != null && midListNow.keytype.ContainsKey("DSN")))
  738. {
  739. // 如果不是全大写字母+数字,返回;
  740. Regex r = new Regex(@"^[A-Z0-9]+$");
  741. if (!r.Match(SN).Success)
  742. {
  743. MessageBox.Show(LResource.WrongBarcode + "\r\n" + SN);
  744. SNText.Enabled = true;
  745. SNText.Text = "";
  746. return;
  747. }
  748. }
  749. }
  750. #region 只有惠州工厂才启用G客户防呆措施;
  751. if (FunctionSettingNow.NTF)
  752. {
  753. StringBuilder strValue = new StringBuilder(256);
  754. // 获取上一次的SN号;
  755. CommonMethod.GetProfileString("MOKAFactoryTools", "LastGSN", "", strValue, 256);
  756. if (strValue.ToString().Equals(SN, StringComparison.OrdinalIgnoreCase))
  757. {
  758. // 连续测试中累计失败的次数;
  759. int lastCount = 0;
  760. CommonMethod.GetProfileString("MOKAFactoryTools", "GFailCount", "0", strValue, 256);
  761. int.TryParse(strValue.ToString(), out lastCount);
  762. // NTF规则:连续测试中累计出现2次Fail,禁止测试.
  763. if (lastCount >= FunctionSettingNow.GFoolProofingCount)
  764. {
  765. Verify dlg = new Verify("累计出现2次Fail,禁止测试!" + "\r\n" + SN);
  766. dlg.ShowDialog();
  767. SNText.Enabled = true;
  768. SNText.Text = "";
  769. return;
  770. }
  771. }
  772. // 根据SN获取订单类型;
  773. string strOrderType;
  774. string strErrorMsg;
  775. if (!CommonMethod.GetOrderTypeFromSN(SN, out strOrderType, out strErrorMsg))
  776. {
  777. Verify dlg = new Verify("根据SN获取订单类型失败,停止测试!" + "\r\nSN:" + SN);
  778. dlg.ShowDialog();
  779. Log.WriteErrorLog(string.Format("SN={0},错误={1}", SN, strErrorMsg));
  780. SNText.Enabled = true;
  781. SNText.Text = "";
  782. return;
  783. }
  784. if (strOrderType.Equals("量产"))
  785. nOrderType = 1;
  786. else if (strOrderType.Equals("试产"))
  787. nOrderType = 0;
  788. else
  789. {
  790. Verify dlg = new Verify("根据SN获取订单类型异常,停止测试!" + "\r\n" + SN);
  791. dlg.ShowDialog();
  792. Log.WriteErrorLog(String.Format("{0}获取订单类型异常={1}", SN, strOrderType));
  793. SNText.Enabled = true;
  794. SNText.Text = "";
  795. return;
  796. }
  797. }
  798. #endregion
  799. if (preloadNow)
  800. {
  801. bool copydone = false;
  802. string keyjson = SQLiteHelper.Getkeys(localDBNow, SNText.Text.Trim(), out copydone);
  803. if (FunctionSettingNow.NoDoublewrite && copydone)
  804. {
  805. MessageBox.Show(LResource.FindcopiedSN + SN);
  806. SNText.Enabled = true;
  807. SNText.Focus();
  808. }
  809. else if (keyjson.Length > 0)
  810. {
  811. JObject jObject = JObject.Parse(keyjson);
  812. keyInfo.DID.data = jObject["did"].Value<string>();
  813. keyInfo.Mac.data = jObject["mac"].Value<string>();
  814. keyInfo.HDCP.data = jObject["hdcp"].Value<string>();
  815. keyInfo.HDCP22.data = jObject["hdcp22"].Value<string>();
  816. keyInfo.WiDi.data = jObject["widi"].Value<string>();
  817. keyInfo.Widevine.data = jObject["widevine"].Value<string>();
  818. keyInfo.ESN.data = jObject["esn"].Value<string>();
  819. keyInfo.CI_plus.data = jObject["cikey"].Value<string>();
  820. keyInfo.MGK.data = jObject["mgk"].Value<string>();
  821. keyInfo.Attestation.data = jObject["attestation"].Value<string>();
  822. keyInfo.Fairplay.data = jObject["fairplay"].Value<string>();
  823. keyInfo.ECP.data = jObject["ecp"].Value<string>();
  824. keyInfo.WiFi_MAC.data = jObject["wifimac"].Value<string>();
  825. keyInfo.BT_MAC.data = jObject["btmac"].Value<string>();
  826. keyInfo.LEK.data = jObject["lek"].Value<string>();
  827. keyInfo.PEK.data = jObject["pek"].Value<string>();
  828. keyInfo.Playready.data = jObject["playready"].Value<string>();
  829. keyInfo.Hashkey.data = jObject["hash"].Value<string>();
  830. keyInfo.YouTube_KEY.data = jObject["youtubekey"].Value<string>();
  831. keyInfo.ACASKey_Data.data = jObject["acaskey_data"].Value<string>();
  832. //keyInfo.ACASKey_Tool.data = jObject["acaskey_tool"].Value<string>();
  833. keyInfo.DAK.data = jObject["dak"].Value<string>();
  834. WriteDID.Checked = (keyInfo.DID.Length > 0 && m_writedid.Text != LResource.Skip);
  835. if (WriteDID.Checked)
  836. Log.WriteGetKeyLog("\r\nLocal DB DeviceID=" + keyInfo.DID.data);
  837. WriteMac.Checked = (keyInfo.Mac.Length > 0 && m_writemac.Text != LResource.Skip);
  838. if (WriteMac.Checked)
  839. Log.WriteGetKeyLog("\r\nLocal DB Mac=" + keyInfo.Mac.data);
  840. WriteHDCP.Checked = (keyInfo.HDCP.Length > 0 && m_writehdcp.Text != LResource.Skip);
  841. if (WriteHDCP.Checked)
  842. Log.WriteGetKeyLog("\r\nLocal DB HDCP=" + keyInfo.HDCP.data);
  843. WriteHDCP22.Checked = (keyInfo.HDCP22.Length > 0 && m_writehdcp22.Text != LResource.Skip);
  844. if (WriteHDCP22.Checked)
  845. Log.WriteGetKeyLog("\r\nLocal DB HDCP22=" + keyInfo.HDCP22.data);
  846. WriteWiDi.Checked = (keyInfo.WiDi.Length > 0 && m_writewidi.Text != LResource.Skip);
  847. if (WriteWiDi.Checked)
  848. Log.WriteGetKeyLog("\r\nLocal DB WiDi=" + keyInfo.WiDi.data);
  849. WriteWidevine.Checked = (keyInfo.Widevine.Length > 0 && m_writewidevine.Text != LResource.Skip);
  850. if (WriteWidevine.Checked)
  851. Log.WriteGetKeyLog("\r\nLocal DB Widevine=" + keyInfo.Widevine.data);
  852. WriteESN.Checked = (keyInfo.ESN.Length > 0 && m_writeesn.Text != LResource.Skip);
  853. if (WriteESN.Checked)
  854. Log.WriteGetKeyLog("\r\nLocal DB ESN=" + keyInfo.ESN.data);
  855. WriteCiplus.Checked = (keyInfo.CI_plus.Length > 0 && m_writeci.Text != LResource.Skip);
  856. if (WriteCiplus.Checked)
  857. Log.WriteGetKeyLog("\r\nLocal DB Ci=" + keyInfo.CI_plus.data);
  858. WriteMGK.Checked = (keyInfo.MGK.Length > 0 && m_writeMGK.Text != LResource.Skip);
  859. if (WriteMGK.Checked)
  860. Log.WriteGetKeyLog("\r\nLocal DB MGK=" + keyInfo.MGK.data);
  861. WriteAttestation.Checked = (keyInfo.Attestation.Length > 0 && m_writeattestation.Text != LResource.Skip);
  862. if (WriteAttestation.Checked)
  863. Log.WriteGetKeyLog("\r\nLocal DB Attestation=" + keyInfo.Attestation.data);
  864. WriteFairplay.Checked = (keyInfo.Fairplay.Length > 0 && m_writeFairplay.Text != LResource.Skip);
  865. if (WriteFairplay.Checked)
  866. Log.WriteGetKeyLog("\r\nLocal DB Fairplay=" + keyInfo.Fairplay.data);
  867. WriteECP.Checked = (keyInfo.ECP.Length > 0 && m_writeECP.Text != LResource.Skip);
  868. if (WriteECP.Checked)
  869. Log.WriteGetKeyLog("\r\nLocal DB ECP=" + keyInfo.ECP.data);
  870. WriteWifiMac.Checked = (keyInfo.WiFi_MAC.Length > 0 && m_writeWifiMac.Text != LResource.Skip);
  871. if (WriteWifiMac.Checked)
  872. Log.WriteGetKeyLog("\r\nLocal DB WifiMac=" + keyInfo.WiFi_MAC.data);
  873. WriteBTMac.Checked = (keyInfo.BT_MAC.Length > 0 && m_writeBTMac.Text != LResource.Skip);
  874. if (WriteBTMac.Checked)
  875. Log.WriteGetKeyLog("\r\nLocal DB BTMac=" + keyInfo.BT_MAC.data);
  876. WriteLEK.Checked = (keyInfo.LEK.Length > 0 && m_writeLEK.Text != LResource.Skip);
  877. if (WriteLEK.Checked)
  878. Log.WriteGetKeyLog("\r\nLocal DB LEK=" + keyInfo.LEK.data);
  879. WritePEK.Checked = (keyInfo.PEK.Length > 0 && m_writePEK.Text != LResource.Skip);
  880. if (WritePEK.Checked)
  881. Log.WriteGetKeyLog("\r\nLocal DB PEK=" + keyInfo.PEK.data);
  882. WritePlayready.Checked = (keyInfo.Playready.Length > 0 && m_writePlayready.Text != LResource.Skip);
  883. if (WritePlayready.Checked)
  884. Log.WriteGetKeyLog("\r\nLocal DB Playready=" + keyInfo.Playready.data);
  885. WriteHash.Checked = (keyInfo.Hashkey.Length > 0 && m_writeHash.Text != LResource.Skip);
  886. if (WriteHash.Checked)
  887. Log.WriteGetKeyLog("\r\nLocal DB Hashkey=" + keyInfo.Hashkey.data);
  888. WriteYouTube.Checked = (keyInfo.YouTube_KEY.Length > 0 && m_writeYouTube.Text != LResource.Skip);
  889. if (WriteYouTube.Checked)
  890. Log.WriteGetKeyLog("\r\nLocal DB YouTube_KEY=" + keyInfo.YouTube_KEY.data);
  891. WriteACASKey.Checked = (keyInfo.ACASKey_Data.Length > 0 && m_writeACASKey.Text != LResource.Skip);
  892. if (WriteACASKey.Checked)
  893. Log.WriteGetKeyLog("\r\nLocal DB ACAS_KEY=" + keyInfo.ACASKey_Data.data);
  894. WriteDAK.Checked = (keyInfo.DAK.Length > 0 && m_writeDAK.Text != LResource.Skip);
  895. if (WriteDAK.Checked)
  896. Log.WriteGetKeyLog("\r\nLocal DB DAK=" + keyInfo.DAK.data);
  897. WriteDSN.Checked = midListNow.keytype == null ? false : midListNow.keytype.ContainsKey("DSN") && m_writeDSN.Text != LResource.Skip;
  898. WritePSN.Checked = FunctionSettingNow.BarcodeWrite;
  899. timer1.Start();
  900. Thread t = new Thread(Writekey);
  901. t.Start();
  902. }
  903. else
  904. {
  905. MessageBox.Show(LResource.FindNullSnInDB + SN);
  906. SNText.Enabled = true;
  907. SNText.Focus();
  908. }
  909. }
  910. else
  911. {
  912. Onlinemode();
  913. }
  914. // 抄写成功后才清空;
  915. //SNText.Text = "";
  916. }
  917. }
  918. /// <summary>
  919. /// 设置成功状态显示
  920. /// </summary>
  921. /// <param name="label"></param>
  922. public void SetsuccessStatus(Label label)
  923. {
  924. if (label.InvokeRequired && label.Text != LResource.Skip)
  925. {
  926. //BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), 参数);
  927. label.BeginInvoke(new Action(() => { label.Text = "OK"; label.BackColor = Color.FromArgb(128, 255, 128); }));
  928. }
  929. }
  930. /// <summary>
  931. /// 设置失败状态显示
  932. /// </summary>
  933. /// <param name="label"></param>
  934. public void SetfailStatus(Label label)
  935. {
  936. if (label.InvokeRequired)
  937. {
  938. label.BeginInvoke(new Action(() => { label.Text = "NG"; label.BackColor = Color.Red; }));
  939. }
  940. }
  941. /// <summary>
  942. /// 设置扫描框为输入状态
  943. /// </summary>
  944. /// <param name="textBox"></param>
  945. public void EnableText(TextBox textBox)
  946. {
  947. if (textBox.InvokeRequired)
  948. {
  949. textBox.BeginInvoke(new Action(() => { textBox.Enabled = true; textBox.Text = ""; textBox.Focus(); }));
  950. }
  951. else
  952. {
  953. textBox.Enabled = true;
  954. textBox.Focus();
  955. textBox.Text = "";
  956. }
  957. }
  958. /// <summary>
  959. /// 设置按钮为可点击状态
  960. /// </summary>
  961. /// <param name="button"></param>
  962. public void EnableButton(Button button)
  963. {
  964. if (button.InvokeRequired)
  965. {
  966. button.BeginInvoke(new Action(() => { button.Enabled = true; }));
  967. }
  968. else
  969. button.Enabled = true;
  970. }
  971. /// <summary>
  972. /// 设置特殊的文本和颜色
  973. /// </summary>
  974. /// <param name="label">标签控件</param>
  975. /// <param name="str">需要显示的文本</param>
  976. /// <param name="color">需要设置的控件背景颜色</param>
  977. public void SetspecificText(Label label, string str, Color color)
  978. {
  979. if (label.InvokeRequired)
  980. {
  981. BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), str);
  982. label.BeginInvoke(new Action(() => { label.BackColor = color; }));
  983. }
  984. else
  985. {
  986. label.Text = str;
  987. label.BackColor = color;
  988. }
  989. }
  990. /// <summary>
  991. /// 设置标签控件颜色
  992. /// </summary>
  993. /// <param name="label">标签控件对象</param>
  994. /// <param name="color">需要设置的标签背景颜色</param>
  995. public void SetcolorStatus(Label label, Color color)
  996. {
  997. if (label.InvokeRequired)
  998. {
  999. label.BeginInvoke(new Action(() => { label.BackColor = color; }));
  1000. }
  1001. }
  1002. /// <summary>
  1003. /// 跨线程关闭窗口
  1004. /// </summary>
  1005. /// <param name="label"></param>
  1006. /// <param name="color"></param>
  1007. public void Closeform()
  1008. {
  1009. if (this.InvokeRequired)
  1010. {
  1011. this.BeginInvoke(new Action(() => { this.Close(); }));
  1012. }
  1013. }
  1014. /// <summary>
  1015. /// 设置标签控件文本
  1016. /// </summary>
  1017. /// <param name="label">标签控件对象</param>
  1018. /// <param name="color">需要设置的标签文本</param>
  1019. public void SetTextStatus(Label label, string txt)
  1020. {
  1021. if (label.InvokeRequired)
  1022. {
  1023. label.BeginInvoke(new Action(() => { label.Text = txt; }));
  1024. }
  1025. else
  1026. label.Text = txt;
  1027. }
  1028. /// <summary>
  1029. /// 线程内&跨线程设置key数量显示控件
  1030. /// </summary>
  1031. /// <param name="label">数量提示控件</param>
  1032. /// <param name="str">数量值</param>
  1033. /// <param name="status">状态,0为正常,1为获取失败,2为数量不足</param>
  1034. public void SetKeyCountStatus(Label label, string str, int status)
  1035. {
  1036. if (label.InvokeRequired)
  1037. {
  1038. BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), str);
  1039. switch (status)
  1040. {
  1041. case 0:
  1042. label.BeginInvoke(new Action(() => { label.ForeColor = Color.Green; }));
  1043. break;
  1044. case 1:
  1045. label.BeginInvoke(new Action(() => { label.BackColor = Color.Red; }));
  1046. break;
  1047. case 2:
  1048. label.BeginInvoke(new Action(() => { label.ForeColor = Color.Red; }));
  1049. break;
  1050. }
  1051. }
  1052. else
  1053. {
  1054. label.Text = str;
  1055. switch (status)
  1056. {
  1057. case 0:
  1058. label.ForeColor = Color.Green; ;
  1059. break;
  1060. case 1:
  1061. label.BackColor = Color.Red;
  1062. break;
  1063. case 2:
  1064. label.ForeColor = Color.Red;
  1065. break;
  1066. }
  1067. }
  1068. }
  1069. /// <summary>
  1070. /// 线程内&跨线程设置checkbox控件的checked值
  1071. /// </summary>
  1072. /// <param name="checkBox">checkbox控件</param>
  1073. /// <param name="status">需要设置的布尔状态</param>
  1074. public void SetCheckboxStatus(CheckBox checkBox, bool status)
  1075. {
  1076. if (checkBox.InvokeRequired)
  1077. {
  1078. BeginInvoke(new Action<bool>(x => { checkBox.Checked = x; }), status);
  1079. }
  1080. else
  1081. {
  1082. checkBox.Checked = status;
  1083. }
  1084. }
  1085. /// <summary>
  1086. /// 重置控件状态,skip除外
  1087. /// </summary>
  1088. public void SetInitialStatus()
  1089. {
  1090. this.CaptionBackColorTop = Color.RoyalBlue;
  1091. this.CaptionBackColorBottom = Color.Cyan;
  1092. this.Refresh();
  1093. /////////////////////////////////////////////////////////////
  1094. #region Set Write;
  1095. if (m_writeci.Text != LResource.Skip)
  1096. {
  1097. m_writeci.Text = "Null";
  1098. m_writeci.BackColor = Color.Transparent;
  1099. }
  1100. if (m_writemac.Text != LResource.Skip)
  1101. {
  1102. m_writemac.Text = "Null";
  1103. m_writemac.BackColor = Color.Transparent;
  1104. }
  1105. if (m_writedid.Text != LResource.Skip)
  1106. {
  1107. m_writedid.Text = "Null";
  1108. m_writedid.BackColor = Color.Transparent;
  1109. }
  1110. if (m_writeesn.Text != LResource.Skip)
  1111. {
  1112. m_writeesn.Text = "Null";
  1113. m_writeesn.BackColor = Color.Transparent;
  1114. }
  1115. if (m_writewidi.Text != LResource.Skip)
  1116. {
  1117. m_writewidi.Text = "Null";
  1118. m_writewidi.BackColor = Color.Transparent;
  1119. }
  1120. if (m_writewidevine.Text != LResource.Skip)
  1121. {
  1122. m_writewidevine.Text = "Null";
  1123. m_writewidevine.BackColor = Color.Transparent;
  1124. }
  1125. if (m_writehdcp.Text != LResource.Skip)
  1126. {
  1127. m_writehdcp.Text = "Null";
  1128. m_writehdcp.BackColor = Color.Transparent;
  1129. }
  1130. if (m_writehdcp22.Text != LResource.Skip)
  1131. {
  1132. m_writehdcp22.Text = "Null";
  1133. m_writehdcp22.BackColor = Color.Transparent;
  1134. }
  1135. if (m_writeattestation.Text != LResource.Skip)
  1136. {
  1137. m_writeattestation.Text = "Null";
  1138. m_writeattestation.BackColor = Color.Transparent;
  1139. }
  1140. if (m_writeMGK.Text != LResource.Skip)
  1141. {
  1142. m_writeMGK.Text = "Null";
  1143. m_writeMGK.BackColor = Color.Transparent;
  1144. }
  1145. if (m_writeFairplay.Text != LResource.Skip)
  1146. {
  1147. m_writeFairplay.Text = "Null";
  1148. m_writeFairplay.BackColor = Color.Transparent;
  1149. }
  1150. if (m_writeECP.Text != LResource.Skip)
  1151. {
  1152. m_writeECP.Text = "Null";
  1153. m_writeECP.BackColor = Color.Transparent;
  1154. }
  1155. if (m_writeLEK.Text != LResource.Skip)
  1156. {
  1157. m_writeLEK.Text = "Null";
  1158. m_writeLEK.BackColor = Color.Transparent;
  1159. }
  1160. if (m_writePEK.Text != LResource.Skip)
  1161. {
  1162. m_writePEK.Text = "Null";
  1163. m_writePEK.BackColor = Color.Transparent;
  1164. }
  1165. if (m_writeHash.Text != LResource.Skip)
  1166. {
  1167. m_writeHash.Text = "Null";
  1168. m_writeHash.BackColor = Color.Transparent;
  1169. }
  1170. if (m_writeDSN.Text != LResource.Skip)
  1171. {
  1172. m_writeDSN.Text = "Null";
  1173. m_writeDSN.BackColor = Color.Transparent;
  1174. }
  1175. if (m_writeWifiMac.Text != LResource.Skip)
  1176. {
  1177. m_writeWifiMac.Text = "Null";
  1178. m_writeWifiMac.BackColor = Color.Transparent;
  1179. }
  1180. if (m_writeBTMac.Text != LResource.Skip)
  1181. {
  1182. m_writeBTMac.Text = "Null";
  1183. m_writeBTMac.BackColor = Color.Transparent;
  1184. }
  1185. if (m_writeDSN.Text != LResource.Skip)
  1186. {
  1187. m_writeDSN.Text = "Null";
  1188. m_writeDSN.BackColor = Color.Transparent;
  1189. }
  1190. if (m_writePlayready.Text != LResource.Skip)
  1191. {
  1192. m_writePlayready.Text = "Null";
  1193. m_writePlayready.BackColor = Color.Transparent;
  1194. }
  1195. if (m_writeYouTube.Text != LResource.Skip)
  1196. {
  1197. m_writeYouTube.Text = "Null";
  1198. m_writeYouTube.BackColor = Color.Transparent;
  1199. }
  1200. if (m_writePSN.Text != LResource.Skip)
  1201. {
  1202. m_writePSN.Text = "Null";
  1203. m_writePSN.BackColor = Color.Transparent;
  1204. }
  1205. if (m_writeACASKey.Text != LResource.Skip)
  1206. {
  1207. m_writeACASKey.Text = "Null";
  1208. m_writeACASKey.BackColor = Color.Transparent;
  1209. }
  1210. if (m_writeEDIDPID.Text != LResource.Skip)
  1211. {
  1212. m_writeEDIDPID.Text = "Null";
  1213. m_writeEDIDPID.BackColor = Color.Transparent;
  1214. }
  1215. if (m_writeEDIDName.Text != LResource.Skip)
  1216. {
  1217. m_writeEDIDName.Text = "Null";
  1218. m_writeEDIDName.BackColor = Color.Transparent;
  1219. }
  1220. #endregion
  1221. /////////////////////////////////////////////////////////////
  1222. #region Write Check;
  1223. if (m_checkci.Text != LResource.Skip)
  1224. {
  1225. m_checkci.Text = "Null";
  1226. m_checkci.BackColor = Color.Transparent;
  1227. }
  1228. if (m_checkmac.Text != LResource.Skip)
  1229. {
  1230. m_checkmac.Text = "Null";
  1231. m_checkmac.BackColor = Color.Transparent;
  1232. }
  1233. if (m_checkdid.Text != LResource.Skip)
  1234. {
  1235. m_checkdid.Text = "Null";
  1236. m_checkdid.BackColor = Color.Transparent;
  1237. }
  1238. if (m_checkesn.Text != LResource.Skip)
  1239. {
  1240. m_checkesn.Text = "Null";
  1241. m_checkesn.BackColor = Color.Transparent;
  1242. }
  1243. if (m_checkwidi.Text != LResource.Skip)
  1244. {
  1245. m_checkwidi.Text = "Null";
  1246. m_checkwidi.BackColor = Color.Transparent;
  1247. }
  1248. if (m_checkwidevine.Text != LResource.Skip)
  1249. {
  1250. m_checkwidevine.Text = "Null";
  1251. m_checkwidevine.BackColor = Color.Transparent;
  1252. }
  1253. if (m_checkhdcp.Text != LResource.Skip)
  1254. {
  1255. m_checkhdcp.Text = "Null";
  1256. m_checkhdcp.BackColor = Color.Transparent;
  1257. }
  1258. if (m_checkhdcp22.Text != LResource.Skip)
  1259. {
  1260. m_checkhdcp22.Text = "Null";
  1261. m_checkhdcp22.BackColor = Color.Transparent;
  1262. }
  1263. if (m_checkattestation.Text != LResource.Skip)
  1264. {
  1265. m_checkattestation.Text = "Null";
  1266. m_checkattestation.BackColor = Color.Transparent;
  1267. }
  1268. if (m_checkMGK.Text != LResource.Skip)
  1269. {
  1270. m_checkMGK.Text = "Null";
  1271. m_checkMGK.BackColor = Color.Transparent;
  1272. }
  1273. if (m_checkFairplay.Text != LResource.Skip)
  1274. {
  1275. m_checkFairplay.Text = "Null";
  1276. m_checkFairplay.BackColor = Color.Transparent;
  1277. }
  1278. if (m_checkECP.Text != LResource.Skip)
  1279. {
  1280. m_checkECP.Text = "Null";
  1281. m_checkECP.BackColor = Color.Transparent;
  1282. }
  1283. if (m_checkLEK.Text != LResource.Skip)
  1284. {
  1285. m_checkLEK.Text = "Null";
  1286. m_checkLEK.BackColor = Color.Transparent;
  1287. }
  1288. if (m_checkPEK.Text != LResource.Skip)
  1289. {
  1290. m_checkPEK.Text = "Null";
  1291. m_checkPEK.BackColor = Color.Transparent;
  1292. }
  1293. if (m_checkHash.Text != LResource.Skip)
  1294. {
  1295. m_checkHash.Text = "Null";
  1296. m_checkHash.BackColor = Color.Transparent;
  1297. }
  1298. if (m_checkDSN.Text != LResource.Skip)
  1299. {
  1300. m_checkDSN.Text = "Null";
  1301. m_checkDSN.BackColor = Color.Transparent;
  1302. }
  1303. if (m_checkWifiMac.Text != LResource.Skip)
  1304. {
  1305. m_checkWifiMac.Text = "Null";
  1306. m_checkWifiMac.BackColor = Color.Transparent;
  1307. }
  1308. if (m_checkBTMac.Text != LResource.Skip)
  1309. {
  1310. m_checkBTMac.Text = "Null";
  1311. m_checkBTMac.BackColor = Color.Transparent;
  1312. }
  1313. if (m_checkDSN.Text != LResource.Skip)
  1314. {
  1315. m_checkDSN.Text = "Null";
  1316. m_checkDSN.BackColor = Color.Transparent;
  1317. }
  1318. if (m_checkPlayready.Text != LResource.Skip)
  1319. {
  1320. m_checkPlayready.Text = "Null";
  1321. m_checkPlayready.BackColor = Color.Transparent;
  1322. }
  1323. if (m_checkYouTube.Text != LResource.Skip)
  1324. {
  1325. m_checkYouTube.Text = "Null";
  1326. m_checkYouTube.BackColor = Color.Transparent;
  1327. }
  1328. if (m_checkACASKey.Text != LResource.Skip)
  1329. {
  1330. m_checkACASKey.Text = "Null";
  1331. m_checkACASKey.BackColor = Color.Transparent;
  1332. }
  1333. #endregion
  1334. /////////////////////////////////////////////////////////////
  1335. #region Read Check;
  1336. if (m_readci.Text != LResource.Skip)
  1337. {
  1338. m_readci.Text = "Null";
  1339. m_readci.BackColor = Color.Transparent;
  1340. }
  1341. if (m_readmac.Text != LResource.Skip)
  1342. {
  1343. m_readmac.Text = "Null";
  1344. m_readmac.BackColor = Color.Transparent;
  1345. }
  1346. if (m_readdid.Text != LResource.Skip)
  1347. {
  1348. m_readdid.Text = "Null";
  1349. m_readdid.BackColor = Color.Transparent;
  1350. }
  1351. if (m_readesn.Text != LResource.Skip)
  1352. {
  1353. m_readesn.Text = "Null";
  1354. m_readesn.BackColor = Color.Transparent;
  1355. }
  1356. if (m_readwidi.Text != LResource.Skip)
  1357. {
  1358. m_readwidi.Text = "Null";
  1359. m_readwidi.BackColor = Color.Transparent;
  1360. }
  1361. if (m_readwidevine.Text != LResource.Skip)
  1362. {
  1363. m_readwidevine.Text = "Null";
  1364. m_readwidevine.BackColor = Color.Transparent;
  1365. }
  1366. if (m_readhdcp.Text != LResource.Skip)
  1367. {
  1368. m_readhdcp.Text = "Null";
  1369. m_readhdcp.BackColor = Color.Transparent;
  1370. }
  1371. if (m_readhdcp22.Text != LResource.Skip)
  1372. {
  1373. m_readhdcp22.Text = "Null";
  1374. m_readhdcp22.BackColor = Color.Transparent;
  1375. }
  1376. if (m_readattestation.Text != LResource.Skip)
  1377. {
  1378. m_readattestation.Text = "Null";
  1379. m_readattestation.BackColor = Color.Transparent;
  1380. }
  1381. if (m_readMGK.Text != LResource.Skip)
  1382. {
  1383. m_readMGK.Text = "Null";
  1384. m_readMGK.BackColor = Color.Transparent;
  1385. }
  1386. if (m_readFairplay.Text != LResource.Skip)
  1387. {
  1388. m_readFairplay.Text = "Null";
  1389. m_readFairplay.BackColor = Color.Transparent;
  1390. }
  1391. if (m_readECP.Text != LResource.Skip)
  1392. {
  1393. m_readECP.Text = "Null";
  1394. m_readECP.BackColor = Color.Transparent;
  1395. }
  1396. if (m_readLEK.Text != LResource.Skip)
  1397. {
  1398. m_readLEK.Text = "Null";
  1399. m_readLEK.BackColor = Color.Transparent;
  1400. }
  1401. if (m_readPEK.Text != LResource.Skip)
  1402. {
  1403. m_readPEK.Text = "Null";
  1404. m_readPEK.BackColor = Color.Transparent;
  1405. }
  1406. if (m_readHash.Text != LResource.Skip)
  1407. {
  1408. m_readHash.Text = "Null";
  1409. m_readHash.BackColor = Color.Transparent;
  1410. }
  1411. if (m_readDSN.Text != LResource.Skip)
  1412. {
  1413. m_readDSN.Text = "Null";
  1414. m_readDSN.BackColor = Color.Transparent;
  1415. }
  1416. if (m_readWifiMac.Text != LResource.Skip)
  1417. {
  1418. m_readWifiMac.Text = "Null";
  1419. m_readWifiMac.BackColor = Color.Transparent;
  1420. }
  1421. if (m_readBTMac.Text != LResource.Skip)
  1422. {
  1423. m_readBTMac.Text = "Null";
  1424. m_readBTMac.BackColor = Color.Transparent;
  1425. }
  1426. if (m_readDSN.Text != LResource.Skip)
  1427. {
  1428. m_readDSN.Text = "Null";
  1429. m_readDSN.BackColor = Color.Transparent;
  1430. }
  1431. if (m_readPlayready.Text != LResource.Skip)
  1432. {
  1433. m_readPlayready.Text = "Null";
  1434. m_readPlayready.BackColor = Color.Transparent;
  1435. }
  1436. if (m_readYouTube.Text != LResource.Skip)
  1437. {
  1438. m_readYouTube.Text = "Null";
  1439. m_readYouTube.BackColor = Color.Transparent;
  1440. }
  1441. if (m_readPSN.Text != LResource.Skip)
  1442. {
  1443. m_readPSN.Text = "Null";
  1444. m_readPSN.BackColor = Color.Transparent;
  1445. }
  1446. if (m_readACASID.Text != LResource.Skip)
  1447. {
  1448. m_readACASID.Text = "Null";
  1449. m_readACASID.BackColor = Color.Transparent;
  1450. }
  1451. if (m_readEDIDPID.Text != LResource.Skip)
  1452. {
  1453. m_readEDIDPID.Text = "Null";
  1454. m_readEDIDPID.BackColor = Color.Transparent;
  1455. }
  1456. if (m_readEDIDName.Text != LResource.Skip)
  1457. {
  1458. m_readEDIDName.Text = "Null";
  1459. m_readEDIDName.BackColor = Color.Transparent;
  1460. }
  1461. if (m_readACASKey.Text != LResource.Skip)
  1462. {
  1463. m_readACASKey.Text = "Null";
  1464. m_readACASKey.BackColor = Color.Transparent;
  1465. }
  1466. #endregion
  1467. ResultStatus.Text = "Wait";
  1468. ResultStatus.BackColor = Color.Transparent;
  1469. SHOPText.BackColor = Color.Transparent;
  1470. OSDText.BackColor = Color.Transparent;
  1471. WBPathText.BackColor = Color.Transparent;
  1472. ProductMsg_Text.BackColor = Color.Transparent;
  1473. }
  1474. /// <summary>
  1475. /// 生成报文;
  1476. /// </summary>
  1477. /// <returns></returns>
  1478. public string GenerateReportInfo()
  1479. {
  1480. #region 移除非IDM抄写的Key;
  1481. if (FunctionSettingNow.MITVEnable && _MiKey != null)
  1482. {
  1483. // 配置要抄写的选项;
  1484. if (_MiKey.EthernetMac != null)
  1485. SetCheckboxStatus(WriteMac, false);
  1486. if (_MiKey.BTMac != null)
  1487. SetCheckboxStatus(WriteBTMac, false);
  1488. if (_MiKey.DSN != null)
  1489. SetCheckboxStatus(WriteDSN, false);
  1490. if (_MiKey.WIFIMAC != null)
  1491. SetCheckboxStatus(WriteWifiMac, false);
  1492. }
  1493. #endregion
  1494. #region 生成IDMKey报文;
  1495. string reportdata = "";
  1496. if (SN.Trim().Length > 0)
  1497. reportdata += "sn=" + SN + "&";
  1498. if (WriteDID.Checked)
  1499. reportdata += "deviceid=" + keyInfo.DID.data + "&";
  1500. if (WriteMac.Checked)
  1501. reportdata += "mac=" + keyInfo.Mac.data + "&";
  1502. if (WriteWifiMac.Checked)
  1503. reportdata += "wifimac=" + keyInfo.WiFi_MAC.data + "&";
  1504. if (WriteBTMac.Checked)
  1505. reportdata += "btmac=" + keyInfo.BT_MAC.data + "&";
  1506. if (WriteHDCP.Checked)
  1507. reportdata += "hdcpkey=" + keyInfo.HDCP.data + "&";
  1508. if (WriteHDCP22.Checked)
  1509. reportdata += "hdcpkey2=" + keyInfo.HDCP22.data + "&";
  1510. if (WriteESN.Checked)
  1511. reportdata += "netfilxesn=" + keyInfo.ESN.data + "&";
  1512. if (WriteWiDi.Checked)
  1513. reportdata += "widi=" + keyInfo.WiDi.data + "&";
  1514. if (WritePEK.Checked)
  1515. reportdata += "pek=" + keyInfo.PEK.data + "&";
  1516. if (WriteYouTube.Checked)
  1517. reportdata += "youtubekey=" + keyInfo.YouTube_KEY.data + "&";
  1518. if (WriteWidevine.Checked)
  1519. reportdata += "widevine=" + keyInfo.Widevine.data + "&";
  1520. if (WriteCiplus.Checked)
  1521. reportdata += "cikey=" + keyInfo.CI_plus.data + "&";
  1522. if (WriteAttestation.Checked)
  1523. reportdata += "attestationmd5=" + keyInfo.Attestation.md5+ "&";
  1524. if (WriteMGK.Checked)
  1525. reportdata += "mgk=" + keyInfo.MGK.data + "&";
  1526. if (WriteFairplay.Checked)
  1527. reportdata += "fairplay=" + keyInfo.Fairplay.data + "&";
  1528. if (WriteECP.Checked)
  1529. reportdata += "ecp=" + keyInfo.ECP.data + "&";
  1530. if (WriteLEK.Checked)
  1531. reportdata += "lek=" + keyInfo.LEK.data + "&";
  1532. if (WritePlayready.Checked)
  1533. reportdata += "playready=" + keyInfo.Playready.data + "&";
  1534. if (WriteHash.Checked)
  1535. reportdata += "hash=" + keyInfo.Hashkey.data + "&";
  1536. if (WriteEDIDPID.Checked)
  1537. reportdata += "EDIDPid=" + keyInfo.EDIDPid.data + "&";
  1538. if (WriteEDIDName.Checked)
  1539. reportdata += "EDIDModeName=" + keyInfo.EDIDModelName.data + "&";
  1540. //if (WriteACASKey.Checked)
  1541. // reportdata += "acas_tool=" + keyInfo.ACASKey_Tool.data + "&";
  1542. if (WriteACASKey.Checked)
  1543. reportdata += "acas_data=" + keyInfo.ACASKey_Data.data + "&";
  1544. if (WriteDAK.Checked)
  1545. reportdata += "DAK=" + keyInfo.DAK.data + "&";
  1546. if (ProjectIDNote.Text != LResource.SkipCovering)
  1547. reportdata += "projectid=" + ProjectIDText.Text + "&";
  1548. if (FunctionSettingNow.WriteWB)
  1549. reportdata += "wbNormal=" + FunctionSettingNow.NormalRGB[0].ToString() + ":" + FunctionSettingNow.NormalRGB[1].ToString() + ":" + FunctionSettingNow.NormalRGB[2].ToString() + "&" + "wbCool=" + FunctionSettingNow.CoolRGB[0].ToString() + ":" + FunctionSettingNow.CoolRGB[1].ToString() + ":" + FunctionSettingNow.CoolRGB[2].ToString() + "&" + "wbWarm=" + FunctionSettingNow.WarmRGB[0].ToString() + ":" + FunctionSettingNow.WarmRGB[1].ToString() + ":" + FunctionSettingNow.WarmRGB[2].ToString() + "&";
  1550. reportdata += "toolVersion=" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "&";
  1551. return reportdata;
  1552. #endregion
  1553. }
  1554. public bool ReportMIInfo(out string msg)
  1555. {
  1556. msg = "";
  1557. // 上报MIKey抄写结果;
  1558. ReportMIKey reportMIKey = new ReportMIKey();
  1559. reportMIKey.EthernetMAC = _MiKey.EthernetMac;
  1560. reportMIKey.BTMAC = _MiKey.BTMac;
  1561. reportMIKey.WIFIMAC = _MiKey.WIFIMAC;
  1562. // 读取HDCP长度赋值;
  1563. reportMIKey.HDCP22 = _MiKey._HDCP22.ToString();
  1564. reportMIKey.HDCP14 = _MiKey._HDCP14.ToString();
  1565. // 返回的PSN作为ChipMN和ChipSN;
  1566. reportMIKey.ChipMN = _MiKey._PSN;
  1567. reportMIKey.ChipSN = _MiKey._PSN;
  1568. reportMIKey.DSN = _MiKey.DSN;
  1569. reportMIKey.TVMN = _MiKey.TVMN;
  1570. reportMIKey.TVSN = SN.Replace("/", ""); // 去掉斜杠;
  1571. if (!CommonMethod.ReportMIKey(FunctionSettingNow.MIKeyReportUrl, reportMIKey, out msg))
  1572. {
  1573. msg = string.Format("ReportMIKey error!\r\n{0}", msg);
  1574. Log.WriteErrorLog(msg);
  1575. return false;
  1576. }
  1577. return true;
  1578. }
  1579. /// <summary>
  1580. /// 执行抄key等动作
  1581. /// </summary>
  1582. public void Writekey()
  1583. {
  1584. DateTime startTime = DateTime.Now;
  1585. ArrayList keypath = new ArrayList();
  1586. ArrayList keyStream = new ArrayList();
  1587. ArrayList keyReader = new ArrayList();
  1588. //int SerailDelay = FunctionSettingNow.SerailDelay;
  1589. int SerailDelay = FunctionSettingNow.NextCommandWaitTime;
  1590. Log.WriteInfoLog(SN + " start testing");
  1591. // 0表示抄写失败,特殊:上报IDM失败\获取key失败\抄写失败;
  1592. // 1表示抄写成功,特殊:无;
  1593. // 2表示抄写成功,特殊:但试产NTF要求连续2次PASS才能上传MES,需要再测试一次;
  1594. // 3表示抄写成功,特殊:上报MES失败;
  1595. int TestResult = 0;
  1596. string keycontent = "";
  1597. bool EnterFactoryResult = false;
  1598. byte[] result;
  1599. byte[] data;
  1600. string error = "";
  1601. // 报错信息;
  1602. string ErrMsg = "";
  1603. string psn = "";
  1604. string devicecode = "";
  1605. //进工厂
  1606. if (!TVPort.IsOpen)
  1607. {
  1608. try
  1609. {
  1610. TVPort.Open();
  1611. }
  1612. catch (Exception ex)
  1613. {
  1614. MessageBox.Show(ex.Message);
  1615. return;
  1616. }
  1617. }
  1618. for (int i = 0; i <= FunctionSettingNow.EnterFactoryRetry; i++)
  1619. {
  1620. if (i == 0)
  1621. Log.WriteInfoLog("Enter factory...");
  1622. else
  1623. Log.WriteInfoLog("Retry enter factory " + i.ToString() + " ...");
  1624. if (SerialCMD.EnterFactory(TVPort, out result, out data, out error, SerailDelay))
  1625. {
  1626. EnterFactoryResult = true;
  1627. break;
  1628. }
  1629. }
  1630. if (!EnterFactoryResult)
  1631. {
  1632. ErrMsg = string.Format("{0} Enter factory fail", SN);
  1633. Log.WriteErrorLog(ErrMsg);
  1634. goto end;
  1635. }
  1636. //烧录SN
  1637. if (WritePSN.Checked)
  1638. {
  1639. Log.WriteInfoLog("Write PSN");
  1640. if (SerialCMD.SetFireTVPSN(TVPort, Encoding.ASCII.GetBytes(SN), out result, out data, out error, SerailDelay))
  1641. {
  1642. SetsuccessStatus(m_writePSN);
  1643. Log.WriteInfoLog("Read PSN");
  1644. if (SerialCMD.ReadFireTVPSN(TVPort, out result, out data, out error, SerailDelay))
  1645. {
  1646. if (!Encoding.ASCII.GetString(data).Equals(SN))
  1647. {
  1648. ErrMsg = string.Format("{0} Compare PSN error!\r\n", SN);
  1649. Log.WriteErrorLog(ErrMsg);
  1650. goto end;
  1651. }
  1652. SetsuccessStatus(m_readPSN);
  1653. }
  1654. else
  1655. {
  1656. SetfailStatus(m_readPSN);
  1657. ErrMsg = string.Format("{0} Read PSN error!\r\n", SN);
  1658. Log.WriteErrorLog(ErrMsg);
  1659. goto end;
  1660. }
  1661. }
  1662. else
  1663. {
  1664. SetfailStatus(m_writePSN);
  1665. ErrMsg = string.Format("{0} Write PSN error!\r\n", SN);
  1666. Log.WriteErrorLog(ErrMsg);
  1667. goto end;
  1668. }
  1669. }
  1670. // 如果是要导出ACASID+SN,先判断ACASID是否等于20位长度;
  1671. if (FunctionSettingNow.ExportSNACASID)
  1672. {
  1673. if (SerialCMD.ReadJapaneseACASID(TVPort, out result, out data, out error, SerailDelay))
  1674. {
  1675. if (data.Length != 20)
  1676. {
  1677. SetfailStatus(m_readACASID);
  1678. ErrMsg = string.Format("{0} The ACAS ID length doesn't equal 20!\r\n{1}", SN, data.ToString());
  1679. Log.WriteErrorLog(ErrMsg);
  1680. goto end;
  1681. }
  1682. SetsuccessStatus(m_readACASID);
  1683. }
  1684. else
  1685. {
  1686. SetfailStatus(m_readACASID);
  1687. ErrMsg = string.Format("{0} Read ACAS ID error!\r\n", SN);
  1688. Log.WriteErrorLog(ErrMsg);
  1689. goto end;
  1690. }
  1691. }
  1692. //获取key
  1693. if (midListNow.host == "LocalPC" && !preloadNow)
  1694. {
  1695. string Didpath = "";
  1696. string Macpath = "";
  1697. string Hdcppath = "";
  1698. string Hdcp22path = "";
  1699. string Esnpath = "";
  1700. string MGKpath = "";
  1701. string Widipath = "";
  1702. string Widevinepath = "";
  1703. string Cipath = "";
  1704. string Attestationpath = "";
  1705. string Fairplaypath = "";
  1706. string LEKpath = "";
  1707. string PEKpath = "";
  1708. string Playreadypath = "";
  1709. string Hashkeypath = "";
  1710. string AcasKeypath = "";
  1711. if (WriteDID.Checked)
  1712. {
  1713. if (GetLocalKeyCount.GetLocalStringKeys(orderNow, "DeviceID", FunctionSettingNow.LocalDidSize, out FileStream Stream, out StreamReader Reader, out string did, out Didpath, out error, errorDBNow, ref localmidList, SN))
  1714. {
  1715. keyInfo.DID.data = did;
  1716. Log.WriteGetKeyLog("\r\nLocal DeviceID=" + keyInfo.DID);
  1717. if (Stream != null && Reader != null)
  1718. {
  1719. keypath.Add(Didpath);
  1720. keyStream.Add(Stream);
  1721. keyReader.Add(Reader);
  1722. }
  1723. }
  1724. else
  1725. {
  1726. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetDIDError, error);
  1727. Log.WriteErrorLog(ErrMsg);
  1728. goto end;
  1729. }
  1730. }
  1731. if (WriteMac.Checked)
  1732. {
  1733. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "MAC", FunctionSettingNow.LocalMacSize, out FileStream Stream, out BinaryReader Reader, out string mac, out Macpath, out error, errorDBNow, ref localmidList, SN))
  1734. {
  1735. keyInfo.Mac.data = mac;
  1736. Log.WriteGetKeyLog("\r\nLocal Mac=" + keyInfo.Mac);
  1737. if (Stream != null && Reader != null)
  1738. {
  1739. keypath.Add(Macpath);
  1740. keyStream.Add(Stream);
  1741. keyReader.Add(Reader);
  1742. }
  1743. }
  1744. else
  1745. {
  1746. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetMacError, error);
  1747. Log.WriteErrorLog(ErrMsg);
  1748. goto end;
  1749. }
  1750. }
  1751. if (WriteHDCP.Checked)
  1752. {
  1753. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "HDCPKEY", FunctionSettingNow.LocalHdcpSize, out FileStream Stream, out BinaryReader Reader, out string hdcp, out Hdcppath, out error, errorDBNow, ref localmidList, SN))
  1754. {
  1755. keyInfo.HDCP.data = hdcp;
  1756. Log.WriteGetKeyLog("\r\nLocal HDCP=" + keyInfo.HDCP);
  1757. if (Stream != null && Reader != null)
  1758. {
  1759. keypath.Add(Hdcppath);
  1760. keyStream.Add(Stream);
  1761. keyReader.Add(Reader);
  1762. }
  1763. }
  1764. else
  1765. {
  1766. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetHDCPError, error);
  1767. Log.WriteErrorLog(ErrMsg);
  1768. goto end;
  1769. }
  1770. }
  1771. if (WriteHDCP22.Checked)
  1772. {
  1773. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "HDCPKEY22", FunctionSettingNow.LocalHdcp22Size, out FileStream Stream, out BinaryReader Reader, out string hdcp22, out Hdcp22path, out error, errorDBNow, ref localmidList, SN))
  1774. {
  1775. keyInfo.HDCP22.data = hdcp22;
  1776. Log.WriteGetKeyLog("\r\nLocal HDCP22=" + keyInfo.HDCP22);
  1777. if (Stream != null && Reader != null)
  1778. {
  1779. keypath.Add(Hdcp22path);
  1780. keyStream.Add(Stream);
  1781. keyReader.Add(Reader);
  1782. }
  1783. }
  1784. else
  1785. {
  1786. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetHDCP22Error, error);
  1787. Log.WriteErrorLog(ErrMsg);
  1788. goto end;
  1789. }
  1790. }
  1791. if (WriteESN.Checked)
  1792. {
  1793. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "ESN", FunctionSettingNow.LocalEsnSize, out FileStream Stream, out BinaryReader Reader, out string esn, out Esnpath, out error, errorDBNow, ref localmidList, SN))
  1794. {
  1795. keyInfo.ESN.data = esn;
  1796. Log.WriteGetKeyLog("\r\nLocal ESN=" + keyInfo.ESN);
  1797. if (Stream != null && Reader != null)
  1798. {
  1799. keypath.Add(Esnpath);
  1800. keyStream.Add(Stream);
  1801. keyReader.Add(Reader);
  1802. }
  1803. }
  1804. else
  1805. {
  1806. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetESNError, error);
  1807. Log.WriteErrorLog(ErrMsg);
  1808. goto end;
  1809. }
  1810. }
  1811. if (WriteMGK.Checked)
  1812. {
  1813. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "MGK", FunctionSettingNow.LocalMGKSize, out FileStream Stream, out BinaryReader Reader, out string mgk, out MGKpath, out error, errorDBNow, ref localmidList, SN))
  1814. {
  1815. keyInfo.MGK.data = mgk;
  1816. Log.WriteGetKeyLog("\r\nLocal MGK=" + keyInfo.MGK);
  1817. if (Stream != null && Reader != null)
  1818. {
  1819. keypath.Add(MGKpath);
  1820. keyStream.Add(Stream);
  1821. keyReader.Add(Reader);
  1822. }
  1823. }
  1824. else
  1825. {
  1826. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetMGKError, error);
  1827. Log.WriteErrorLog(ErrMsg);
  1828. goto end;
  1829. }
  1830. }
  1831. if (WriteFairplay.Checked)
  1832. {
  1833. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Fairplay", FunctionSettingNow.LocalFairplaySize, out FileStream Stream, out BinaryReader Reader, out string fairplay, out Fairplaypath, out error, errorDBNow, ref localmidList, SN))
  1834. {
  1835. keyInfo.Fairplay.data = fairplay;
  1836. Log.WriteGetKeyLog("\r\nLocal Fairplay=" + keyInfo.Fairplay);
  1837. if (Stream != null && Reader != null)
  1838. {
  1839. keypath.Add(Fairplaypath);
  1840. keyStream.Add(Stream);
  1841. keyReader.Add(Reader);
  1842. }
  1843. }
  1844. else
  1845. {
  1846. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetFairplayError, error);
  1847. Log.WriteErrorLog(ErrMsg);
  1848. goto end;
  1849. }
  1850. }
  1851. if (WriteWiDi.Checked)
  1852. {
  1853. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "WiDi", FunctionSettingNow.LocalWidiSize, out FileStream Stream, out BinaryReader Reader, out string widi, out Widipath, out error, errorDBNow, ref localmidList, SN))
  1854. {
  1855. keyInfo.WiDi.data = widi;
  1856. Log.WriteGetKeyLog("\r\nLocal WiDi=" + keyInfo.WiDi);
  1857. if (Stream != null && Reader != null)
  1858. {
  1859. keypath.Add(Widipath);
  1860. keyStream.Add(Stream);
  1861. keyReader.Add(Reader);
  1862. }
  1863. }
  1864. else
  1865. {
  1866. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetWiDiError, error);
  1867. Log.WriteErrorLog(ErrMsg);
  1868. goto end;
  1869. }
  1870. }
  1871. if (WriteWidevine.Checked)
  1872. {
  1873. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Widevine", FunctionSettingNow.LocalWidevineSize, out FileStream Stream, out BinaryReader Reader, out string widevine, out Widevinepath, out error, errorDBNow, ref localmidList, SN))
  1874. {
  1875. keyInfo.Widevine.data = widevine;
  1876. Log.WriteGetKeyLog("\r\nLocal Widevine=" + keyInfo.Widevine);
  1877. if (Stream != null && Reader != null)
  1878. {
  1879. keypath.Add(Widevinepath);
  1880. keyStream.Add(Stream);
  1881. keyReader.Add(Reader);
  1882. }
  1883. }
  1884. else
  1885. {
  1886. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetWidevineError, error);
  1887. Log.WriteErrorLog(ErrMsg);
  1888. goto end;
  1889. }
  1890. }
  1891. if (WriteCiplus.Checked)
  1892. {
  1893. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "CIKEY", FunctionSettingNow.LocalCiSize, out FileStream Stream, out BinaryReader Reader, out string ci, out Cipath, out error, errorDBNow, ref localmidList, SN))
  1894. {
  1895. keyInfo.CI_plus.data = ci;
  1896. Log.WriteGetKeyLog("\r\nLocal CI_plus=" + keyInfo.CI_plus);
  1897. if (Stream != null && Reader != null)
  1898. {
  1899. keypath.Add(Cipath);
  1900. keyStream.Add(Stream);
  1901. keyReader.Add(Reader);
  1902. }
  1903. }
  1904. else
  1905. {
  1906. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetCiError, error);
  1907. Log.WriteErrorLog(ErrMsg);
  1908. goto end;
  1909. }
  1910. }
  1911. if (WriteAttestation.Checked)
  1912. {
  1913. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Attestation", FunctionSettingNow.LocalCiSize, out FileStream Stream, out BinaryReader Reader, out string attestation, out Attestationpath, out error, errorDBNow, ref localmidList, SN))
  1914. {
  1915. keyInfo.Attestation.data = attestation;
  1916. Log.WriteGetKeyLog("\r\nLocal attestation=" + keyInfo.Attestation);
  1917. if (Stream != null && Reader != null)
  1918. {
  1919. keypath.Add(Attestationpath);
  1920. keyStream.Add(Stream);
  1921. keyReader.Add(Reader);
  1922. }
  1923. }
  1924. else
  1925. {
  1926. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetAttestationError, error);
  1927. Log.WriteErrorLog(ErrMsg);
  1928. goto end;
  1929. }
  1930. }
  1931. if (fireTVKey.LEK)
  1932. {
  1933. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "LEK", -1, out FileStream Stream, out BinaryReader Reader, out string lek, out LEKpath, out error, errorDBNow, ref localmidList, SN))
  1934. {
  1935. keyInfo.LEK.data = lek;
  1936. Log.WriteGetKeyLog("\r\nLocal LEK=" + keyInfo.LEK);
  1937. if (Stream != null && Reader != null)
  1938. {
  1939. keypath.Add(LEKpath);
  1940. keyStream.Add(Stream);
  1941. keyReader.Add(Reader);
  1942. }
  1943. }
  1944. else
  1945. {
  1946. ErrMsg = String.Format("获取LEK失败 {0}", error);
  1947. Log.WriteErrorLog(ErrMsg);
  1948. goto end;
  1949. }
  1950. }
  1951. if (fireTVKey.PEK)
  1952. {
  1953. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "PEK", -1, out FileStream Stream, out BinaryReader Reader, out string pek, out PEKpath, out error, errorDBNow, ref localmidList, SN))
  1954. {
  1955. keyInfo.PEK.data = pek;
  1956. Log.WriteGetKeyLog("\r\nLocal LEK=" + keyInfo.PEK);
  1957. if (Stream != null && Reader != null)
  1958. {
  1959. keypath.Add(PEKpath);
  1960. keyStream.Add(Stream);
  1961. keyReader.Add(Reader);
  1962. }
  1963. }
  1964. else
  1965. {
  1966. ErrMsg = String.Format("获取PEK失败{0}", error);
  1967. Log.WriteErrorLog(ErrMsg);
  1968. goto end;
  1969. }
  1970. }
  1971. if (fireTVKey.Playready)
  1972. {
  1973. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Playready", -1, out FileStream Stream, out BinaryReader Reader, out string playready, out Playreadypath, out error, errorDBNow, ref localmidList, SN))
  1974. {
  1975. keyInfo.Playready.data = playready;
  1976. Log.WriteGetKeyLog("\r\nLocal Playready=" + keyInfo.Playready);
  1977. if (Stream != null && Reader != null)
  1978. {
  1979. keypath.Add(Playreadypath);
  1980. keyStream.Add(Stream);
  1981. keyReader.Add(Reader);
  1982. }
  1983. }
  1984. else
  1985. {
  1986. ErrMsg = String.Format("获取Playready失败{0}", error);
  1987. Log.WriteErrorLog(ErrMsg);
  1988. goto end;
  1989. }
  1990. }
  1991. if (fireTVKey.Hashkey)
  1992. {
  1993. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Hashkey", -1, out FileStream Stream, out BinaryReader Reader, out string hashkey, out Hashkeypath, out error, errorDBNow, ref localmidList, SN))
  1994. {
  1995. keyInfo.Hashkey.data = hashkey;
  1996. Log.WriteGetKeyLog("\r\nLocal Hashkey=" + keyInfo.Hashkey);
  1997. if (Stream != null && Reader != null)
  1998. {
  1999. keypath.Add(Fairplaypath);
  2000. keyStream.Add(Stream);
  2001. keyReader.Add(Reader);
  2002. }
  2003. }
  2004. else
  2005. {
  2006. ErrMsg = String.Format("获取hashkey失败 {0}", error);
  2007. Log.WriteErrorLog(ErrMsg);
  2008. goto end;
  2009. }
  2010. }
  2011. if (WriteACASKey.Checked)
  2012. {
  2013. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "ACAS_KEY", FunctionSettingNow.localACASKeySize, out FileStream Stream, out BinaryReader Reader, out string acaskey, out AcasKeypath, out error, errorDBNow, ref localmidList, SN))
  2014. {
  2015. keyInfo.ACASKey_Data.data = acaskey;
  2016. Log.WriteGetKeyLog("\r\nLocal ACASKey=" + keyInfo.ACASKey_Data);
  2017. if (Stream != null && Reader != null)
  2018. {
  2019. keypath.Add(AcasKeypath);
  2020. keyStream.Add(Stream);
  2021. keyReader.Add(Reader);
  2022. }
  2023. }
  2024. else
  2025. {
  2026. ErrMsg = String.Format("{0} {1}", LResource.GetACASKeyError, error);
  2027. Log.WriteErrorLog(ErrMsg);
  2028. goto end;
  2029. }
  2030. }
  2031. if (localmidList.host != null)
  2032. {
  2033. if (ClientTypeText.Text.Length == 0)
  2034. {
  2035. SetTextStatus(ClientTypeText, localmidList.clienttype);
  2036. }
  2037. if (SVText.Text.Length == 0)
  2038. {
  2039. SetTextStatus(SVText, localmidList.version);
  2040. }
  2041. if (ProjectIDText.Text.Length == 0)
  2042. {
  2043. SetTextStatus(ProjectIDText, localmidList.projectid);
  2044. }
  2045. }
  2046. }
  2047. else if (!preloadNow)
  2048. {
  2049. // 计算获取全部key耗时;
  2050. Stopwatch watch = new Stopwatch();
  2051. watch.Start();
  2052. // 只用一个接口获取所有Key;
  2053. if ( midListNow.keytype.ContainsKey("DSN") )
  2054. {
  2055. // 读取dvicecode
  2056. if (SerialCMD.GetFireTVDevcieCode(TVPort, out result, out data, out error, SerailDelay))
  2057. {
  2058. devicecode = Encoding.ASCII.GetString(data);
  2059. if (devicecode == "N/A")
  2060. {
  2061. ErrMsg = string.Format("Device code format error!\r\n{0}", devicecode);
  2062. Log.WriteErrorLog(ErrMsg);
  2063. goto end;
  2064. }
  2065. }
  2066. else
  2067. {
  2068. ErrMsg = string.Format("{0} Get Device Code Error", SN);
  2069. Log.WriteErrorLog(ErrMsg);
  2070. goto end;
  2071. }
  2072. // 读取psn的值;
  2073. if (SerialCMD.ReadFireTVPSN(TVPort, out result, out data, out error, SerailDelay))
  2074. {
  2075. psn = keyInfo._PSN.data = Encoding.ASCII.GetString(data);
  2076. }
  2077. else
  2078. {
  2079. ErrMsg = string.Format("Failed to read PSN when requesting DSN !\r\n{0}", devicecode);
  2080. Log.WriteErrorLog(ErrMsg);
  2081. goto end;
  2082. }
  2083. }
  2084. if ( !CommonMethod.GetIDMKeys(midListNow.host, SN, orderNow, psn, devicecode, errorDBNow, out keyInfo, out error) )
  2085. {
  2086. ErrMsg = string.Format("{0} GetIDMKeys Failed!\r\n{1}", SN, error);
  2087. Log.WriteErrorLog(ErrMsg);
  2088. goto end;
  2089. }
  2090. if (midListNow.keytype.ContainsKey("DSN"))
  2091. {
  2092. // 预防切了pid后,deviceCode变化了;
  2093. if (keyInfo.DSN.data.IndexOf(devicecode) == -1)
  2094. {
  2095. ErrMsg = string.Format("The device code [{0}] is not included in the DSN [{1}]!\r\n", devicecode, keyInfo.DSN.data);
  2096. Log.WriteErrorLog(ErrMsg);
  2097. goto end;
  2098. }
  2099. }
  2100. #region EDID屏抄写是从MID中获取值;
  2101. if (WriteEDIDPID.Checked)
  2102. {
  2103. keyInfo.EDIDPid.data = midListNow.keytype["edid_pid"];
  2104. }
  2105. if (WriteEDIDName.Checked)
  2106. {
  2107. keyInfo.EDIDModelName.data = midListNow.keytype["edid_model_name"];
  2108. }
  2109. #endregion
  2110. watch.Stop();
  2111. Log.WriteInfoLog(string.Format("Get All Keys Elapsed={0}", watch.Elapsed.TotalMilliseconds));
  2112. }
  2113. #region 小米FireTV功能启用;
  2114. if (FunctionSettingNow.MITVEnable)
  2115. {
  2116. // 获取Key;
  2117. if (!CommonMethod.GetMIKey(FunctionSettingNow.MIKeyUrl, SN, out _MiKey, out error))
  2118. {
  2119. ErrMsg = string.Format("GetMIKey error!\r\n{0}", error);
  2120. Log.WriteErrorLog(ErrMsg);
  2121. goto end;
  2122. }
  2123. // 配置要抄写的选项;
  2124. if (_MiKey.EthernetMac != null)
  2125. {
  2126. SetCheckboxStatus(WriteMac, true);
  2127. keyInfo.Mac.data = _MiKey.EthernetMac;
  2128. keyInfo.Mac.enable = true;
  2129. }
  2130. else
  2131. {
  2132. SetCheckboxStatus(WriteMac, false);
  2133. }
  2134. if (_MiKey.BTMac != null)
  2135. {
  2136. SetCheckboxStatus(WriteBTMac, true);
  2137. keyInfo.BT_MAC.data = _MiKey.BTMac;
  2138. keyInfo.BT_MAC.enable = true;
  2139. }
  2140. else
  2141. {
  2142. SetCheckboxStatus(WriteBTMac, false);
  2143. }
  2144. if (_MiKey.DSN != null)
  2145. {
  2146. SetCheckboxStatus(WriteDSN, true);
  2147. keyInfo.DSN.data = _MiKey.DSN;
  2148. keyInfo.DSN.enable = true;
  2149. }
  2150. else
  2151. {
  2152. SetCheckboxStatus(WriteDSN, false);
  2153. }
  2154. if (_MiKey.WIFIMAC != null)
  2155. {
  2156. SetCheckboxStatus(WriteWifiMac, true);
  2157. keyInfo.WiFi_MAC.data = _MiKey.WIFIMAC;
  2158. keyInfo.WiFi_MAC.enable = true;
  2159. }
  2160. else
  2161. {
  2162. SetCheckboxStatus(WriteWifiMac, false);
  2163. }
  2164. }
  2165. #endregion
  2166. #region 开始抄写;
  2167. // 如果是抄写EDID,则不获取白平衡数据;
  2168. if (CommonMethod.IsEDIDCopy(midListNow))
  2169. {
  2170. SetspecificText(SoftwareVersionNote, LResource.SkipChecking, Color.Yellow);
  2171. SetspecificText(ClientTypeNote, LResource.SkipChecking, Color.Yellow);
  2172. if (midListNow.projectid.Equals("0"))
  2173. SetspecificText(ProjectIDNote, LResource.SkipCovering, Color.Yellow);
  2174. }
  2175. //检查Software version
  2176. if (SoftwareVersionNote.Text != LResource.SkipChecking)
  2177. {
  2178. Log.WriteInfoLog("Check software version...\r\n");
  2179. if (SerialCMD.GetSoftVersion(TVPort, out result, out data, out error, SerailDelay))
  2180. {
  2181. string sfv = Encoding.ASCII.GetString(data);
  2182. if (sfv != SVText.Text)
  2183. {
  2184. MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
  2185. DialogResult dr = MessageBox.Show(LResource.MainboardFV + sfv + LResource.differentfromserver + SVText.Text + "\r\n" + LResource.SkipFVChecking, LResource.Error, messButton);
  2186. if (dr == DialogResult.OK)
  2187. {
  2188. SetspecificText(SoftwareVersionNote, LResource.SkipChecking, Color.Yellow);
  2189. SetcolorStatus(SVText, Color.Yellow);
  2190. }
  2191. else
  2192. {
  2193. SetspecificText(SoftwareVersionNote, sfv, Color.Red);
  2194. SetcolorStatus(SVText, Color.Red);
  2195. goto end;
  2196. }
  2197. }
  2198. else
  2199. {
  2200. SetcolorStatus(SVText, Color.FromArgb(128, 255, 128));
  2201. }
  2202. }
  2203. else
  2204. {
  2205. ErrMsg = string.Format("{0} Read software version fail!", SN);
  2206. Log.WriteErrorLog(ErrMsg);
  2207. goto end;
  2208. }
  2209. }
  2210. //DID抄写
  2211. if (WriteDID.Checked)
  2212. {
  2213. if (!CommonMethod.IsNumberAndWord(keyInfo.DID.data))
  2214. {
  2215. ErrMsg = string.Format("DID format error!\r\n{0}", keyInfo.DID.data);
  2216. Log.WriteErrorLog(ErrMsg);
  2217. goto end;
  2218. }
  2219. byte[] DIDData = Encoding.ASCII.GetBytes(keyInfo.DID.data);
  2220. Log.WriteInfoLog("Write DID...");
  2221. if (SerialCMD.SetDeviceID(TVPort, DIDData, out result, out data, out error, SerailDelay))
  2222. {
  2223. SetsuccessStatus(m_writedid);
  2224. Log.WriteInfoLog("Check DID...");
  2225. if (cfg_writecheck.DIDCheckcheck ? SerialCMD.CheckDeviceId(TVPort, out result, out data, out error, SerailDelay) : true)
  2226. {
  2227. SetsuccessStatus(m_checkdid);
  2228. Log.WriteInfoLog("Read DID...");
  2229. if (cfg_readcheck.DIDReadcheck ? SerialCMD.GetDeviceId(TVPort, out result, out data, out error, SerailDelay) : true)
  2230. {
  2231. if (cfg_readcheck.DIDReadcheck)
  2232. {
  2233. if (SerialInit.BytesCompare_Base64(data, DIDData))
  2234. {
  2235. SetsuccessStatus(m_readdid);
  2236. }
  2237. else
  2238. {
  2239. SetfailStatus(m_readdid);
  2240. ErrMsg = string.Format("{0} contrast DID fail!", SN);
  2241. Log.WriteErrorLog(ErrMsg);
  2242. goto end; ;
  2243. }
  2244. }
  2245. }
  2246. else
  2247. {
  2248. SetfailStatus(m_readdid);
  2249. ErrMsg = string.Format("{0} read DID fail!", SN);
  2250. Log.WriteErrorLog(ErrMsg);
  2251. goto end;
  2252. }
  2253. }
  2254. else
  2255. {
  2256. SetfailStatus(m_checkdid);
  2257. ErrMsg = string.Format("{0} check DID fail!", SN);
  2258. Log.WriteErrorLog(ErrMsg);
  2259. goto end;
  2260. }
  2261. }
  2262. else
  2263. {
  2264. SetfailStatus(m_writedid);
  2265. ErrMsg = string.Format("{0} Write DID fail!", SN);
  2266. Log.WriteErrorLog(ErrMsg);
  2267. goto end;
  2268. }
  2269. keyInfo.DID.result = true;
  2270. }
  2271. //Eth_Mac抄写
  2272. if (WriteMac.Checked)
  2273. {
  2274. string mac = keyInfo.Mac.data.Replace("-", "");
  2275. if (FunctionSettingNow.MITVEnable == true)
  2276. mac = keyInfo.Mac.data.Replace(":", "");
  2277. if (!CommonMethod.IsNumberAndWord(mac))
  2278. {
  2279. ErrMsg = string.Format("Mac format error!\r\n{0}", mac);
  2280. Log.WriteErrorLog(ErrMsg);
  2281. goto end;
  2282. }
  2283. byte[] MacData = SerialInit.HexToByte(mac);
  2284. Log.WriteInfoLog("Write Mac...");
  2285. if (SerialCMD.SetMAC(TVPort, MacData, out result, out data, out error, SerailDelay))
  2286. {
  2287. SetsuccessStatus(m_writemac);
  2288. Log.WriteInfoLog("Check Mac...");
  2289. if (cfg_writecheck.MacCheckcheck ? SerialCMD.CheckMAC(TVPort, out result, out data, out error, SerailDelay) : true)
  2290. {
  2291. SetsuccessStatus(m_checkmac);
  2292. Log.WriteInfoLog("Read Mac...");
  2293. if (cfg_readcheck.MacReadcheck ? SerialCMD.GetMAC(TVPort, out result, out data, out error, SerailDelay) : true)
  2294. {
  2295. if (cfg_readcheck.MacReadcheck)
  2296. {
  2297. if (SerialInit.BytesCompare_Base64(data, MacData))
  2298. {
  2299. SetsuccessStatus(m_readmac);
  2300. }
  2301. else
  2302. {
  2303. SetfailStatus(m_readmac);
  2304. ErrMsg = string.Format("{0} contrast Mac fail!", SN);
  2305. Log.WriteErrorLog(ErrMsg);
  2306. goto end;
  2307. }
  2308. }
  2309. }
  2310. else
  2311. {
  2312. SetfailStatus(m_readmac);
  2313. ErrMsg = string.Format("{0} read Mac fail!", SN);
  2314. Log.WriteErrorLog(ErrMsg);
  2315. goto end;
  2316. }
  2317. }
  2318. else
  2319. {
  2320. SetfailStatus(m_checkmac);
  2321. ErrMsg = string.Format("{0} check Mac fail!", SN);
  2322. Log.WriteErrorLog(ErrMsg);
  2323. goto end;
  2324. }
  2325. }
  2326. else
  2327. {
  2328. SetfailStatus(m_writemac);
  2329. ErrMsg = string.Format("{0} Write Mac fail!", SN);
  2330. Log.WriteErrorLog(ErrMsg);
  2331. goto end;
  2332. }
  2333. keyInfo.Mac.result = true;
  2334. }
  2335. //WiFi_MAC抄写
  2336. if (WriteWifiMac.Checked)
  2337. {
  2338. string wifimac = keyInfo.WiFi_MAC.data.Replace("-", "");
  2339. if (FunctionSettingNow.MITVEnable == true)
  2340. wifimac = keyInfo.WiFi_MAC.data.Replace(":", "");
  2341. if (!CommonMethod.IsNumberAndWord(wifimac))
  2342. {
  2343. ErrMsg = string.Format("Wifi Mac format error!\r\n{0}", wifimac);
  2344. Log.WriteErrorLog(ErrMsg);
  2345. goto end;
  2346. }
  2347. byte[] WifiMacData = Encoding.ASCII.GetBytes(wifimac);
  2348. Log.WriteInfoLog("Write WifiMac...");
  2349. if (SerialCMD.SetFireTVWifiMac(TVPort, WifiMacData, out result, out data, out error, SerailDelay))
  2350. {
  2351. SetsuccessStatus(m_writeWifiMac);
  2352. Log.WriteInfoLog("Check WifiMac...");
  2353. if (cfg_writecheck.WifiMacCheckcheck ? SerialCMD.CheckFireTVWifiMac(TVPort, out result, out data, out error, SerailDelay) : true)
  2354. {
  2355. SetsuccessStatus(m_checkWifiMac);
  2356. Log.WriteInfoLog("Read WifiMac...");
  2357. if (cfg_readcheck.WifiMacReadcheck ? SerialCMD.GetFireTVWiFi_Mac(TVPort, out result, out data, out error, SerailDelay) : true)
  2358. {
  2359. if (cfg_readcheck.WifiMacReadcheck)
  2360. {
  2361. if (SerialInit.BytesCompare_Base64(data, WifiMacData))
  2362. {
  2363. SetsuccessStatus(m_readWifiMac);
  2364. }
  2365. else
  2366. {
  2367. SetfailStatus(m_readWifiMac);
  2368. ErrMsg = string.Format("{0} contrast Wifi Mac fail!", SN);
  2369. Log.WriteErrorLog(ErrMsg);
  2370. goto end;
  2371. }
  2372. }
  2373. }
  2374. else
  2375. {
  2376. SetfailStatus(m_readWifiMac);
  2377. ErrMsg = string.Format("{0} read Wifi Mac fail!", SN);
  2378. Log.WriteErrorLog(ErrMsg);
  2379. goto end;
  2380. }
  2381. }
  2382. else
  2383. {
  2384. SetfailStatus(m_checkWifiMac);
  2385. ErrMsg = string.Format("{0} check Wifi Mac fail!", SN);
  2386. Log.WriteErrorLog(ErrMsg);
  2387. goto end;
  2388. }
  2389. }
  2390. else
  2391. {
  2392. SetfailStatus(m_writeWifiMac);
  2393. ErrMsg = string.Format("{0} Write Wifi Mac fail!", SN);
  2394. Log.WriteErrorLog(ErrMsg);
  2395. goto end;
  2396. }
  2397. keyInfo.WiFi_MAC.result = true;
  2398. }
  2399. //BT_MAC抄写
  2400. if (WriteBTMac.Checked)
  2401. {
  2402. string btmac = keyInfo.BT_MAC.data.Replace("-", "");
  2403. if (FunctionSettingNow.MITVEnable == true)
  2404. btmac = keyInfo.BT_MAC.data.Replace(":", "");
  2405. if (!CommonMethod.IsNumberAndWord(btmac))
  2406. {
  2407. ErrMsg = string.Format("BTMac format error!\r\n{0}", btmac);
  2408. Log.WriteErrorLog(ErrMsg);
  2409. goto end;
  2410. }
  2411. byte[] BTMacData = Encoding.ASCII.GetBytes(btmac);
  2412. Log.WriteInfoLog("Write BTMac...");
  2413. if (SerialCMD.SetFireTVBTMac(TVPort, BTMacData, out result, out data, out error, SerailDelay))
  2414. {
  2415. SetsuccessStatus(m_writeBTMac);
  2416. Log.WriteInfoLog("Check BTMac...");
  2417. if (cfg_writecheck.BTMacCheckcheck ? SerialCMD.CheckFireTVBTMac(TVPort, out result, out data, out error, SerailDelay) : true)
  2418. {
  2419. SetsuccessStatus(m_checkBTMac);
  2420. Log.WriteInfoLog("Read BTMac...");
  2421. if (cfg_readcheck.BTMacReadcheck ? SerialCMD.GetFireTVBT_Mac(TVPort, out result, out data, out error, SerailDelay) : true)
  2422. {
  2423. if (cfg_readcheck.BTMacReadcheck)
  2424. {
  2425. if (SerialInit.BytesCompare_Base64(data, BTMacData))
  2426. {
  2427. SetsuccessStatus(m_readBTMac);
  2428. }
  2429. else
  2430. {
  2431. SetfailStatus(m_readBTMac);
  2432. ErrMsg = string.Format("{0} contrast BT Mac fail!", SN);
  2433. Log.WriteErrorLog(ErrMsg);
  2434. goto end;
  2435. }
  2436. }
  2437. }
  2438. else
  2439. {
  2440. SetfailStatus(m_readBTMac);
  2441. ErrMsg = string.Format("{0} read BT Mac fail!", SN);
  2442. Log.WriteErrorLog(ErrMsg);
  2443. goto end;
  2444. }
  2445. }
  2446. else
  2447. {
  2448. SetfailStatus(m_checkBTMac);
  2449. ErrMsg = string.Format("{0} check BT Mac fail!", SN);
  2450. Log.WriteErrorLog(ErrMsg);
  2451. goto end;
  2452. }
  2453. }
  2454. else
  2455. {
  2456. SetfailStatus(m_writeBTMac);
  2457. ErrMsg = string.Format("{0} Write BT Mac fail!", SN);
  2458. Log.WriteErrorLog(ErrMsg);
  2459. goto end;
  2460. }
  2461. keyInfo.BT_MAC.result = true;
  2462. }
  2463. //PEK抄写
  2464. if (WritePEK.Checked)
  2465. {
  2466. if (!CommonMethod.IsNumberAndWord(keyInfo.PEK.data))
  2467. {
  2468. ErrMsg = string.Format("PEK format error!\r\n{0}", keyInfo.PEK.data);
  2469. Log.WriteErrorLog(ErrMsg);
  2470. goto end;
  2471. }
  2472. byte[] PEKData = SerialInit.HexToByte(keyInfo.PEK.data);
  2473. Log.WriteInfoLog("Write PEK...");
  2474. if (SerialCMD.SetFireTVPEK(TVPort, PEKData, out result, out data, out error, SerailDelay))
  2475. {
  2476. SetsuccessStatus(m_writePEK);
  2477. Log.WriteInfoLog("Check PEK...");
  2478. if (cfg_writecheck.PEKCheckcheck ? SerialCMD.CheckFireTVPEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2479. {
  2480. SetsuccessStatus(m_checkPEK);
  2481. Log.WriteInfoLog("Read PEK...");
  2482. if (cfg_readcheck.PEKReadcheck ? SerialCMD.ReadFireTVPEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2483. {
  2484. if (cfg_readcheck.PEKReadcheck)
  2485. {
  2486. if (SerialInit.BytesCompare_Base64(data, PEKData))
  2487. {
  2488. SetsuccessStatus(m_readPEK);
  2489. }
  2490. else
  2491. {
  2492. SetfailStatus(m_readPEK);
  2493. ErrMsg = string.Format("{0} contrast PEK fail!", SN);
  2494. Log.WriteErrorLog(ErrMsg);
  2495. goto end;
  2496. }
  2497. }
  2498. }
  2499. else
  2500. {
  2501. SetfailStatus(m_readPEK);
  2502. ErrMsg = string.Format("{0} read PEK fail!", SN);
  2503. Log.WriteErrorLog(ErrMsg);
  2504. goto end;
  2505. }
  2506. }
  2507. else
  2508. {
  2509. SetfailStatus(m_checkPEK);
  2510. ErrMsg = string.Format("{0} check PEK fail!", SN);
  2511. Log.WriteErrorLog(ErrMsg);
  2512. goto end;
  2513. }
  2514. }
  2515. else
  2516. {
  2517. SetfailStatus(m_writePEK);
  2518. ErrMsg = string.Format("{0} Write PEK fail!", SN);
  2519. Log.WriteErrorLog(ErrMsg);
  2520. goto end;
  2521. }
  2522. keyInfo.PEK.result = true;
  2523. }
  2524. // DAK 抄写;
  2525. if (WriteDAK.Checked)
  2526. {
  2527. if (!CommonMethod.IsNumberAndWord(keyInfo.DAK.data))
  2528. {
  2529. ErrMsg = string.Format("DAK format error!\r\n{0}", keyInfo.DAK.data);
  2530. Log.WriteErrorLog(ErrMsg);
  2531. goto end;
  2532. }
  2533. byte[] DAKData = SerialInit.HexToByte(keyInfo.DAK.data);
  2534. Log.WriteInfoLog("Write DAK...");
  2535. if (SerialCMD.SetFireTVDAK(TVPort, DAKData, out result, out data, out error, SerailDelay))
  2536. {
  2537. SetsuccessStatus(m_writeDAK);
  2538. Log.WriteInfoLog("Check DAK...");
  2539. if (cfg_writecheck.DAKCheckcheck ? SerialCMD.CheckFireTVDAK(TVPort, out result, out data, out error, SerailDelay) : true)
  2540. {
  2541. SetsuccessStatus(m_checkDAK);
  2542. }
  2543. else
  2544. {
  2545. SetfailStatus(m_checkDAK);
  2546. ErrMsg = string.Format("{0} check DAK fail!", SN);
  2547. Log.WriteErrorLog(ErrMsg);
  2548. goto end;
  2549. }
  2550. }
  2551. else
  2552. {
  2553. SetfailStatus(m_writeDAK);
  2554. ErrMsg = string.Format("{0} Write DAK fail!", SN);
  2555. Log.WriteErrorLog(ErrMsg);
  2556. goto end;
  2557. }
  2558. keyInfo.DAK.result = true;
  2559. }
  2560. //LEK抄写
  2561. if (WriteLEK.Checked)
  2562. {
  2563. if (!CommonMethod.IsNumberAndWord(keyInfo.LEK.data))
  2564. {
  2565. ErrMsg = string.Format("LEK format error!\r\n{0}", keyInfo.LEK.data);
  2566. Log.WriteErrorLog(ErrMsg);
  2567. goto end;
  2568. }
  2569. byte[] LEKData = SerialInit.HexToByte(keyInfo.LEK.data);
  2570. Log.WriteInfoLog("Write LEK...");
  2571. if (SerialCMD.SetFireTVLEK(TVPort, LEKData, out result, out data, out error, SerailDelay))
  2572. {
  2573. SetsuccessStatus(m_writeLEK);
  2574. Log.WriteInfoLog("Check LEK...");
  2575. if (cfg_writecheck.LEKCheckcheck ? SerialCMD.CheckFireTVLEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2576. {
  2577. SetsuccessStatus(m_checkLEK);
  2578. Log.WriteInfoLog("Read LEK...");
  2579. if (cfg_readcheck.LEKReadcheck ? SerialCMD.ReadFireTVLEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2580. {
  2581. if (cfg_readcheck.LEKReadcheck)
  2582. {
  2583. if (SerialInit.BytesCompare_Base64(data, LEKData))
  2584. {
  2585. SetsuccessStatus(m_readLEK);
  2586. }
  2587. else
  2588. {
  2589. SetfailStatus(m_readLEK);
  2590. ErrMsg = string.Format("{0} contrast LEK fail!", SN);
  2591. Log.WriteErrorLog(ErrMsg);
  2592. goto end;
  2593. }
  2594. }
  2595. }
  2596. else
  2597. {
  2598. SetfailStatus(m_readLEK);
  2599. ErrMsg = string.Format("{0} read LEK fail!", SN);
  2600. Log.WriteErrorLog(ErrMsg);
  2601. goto end;
  2602. }
  2603. }
  2604. else
  2605. {
  2606. SetfailStatus(m_checkLEK);
  2607. ErrMsg = string.Format("{0} check LEK fail!", SN);
  2608. Log.WriteErrorLog(ErrMsg);
  2609. goto end;
  2610. }
  2611. }
  2612. else
  2613. {
  2614. SetfailStatus(m_writeLEK);
  2615. ErrMsg = string.Format("{0} Write LEK fail!", SN);
  2616. Log.WriteErrorLog(ErrMsg);
  2617. goto end;
  2618. }
  2619. keyInfo.LEK.result = true;
  2620. }
  2621. //HDCP KEY抄写
  2622. if (WriteHDCP.Checked)
  2623. {
  2624. if (!CommonMethod.IsNumberAndWord(keyInfo.HDCP.data))
  2625. {
  2626. ErrMsg = string.Format("HDCP format error!\r\n{0}", keyInfo.HDCP.data);
  2627. Log.WriteErrorLog(ErrMsg);
  2628. goto end;
  2629. }
  2630. byte[] HDCPData = SerialInit.HexToByte(keyInfo.HDCP.data);
  2631. Log.WriteInfoLog("Write HDCP...");
  2632. if (SerialCMD.SetHDCPKey(TVPort, HDCPData, out result, out data, out error, SerailDelay))
  2633. {
  2634. SetsuccessStatus(m_writehdcp);
  2635. Log.WriteInfoLog("Check HDCP...");
  2636. if (cfg_writecheck.HDCPCheckcheck ? SerialCMD.CheckHDCP(TVPort, out result, out data, out error, SerailDelay) : true)
  2637. {
  2638. SetsuccessStatus(m_checkhdcp);
  2639. Log.WriteInfoLog("Read HDCP...");
  2640. if (cfg_readcheck.HDCPReadcheck ? SerialCMD.GetHDCPKey(TVPort, out result, out data, out error, SerailDelay) : true)
  2641. {
  2642. if (cfg_readcheck.HDCPReadcheck)
  2643. {
  2644. if (SerialInit.BytesCompare_Base64(data, HDCPData))
  2645. {
  2646. SetsuccessStatus(m_readhdcp);
  2647. }
  2648. else
  2649. {
  2650. SetfailStatus(m_readhdcp);
  2651. ErrMsg = string.Format("{0} contrast HDCP fail!", SN);
  2652. Log.WriteErrorLog(ErrMsg);
  2653. goto end;
  2654. }
  2655. }
  2656. }
  2657. else
  2658. {
  2659. SetfailStatus(m_readhdcp);
  2660. ErrMsg = string.Format("{0} read HDCP fail!", SN);
  2661. Log.WriteErrorLog(ErrMsg);
  2662. goto end;
  2663. }
  2664. }
  2665. else
  2666. {
  2667. SetfailStatus(m_checkhdcp);
  2668. ErrMsg = string.Format("{0} check HDCP fail!", SN);
  2669. Log.WriteErrorLog(ErrMsg);
  2670. goto end;
  2671. }
  2672. }
  2673. else
  2674. {
  2675. SetfailStatus(m_writehdcp);
  2676. ErrMsg = string.Format("{0} Write HDCP fail!", SN);
  2677. Log.WriteErrorLog(ErrMsg);
  2678. goto end;
  2679. }
  2680. keyInfo.HDCP.result = true;
  2681. }
  2682. //HDCP22 KEY抄写
  2683. if (WriteHDCP22.Checked)
  2684. {
  2685. if (!CommonMethod.IsNumberAndWord(keyInfo.HDCP22.data))
  2686. {
  2687. ErrMsg = string.Format("HDCP22 format error!\r\n{0}", keyInfo.HDCP22.data);
  2688. Log.WriteErrorLog(ErrMsg);
  2689. goto end;
  2690. }
  2691. byte[] HDCP22Data = SerialInit.HexToByte(keyInfo.HDCP22.data);
  2692. Log.WriteInfoLog("Write HDCP22...");
  2693. if (SerialCMD.SetHDCPKey22(TVPort, HDCP22Data, out result, out data, out error, SerailDelay))
  2694. {
  2695. SetsuccessStatus(m_writehdcp22);
  2696. Log.WriteInfoLog("Check HDCP22...");
  2697. if (cfg_writecheck.HDCP22Checkcheck ? SerialCMD.CheckHDCP22(TVPort, out result, out data, out error, SerailDelay) : true)
  2698. {
  2699. SetsuccessStatus(m_checkhdcp22);
  2700. Log.WriteInfoLog("Read HDCP22...");
  2701. if (cfg_readcheck.HDCP22Readcheck ? SerialCMD.GetHDCPKey22(TVPort, out result, out data, out error, SerailDelay) : true)
  2702. {
  2703. if (cfg_readcheck.HDCP22Readcheck)
  2704. {
  2705. if (SerialInit.BytesCompare_Base64(data, HDCP22Data))
  2706. {
  2707. SetsuccessStatus(m_readhdcp22);
  2708. }
  2709. else
  2710. {
  2711. SetfailStatus(m_readhdcp22);
  2712. ErrMsg = string.Format("{0} contrast HDCP22 fail!", SN);
  2713. Log.WriteErrorLog(ErrMsg);
  2714. goto end;
  2715. }
  2716. }
  2717. }
  2718. else
  2719. {
  2720. SetfailStatus(m_readhdcp22);
  2721. ErrMsg = string.Format("{0} read HDCP22 fail!", SN);
  2722. Log.WriteErrorLog(ErrMsg);
  2723. goto end;
  2724. }
  2725. }
  2726. else
  2727. {
  2728. SetfailStatus(m_checkhdcp22);
  2729. ErrMsg = string.Format("{0} check HDCP22 fail!", SN);
  2730. Log.WriteErrorLog(ErrMsg);
  2731. goto end;
  2732. }
  2733. }
  2734. else
  2735. {
  2736. SetfailStatus(m_writehdcp22);
  2737. ErrMsg = string.Format("{0} Write HDCP22 fail!", SN);
  2738. Log.WriteErrorLog(ErrMsg);
  2739. goto end;
  2740. }
  2741. keyInfo.HDCP22.result = true;
  2742. }
  2743. //ESN KEY抄写
  2744. if (WriteESN.Checked)
  2745. {
  2746. if (!CommonMethod.IsNumberAndWord(keyInfo.ESN.data))
  2747. {
  2748. ErrMsg = string.Format("ESN format error!\r\n{0}", keyInfo.ESN.data);
  2749. Log.WriteErrorLog(ErrMsg);
  2750. goto end;
  2751. }
  2752. byte[] ESNData = SerialInit.HexToByte(keyInfo.ESN.data);
  2753. Log.WriteInfoLog("Write ESN...");
  2754. if (SerialCMD.SetNetflixESN(TVPort, ESNData, out result, out data, out error, SerailDelay))
  2755. {
  2756. SetsuccessStatus(m_writeesn);
  2757. Log.WriteInfoLog("Check ESN...");
  2758. if (cfg_writecheck.ESNCheckcheck ? SerialCMD.CheckNetflixESN(TVPort, out result, out data, out error, SerailDelay) : true)
  2759. {
  2760. SetsuccessStatus(m_checkesn);
  2761. Log.WriteInfoLog("Read ESN...");
  2762. if (cfg_readcheck.ESNReadcheck ? SerialCMD.GetNetflixESN(TVPort, out result, out data, out error, SerailDelay) : true)
  2763. {
  2764. if (cfg_readcheck.ESNReadcheck)
  2765. {
  2766. if (SerialInit.BytesCompare_Base64(data, ESNData))
  2767. {
  2768. SetsuccessStatus(m_readesn);
  2769. }
  2770. else
  2771. {
  2772. SetfailStatus(m_readesn);
  2773. ErrMsg = string.Format("{0} contrast ESN fail!", SN);
  2774. Log.WriteErrorLog(ErrMsg);
  2775. goto end;
  2776. }
  2777. }
  2778. }
  2779. else
  2780. {
  2781. SetfailStatus(m_readesn);
  2782. ErrMsg = string.Format("{0} read ESN fail!", SN);
  2783. Log.WriteErrorLog(ErrMsg);
  2784. goto end;
  2785. }
  2786. }
  2787. else
  2788. {
  2789. SetfailStatus(m_checkesn);
  2790. ErrMsg = string.Format("{0} check ESN fail!", SN);
  2791. Log.WriteErrorLog(ErrMsg);
  2792. goto end;
  2793. }
  2794. }
  2795. else
  2796. {
  2797. SetfailStatus(m_writeesn);
  2798. ErrMsg = string.Format("{0} Write ESN fail!", SN);
  2799. Log.WriteErrorLog(ErrMsg);
  2800. goto end;
  2801. }
  2802. }
  2803. //WiDi KEY抄写
  2804. if (WriteWiDi.Checked)
  2805. {
  2806. if (!CommonMethod.IsNumberAndWord(keyInfo.WiDi.data))
  2807. {
  2808. ErrMsg = string.Format("WiDi format error!\r\n{0}", keyInfo.WiDi.data);
  2809. Log.WriteErrorLog(ErrMsg);
  2810. goto end;
  2811. }
  2812. byte[] WiDiData = SerialInit.HexToByte(keyInfo.WiDi.data);
  2813. Log.WriteInfoLog("Write WiDi...");
  2814. if (SerialCMD.SetWidi(TVPort, WiDiData, out result, out data, out error, SerailDelay))
  2815. {
  2816. SetsuccessStatus(m_writewidi);
  2817. Log.WriteInfoLog("Check WiDi...");
  2818. if (cfg_writecheck.WiDiCheckcheck ? SerialCMD.CheckWidi(TVPort, out result, out data, out error, SerailDelay) : true)
  2819. {
  2820. SetsuccessStatus(m_checkwidi);
  2821. Log.WriteInfoLog("Read WiDi...");
  2822. if (cfg_readcheck.WiDiReadcheck ? SerialCMD.GetWidi(TVPort, out result, out data, out error, SerailDelay) : true)
  2823. {
  2824. if (cfg_readcheck.WiDiReadcheck)
  2825. {
  2826. if (SerialInit.BytesCompare_Base64(data, WiDiData))
  2827. {
  2828. SetsuccessStatus(m_readwidi);
  2829. }
  2830. else
  2831. {
  2832. SetfailStatus(m_readwidi);
  2833. ErrMsg = string.Format("{0} contrast WiDi fail!", SN);
  2834. Log.WriteErrorLog(ErrMsg);
  2835. goto end;
  2836. }
  2837. }
  2838. }
  2839. else
  2840. {
  2841. SetfailStatus(m_readwidi);
  2842. ErrMsg = string.Format("{0} read WiDi fail!", SN);
  2843. Log.WriteErrorLog(ErrMsg);
  2844. goto end;
  2845. }
  2846. }
  2847. else
  2848. {
  2849. SetfailStatus(m_checkwidi);
  2850. ErrMsg = string.Format("{0} check WiDi fail!", SN);
  2851. Log.WriteErrorLog(ErrMsg);
  2852. goto end;
  2853. }
  2854. }
  2855. else
  2856. {
  2857. SetfailStatus(m_writewidi);
  2858. ErrMsg = string.Format("{0} Write WiDi fail!", SN);
  2859. Log.WriteErrorLog(ErrMsg);
  2860. goto end;
  2861. }
  2862. keyInfo.WiDi.result = true;
  2863. }
  2864. //Youtube key抄写
  2865. if (WriteYouTube.Checked)
  2866. {
  2867. if (!CommonMethod.IsNumberAndWord(keyInfo.YouTube_KEY.data))
  2868. {
  2869. ErrMsg = string.Format("YouTube format error!\r\n{0}", keyInfo.YouTube_KEY.data);
  2870. Log.WriteErrorLog(ErrMsg);
  2871. goto end;
  2872. }
  2873. byte[] YouTubeData = SerialInit.HexToByte(keyInfo.YouTube_KEY.data);
  2874. Log.WriteInfoLog("Write YouTube key...");
  2875. if (SerialCMD.SetFireTVYoutube(TVPort, YouTubeData, out result, out data, out error, SerailDelay))
  2876. {
  2877. SetsuccessStatus(m_writeYouTube);
  2878. Log.WriteInfoLog("Check YouTube_KEY...");
  2879. if (cfg_writecheck.YouTubeCheckcheck ? SerialCMD.CheckFireTVYoutube(TVPort, out result, out data, out error, SerailDelay) : true)
  2880. {
  2881. SetsuccessStatus(m_checkYouTube);
  2882. Log.WriteInfoLog("Read YouTube_KEY...");
  2883. if (cfg_readcheck.YouTubeReadcheck ? SerialCMD.ReadFireTVYoutube(TVPort, out result, out data, out error, SerailDelay) : true)
  2884. {
  2885. if (cfg_readcheck.YouTubeReadcheck)
  2886. {
  2887. if (SerialInit.BytesCompare_Base64(data, YouTubeData))
  2888. {
  2889. SetsuccessStatus(m_readYouTube);
  2890. }
  2891. else
  2892. {
  2893. SetfailStatus(m_readYouTube);
  2894. ErrMsg = string.Format("{0} contrast YouTube_KEY fail!", SN);
  2895. Log.WriteErrorLog(ErrMsg);
  2896. goto end;
  2897. }
  2898. }
  2899. }
  2900. else
  2901. {
  2902. SetfailStatus(m_readYouTube);
  2903. ErrMsg = string.Format("{0} read YouTube_KEY fail!", SN);
  2904. Log.WriteErrorLog(ErrMsg);
  2905. goto end;
  2906. }
  2907. }
  2908. else
  2909. {
  2910. SetfailStatus(m_checkYouTube);
  2911. ErrMsg = string.Format("{0} check YouTube_KEY fail!", SN);
  2912. Log.WriteErrorLog(ErrMsg);
  2913. goto end;
  2914. }
  2915. }
  2916. else
  2917. {
  2918. SetfailStatus(m_writeYouTube);
  2919. ErrMsg = string.Format("{0} Write YouTube_KEY fail!", SN);
  2920. Log.WriteErrorLog(ErrMsg);
  2921. goto end;
  2922. }
  2923. keyInfo.YouTube_KEY.result = true;
  2924. }
  2925. //Widevine KEY抄写
  2926. if (WriteWidevine.Checked)
  2927. {
  2928. if (!CommonMethod.IsNumberAndWord(keyInfo.Widevine.data))
  2929. {
  2930. ErrMsg = string.Format("Widevine format error!\r\n{0}", keyInfo.Widevine.data);
  2931. Log.WriteErrorLog(ErrMsg);
  2932. goto end;
  2933. }
  2934. byte[] WidevineData = SerialInit.HexToByte(keyInfo.Widevine.data);
  2935. Log.WriteInfoLog("Write Widevine...");
  2936. if (SerialCMD.SetWidevine(TVPort, WidevineData, out result, out data, out error, SerailDelay))
  2937. {
  2938. SetsuccessStatus(m_writewidevine);
  2939. Log.WriteInfoLog("Check Widevine...");
  2940. if (cfg_writecheck.WidevineCheckcheck ? SerialCMD.CheckWidevine(TVPort, out result, out data, out error, SerailDelay) : true)
  2941. {
  2942. SetsuccessStatus(m_checkwidevine);
  2943. Log.WriteInfoLog("Read Widevine...");
  2944. if (cfg_readcheck.WidevineReadcheck ? SerialCMD.GetWidevine(TVPort, out result, out data, out error, SerailDelay) : true)
  2945. {
  2946. if (cfg_readcheck.WidevineReadcheck)
  2947. {
  2948. if (CommonMethod.CompareMD5(WidevineData, data))
  2949. {
  2950. SetsuccessStatus(m_readwidevine);
  2951. }
  2952. else
  2953. {
  2954. if (SerialInit.BytesCompare_Base64(data, WidevineData))
  2955. {
  2956. SetsuccessStatus(m_readwidevine);
  2957. }
  2958. else
  2959. {
  2960. SetfailStatus(m_readwidevine);
  2961. ErrMsg = string.Format("{0} contrast Widevine fail!", SN);
  2962. Log.WriteErrorLog(ErrMsg);
  2963. goto end;
  2964. }
  2965. }
  2966. }
  2967. }
  2968. else
  2969. {
  2970. SetfailStatus(m_readwidevine);
  2971. ErrMsg = string.Format("{0} read Widevine fail!", SN);
  2972. Log.WriteErrorLog(ErrMsg);
  2973. goto end;
  2974. }
  2975. }
  2976. else
  2977. {
  2978. SetfailStatus(m_checkwidevine);
  2979. ErrMsg = string.Format("{0} check Widevine fail!", SN);
  2980. Log.WriteErrorLog(ErrMsg);
  2981. goto end;
  2982. }
  2983. }
  2984. else
  2985. {
  2986. SetfailStatus(m_writewidevine);
  2987. ErrMsg = string.Format("{0} Write Widevine fail!", SN);
  2988. Log.WriteErrorLog(ErrMsg);
  2989. goto end;
  2990. }
  2991. keyInfo.Widevine.result = true;
  2992. }
  2993. //CI plus KEY抄写
  2994. if (WriteCiplus.Checked)
  2995. {
  2996. if (!CommonMethod.IsNumberAndWord(keyInfo.CI_plus.data))
  2997. {
  2998. ErrMsg = string.Format("CI_plus format error!\r\n{0}", keyInfo.CI_plus.data);
  2999. Log.WriteErrorLog(ErrMsg);
  3000. goto end;
  3001. }
  3002. byte[] CiplusData = SerialInit.HexToByte(keyInfo.CI_plus.data);
  3003. Log.WriteInfoLog("Write CI plus...");
  3004. if (SerialCMD.SetCiKey(TVPort, CiplusData, out result, out data, out error, SerailDelay))
  3005. {
  3006. SetsuccessStatus(m_writeci);
  3007. Log.WriteInfoLog("Check CI plus...");
  3008. if (cfg_writecheck.CI_plusCheckcheck ? SerialCMD.CheckCikey(TVPort, out result, out data, out error, SerailDelay) : true)
  3009. {
  3010. SetsuccessStatus(m_checkci);
  3011. Log.WriteInfoLog("Read CI plus...");
  3012. if (cfg_readcheck.CI_plusReadcheck ? SerialCMD.GetCiKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3013. {
  3014. if (cfg_readcheck.CI_plusReadcheck)
  3015. {
  3016. if (CommonMethod.CompareMD5(CiplusData, data))
  3017. {
  3018. SetsuccessStatus(m_readci);
  3019. }
  3020. else
  3021. {
  3022. if (SerialInit.BytesCompare_Base64(data, CiplusData))
  3023. {
  3024. SetsuccessStatus(m_readci);
  3025. }
  3026. else
  3027. {
  3028. SetfailStatus(m_readci);
  3029. ErrMsg = string.Format("{0} contrast CI plus fail!", SN);
  3030. Log.WriteErrorLog(ErrMsg);
  3031. goto end;
  3032. }
  3033. }
  3034. }
  3035. }
  3036. else
  3037. {
  3038. SetfailStatus(m_readci);
  3039. ErrMsg = string.Format("{0} read CI plus fail!", SN);
  3040. Log.WriteErrorLog(ErrMsg);
  3041. goto end;
  3042. }
  3043. }
  3044. else
  3045. {
  3046. SetfailStatus(m_checkci);
  3047. ErrMsg = string.Format("{0} check CI plus fail!", SN);
  3048. Log.WriteErrorLog(ErrMsg);
  3049. goto end;
  3050. }
  3051. }
  3052. else
  3053. {
  3054. SetfailStatus(m_writeci);
  3055. ErrMsg = string.Format("{0} Write CI plus fail!", SN);
  3056. Log.WriteErrorLog(ErrMsg);
  3057. goto end;
  3058. }
  3059. keyInfo.CI_plus.result = true;
  3060. }
  3061. //Attestation KEY抄写
  3062. if (WriteAttestation.Checked)
  3063. {
  3064. if (!CommonMethod.IsNumberAndWord(keyInfo.Attestation.data))
  3065. {
  3066. ErrMsg = string.Format("Attestation key format error!\r\n{0}", keyInfo.Attestation.data);
  3067. Log.WriteErrorLog(ErrMsg);
  3068. goto end;
  3069. }
  3070. byte[] AttestationData = SerialInit.HexToByte(keyInfo.Attestation.data);
  3071. Log.WriteInfoLog("Write Attestation key...");
  3072. if (SerialCMD.SetAttestationKey(TVPort, AttestationData, out result, out data, out error, SerailDelay))
  3073. {
  3074. SetsuccessStatus(m_writeattestation);
  3075. Log.WriteInfoLog("Check Attestation key...");
  3076. if (cfg_writecheck.AttestationCheckcheck ? SerialCMD.CheckAttestationKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3077. {
  3078. SetsuccessStatus(m_checkattestation);
  3079. Log.WriteInfoLog("Read Attestation key...");
  3080. if (cfg_readcheck.AttestationReadcheck ? SerialCMD.GetAttestationKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3081. {
  3082. if (cfg_readcheck.AttestationReadcheck)
  3083. {
  3084. if (CommonMethod.CompareMD5(AttestationData, data))
  3085. {
  3086. SetsuccessStatus(m_readattestation);
  3087. }
  3088. else
  3089. {
  3090. if (SerialInit.BytesCompare_Base64(data, AttestationData))
  3091. {
  3092. SetsuccessStatus(m_readattestation);
  3093. }
  3094. else
  3095. {
  3096. SetfailStatus(m_readattestation);
  3097. ErrMsg = string.Format("{0} contrast Attestation key fail!", SN);
  3098. Log.WriteErrorLog(ErrMsg);
  3099. goto end;
  3100. }
  3101. }
  3102. }
  3103. }
  3104. else
  3105. {
  3106. SetfailStatus(m_readattestation);
  3107. ErrMsg = string.Format("{0} read Attestation key fail!", SN);
  3108. Log.WriteErrorLog(ErrMsg);
  3109. goto end;
  3110. }
  3111. }
  3112. else
  3113. {
  3114. SetfailStatus(m_checkattestation);
  3115. ErrMsg = string.Format("{0} check Attestation key fail!", SN);
  3116. Log.WriteErrorLog(ErrMsg);
  3117. goto end;
  3118. }
  3119. }
  3120. else
  3121. {
  3122. SetfailStatus(m_writeattestation);
  3123. ErrMsg = string.Format("{0} Write Attestation key fail!", SN);
  3124. Log.WriteErrorLog(ErrMsg);
  3125. goto end;
  3126. }
  3127. keyInfo.Attestation.result = true;
  3128. }
  3129. //MGK KEY抄写
  3130. if (WriteMGK.Checked)
  3131. {
  3132. if (!CommonMethod.IsNumberAndWord(keyInfo.MGK.data))
  3133. {
  3134. ErrMsg = string.Format("MGK format error!\r\n{0}", keyInfo.MGK.data);
  3135. Log.WriteErrorLog(ErrMsg);
  3136. goto end;
  3137. }
  3138. byte[] MGKData = SerialInit.HexToByte(keyInfo.MGK.data);
  3139. Log.WriteInfoLog("Write MGK...");
  3140. if (SerialCMD.SetMGKKey(TVPort, MGKData, out result, out data, out error, SerailDelay))
  3141. {
  3142. SetsuccessStatus(m_writeMGK);
  3143. Log.WriteInfoLog("Check MGK...");
  3144. if (cfg_writecheck.MGKCheckcheck ? SerialCMD.CheckMGKkey(TVPort, out result, out data, out error, SerailDelay) : true)
  3145. {
  3146. SetsuccessStatus(m_checkMGK);
  3147. Log.WriteInfoLog("Read MGK...");
  3148. if (cfg_readcheck.MGKReadcheck ? SerialCMD.GetMGKKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3149. {
  3150. if (cfg_readcheck.MGKReadcheck)
  3151. {
  3152. if (CommonMethod.CompareMD5(MGKData, data))
  3153. {
  3154. SetsuccessStatus(m_readMGK);
  3155. }
  3156. else
  3157. {
  3158. if (SerialInit.BytesCompare_Base64(data, MGKData))
  3159. {
  3160. SetsuccessStatus(m_readMGK);
  3161. }
  3162. else
  3163. {
  3164. SetfailStatus(m_readMGK);
  3165. ErrMsg = string.Format("{0} contrast MGK fail!", SN);
  3166. Log.WriteErrorLog(ErrMsg);
  3167. goto end;
  3168. }
  3169. }
  3170. }
  3171. }
  3172. else
  3173. {
  3174. SetfailStatus(m_readMGK);
  3175. ErrMsg = string.Format("{0} read MGK fail!", SN);
  3176. Log.WriteErrorLog(ErrMsg);
  3177. goto end;
  3178. }
  3179. }
  3180. else
  3181. {
  3182. SetfailStatus(m_checkMGK);
  3183. ErrMsg = string.Format("{0} check MGK fail!", SN);
  3184. Log.WriteErrorLog(ErrMsg);
  3185. goto end;
  3186. }
  3187. }
  3188. else
  3189. {
  3190. SetfailStatus(m_writeMGK);
  3191. ErrMsg = string.Format("{0} Write MGK fail!", SN);
  3192. Log.WriteErrorLog(ErrMsg);
  3193. goto end;
  3194. }
  3195. keyInfo.MGK.result = true;
  3196. }
  3197. //Fairplay KEY抄写
  3198. if (WriteFairplay.Checked)
  3199. {
  3200. if (!CommonMethod.IsNumberAndWord(keyInfo.Fairplay.data))
  3201. {
  3202. ErrMsg = string.Format("Fairplay format error!\r\n{0}", keyInfo.Fairplay.data);
  3203. Log.WriteErrorLog(ErrMsg);
  3204. goto end;
  3205. }
  3206. byte[] FairplayData = SerialInit.HexToByte(keyInfo.Fairplay.data);
  3207. Log.WriteInfoLog("Write Fairplay...");
  3208. if (SerialCMD.SetFireTVFairplay(TVPort, FairplayData, out result, out data, out error, SerailDelay))
  3209. {
  3210. SetsuccessStatus(m_writeFairplay);
  3211. Log.WriteInfoLog("Check Fairplay...");
  3212. if (cfg_writecheck.FairplayCheckcheck ? SerialCMD.CheckFireTVFairplay(TVPort, out result, out data, out error, SerailDelay) : true)
  3213. {
  3214. SetsuccessStatus(m_checkFairplay);
  3215. Log.WriteInfoLog("Read Fairplay...");
  3216. if (cfg_readcheck.FairplayReadcheck ? SerialCMD.ReadFireTVFairplay(TVPort, out result, out data, out error, SerailDelay) : true)
  3217. {
  3218. if (cfg_readcheck.FairplayReadcheck)
  3219. {
  3220. if (SerialInit.BytesCompare_Base64(data, FairplayData))
  3221. {
  3222. SetsuccessStatus(m_readFairplay);
  3223. }
  3224. else
  3225. {
  3226. SetfailStatus(m_readFairplay);
  3227. ErrMsg = string.Format("{0} contrast Fairplay fail!", SN);
  3228. Log.WriteErrorLog(ErrMsg);
  3229. goto end;
  3230. }
  3231. }
  3232. }
  3233. else
  3234. {
  3235. SetfailStatus(m_readFairplay);
  3236. ErrMsg = string.Format("{0} read Fairplay fail!", SN);
  3237. Log.WriteErrorLog(ErrMsg);
  3238. goto end;
  3239. }
  3240. }
  3241. else
  3242. {
  3243. SetfailStatus(m_checkFairplay);
  3244. ErrMsg = string.Format("{0} check Fairplay fail!", SN);
  3245. Log.WriteErrorLog(ErrMsg);
  3246. goto end;
  3247. }
  3248. }
  3249. else
  3250. {
  3251. SetfailStatus(m_writeFairplay);
  3252. ErrMsg = string.Format("{0} Write Fairplay fail!", SN);
  3253. Log.WriteErrorLog(ErrMsg);
  3254. goto end;
  3255. }
  3256. keyInfo.Fairplay.result = true;
  3257. }
  3258. //ECP KEY抄写
  3259. if (WriteECP.Checked)
  3260. {
  3261. if (!CommonMethod.IsNumberAndWord(keyInfo.ECP.data))
  3262. {
  3263. ErrMsg = string.Format("ECP format error!\r\n{0}", keyInfo.ECP.data);
  3264. Log.WriteErrorLog(ErrMsg);
  3265. goto end;
  3266. }
  3267. byte[] ECPData = SerialInit.HexToByte(keyInfo.ECP.data);
  3268. Log.WriteInfoLog("Write ECP...");
  3269. if (SerialCMD.SetECP(TVPort, ECPData, out result, out data, out error, SerailDelay))
  3270. {
  3271. SetsuccessStatus(m_writeECP);
  3272. Log.WriteInfoLog("Check ECP...");
  3273. if (cfg_writecheck.ECPCheckcheck ? SerialCMD.CheckECP(TVPort, out result, out data, out error, SerailDelay) : true)
  3274. {
  3275. SetsuccessStatus(m_checkECP);
  3276. Log.WriteInfoLog("Read ECP...");
  3277. if (cfg_readcheck.ECPReadcheck ? SerialCMD.GetECP(TVPort, out result, out data, out error, SerailDelay) : true)
  3278. {
  3279. if (cfg_readcheck.ECPReadcheck)
  3280. {
  3281. if (SerialInit.BytesCompare_Base64(data, ECPData))
  3282. {
  3283. SetsuccessStatus(m_readECP);
  3284. }
  3285. else
  3286. {
  3287. SetfailStatus(m_readECP);
  3288. ErrMsg = string.Format("{0} contrast ECP fail!", SN);
  3289. Log.WriteErrorLog(ErrMsg);
  3290. goto end;
  3291. }
  3292. }
  3293. }
  3294. else
  3295. {
  3296. SetfailStatus(m_readECP);
  3297. ErrMsg = string.Format("{0} read ECP fail!", SN);
  3298. Log.WriteErrorLog(ErrMsg);
  3299. goto end;
  3300. }
  3301. }
  3302. else
  3303. {
  3304. SetfailStatus(m_checkECP);
  3305. ErrMsg = string.Format("{0} check ECP fail!", SN);
  3306. Log.WriteErrorLog(ErrMsg);
  3307. goto end;
  3308. }
  3309. }
  3310. else
  3311. {
  3312. SetfailStatus(m_writeECP);
  3313. ErrMsg = string.Format("{0} Write ECP fail!", SN);
  3314. Log.WriteErrorLog(ErrMsg);
  3315. goto end;
  3316. }
  3317. keyInfo.ECP.result = true;
  3318. }
  3319. //Playready抄写
  3320. if (WritePlayready.Checked)
  3321. {
  3322. if (!CommonMethod.IsNumberAndWord(keyInfo.Playready.data))
  3323. {
  3324. ErrMsg = string.Format("Playready format error!\r\n{0}", keyInfo.Playready.data);
  3325. Log.WriteErrorLog(ErrMsg);
  3326. goto end;
  3327. }
  3328. byte[] PlayreadyData = SerialInit.HexToByte(keyInfo.Playready.data);
  3329. Log.WriteInfoLog("Write Playready...");
  3330. if (SerialCMD.SetFireTVPlayready(TVPort, PlayreadyData, out result, out data, out error, SerailDelay))
  3331. {
  3332. SetsuccessStatus(m_writePlayready);
  3333. Log.WriteInfoLog("Check Playready...");
  3334. if (cfg_writecheck.PlayreadyCheckcheck ? SerialCMD.CheckFireTVPlayready(TVPort, out result, out data, out error, SerailDelay) : true)
  3335. {
  3336. SetsuccessStatus(m_checkPlayready);
  3337. Log.WriteInfoLog("Read Playready...");
  3338. if (cfg_readcheck.PlayreadyReadcheck ? SerialCMD.ReadFireTVPlayready(TVPort, out result, out data, out error, SerailDelay) : true)
  3339. {
  3340. if (cfg_readcheck.PlayreadyReadcheck)
  3341. {
  3342. if (CommonMethod.CompareMD5(PlayreadyData, data))
  3343. {
  3344. SetsuccessStatus(m_readPlayready);
  3345. }
  3346. else
  3347. {
  3348. if (SerialInit.BytesCompare_Base64(data, PlayreadyData))
  3349. {
  3350. SetsuccessStatus(m_readPlayready);
  3351. }
  3352. else
  3353. {
  3354. SetfailStatus(m_readPlayready);
  3355. ErrMsg = string.Format("{0} contrast Playready fail!", SN);
  3356. Log.WriteErrorLog(ErrMsg);
  3357. goto end;
  3358. }
  3359. }
  3360. }
  3361. }
  3362. else
  3363. {
  3364. SetfailStatus(m_readPlayready);
  3365. ErrMsg = string.Format("{0} read Playready fail!", SN);
  3366. Log.WriteErrorLog(ErrMsg);
  3367. goto end;
  3368. }
  3369. }
  3370. else
  3371. {
  3372. SetfailStatus(m_checkPlayready);
  3373. ErrMsg = string.Format("{0} check Playready fail!", SN);
  3374. Log.WriteErrorLog(ErrMsg);
  3375. goto end;
  3376. }
  3377. }
  3378. else
  3379. {
  3380. SetfailStatus(m_writePlayready);
  3381. ErrMsg = string.Format("{0} Write Playready fail!", SN);
  3382. Log.WriteErrorLog(ErrMsg);
  3383. goto end;
  3384. }
  3385. keyInfo.Playready.result = true;
  3386. }
  3387. //Hash抄写
  3388. if (WriteHash.Checked)
  3389. {
  3390. if (!CommonMethod.IsNumberAndWord(keyInfo.Hashkey.data))
  3391. {
  3392. ErrMsg = string.Format("Hash format error!\r\n{0}", keyInfo.Hashkey.data);
  3393. Log.WriteErrorLog(ErrMsg);
  3394. goto end;
  3395. }
  3396. byte[] HashData = SerialInit.HexToByte(keyInfo.Hashkey.data);
  3397. Log.WriteInfoLog("Write Hash...");
  3398. if (SerialCMD.SetFireTVHashkey(TVPort, HashData, out result, out data, out error, SerailDelay))
  3399. {
  3400. SetsuccessStatus(m_writeHash);
  3401. Log.WriteInfoLog("Check Hash...");
  3402. if (cfg_writecheck.HashCheckcheck ? SerialCMD.CheckFireTVHashkey(TVPort, out result, out data, out error, SerailDelay) : true)
  3403. {
  3404. SetsuccessStatus(m_checkHash);
  3405. Log.WriteInfoLog("Read Hash...");
  3406. if (cfg_readcheck.HashReadcheck ? SerialCMD.ReadFireTVHashkey(TVPort, out result, out data, out error, SerailDelay) : true)
  3407. {
  3408. if (cfg_readcheck.HashReadcheck)
  3409. {
  3410. if (SerialInit.BytesCompare_Base64(data, HashData))
  3411. {
  3412. SetsuccessStatus(m_readHash);
  3413. }
  3414. else
  3415. {
  3416. SetfailStatus(m_readHash);
  3417. ErrMsg = string.Format("{0} contrast Hash fail!", SN);
  3418. Log.WriteErrorLog(ErrMsg);
  3419. goto end;
  3420. }
  3421. }
  3422. }
  3423. else
  3424. {
  3425. SetfailStatus(m_readHash);
  3426. ErrMsg = string.Format("{0} read Hash fail!", SN);
  3427. Log.WriteErrorLog(ErrMsg);
  3428. goto end;
  3429. }
  3430. }
  3431. else
  3432. {
  3433. SetfailStatus(m_checkHash);
  3434. ErrMsg = string.Format("{0} check Hash fail!", SN);
  3435. Log.WriteErrorLog(ErrMsg);
  3436. goto end;
  3437. }
  3438. }
  3439. else
  3440. {
  3441. SetfailStatus(m_writeHash);
  3442. ErrMsg = string.Format("{0} Write Hash fail!", SN);
  3443. Log.WriteErrorLog(ErrMsg);
  3444. goto end;
  3445. }
  3446. keyInfo.Hashkey.result = true;
  3447. }
  3448. //频道预置
  3449. if (FunctionSettingNow.WriteChannel)
  3450. {
  3451. Log.WriteInfoLog("setting channel...");
  3452. if (SerialCMD.SetChannel(TVPort, FunctionSettingNow.ChannelCode, out result, out data, out error, SerailDelay))
  3453. {
  3454. /*
  3455. Log.WriteInfoLog("getting channel...");
  3456. if (SerialCMD.GetChannel(TVPort, out result, out data, out error))
  3457. {
  3458. if(SerialInit.BytesCompare_Base64(data, FunctionSettingNow.ChannelCode))
  3459. {
  3460. }
  3461. else
  3462. {
  3463. Log.WriteErrorLog(SN + " get different channel");
  3464. goto end;
  3465. }
  3466. }
  3467. else
  3468. {
  3469. Log.WriteErrorLog(SN + " fail to get channel");
  3470. goto end;
  3471. }*/
  3472. Log.WriteInfoLog(SN + " set channel success");
  3473. SetcolorStatus(ChannelText, Color.FromArgb(128, 255, 128));
  3474. }
  3475. else
  3476. {
  3477. ErrMsg = string.Format("{0} fail to set channel!", SN);
  3478. Log.WriteErrorLog(ErrMsg);
  3479. goto end;
  3480. }
  3481. }
  3482. //OSD语言设置
  3483. if (FunctionSettingNow.WriteOSD)
  3484. {
  3485. Log.WriteInfoLog("setting OSD language...");
  3486. if (SerialCMD.SetOSDLanguage(TVPort, FunctionSettingNow.OSDLCode, out result, out data, out error, SerailDelay))
  3487. {
  3488. if (cfg_readcheck.OSDReadcheck)
  3489. {
  3490. Log.WriteInfoLog("getting OSD language...");
  3491. if (SerialCMD.GetOSDLanguage(TVPort, out result, out data, out error, SerailDelay))
  3492. {
  3493. if (SerialInit.BytesCompare_Base64(data, FunctionSettingNow.OSDLCode))
  3494. {
  3495. SetcolorStatus(OSDText, Color.FromArgb(128, 255, 128));
  3496. }
  3497. else
  3498. {
  3499. ErrMsg = string.Format("{0} get different OSD language!", SN);
  3500. Log.WriteErrorLog(ErrMsg);
  3501. goto end;
  3502. }
  3503. }
  3504. else
  3505. {
  3506. ErrMsg = string.Format("{0} fail to get OSD language!", SN);
  3507. Log.WriteErrorLog(ErrMsg);
  3508. goto end;
  3509. }
  3510. }
  3511. else
  3512. Log.WriteInfoLog("skip read OSD language...");
  3513. }
  3514. else
  3515. {
  3516. ErrMsg = string.Format("{0} fail to set OSD language!", SN);
  3517. Log.WriteErrorLog(ErrMsg);
  3518. goto end;
  3519. }
  3520. }
  3521. //Shop语言设置
  3522. if (FunctionSettingNow.WriteSHOP)
  3523. {
  3524. Log.WriteInfoLog("setting SHOP language...");
  3525. if (SerialCMD.SetShopLanguage(TVPort, FunctionSettingNow.ShopLCode, out result, out data, out error, SerailDelay))
  3526. {
  3527. if (cfg_readcheck.SHOPReadcheck)
  3528. {
  3529. Log.WriteInfoLog("getting SHOP language...");
  3530. if (SerialCMD.GetShopLanguage(TVPort, out result, out data, out error, SerailDelay))
  3531. {
  3532. if (SerialInit.BytesCompare_Base64(data, FunctionSettingNow.ShopLCode))
  3533. {
  3534. SetcolorStatus(SHOPText, Color.FromArgb(128, 255, 128));
  3535. }
  3536. else
  3537. {
  3538. ErrMsg = string.Format("{0} get different SHOP language!", SN);
  3539. Log.WriteErrorLog(ErrMsg);
  3540. goto end;
  3541. }
  3542. }
  3543. else
  3544. {
  3545. ErrMsg = string.Format("{0} fail to get SHOP language!", SN);
  3546. Log.WriteErrorLog(ErrMsg);
  3547. goto end;
  3548. }
  3549. }
  3550. else
  3551. Log.WriteInfoLog("skip read SHOP language...");
  3552. }
  3553. else
  3554. {
  3555. ErrMsg = string.Format("{0} fail to set SHOP language!", SN);
  3556. Log.WriteErrorLog(ErrMsg);
  3557. goto end;
  3558. }
  3559. }
  3560. // EDID Pid抄写;
  3561. if (WriteEDIDPID.Checked)
  3562. {
  3563. // 4字节转成整数:0~65535,0x0000~0xffff;
  3564. if (Regex.IsMatch(keyInfo.EDIDPid.data, "^[A-Za-z0-9]{4}$"))
  3565. {
  3566. byte[] EDIDPidData = SerialInit.strToToHexByte(keyInfo.EDIDPid.data);
  3567. Log.WriteInfoLog("Write EDID Pid...");
  3568. if (SerialCMD.SetEDIDPid(TVPort, EDIDPidData, out result, out data, out error, SerailDelay))
  3569. {
  3570. SetsuccessStatus(m_writeEDIDPID);
  3571. Log.WriteInfoLog("Read EDID Pid...");
  3572. if (cfg_readcheck.EDIDPIDReadcheck ? SerialCMD.ReadEDIDPid(TVPort, out result, out data, out error, SerailDelay) : true)
  3573. {
  3574. if (cfg_readcheck.EDIDPIDReadcheck)
  3575. {
  3576. if (SerialInit.BytesCompare_Base64(data, EDIDPidData))
  3577. {
  3578. SetsuccessStatus(m_readEDIDPID);
  3579. }
  3580. else
  3581. {
  3582. SetfailStatus(m_readEDIDPID);
  3583. ErrMsg = string.Format("{0} contrast EDID PID fail!", SN);
  3584. Log.WriteErrorLog(ErrMsg);
  3585. goto end;
  3586. }
  3587. }
  3588. }
  3589. else
  3590. {
  3591. SetfailStatus(m_readEDIDPID);
  3592. ErrMsg = string.Format("{0} read EDID PID fail!", SN);
  3593. Log.WriteErrorLog(ErrMsg);
  3594. goto end;
  3595. }
  3596. }
  3597. else
  3598. {
  3599. SetfailStatus(m_writeEDIDPID);
  3600. ErrMsg = string.Format("{0} Write EDID PID fail!", SN);
  3601. Log.WriteErrorLog(ErrMsg);
  3602. goto end;
  3603. }
  3604. }
  3605. else
  3606. {
  3607. SetfailStatus(m_writeEDIDPID);
  3608. ErrMsg = string.Format("{0} The EDID PID Format Error!", SN);
  3609. Log.WriteErrorLog(ErrMsg);
  3610. goto end;
  3611. }
  3612. keyInfo.EDIDPid.result = true;
  3613. }
  3614. // EDID Mode Name抄写;
  3615. if (WriteEDIDName.Checked)
  3616. {
  3617. if (Regex.IsMatch(keyInfo.EDIDModelName.data, @"^[A-Za-z0-9][A-Za-z0-9_ -]{0,12}$"))
  3618. {
  3619. // 长度为13字节;
  3620. byte[] EDIDNameData = Encoding.ASCII.GetBytes(keyInfo.EDIDModelName.data);
  3621. Log.WriteInfoLog("Write EDID Mode Name...");
  3622. if (SerialCMD.SetEDIDModelName(TVPort, EDIDNameData, out result, out data, out error, SerailDelay))
  3623. {
  3624. SetsuccessStatus(m_writeEDIDName);
  3625. Log.WriteInfoLog("Read EDID Mode Name...");
  3626. if (cfg_readcheck.EDIDModeNameReadcheck ? SerialCMD.ReadEDIDModelName(TVPort, out result, out data, out error, SerailDelay) : true)
  3627. {
  3628. if (cfg_readcheck.EDIDModeNameReadcheck)
  3629. {
  3630. if (SerialInit.BytesCompare_Base64(data, EDIDNameData))
  3631. {
  3632. SetsuccessStatus(m_readEDIDName);
  3633. }
  3634. else
  3635. {
  3636. SetfailStatus(m_readEDIDName);
  3637. ErrMsg = string.Format("{0} contrast EDID Mode Name fail!", SN);
  3638. Log.WriteErrorLog(ErrMsg);
  3639. goto end;
  3640. }
  3641. }
  3642. }
  3643. else
  3644. {
  3645. SetfailStatus(m_readEDIDName);
  3646. ErrMsg = string.Format("{0} read EDID Mode Name fail!", SN);
  3647. Log.WriteErrorLog(ErrMsg);
  3648. goto end;
  3649. }
  3650. }
  3651. else
  3652. {
  3653. SetfailStatus(m_writeEDIDName);
  3654. ErrMsg = string.Format("{0} Write EDID Mode Name fail!", SN);
  3655. Log.WriteErrorLog(ErrMsg);
  3656. goto end;
  3657. }
  3658. }
  3659. else
  3660. {
  3661. SetfailStatus(m_writeEDIDName);
  3662. ErrMsg = string.Format("{0} The EDID Model Name Format Error!", SN);
  3663. Log.WriteErrorLog(ErrMsg);
  3664. goto end;
  3665. }
  3666. keyInfo.EDIDModelName.result = true;
  3667. }
  3668. // ACAS Key抄写;
  3669. if (WriteACASKey.Checked)
  3670. {
  3671. // 1.acas key抄写前,必须先抄写playreadkey;
  3672. // 2.将tool先抄写再抄写data;
  3673. Log.WriteInfoLog("Write ACAC Key...");
  3674. byte[] ACASKeyData = SerialInit.HexToByte(keyInfo.ACASKey_Data.data);
  3675. if (SerialCMD.SetACASKeyData(TVPort, ACASKeyData, out result, out data, out error, SerailDelay))
  3676. {
  3677. SetsuccessStatus(m_writeACASKey);
  3678. Log.WriteInfoLog("Check ACAS Key Data...");
  3679. if (cfg_writecheck.ACASKeyCheckcheck ? SerialCMD.CheckACASKeyData(TVPort, out result, out data, out error, SerailDelay) : true)
  3680. {
  3681. SetsuccessStatus(m_checkACASKey);
  3682. Log.WriteInfoLog("Read ACAS Key Data...");
  3683. if (cfg_readcheck.ACASKeyReadcheck ? SerialCMD.ReadACASKeyData(TVPort, out result, out data, out error, SerailDelay) : true)
  3684. {
  3685. if (cfg_readcheck.ACASKeyReadcheck)
  3686. {
  3687. if (CommonMethod.CompareMD5(ACASKeyData, data))
  3688. {
  3689. SetsuccessStatus(m_readACASKey);
  3690. }
  3691. else
  3692. {
  3693. SetfailStatus(m_readACASKey);
  3694. ErrMsg = string.Format("{0} contrast ACAS Key Data fail!", SN);
  3695. Log.WriteErrorLog(ErrMsg);
  3696. goto end;
  3697. }
  3698. }
  3699. }
  3700. else
  3701. {
  3702. SetfailStatus(m_readACASKey);
  3703. ErrMsg = string.Format("{0} read ACAS Key Data fail!", SN);
  3704. Log.WriteErrorLog(ErrMsg);
  3705. goto end;
  3706. }
  3707. }
  3708. else
  3709. {
  3710. SetfailStatus(m_checkACASKey);
  3711. ErrMsg = string.Format("{0} Check ACAS Key Data fail!", SN);
  3712. Log.WriteErrorLog(ErrMsg);
  3713. goto end;
  3714. }
  3715. }
  3716. else
  3717. {
  3718. SetfailStatus(m_writeACASKey);
  3719. ErrMsg = string.Format("{0} Write ACAS Key Data fail!", SN);
  3720. Log.WriteErrorLog(ErrMsg);
  3721. goto end;
  3722. }
  3723. keyInfo.ACASKey_Data.result = true;
  3724. }
  3725. //Project ID 抄写检查
  3726. if (ProjectIDNote.Text != LResource.SkipCovering)
  3727. {
  3728. Log.WriteInfoLog("Write projectID...");
  3729. if (ProjectIDNote.Text == LResource.Covering || ProjectIDNote.Text == LResource.SkipReadCheck)
  3730. {
  3731. SetspecificText(ProjectIDNote, ProjectIDNote.Text, Color.FromArgb(128, 255, 128));
  3732. byte[] param = CommonMethod.InttoBytelist(Convert.ToInt32(ProjectIDText.Text));
  3733. Log.WriteInfoLog("Set projectID...");
  3734. if (SerialCMD.SetProjectId(TVPort, param, out result, out data, out error, SerailDelay))
  3735. {
  3736. if (ProjectIDNote.Text != LResource.SkipReadCheck)
  3737. {
  3738. Log.WriteInfoLog("Check projectID...");
  3739. if (cfg_writedone.PIDWriteDelay > 0)
  3740. {
  3741. Thread.Sleep(cfg_writedone.PIDWriteDelay);//MS6586切完PID需要强制等待3s
  3742. }
  3743. if (SerialCMD.GetProjectID(TVPort, out result, out data, out error, SerailDelay, CommonMethod.IsEDIDCopy(midListNow)))
  3744. {
  3745. int readpid2 = CommonMethod.BytelisttoInt(data);
  3746. if (readpid2.ToString() != ProjectIDText.Text)
  3747. {
  3748. SetcolorStatus(ProjectIDText, Color.Red);
  3749. ErrMsg = SN + " read project id:" + readpid2.ToString() + "different from written: " + ProjectIDText.Text + " error";
  3750. Log.WriteErrorLog(ErrMsg);
  3751. goto end;
  3752. }
  3753. else
  3754. {
  3755. SetcolorStatus(ProjectIDText, Color.Green);
  3756. }
  3757. }
  3758. else
  3759. {
  3760. SetcolorStatus(ProjectIDText, Color.Red);
  3761. ErrMsg = string.Format("{0} get project id error!", SN);
  3762. Log.WriteErrorLog(ErrMsg);
  3763. goto end;
  3764. }
  3765. }
  3766. else
  3767. {
  3768. Log.WriteInfoLog("Skip check projectID...");
  3769. }
  3770. }
  3771. else
  3772. {
  3773. SetcolorStatus(ProjectIDText, Color.Red);
  3774. ErrMsg = string.Format("{0} set project id error!", SN);
  3775. Log.WriteErrorLog(ErrMsg);
  3776. goto end;
  3777. }
  3778. }
  3779. else
  3780. {
  3781. if (SerialCMD.GetProjectID(TVPort, out result, out data, out error, SerailDelay, CommonMethod.IsEDIDCopy(midListNow)))
  3782. {
  3783. int readpid = CommonMethod.BytelisttoInt(data);
  3784. if (readpid.ToString() != ProjectIDText.Text)
  3785. {
  3786. MessageBoxButtons messButton = MessageBoxButtons.YesNoCancel;
  3787. DialogResult dr = MessageBox.Show(LResource.MainboardPID + readpid.ToString() + LResource.DifferentFromSetting + "\r\n" + LResource.CoveringPID, LResource.Error, messButton);
  3788. if (dr == DialogResult.Yes)
  3789. {
  3790. SetspecificText(ProjectIDNote, LResource.Covering, Color.FromArgb(128, 255, 128));
  3791. byte[] param = CommonMethod.InttoBytelist(Convert.ToInt32(ProjectIDText.Text));
  3792. if (SerialCMD.SetProjectId(TVPort, param, out result, out data, out error, SerailDelay))
  3793. {
  3794. if (cfg_writedone.PIDWriteDelay > 0)
  3795. {
  3796. Thread.Sleep(cfg_writedone.PIDWriteDelay);//MS6586切完PID需要强制等待3s
  3797. }
  3798. Log.WriteInfoLog("Check projectID...");
  3799. if (SerialCMD.GetProjectID(TVPort, out result, out data, out error, SerailDelay, CommonMethod.IsEDIDCopy(midListNow)))
  3800. {
  3801. int readpid2 = CommonMethod.BytelisttoInt(data);
  3802. if (readpid2.ToString() != ProjectIDText.Text)
  3803. {
  3804. SetcolorStatus(ProjectIDText, Color.Red);
  3805. ErrMsg = SN + " read project id:" + readpid2.ToString() + "different from written: " + ProjectIDText.Text + " error";
  3806. Log.WriteErrorLog(ErrMsg);
  3807. goto end;
  3808. }
  3809. else
  3810. {
  3811. SetcolorStatus(ProjectIDText, Color.Green);
  3812. }
  3813. }
  3814. else
  3815. {
  3816. SetcolorStatus(ProjectIDText, Color.Red);
  3817. ErrMsg = string.Format("{0} get project id error!", SN);
  3818. Log.WriteErrorLog(ErrMsg);
  3819. goto end;
  3820. }
  3821. }
  3822. else
  3823. {
  3824. SetcolorStatus(ProjectIDText, Color.Red);
  3825. ErrMsg = string.Format("{0} set project id error!", SN);
  3826. Log.WriteErrorLog(ErrMsg);
  3827. goto end;
  3828. }
  3829. }
  3830. else if (dr == DialogResult.No)
  3831. {
  3832. SetspecificText(ProjectIDNote, LResource.SkipCovering, Color.Yellow);
  3833. SetcolorStatus(ProjectIDText, Color.Yellow);
  3834. }
  3835. else
  3836. {
  3837. SetspecificText(ProjectIDNote, readpid.ToString(), Color.Red);
  3838. SetcolorStatus(ProjectIDText, Color.Red);
  3839. goto end;
  3840. }
  3841. }
  3842. else
  3843. {
  3844. SetcolorStatus(ProjectIDText, Color.FromArgb(128, 255, 128));
  3845. }
  3846. }
  3847. else
  3848. {
  3849. ErrMsg = string.Format("{0} Read ProjectID fail!", SN);
  3850. Log.WriteErrorLog(ErrMsg);
  3851. goto end;
  3852. }
  3853. }
  3854. }
  3855. //检查ClientType
  3856. if (ClientTypeNote.Text != LResource.SkipChecking)
  3857. {
  3858. Log.WriteInfoLog("Read ClientType...");
  3859. if (SerialCMD.GetClientType(TVPort, out result, out data, out error, SerailDelay))
  3860. {
  3861. string ctype = Encoding.ASCII.GetString(data);
  3862. if (ctype != ClientTypeText.Text)
  3863. {
  3864. MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
  3865. DialogResult dr = MessageBox.Show(LResource.MainboardCType + ctype + LResource.differentfromserver + ClientTypeText.Text + "\r\n" + LResource.SkipCTypeChecking, LResource.Error, messButton);
  3866. if (dr == DialogResult.OK)
  3867. {
  3868. SetspecificText(ClientTypeNote, LResource.SkipChecking, Color.Yellow);
  3869. SetcolorStatus(ClientTypeText, Color.Yellow);
  3870. }
  3871. else
  3872. {
  3873. SetspecificText(ClientTypeNote, ctype, Color.Red);
  3874. SetcolorStatus(ClientTypeText, Color.Red);
  3875. goto end;
  3876. }
  3877. }
  3878. else
  3879. {
  3880. SetcolorStatus(ClientTypeText, Color.FromArgb(128, 255, 128));
  3881. }
  3882. }
  3883. else
  3884. {
  3885. ErrMsg = string.Format("{0} Read ClientType fail!", SN);
  3886. Log.WriteErrorLog(ErrMsg);
  3887. goto end;
  3888. }
  3889. }
  3890. //白平衡初始化
  3891. if (FunctionSettingNow.WBInit)
  3892. {
  3893. Log.WriteInfoLog("WhiteBalance init...");
  3894. if (SerialCMD.WBInit(TVPort, out result, out data, out error, SerailDelay))
  3895. {
  3896. }
  3897. else
  3898. {
  3899. ErrMsg = string.Format("{0} WhiteBalance ini fail!", SN);
  3900. Log.WriteErrorLog(ErrMsg);
  3901. goto end;
  3902. }
  3903. }
  3904. //白平衡赋值
  3905. if (FunctionSettingNow.WriteWB)
  3906. {
  3907. Log.WriteInfoLog("Set normal RGB...");
  3908. if (SerialCMD.SetWBNormal(TVPort, FunctionSettingNow.NormalRGB, out result, out data, out error, SerailDelay))
  3909. {
  3910. Log.WriteInfoLog("Set cool RGB...");
  3911. if (SerialCMD.SetWBCool(TVPort, FunctionSettingNow.CoolRGB, out result, out data, out error, SerailDelay))
  3912. {
  3913. Log.WriteInfoLog("Set warm RGB...");
  3914. if (SerialCMD.SetWBWarm(TVPort, FunctionSettingNow.WarmRGB, out result, out data, out error, SerailDelay))
  3915. {
  3916. SetcolorStatus(WBPathText, Color.FromArgb(128, 255, 128));
  3917. }
  3918. else
  3919. {
  3920. ErrMsg = string.Format("{0} Set warm RGB fail!", SN);
  3921. Log.WriteErrorLog(ErrMsg);
  3922. goto end;
  3923. }
  3924. }
  3925. else
  3926. {
  3927. ErrMsg = string.Format("{0} Set cool RGB fail!", SN);
  3928. Log.WriteErrorLog(ErrMsg);
  3929. goto end;
  3930. }
  3931. }
  3932. else
  3933. {
  3934. ErrMsg = string.Format("{0} Set normal RGB fail!", SN);
  3935. Log.WriteErrorLog(ErrMsg);
  3936. goto end;
  3937. }
  3938. }
  3939. //Roku客户服务信息抄写
  3940. if (midListNow.rokuCustomer != null)
  3941. {
  3942. string brand = midListNow.rokuCustomer.brand;
  3943. Log.WriteInfoLog("Write Roku brand...");
  3944. if (SerialCMD.SetROKUBrand(TVPort, Encoding.ASCII.GetBytes(brand), out result, out data, out error, SerailDelay))
  3945. {
  3946. Log.WriteInfoLog("Check Roku brand...");
  3947. if (SerialCMD.CheckROKUBrand(TVPort, out result, out data, out error, SerailDelay))
  3948. {
  3949. Log.WriteInfoLog("Read Roku brand...");
  3950. if (SerialCMD.GetROKUBrand(TVPort, out result, out data, out error, SerailDelay))
  3951. {
  3952. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(brand)))
  3953. {
  3954. Log.WriteInfoLog("ROKU brand 写入成功:" + Encoding.ASCII.GetString(data));
  3955. }
  3956. else
  3957. {
  3958. ErrMsg = string.Format("{0} Contrast ROKU brand fail!", SN);
  3959. Log.WriteErrorLog(ErrMsg);
  3960. goto end;
  3961. }
  3962. }
  3963. else
  3964. {
  3965. ErrMsg = string.Format("{0} Read ROKU brand fail!", SN);
  3966. Log.WriteErrorLog(ErrMsg);
  3967. goto end;
  3968. }
  3969. }
  3970. else
  3971. {
  3972. ErrMsg = string.Format("{0} Check ROKU brand fail!", SN);
  3973. Log.WriteErrorLog(ErrMsg);
  3974. goto end;
  3975. }
  3976. }
  3977. else
  3978. {
  3979. ErrMsg = string.Format("{0} Write ROKU brand fail!", SN);
  3980. Log.WriteErrorLog(ErrMsg);
  3981. goto end;
  3982. }
  3983. string model = midListNow.rokuCustomer.oemmodel;
  3984. Log.WriteInfoLog("Write Roku model...");
  3985. if (SerialCMD.SetModelName(TVPort, Encoding.ASCII.GetBytes(model), out result, out data, out error, SerailDelay))
  3986. {
  3987. Log.WriteInfoLog("Check Roku model...");
  3988. if (SerialCMD.CheckModelName(TVPort, out result, out data, out error, SerailDelay))
  3989. {
  3990. Log.WriteInfoLog("Read Roku model...");
  3991. if (SerialCMD.GetModelName(TVPort, out result, out data, out error, SerailDelay))
  3992. {
  3993. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(model)))
  3994. {
  3995. Log.WriteInfoLog("ROKU model 写入成功:" + Encoding.ASCII.GetString(data));
  3996. }
  3997. else
  3998. {
  3999. ErrMsg = string.Format("{0} Contrast ROKU model fail!", SN);
  4000. Log.WriteErrorLog(ErrMsg);
  4001. goto end;
  4002. }
  4003. }
  4004. else
  4005. {
  4006. ErrMsg = string.Format("{0} Read ROKU model fail!", SN);
  4007. Log.WriteErrorLog(ErrMsg);
  4008. goto end;
  4009. }
  4010. }
  4011. else
  4012. {
  4013. ErrMsg = string.Format("{0} Check ROKU model fail!", SN);
  4014. Log.WriteErrorLog(ErrMsg);
  4015. goto end;
  4016. }
  4017. }
  4018. else
  4019. {
  4020. ErrMsg = string.Format("{0} Write ROKU model fail!", SN);
  4021. Log.WriteErrorLog(ErrMsg);
  4022. goto end;
  4023. }
  4024. string[] dateInit = midListNow.rokuCustomer.productiondate.Split('-');
  4025. byte[] productdate = new byte[3] { Convert.ToByte(dateInit[0]), Convert.ToByte(dateInit[1]), Convert.ToByte(dateInit[2]) };
  4026. Log.WriteInfoLog("Write Roku production date...");
  4027. if (SerialCMD.SetROKUProductionDate(TVPort, productdate, out result, out data, out error, SerailDelay))
  4028. {
  4029. Log.WriteInfoLog("Check Roku production date...");
  4030. if (SerialCMD.CheckROKUProductionDate(TVPort, out result, out data, out error, SerailDelay))
  4031. {
  4032. Log.WriteInfoLog("Read Roku production date...");
  4033. if (SerialCMD.GetROKUProductionDate(TVPort, out result, out data, out error, SerailDelay))
  4034. {
  4035. string date = "20" + productdate[0].ToString() + "." + productdate[1].ToString() + ".WW" + productdate[2].ToString();
  4036. if (Encoding.ASCII.GetString(data) == date)
  4037. {
  4038. Log.WriteInfoLog("ROKU production date 写入成功:" + Encoding.ASCII.GetString(data));
  4039. }
  4040. else
  4041. {
  4042. ErrMsg = string.Format("{0} Contrast ROKU production fail!", SN);
  4043. Log.WriteErrorLog(ErrMsg);
  4044. goto end;
  4045. }
  4046. }
  4047. else
  4048. {
  4049. ErrMsg = string.Format("{0} Read ROKU production fail!", SN);
  4050. Log.WriteErrorLog(ErrMsg);
  4051. goto end;
  4052. }
  4053. }
  4054. else
  4055. {
  4056. ErrMsg = string.Format("{0} Check ROKU production fail!", SN);
  4057. Log.WriteErrorLog(ErrMsg);
  4058. goto end;
  4059. }
  4060. }
  4061. else
  4062. {
  4063. ErrMsg = string.Format("{0} Write ROKU production fail!", SN);
  4064. Log.WriteErrorLog(ErrMsg);
  4065. goto end;
  4066. }
  4067. string region = midListNow.rokuCustomer.region;
  4068. Log.WriteInfoLog("Write Roku region...");
  4069. if (SerialCMD.SetROKURegion(TVPort, Encoding.ASCII.GetBytes(region), out result, out data, out error, SerailDelay))
  4070. {
  4071. Log.WriteInfoLog("Check Roku region...");
  4072. if (SerialCMD.CheckROKURegion(TVPort, out result, out data, out error, SerailDelay))
  4073. {
  4074. Log.WriteInfoLog("Read Roku region...");
  4075. if (SerialCMD.GetROKURegion(TVPort, out result, out data, out error, SerailDelay))
  4076. {
  4077. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(region)))
  4078. {
  4079. Log.WriteInfoLog("ROKU region 写入成功:" + Encoding.ASCII.GetString(data));
  4080. }
  4081. else
  4082. {
  4083. ErrMsg = string.Format("{0} Contrast ROKU region fail!", SN);
  4084. Log.WriteErrorLog(ErrMsg);
  4085. goto end;
  4086. }
  4087. }
  4088. else
  4089. {
  4090. ErrMsg = string.Format("{0} Read ROKU region fail!", SN);
  4091. Log.WriteErrorLog(ErrMsg);
  4092. goto end;
  4093. }
  4094. }
  4095. else
  4096. {
  4097. ErrMsg = string.Format("{0} Check ROKU region fail!", SN);
  4098. Log.WriteErrorLog(ErrMsg);
  4099. goto end;
  4100. }
  4101. }
  4102. else
  4103. {
  4104. ErrMsg = string.Format("{0} Write ROKU region fail!", SN);
  4105. Log.WriteErrorLog(ErrMsg);
  4106. goto end;
  4107. }
  4108. string phone = midListNow.rokuCustomer.supportphone;
  4109. Log.WriteInfoLog("Write Roku phone...");
  4110. if (SerialCMD.SetROKUSupportPhone(TVPort, Encoding.ASCII.GetBytes(phone), out result, out data, out error, SerailDelay))
  4111. {
  4112. Log.WriteInfoLog("Check Roku phone...");
  4113. if (SerialCMD.CheckROKUSupportPhone(TVPort, out result, out data, out error, SerailDelay))
  4114. {
  4115. Log.WriteInfoLog("Read Roku phone...");
  4116. if (SerialCMD.GetROKUSupportPhone(TVPort, out result, out data, out error, SerailDelay))
  4117. {
  4118. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(phone)))
  4119. {
  4120. Log.WriteInfoLog("ROKU phone 写入成功:" + Encoding.ASCII.GetString(data));
  4121. }
  4122. else
  4123. {
  4124. ErrMsg = string.Format("{0} Contrast ROKU phone fail!", SN);
  4125. Log.WriteErrorLog(ErrMsg);
  4126. goto end;
  4127. }
  4128. }
  4129. else
  4130. {
  4131. ErrMsg = string.Format("{0} Read ROKU phone fail!", SN);
  4132. Log.WriteErrorLog(ErrMsg);
  4133. goto end;
  4134. }
  4135. }
  4136. else
  4137. {
  4138. ErrMsg = string.Format("{0} Check ROKU phone fail!", SN);
  4139. Log.WriteErrorLog(ErrMsg);
  4140. goto end;
  4141. }
  4142. }
  4143. else
  4144. {
  4145. ErrMsg = string.Format("{0} Write ROKU phone fail!", SN);
  4146. Log.WriteErrorLog(ErrMsg);
  4147. goto end;
  4148. }
  4149. string url = midListNow.rokuCustomer.supporturl;
  4150. Log.WriteInfoLog("Write Roku url...");
  4151. if (SerialCMD.SetROKUSupportURL(TVPort, Encoding.ASCII.GetBytes(url), out result, out data, out error, SerailDelay))
  4152. {
  4153. Log.WriteInfoLog("Check Roku url...");
  4154. if (SerialCMD.CheckROKUSupportURL(TVPort, out result, out data, out error, SerailDelay))
  4155. {
  4156. Log.WriteInfoLog("Read Roku url...");
  4157. if (SerialCMD.GetROKUSupportURL(TVPort, out result, out data, out error, SerailDelay))
  4158. {
  4159. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(url)))
  4160. {
  4161. Log.WriteInfoLog("ROKU url 写入成功:" + Encoding.ASCII.GetString(data));
  4162. }
  4163. else
  4164. {
  4165. ErrMsg = string.Format("{0} Contrast ROKU url fail!", SN);
  4166. Log.WriteErrorLog(ErrMsg);
  4167. goto end;
  4168. }
  4169. }
  4170. else
  4171. {
  4172. ErrMsg = string.Format("{0} Read ROKU url fail!", SN);
  4173. Log.WriteErrorLog(ErrMsg);
  4174. goto end;
  4175. }
  4176. }
  4177. else
  4178. {
  4179. ErrMsg = string.Format("{0} Check ROKU url fail!", SN);
  4180. Log.WriteErrorLog(ErrMsg);
  4181. goto end;
  4182. }
  4183. }
  4184. else
  4185. {
  4186. ErrMsg = string.Format("{0} Write ROKU url fail!", SN);
  4187. Log.WriteErrorLog(ErrMsg);
  4188. goto end;
  4189. }
  4190. if (midListNow.rokuCustomer.remotetype.Length > 0 && midListNow.rokuCustomer.remotetype != "null")
  4191. {
  4192. byte[] remotetype = new byte[1] { Convert.ToByte(midListNow.rokuCustomer.remotetype) };
  4193. Log.WriteInfoLog("Write Roku remotetype...");
  4194. if (SerialCMD.SetROKURemoteType(TVPort, remotetype, out result, out data, out error, SerailDelay))
  4195. {
  4196. Log.WriteInfoLog("Check Roku remotetype...");
  4197. if (SerialCMD.CheckROKURemoteType(TVPort, out result, out data, out error, SerailDelay))
  4198. {
  4199. Log.WriteInfoLog("Read Roku remotetype...");
  4200. if (SerialCMD.GetROKURemoteType(TVPort, out result, out data, out error, SerailDelay))
  4201. {
  4202. if (SerialInit.BytesCompare_Base64(data, remotetype))
  4203. {
  4204. Log.WriteInfoLog("ROKU remotetype 写入成功:" + Encoding.ASCII.GetString(data));
  4205. }
  4206. else
  4207. {
  4208. ErrMsg = string.Format("{0} Contrast ROKU remotetype fail!", SN);
  4209. Log.WriteErrorLog(ErrMsg);
  4210. goto end;
  4211. }
  4212. }
  4213. else
  4214. {
  4215. ErrMsg = string.Format("{0} Read ROKU remotetype fail!", SN);
  4216. Log.WriteErrorLog(ErrMsg);
  4217. goto end;
  4218. }
  4219. }
  4220. else
  4221. {
  4222. ErrMsg = string.Format("{0} Check ROKU remotetype fail!", SN);
  4223. Log.WriteErrorLog(ErrMsg);
  4224. goto end;
  4225. }
  4226. }
  4227. else
  4228. {
  4229. ErrMsg = string.Format("{0} Write ROKU remotetype fail!", SN);
  4230. Log.WriteErrorLog(ErrMsg);
  4231. goto end;
  4232. }
  4233. }
  4234. SetcolorStatus(ProductMsg_Text, Color.FromArgb(128, 255, 128));
  4235. }
  4236. // DSN抄写;
  4237. if (WriteDSN.Checked)
  4238. {
  4239. if (FunctionSettingNow.MITVEnable)
  4240. {// 小米的DSN抄写不用这么多处理;
  4241. if (!CommonMethod.IsNumberAndWord(keyInfo.DSN.data))
  4242. {
  4243. ErrMsg = string.Format("DSN format error!\r\n{0}", keyInfo.DSN.data);
  4244. Log.WriteErrorLog(ErrMsg);
  4245. goto end;
  4246. }
  4247. byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(keyInfo.DSN.data);
  4248. Log.WriteInfoLog("Write DSN...");
  4249. if (SerialCMD.SetFireTVDSN(TVPort, DSNData, out result, out data, out error, SerailDelay))
  4250. {
  4251. SetsuccessStatus(m_writeDSN);
  4252. Log.WriteInfoLog("Check DSN...");
  4253. if (cfg_writecheck.DSNCheckcheck ? SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4254. {
  4255. SetsuccessStatus(m_checkDSN);
  4256. Log.WriteInfoLog("Read DSN...");
  4257. if (cfg_readcheck.DSNReadcheck ? SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4258. {
  4259. if (SerialInit.BytesCompare_Base64(data, DSNData))
  4260. {
  4261. SetsuccessStatus(m_readDSN);
  4262. //DSN读取别对成功
  4263. }
  4264. else
  4265. {
  4266. SetfailStatus(m_readDSN);
  4267. ErrMsg = string.Format("{0} contrast DSN fail!", SN);
  4268. Log.WriteErrorLog(ErrMsg);
  4269. goto end;
  4270. }
  4271. }
  4272. else
  4273. {
  4274. SetfailStatus(m_readDSN);
  4275. ErrMsg = string.Format("{0} read DSN fail!", SN);
  4276. Log.WriteErrorLog(ErrMsg);
  4277. goto end;
  4278. }
  4279. }
  4280. else
  4281. {
  4282. SetfailStatus(m_checkDSN);
  4283. ErrMsg = string.Format("{0} check DSN fail!", SN);
  4284. Log.WriteErrorLog(ErrMsg);
  4285. goto end;
  4286. }
  4287. }
  4288. else
  4289. {
  4290. SetfailStatus(m_writeDSN);
  4291. ErrMsg = string.Format("{0} Write DSN fail!", SN);
  4292. Log.WriteErrorLog(ErrMsg);
  4293. goto end;
  4294. }
  4295. }
  4296. else
  4297. {// 如果是G客户,要在抄写其他key前时行fsn+psn查重处理;
  4298. if (!CommonMethod.IsNumberAndWord(keyInfo.DSN.data))
  4299. {
  4300. ErrMsg = string.Format("DSN format error!\r\n{0}", keyInfo.DSN.data);
  4301. Log.WriteErrorLog(ErrMsg);
  4302. goto end;
  4303. }
  4304. byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(keyInfo.DSN.data);
  4305. Log.WriteInfoLog("Write DSN...");
  4306. if (SerialCMD.SetFireTVDSN(TVPort, DSNData, out result, out data, out error, SerailDelay))
  4307. {
  4308. SetsuccessStatus(m_writeDSN);
  4309. Log.WriteInfoLog("Check DSN...");
  4310. if (cfg_writecheck.DSNCheckcheck ? SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4311. {
  4312. SetsuccessStatus(m_checkDSN);
  4313. Log.WriteInfoLog("Read DSN...");
  4314. if (cfg_readcheck.DSNReadcheck ? SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4315. {
  4316. if (SerialInit.BytesCompare_Base64(data, DSNData))
  4317. {
  4318. //DSN读取别对成功
  4319. SetsuccessStatus(m_readDSN);
  4320. }
  4321. else
  4322. {
  4323. SetfailStatus(m_readDSN);
  4324. ErrMsg = string.Format("{0} contrast DSN fail!", SN);
  4325. Log.WriteErrorLog(ErrMsg);
  4326. goto end;
  4327. }
  4328. }
  4329. else
  4330. {
  4331. SetfailStatus(m_readDSN);
  4332. ErrMsg = string.Format("{0} read DSN fail!", SN);
  4333. Log.WriteErrorLog(ErrMsg);
  4334. goto end;
  4335. }
  4336. }
  4337. else
  4338. {
  4339. SetfailStatus(m_checkDSN);
  4340. ErrMsg = string.Format("{0} check DSN fail!", SN);
  4341. Log.WriteErrorLog(ErrMsg);
  4342. goto end;
  4343. }
  4344. }
  4345. else
  4346. {
  4347. SetfailStatus(m_writeDSN);
  4348. ErrMsg = string.Format("{0} Write DSN fail!", SN);
  4349. Log.WriteErrorLog(ErrMsg);
  4350. goto end;
  4351. }
  4352. }
  4353. keyInfo.DSN.result = true;
  4354. }
  4355. #region 小米FireTV功能;
  4356. if (FunctionSettingNow.MITVEnable)
  4357. {
  4358. // 读取PSN;
  4359. if (SerialCMD.ReadFireTVPSN(TVPort, out result, out data, out error, SerailDelay))
  4360. {
  4361. _MiKey._PSN = Encoding.ASCII.GetString(data);
  4362. }
  4363. else
  4364. {
  4365. ErrMsg = string.Format("读取PSN失败 {0}", error);
  4366. Log.WriteErrorLog(ErrMsg);
  4367. goto end;
  4368. }
  4369. // CVT抄写: Hashkey、HDCP_KEY1.4、HDCP2.2_KEY、CI_PLUS_KEY、ECP_KEY、FVP
  4370. // 激活FVP;
  4371. byte[] FVPData = new byte[] { };
  4372. if (!SerialCMD.ActiveMiFireTVFVP(TVPort, FVPData, out result, out data, out error, SerailDelay))
  4373. {
  4374. ErrMsg = string.Format("激活FVP失败 {0}", error);
  4375. Log.WriteErrorLog(ErrMsg);
  4376. goto end;
  4377. }
  4378. SetsuccessStatus(m_writeFVP);
  4379. if (!SerialCMD.CheckMiFireTVFVP(TVPort, out result, out data, out error, SerailDelay))
  4380. {
  4381. ErrMsg = string.Format("Check FVP失败 {0}", error);
  4382. Log.WriteErrorLog(ErrMsg);
  4383. goto end;
  4384. }
  4385. SetsuccessStatus(m_checkFVP);
  4386. if (cfg_writecheck.HashCheckcheck ? !SerialCMD.CheckFireTVHashkey(TVPort, out result, out data, out error, SerailDelay) : false)
  4387. {
  4388. ErrMsg = string.Format("Check Hashkey失败 {0}", error);
  4389. Log.WriteErrorLog(ErrMsg);
  4390. goto end;
  4391. }
  4392. if (cfg_writecheck.CI_plusCheckcheck ? !SerialCMD.CheckCikey(TVPort, out result, out data, out error, SerailDelay) : false)
  4393. {
  4394. ErrMsg = string.Format("Check Cikey失败 {0}", error);
  4395. Log.WriteErrorLog(ErrMsg);
  4396. goto end;
  4397. }
  4398. if (cfg_writecheck.ECPCheckcheck ? !SerialCMD.CheckECP(TVPort, out result, out data, out error, SerailDelay) : false)
  4399. {
  4400. ErrMsg = string.Format("Check Cikey失败 {0}", error);
  4401. Log.WriteErrorLog(ErrMsg);
  4402. goto end;
  4403. }
  4404. if (cfg_writecheck.HDCPCheckcheck ? !SerialCMD.CheckHDCP(TVPort, out result, out data, out error, SerailDelay) : false)
  4405. {
  4406. ErrMsg = string.Format("Check HDCP 失败 {0}", error);
  4407. Log.WriteErrorLog(ErrMsg);
  4408. goto end;
  4409. }
  4410. if (cfg_writecheck.HDCP22Checkcheck ? !SerialCMD.CheckHDCP22(TVPort, out result, out data, out error, SerailDelay) : false)
  4411. {
  4412. ErrMsg = string.Format("Check HDCP22 失败 {0}", error);
  4413. Log.WriteErrorLog(ErrMsg);
  4414. goto end;
  4415. }
  4416. // 读取HDCP;
  4417. if (cfg_readcheck.HDCPReadcheck ? !SerialCMD.GetHDCPKey(TVPort, out result, out data, out error, SerailDelay) : false)
  4418. {
  4419. ErrMsg = string.Format("读取HDCP失败 {0}", error);
  4420. Log.WriteErrorLog(ErrMsg);
  4421. goto end;
  4422. }
  4423. _MiKey._HDCP14 = cfg_readcheck.HDCPReadcheck ? data.Length : 0;
  4424. // 读取HDCP;
  4425. if (cfg_readcheck.HDCP22Readcheck ? !SerialCMD.GetHDCPKey22(TVPort, out result, out data, out error, SerailDelay) : false)
  4426. {
  4427. ErrMsg = string.Format("读取HDCP22失败 {0}", error);
  4428. Log.WriteErrorLog(ErrMsg);
  4429. goto end;
  4430. }
  4431. _MiKey._HDCP22 = cfg_readcheck.HDCP22Readcheck ? data.Length : 0;
  4432. }
  4433. #endregion
  4434. // 生成IDM报文;
  4435. keycontent = GenerateReportInfo();
  4436. //自定义指令发送
  4437. if (FunctionSettingNow.CustomCMD != null)
  4438. {
  4439. if (FunctionSettingNow.CustomCMD.Count > 0)
  4440. {
  4441. foreach (string cmd in FunctionSettingNow.CustomCMD.Values)
  4442. {
  4443. byte[] Cmddata = SerialInit.HexToByte(cmd);
  4444. TVPort.Write(Cmddata, 0, Cmddata.Count());
  4445. Thread.Sleep(500);
  4446. }
  4447. }
  4448. }
  4449. #region 波兰工厂DHA功能-抄写所有Key后执行Trigger和Check指令;
  4450. if (FunctionSettingNow.DHA == true)
  4451. {
  4452. Log.WriteInfoLog("Start to Trigger DHA...");
  4453. if (SerialCMD.TriggerDHA(TVPort, out result, out data, out error, SerailDelay))
  4454. {
  4455. Thread.Sleep(FunctionSettingNow.CheckDHAWaitTime);
  4456. Log.WriteInfoLog("Start to Check DHA...");
  4457. if (!SerialCMD.CheckDHA(TVPort, out result, out data, out error, SerailDelay))
  4458. {
  4459. ErrMsg = string.Format("{0} Check DHA Fail", SN);
  4460. Log.WriteErrorLog(ErrMsg);
  4461. goto end;
  4462. }
  4463. }
  4464. else
  4465. {
  4466. ErrMsg = string.Format("{0} Trigger DHA Fail", SN);
  4467. Log.WriteErrorLog(ErrMsg);
  4468. goto end;
  4469. }
  4470. }
  4471. #endregion
  4472. #endregion
  4473. //数据上传
  4474. if (midListNow.host == "LocalPC" && !preloadNow)
  4475. {// 离线抄写
  4476. if (GetLocalKeyCount.DeleteLocalKeys(keypath, keyStream, keyReader))
  4477. {
  4478. TestResult = 1;
  4479. UploadCopyCount();
  4480. LocalTxtRecord.LocalRecord(keycontent + "sversionid=" + localmidList.version + "&clienttype=" + localmidList.clienttype + "&ordernum=" + orderNow + "\r\n", orderNow);
  4481. }
  4482. else
  4483. {
  4484. ErrMsg = "Fail to delete local keys";
  4485. Log.WriteErrorLog(ErrMsg);
  4486. goto end;
  4487. }
  4488. }
  4489. else if (preloadNow)
  4490. {// 预绑定抄写;
  4491. //更新DB抄写状态
  4492. if (SQLiteHelper.UpdateCopyStatus(localDBNow, SN, out string copydate))
  4493. {
  4494. UploadCopyCount();
  4495. TestResult = 1;
  4496. }
  4497. else
  4498. {
  4499. ErrMsg = string.Format("{0} update copy record fail!", SN);
  4500. Log.WriteErrorLog(ErrMsg);
  4501. goto end;
  4502. }
  4503. //上传抄写状态
  4504. if (midListNow.host != "LocalPC")
  4505. CommonMethod.UploadPreloadCopyResult(MidAddressNow.host, copydate, SN, localDBNow, errorDBNow, false, "", FunctionSettingNow.ReportTimeOut);
  4506. }
  4507. else if (!CommonMethod.HTTPChecker(midListNow.host))
  4508. {
  4509. Log.WriteGetKeyLog("Order:" + orderNow + " host is null,scanning sn:" + SN);
  4510. TestResult = 1;
  4511. UploadCopyCount();
  4512. UpdateKeys(midListNow.keytype, false);
  4513. }
  4514. else
  4515. {// 在线抄写;
  4516. if (WriteDID.Checked)
  4517. {
  4518. if (CommonMethod.UploadCopyResult(keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow, midListNow.host + "/report.do?", errorDBNow, orderNow, false, "", FunctionSettingNow.ReportTimeOut))
  4519. TestResult = 1;
  4520. else
  4521. {
  4522. TestResult = 0;
  4523. UploadCopyCount();
  4524. ErrMsg = "上报结果到MID系统失败";
  4525. Log.WriteErrorLog(ErrMsg);
  4526. UpdateKeys(midListNow.keytype, false);
  4527. goto end;
  4528. }
  4529. }
  4530. else
  4531. {
  4532. if (SN.Trim().Length > 0)
  4533. {
  4534. keycontent += "nodid=true&";
  4535. if (CommonMethod.UploadCopyResult(keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow, midListNow.host + "/report.do?", errorDBNow, orderNow, false, "", FunctionSettingNow.ReportTimeOut))
  4536. TestResult = 1;
  4537. else
  4538. {
  4539. TestResult = 0;
  4540. UploadCopyCount();
  4541. ErrMsg = "上报结果到MID系统失败";
  4542. Log.WriteErrorLog(ErrMsg);
  4543. UpdateKeys(midListNow.keytype, false);
  4544. goto end;
  4545. }
  4546. }
  4547. else
  4548. {
  4549. LocalTxtRecord.LocalRecord(midListNow.host + "/report.do?\r\n" + keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow + "\r\n\r\n", orderNow);
  4550. if (FunctionSettingNow.AllowNoScanning)
  4551. {
  4552. TestResult = 1;
  4553. }
  4554. else
  4555. {
  4556. ErrMsg = "未扫码启动数据抄写";
  4557. Log.WriteErrorLog(ErrMsg);
  4558. MessageBox.Show("You must scan to start the burning!");
  4559. TestResult = 0;
  4560. }
  4561. }
  4562. }
  4563. // 上报完成后,更新本地数据库Key的数量;
  4564. UploadCopyCount();
  4565. // 同时,在线更新Key数量;
  4566. UpdateKeys(midListNow.keytype, false);
  4567. }
  4568. if (FunctionSettingNow.ExportSNACASID)
  4569. {
  4570. SerialCMD.ReadJapaneseACASID(TVPort, out result, out data, out error, SerailDelay);
  4571. CommonMethod.ExportSNACASID(orderNow, SN, Encoding.ASCII.GetString(data));
  4572. }
  4573. #region 小米FireTV功能;
  4574. if (FunctionSettingNow.MITVEnable)
  4575. {
  4576. if (!ReportMIInfo(out error))
  4577. {
  4578. TestResult = 0;
  4579. ErrMsg = string.Format("{0} ReportMIInfo ini fail! {1}", SN, error);
  4580. Log.WriteErrorLog(ErrMsg);
  4581. goto end;
  4582. }
  4583. }
  4584. #endregion
  4585. Thread.Sleep(FunctionSettingNow.Wait_after_completion);
  4586. SetsuccessStatus(ResultStatus);
  4587. end:
  4588. #region 只有惠州工厂才启用G客户防呆措施;
  4589. if (FunctionSettingNow.NTF)
  4590. {
  4591. string strLastResult = "";
  4592. string strLastSN = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastGSN", "");
  4593. if (strLastSN.Equals(SN, StringComparison.OrdinalIgnoreCase))
  4594. {
  4595. if (TestResult == 0)
  4596. {
  4597. int lastCount = 0;
  4598. // 更新连续测试中累计失败的次数
  4599. string strFailCount = CommonMethod.ReadProfileString("MOKAFactoryTools", "GFailCount", "0");
  4600. int.TryParse(strFailCount, out lastCount);
  4601. CommonMethod.WriteProfileString("MOKAFactoryTools", "GFailCount", (++lastCount).ToString());
  4602. if (lastCount >= 2)
  4603. {// 累计2次Fail;
  4604. ShowVerifyDelegate("累计2次测试失败,禁止再测试,请做好坏机标记");
  4605. }
  4606. }
  4607. // 获取上一次抄写状态;
  4608. strLastResult = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastGResult", "");
  4609. // 更新抄写结果;
  4610. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastGResult", TestResult != 0 ? "1" : "0");
  4611. }
  4612. else
  4613. {
  4614. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastGSN", SN);
  4615. // 重置连续测试中累计失败的次数为0;
  4616. CommonMethod.WriteProfileString("MOKAFactoryTools", "GFailCount", TestResult == 0 ? "1" : "0");
  4617. // 更新抄写状态;
  4618. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastGResult", TestResult != 0 ? "1" : "0");
  4619. // 如果是试产NTF,且第一次测试就Fail,提示再测试多一次;
  4620. if (TestResult == 0 && nOrderType == 0)
  4621. {
  4622. Log.WriteErrorLog("试产订单:请再测试一次\r\n第一次测试为FAIL,请再测试确认结果!");
  4623. ShowVerifyDelegate("试产订单:请再测试一次\r\n第一次测试为FAIL,请再测试确认结果!");
  4624. }
  4625. }
  4626. if (strLastResult.ToString().Equals("0") && (TestResult == 1) && (nOrderType == 0))
  4627. {
  4628. // 上次抄写是失败,这次是成功的,试产NTF要再次要求抄写一次才能上报AMTest.
  4629. ErrMsg = "试产订单:请再测试一次\r\n上一次测试为FAIL,需要连续2次PASS,请再测试确认结果!";
  4630. Log.WriteErrorLog(ErrMsg);
  4631. ShowVerifyDelegate(ErrMsg);
  4632. // 仍设置为失败;
  4633. TestResult = 2;
  4634. }
  4635. if (!ntfBLL.SetDataBuringResult(FunctionSettingNow.Line, FunctionSettingNow.Station, SN, keyInfo.DSN, TestResult == 0 ? false : true, strLastSN, nOrderType, TestResult == 0 ? ErrMsg : ""))
  4636. {
  4637. //ntf失败,也需要提示;
  4638. ErrMsg = string.Format("统计NTF失败:{0}", SN);
  4639. Log.WriteErrorLog(ErrMsg);
  4640. TestResult = 0;
  4641. }
  4642. else
  4643. {
  4644. if ((TestResult == 1) && ntfBLL.ResultType.Equals("NTF", StringComparison.OrdinalIgnoreCase))
  4645. {
  4646. // TestResut == 0 && TestResut == 2时,也不提示NTF;
  4647. ErrMsg = string.Format("结果类型为NTF,请将产品做好NTF标记:{0}", SN);
  4648. ShowVerifyDelegate(ErrMsg);
  4649. }
  4650. }
  4651. if (TestResult != 2)
  4652. { // 上报抄写结果到MES系统中;
  4653. string strOutMsg;
  4654. string returnObject;
  4655. if (!CommonMethod.ReportDataBurningResultToMES(SN, keyInfo.DSN, (TestResult != 0) ? "Pass" : "Fail", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), errorDBNow, out strOutMsg, out returnObject))
  4656. {
  4657. ErrMsg = string.Format("上报抄写结果到MES失败,请紧急处理:{0}", strOutMsg);
  4658. Log.WriteErrorLog(ErrMsg);
  4659. // 上报MES失败,重置为False
  4660. TestResult = 0;
  4661. }
  4662. // 将测试结果保存到Kayla要求的csv文件中;
  4663. CommonMethod.GeneratKaylaData(FunctionSettingNow.Line, FunctionSettingNow.Station, OrderText.Text, SN, startTime, DateTime.Now, returnObject, keyInfo, TestResult != 0 ? true : false);
  4664. }
  4665. }
  4666. #endregion
  4667. if (TestResult == 0)
  4668. {
  4669. if (ErrMsg == "")
  4670. ErrMsg = error;
  4671. SetfailStatus(ResultStatus);
  4672. if (midListNow.host == "LocalPC" && !preloadNow)
  4673. {
  4674. GetLocalKeyCount.UnlockLocalKeys(keypath, keyStream, keyReader);
  4675. }
  4676. // 启动NG弹框功能;
  4677. ShowVerifyDelegate(ErrMsg);
  4678. Thread.Sleep(300);
  4679. }
  4680. if (midListNow.host == "LocalPC" && !preloadNow)
  4681. {
  4682. GetLocalKeysCount();
  4683. }
  4684. timer1.Stop();
  4685. usingTime = 0;
  4686. EnableText(SNText);
  4687. EnableButton(BtnClickstart);
  4688. SN = "";
  4689. }
  4690. /// <summary>
  4691. /// 显示白平衡配置
  4692. /// </summary>
  4693. /// <param name="sender"></param>
  4694. /// <param name="e"></param>
  4695. private void OnBtnWBView(object sender, EventArgs e)
  4696. {
  4697. SNText.Focus();
  4698. if (FunctionSettingNow.WriteWB)
  4699. {
  4700. MessageBox.Show("NormalR:" + FunctionSettingNow.NormalRGB[0] + "\r\nNormalG:" + FunctionSettingNow.NormalRGB[1] + "\r\nNormalB:" + FunctionSettingNow.NormalRGB[2] + "\r\nCoolR:" + FunctionSettingNow.CoolRGB[0] + "\r\nCoolG:" + FunctionSettingNow.CoolRGB[1] + "\r\nCoolB:" + FunctionSettingNow.CoolRGB[2] + "\r\nWarmR:" + FunctionSettingNow.WarmRGB[0] + "\r\nWarmG:" + FunctionSettingNow.WarmRGB[1] + "\r\nWarmB:" + FunctionSettingNow.WarmRGB[2]);
  4701. }
  4702. else
  4703. {
  4704. MessageBox.Show(LResource.WBNoSet);
  4705. }
  4706. }
  4707. /// <summary>
  4708. /// 更新key的状态
  4709. /// </summary>
  4710. /// <param name="keys">GetMIDInfo的keytype字典</param>
  4711. /// <returns></returns>
  4712. public bool UpdateKeys(Dictionary<string, string> keys, bool autokey)
  4713. {
  4714. if (keys.ContainsKey("DeviceID"))
  4715. {
  4716. if (cfg_writedone.DIDWrite_YesNo)
  4717. SetCheckboxStatus(WriteDID, true);
  4718. UpdateKeyCountOnline("DeviceID", midListNow.clienttype, autokey);
  4719. }
  4720. if (keys.ContainsKey("MAC"))
  4721. {
  4722. if (cfg_writedone.MacWrite_YesNo)
  4723. SetCheckboxStatus(WriteMac, true);
  4724. UpdateKeyCountOnline("MAC", keys["MAC"], autokey);
  4725. }
  4726. if (keys.ContainsKey("HDCP_KEY"))
  4727. {
  4728. if (cfg_writedone.HDCPWrite_YesNo)
  4729. SetCheckboxStatus(WriteHDCP, true);
  4730. UpdateKeyCountOnline("HDCP_KEY", keys["HDCP_KEY"], autokey);
  4731. }
  4732. if (keys.ContainsKey("CI_PLUS_KEY"))
  4733. {
  4734. if (cfg_writedone.CI_plusWrite_YesNo)
  4735. SetCheckboxStatus(WriteCiplus, true);
  4736. UpdateKeyCountOnline("CI_PLUS_KEY", keys["CI_PLUS_KEY"], autokey);
  4737. }
  4738. if (keys.ContainsKey("WiDi"))
  4739. {
  4740. if (cfg_writedone.WiDiWrite_YesNo)
  4741. SetCheckboxStatus(WriteWiDi, true);
  4742. UpdateKeyCountOnline("WiDi", keys["WiDi"], autokey);
  4743. }
  4744. if (keys.ContainsKey("Widevine_KEY"))
  4745. {
  4746. if (cfg_writedone.WidevineWrite_YesNo)
  4747. SetCheckboxStatus(WriteWidevine, true);
  4748. UpdateKeyCountOnline("Widevine_KEY", keys["Widevine_KEY"], autokey);
  4749. }
  4750. if (keys.ContainsKey("HDCP2.2_KEY"))
  4751. {
  4752. if (cfg_writedone.HDCP22Write_YesNo)
  4753. SetCheckboxStatus(WriteHDCP22, true);
  4754. UpdateKeyCountOnline("HDCP2.2_KEY", keys["HDCP2.2_KEY"], autokey);
  4755. }
  4756. if (keys.ContainsKey("NETFILX_ESN"))
  4757. {
  4758. if (cfg_writedone.ESNWrite_YesNo)
  4759. SetCheckboxStatus(WriteESN, true);
  4760. UpdateKeyCountOnline("NETFILX_ESN", keys["NETFILX_ESN"], autokey);
  4761. }
  4762. if (keys.ContainsKey("Attestation_key"))
  4763. {
  4764. if (cfg_writedone.AttestationWrite_YesNo)
  4765. SetCheckboxStatus(WriteAttestation, true);
  4766. UpdateKeyCountOnline("Attestation_key", keys["Attestation_key"], autokey);
  4767. }
  4768. if (keys.ContainsKey("MGK_KEY"))
  4769. {
  4770. if (cfg_writedone.MGKWrite_YesNo)
  4771. SetCheckboxStatus(WriteMGK, true);
  4772. UpdateKeyCountOnline("MGK_KEY", keys["MGK_KEY"], autokey);
  4773. }
  4774. if (keys.ContainsKey("Fairplay_KEY"))
  4775. {
  4776. if (cfg_writedone.FairplayWrite_YesNo)
  4777. SetCheckboxStatus(WriteFairplay, true);
  4778. UpdateKeyCountOnline("Fairplay_KEY", keys["Fairplay_KEY"], autokey);
  4779. }
  4780. if (keys.ContainsKey("ECP_KEY"))
  4781. {
  4782. if (cfg_writedone.ECPWrite_YesNo)
  4783. SetCheckboxStatus(WriteECP, true);
  4784. UpdateKeyCountOnline("ECP_KEY", keys["ECP_KEY"], autokey);
  4785. }
  4786. if (keys.ContainsKey("WiFi_MAC"))
  4787. {
  4788. if (cfg_writedone.WifiMacWrite_YesNo)
  4789. SetCheckboxStatus(WriteWifiMac, true);
  4790. UpdateKeyCountOnline("WiFi_MAC", keys["WiFi_MAC"], autokey);
  4791. }
  4792. if (keys.ContainsKey("BT_MAC"))
  4793. {
  4794. if (cfg_writedone.BTMacWrite_YesNo)
  4795. SetCheckboxStatus(WriteBTMac, true);
  4796. UpdateKeyCountOnline("BT_MAC", keys["BT_MAC"], autokey);
  4797. }
  4798. if (keys.ContainsKey("LEK"))
  4799. {
  4800. if (cfg_writedone.LEKWrite_YesNo)
  4801. SetCheckboxStatus(WriteLEK, true);
  4802. UpdateKeyCountOnline("LEK", keys["LEK"], false);
  4803. }
  4804. if (keys.ContainsKey("PEK"))
  4805. {
  4806. if (cfg_writedone.PEKWrite_YesNo)
  4807. SetCheckboxStatus(WritePEK, true);
  4808. UpdateKeyCountOnline("PEK", keys["PEK"], false);
  4809. }
  4810. if (keys.ContainsKey("PlayReady_key"))
  4811. {
  4812. if (cfg_writedone.PlayreadyWrite_YesNo)
  4813. SetCheckboxStatus(WritePlayready, true);
  4814. UpdateKeyCountOnline("PlayReady_key", keys["PlayReady_key"], false);
  4815. }
  4816. if (keys.ContainsKey("Hashkey"))
  4817. {
  4818. if (cfg_writedone.HashWrite_YesNo)
  4819. SetCheckboxStatus(WriteHash, true);
  4820. UpdateKeyCountOnline("Hashkey", keys["Hashkey"], false);
  4821. }
  4822. if (keys.ContainsKey("YouTube_KEY"))
  4823. {
  4824. if (cfg_writedone.YouTubeWrite_YesNo)
  4825. SetCheckboxStatus(WriteYouTube, true);
  4826. UpdateKeyCountOnline("YouTube_KEY", keys["YouTube_KEY"], false);
  4827. }
  4828. if (keys.ContainsKey("DSN"))
  4829. {
  4830. if (cfg_writedone.DSNWrite_YesNo)
  4831. SetCheckboxStatus(WriteDSN, true);
  4832. }
  4833. if (keys.ContainsKey("edid_pid"))
  4834. {
  4835. if (cfg_writedone.EDIDPIDWrite_YesNo)
  4836. SetCheckboxStatus(WriteEDIDPID, true);
  4837. }
  4838. if (keys.ContainsKey("edid_model_name"))
  4839. {
  4840. if (cfg_writedone.EDIDModeNameWrite_YesNo)
  4841. SetCheckboxStatus(WriteEDIDName, true);
  4842. }
  4843. if (keys.ContainsKey("ACAS_KEY"))
  4844. {
  4845. if (cfg_writedone.ACASKeyWrite_YesNo)
  4846. SetCheckboxStatus(WriteACASKey, true);
  4847. UpdateKeyCountOnline("ACAS_KEY", keys["ACAS_KEY"], false);
  4848. }
  4849. if (keys.ContainsKey("DAK"))
  4850. {
  4851. if (cfg_writedone.DAKWrite_YesNo)
  4852. SetCheckboxStatus(WriteDAK, true);
  4853. UpdateKeyCountOnline("DAK", keys["DAK"], false);
  4854. }
  4855. return true;
  4856. }
  4857. /// <summary>
  4858. /// 在线获取key数量,更新Keycount
  4859. /// </summary>
  4860. /// <param name="key">key种类</param>
  4861. /// <param name="keytype">key的具体类型</param>
  4862. /// <returns></returns>
  4863. public bool UpdateKeyCountOnline(string key, string keytype, bool autokey)
  4864. {
  4865. return true;
  4866. }
  4867. /// <summary>
  4868. /// 按键触发在线抄写
  4869. /// 注意:此按键的作用是给不需要输入SN号的工厂使用;
  4870. /// </summary>
  4871. /// <param name="sender"></param>
  4872. /// <param name="e"></param>
  4873. private void OnBtnClickStart(object sender, EventArgs e)
  4874. {
  4875. SN = ""; // SN置为空,用于不需要扫码SN的某些工厂;
  4876. keyInfo = new KeyInfo();
  4877. if (preloadNow)
  4878. {
  4879. MessageBox.Show(LResource.PreloadError, LResource.Error);
  4880. return;
  4881. }
  4882. SetInitialStatus();
  4883. BtnClickstart.Enabled = false;
  4884. SNText.Enabled = false;
  4885. Onlinemode();
  4886. }
  4887. /// <summary>
  4888. /// 在线获取key的方式抄写
  4889. /// </summary>
  4890. public void Onlinemode()
  4891. {
  4892. keyInfo.DID.enable = WriteDID.Checked = (WriteDID.Checked && m_writedid.Text != LResource.Skip);
  4893. keyInfo.Mac.enable = WriteMac.Checked = (WriteMac.Checked && m_writemac.Text != LResource.Skip);
  4894. keyInfo.HDCP.enable = WriteHDCP.Checked = (WriteHDCP.Checked && m_writehdcp.Text != LResource.Skip);
  4895. keyInfo.HDCP22.enable = WriteHDCP22.Checked = (WriteHDCP22.Checked && m_writehdcp22.Text != LResource.Skip);
  4896. keyInfo.WiDi.enable = WriteWiDi.Checked = (WriteWiDi.Checked && m_writewidi.Text != LResource.Skip);
  4897. keyInfo.Widevine.enable = WriteWidevine.Checked = (WriteWidevine.Checked && m_writewidevine.Text != LResource.Skip);
  4898. keyInfo.ESN.enable = WriteESN.Checked = (WriteESN.Checked && m_writeesn.Text != LResource.Skip);
  4899. keyInfo.CI_plus.enable = WriteCiplus.Checked = (WriteCiplus.Checked && m_writeci.Text != LResource.Skip);
  4900. keyInfo.Attestation.enable = WriteAttestation.Checked = (WriteAttestation.Checked && m_writeattestation.Text != LResource.Skip);
  4901. keyInfo.MGK.enable = WriteMGK.Checked = (WriteMGK.Checked && m_writeMGK.Text != LResource.Skip);
  4902. keyInfo.WiFi_MAC.enable = WriteWifiMac.Checked = (WriteWifiMac.Checked && m_writeWifiMac.Text != LResource.Skip);
  4903. keyInfo.BT_MAC.enable = WriteBTMac.Checked = (WriteBTMac.Checked && m_writeBTMac.Text != LResource.Skip);
  4904. keyInfo.ECP.enable = WriteECP.Checked = (WriteECP.Checked && m_writeECP.Text != LResource.Skip);
  4905. keyInfo.LEK.enable = WriteLEK.Checked = (WriteLEK.Checked && m_writeLEK.Text != LResource.Skip);
  4906. keyInfo.PEK.enable = WritePEK.Checked = (WritePEK.Checked && m_writePEK.Text != LResource.Skip);
  4907. keyInfo.Playready.enable = WritePlayready.Checked = (WritePlayready.Checked && m_writePlayready.Text != LResource.Skip);
  4908. keyInfo.Hashkey.enable = WriteHash.Checked = (WriteHash.Checked && m_writeHash.Text != LResource.Skip);
  4909. keyInfo.YouTube_KEY.enable = WriteYouTube.Checked = (WriteYouTube.Checked && m_writeYouTube.Text != LResource.Skip);
  4910. keyInfo.EDIDPid.enable = WriteEDIDPID.Checked = (WriteEDIDPID.Checked && m_writeEDIDPID.Text != LResource.Skip);
  4911. keyInfo.EDIDModelName.enable = WriteEDIDName.Checked = (WriteEDIDName.Checked && m_writeEDIDName.Text != LResource.Skip);
  4912. keyInfo.ACASKey_Data.enable = WriteACASKey.Checked = (WriteACASKey.Checked && m_writeACASKey.Text != LResource.Skip);
  4913. keyInfo.DAK.enable = WriteDAK.Checked = (WriteDAK.Checked && WriteDAK.Text != LResource.Skip);
  4914. bool preloadresult = false;
  4915. preloadresult = true;
  4916. timer1.Start();
  4917. UpdateKeys(midListNow.keytype, true);
  4918. WritekeyThread = new Thread(Writekey);
  4919. WritekeyThread.Start();
  4920. if (!preloadresult)
  4921. {
  4922. SNText.Enabled = true;
  4923. }
  4924. }
  4925. /// <summary>
  4926. /// 更新订单抄写数量
  4927. /// </summary>
  4928. /// <returns></returns>
  4929. public bool UploadCopyCount()
  4930. {
  4931. return (SQLiteHelper.UpdateProductionNum(errorDBNow, orderNow));
  4932. }
  4933. /// <summary>
  4934. /// 获取定制化抄写信息
  4935. /// </summary>
  4936. /// <param name="sender"></param>
  4937. /// <param name="e"></param>
  4938. private void OnBtnOtherView(object sender, EventArgs e)
  4939. {
  4940. if (midListNow.rokuCustomer != null)
  4941. MessageBox.Show("Roku TV\r\n" + "Brand:" + midListNow.rokuCustomer.brand + "\r\nOEM Model:" + midListNow.rokuCustomer.oemmodel + "\r\nDate:" + midListNow.rokuCustomer.productiondate + "\r\nRegion:" + midListNow.rokuCustomer.region + "\r\nPhone:" + midListNow.rokuCustomer.supportphone + "\r\nUrl:" + midListNow.rokuCustomer.supporturl + "\r\nRemote Type:" + midListNow.rokuCustomer.remotetype, LResource.ProductMsg);
  4942. else
  4943. MessageBox.Show("null");
  4944. }
  4945. /// <summary>
  4946. /// 获取本地key数量
  4947. /// </summary>
  4948. public void GetLocalKeysCount()
  4949. {
  4950. int didnum;
  4951. if (GetLocalKeyCount.GetLocalDidCount(orderNow, out didnum, ref localmidList, errorDBNow))
  4952. {
  4953. SetCheckboxStatus(WriteDID, true);
  4954. if (didnum != -1)
  4955. SetKeyCountStatus(DIDCount, didnum.ToString(), 0);
  4956. else
  4957. SetKeyCountStatus(DIDCount, "Read error", 1);
  4958. }
  4959. int macnum;
  4960. if (GetLocalKeyCount.GetLocalMacCount(orderNow, out macnum, ref localmidList, errorDBNow))
  4961. {
  4962. SetCheckboxStatus(WriteMac, true);
  4963. if (macnum != -1)
  4964. SetKeyCountStatus(MacCount, macnum.ToString(), 0);
  4965. else
  4966. SetKeyCountStatus(MacCount, "Read error", 1);
  4967. }
  4968. int hdcpnum;
  4969. if (GetLocalKeyCount.GetLocalHDCPKEYCount(orderNow, out hdcpnum))
  4970. {
  4971. SetCheckboxStatus(WriteHDCP, true);
  4972. if (hdcpnum != -1)
  4973. SetKeyCountStatus(HDCPCount, hdcpnum.ToString(), 0);
  4974. else
  4975. SetKeyCountStatus(HDCPCount, "Read error", 1);
  4976. }
  4977. int widinum;
  4978. if (GetLocalKeyCount.GetLocalWiDiCount(orderNow, out widinum))
  4979. {
  4980. SetCheckboxStatus(WriteWiDi, true);
  4981. if (widinum != -1)
  4982. SetKeyCountStatus(WidiCount, widinum.ToString(), 0);
  4983. else
  4984. SetKeyCountStatus(WidiCount, "Read error", 1);
  4985. }
  4986. int hdcp22num;
  4987. if (GetLocalKeyCount.GetLocalHDCPKEY22Count(orderNow, out hdcp22num))
  4988. {
  4989. SetCheckboxStatus(WriteHDCP22, true);
  4990. if (hdcp22num != -1)
  4991. SetKeyCountStatus(HDCP22Count, hdcp22num.ToString(), 0);
  4992. else
  4993. SetKeyCountStatus(HDCP22Count, "Read error", 1);
  4994. }
  4995. int esnnum;
  4996. if (GetLocalKeyCount.GetLocalESNCount(orderNow, out esnnum))
  4997. {
  4998. SetCheckboxStatus(WriteESN, true);
  4999. if (esnnum != -1)
  5000. SetKeyCountStatus(ESNCount, esnnum.ToString(), 0);
  5001. else
  5002. SetKeyCountStatus(ESNCount, "Read error", 1);
  5003. }
  5004. int widevinenum;
  5005. if (GetLocalKeyCount.GetLocalWidevineCount(orderNow, out widevinenum))
  5006. {
  5007. SetCheckboxStatus(WriteWidevine, true);
  5008. if (widevinenum != -1)
  5009. SetKeyCountStatus(WideVineCount, widevinenum.ToString(), 0);
  5010. else
  5011. SetKeyCountStatus(WideVineCount, "Read error", 1);
  5012. }
  5013. int cinum;
  5014. if (GetLocalKeyCount.GetLocalCIKEYCount(orderNow, out cinum))
  5015. {
  5016. SetCheckboxStatus(WriteCiplus, true);
  5017. if (cinum != -1)
  5018. SetKeyCountStatus(CICount, cinum.ToString(), 0);
  5019. else
  5020. SetKeyCountStatus(CICount, "Read error", 1);
  5021. }
  5022. int mgknum;
  5023. if (GetLocalKeyCount.GetLocalMGKCount(orderNow, out mgknum))
  5024. {
  5025. SetCheckboxStatus(WriteMGK, true);
  5026. if (mgknum != -1)
  5027. SetKeyCountStatus(MGKCount, mgknum.ToString(), 0);
  5028. else
  5029. SetKeyCountStatus(MGKCount, "Read error", 1);
  5030. }
  5031. int attestationnum;
  5032. if (GetLocalKeyCount.GetLocalAttestationCount(orderNow, out attestationnum))
  5033. {
  5034. SetCheckboxStatus(WriteAttestation, true);
  5035. if (attestationnum != -1)
  5036. SetKeyCountStatus(AttestationCount, attestationnum.ToString(), 0);
  5037. else
  5038. SetKeyCountStatus(AttestationCount, "Read error", 1);
  5039. }
  5040. int fairplaynum;
  5041. if (GetLocalKeyCount.GetLocalFairplayCount(orderNow, out fairplaynum))
  5042. {
  5043. SetCheckboxStatus(WriteFairplay, true);
  5044. if (fairplaynum != -1)
  5045. SetKeyCountStatus(FairplayCount, fairplaynum.ToString(), 0);
  5046. else
  5047. SetKeyCountStatus(FairplayCount, "Read error", 1);
  5048. }
  5049. int leknum;
  5050. fireTVKey.LEK = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "LEK", out leknum);
  5051. int peknum;
  5052. fireTVKey.PEK = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "PEK", out peknum);
  5053. int palyreadynum;
  5054. fireTVKey.Playready = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "Playready", out palyreadynum);
  5055. int hashkeynum;
  5056. fireTVKey.Hashkey = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "Hashkey", out hashkeynum);
  5057. }
  5058. /// <summary>
  5059. /// 抄写用时计数
  5060. /// </summary>
  5061. /// <param name="sender"></param>
  5062. /// <param name="e"></param>
  5063. private void timer1_Tick(object sender, EventArgs e)
  5064. {
  5065. usingTime += 1;
  5066. UsingTime_Text.Text = usingTime.ToString();
  5067. }
  5068. /// <summary>
  5069. /// 取消SN扫描框聚焦
  5070. /// </summary>
  5071. /// <param name="sender"></param>
  5072. /// <param name="e"></param>
  5073. private void SNText_DoubleClick(object sender, EventArgs e)
  5074. {
  5075. FocusMark = false;
  5076. this.CaptionBackColorTop = Color.RoyalBlue;
  5077. this.CaptionBackColorBottom = Color.Cyan;
  5078. this.Refresh();
  5079. }
  5080. /// <summary>
  5081. /// 强制刷新抄写线程
  5082. /// </summary>
  5083. private void OnBtnRefresh(object sender, EventArgs e)
  5084. {
  5085. usingTime = 0;
  5086. EnableText(SNText);
  5087. EnableButton(BtnClickstart);
  5088. SN = "";
  5089. keyInfo = new KeyInfo();
  5090. SetInitialStatus();
  5091. if (WritekeyThread != null)
  5092. {
  5093. if (WritekeyThread.IsAlive)
  5094. {
  5095. WritekeyThread.Abort();
  5096. if (timer1.Enabled)
  5097. {
  5098. timer1.Stop();
  5099. }
  5100. while (WritekeyThread.ThreadState != System.Threading.ThreadState.Aborted)
  5101. {
  5102. Thread.Sleep(100);
  5103. }
  5104. }
  5105. }
  5106. UsingTime_Text.Text = "0";
  5107. GC.Collect();
  5108. MessageBox.Show(LResource.RefreshPanel);
  5109. }
  5110. /// <summary>
  5111. /// 显示订单key可用余量
  5112. /// </summary>
  5113. /// <param name="sender"></param>
  5114. /// <param name="e"></param>
  5115. private void OrderText_MouseEnter(object sender, EventArgs e)
  5116. {
  5117. toolTip1.SetToolTip(OrderText, LResource.AvailableKey + availableCount);
  5118. }
  5119. }
  5120. }