OperationPanel.cs 245 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395
  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. // 如果是抄写EDID,则不获取白平衡数据;
  2167. if (CommonMethod.IsEDIDCopy(midListNow))
  2168. {
  2169. SetspecificText(SoftwareVersionNote, LResource.SkipChecking, Color.Yellow);
  2170. SetspecificText(ClientTypeNote, LResource.SkipChecking, Color.Yellow);
  2171. if (midListNow.projectid.Equals("0"))
  2172. SetspecificText(ProjectIDNote, LResource.SkipCovering, Color.Yellow);
  2173. }
  2174. //检查Software version
  2175. if (SoftwareVersionNote.Text != LResource.SkipChecking)
  2176. {
  2177. Log.WriteInfoLog("Check software version...\r\n");
  2178. if (SerialCMD.GetSoftVersion(TVPort, out result, out data, out error, SerailDelay))
  2179. {
  2180. string sfv = Encoding.ASCII.GetString(data);
  2181. if (sfv != SVText.Text)
  2182. {
  2183. MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
  2184. DialogResult dr = MessageBox.Show(LResource.MainboardFV + sfv + LResource.differentfromserver + SVText.Text + "\r\n" + LResource.SkipFVChecking, LResource.Error, messButton);
  2185. if (dr == DialogResult.OK)
  2186. {
  2187. SetspecificText(SoftwareVersionNote, LResource.SkipChecking, Color.Yellow);
  2188. SetcolorStatus(SVText, Color.Yellow);
  2189. }
  2190. else
  2191. {
  2192. SetspecificText(SoftwareVersionNote, sfv, Color.Red);
  2193. SetcolorStatus(SVText, Color.Red);
  2194. goto end;
  2195. }
  2196. }
  2197. else
  2198. {
  2199. SetcolorStatus(SVText, Color.FromArgb(128, 255, 128));
  2200. }
  2201. }
  2202. else
  2203. {
  2204. ErrMsg = string.Format("{0} Read software version fail!", SN);
  2205. Log.WriteErrorLog(ErrMsg);
  2206. goto end;
  2207. }
  2208. }
  2209. //DID抄写
  2210. if (WriteDID.Checked)
  2211. {
  2212. if (!CommonMethod.IsNumberAndWord(keyInfo.DID.data))
  2213. {
  2214. ErrMsg = string.Format("DID format error!\r\n{0}", keyInfo.DID.data);
  2215. Log.WriteErrorLog(ErrMsg);
  2216. goto end;
  2217. }
  2218. byte[] DIDData = Encoding.ASCII.GetBytes(keyInfo.DID.data);
  2219. Log.WriteInfoLog("Write DID...");
  2220. if (SerialCMD.SetDeviceID(TVPort, DIDData, out result, out data, out error, SerailDelay))
  2221. {
  2222. SetsuccessStatus(m_writedid);
  2223. Log.WriteInfoLog("Check DID...");
  2224. if (cfg_writecheck.DIDCheckcheck ? SerialCMD.CheckDeviceId(TVPort, out result, out data, out error, SerailDelay) : true)
  2225. {
  2226. SetsuccessStatus(m_checkdid);
  2227. Log.WriteInfoLog("Read DID...");
  2228. if (cfg_readcheck.DIDReadcheck ? SerialCMD.GetDeviceId(TVPort, out result, out data, out error, SerailDelay) : true)
  2229. {
  2230. if (cfg_readcheck.DIDReadcheck)
  2231. {
  2232. if (SerialInit.BytesCompare_Base64(data, DIDData))
  2233. {
  2234. SetsuccessStatus(m_readdid);
  2235. }
  2236. else
  2237. {
  2238. SetfailStatus(m_readdid);
  2239. ErrMsg = string.Format("{0} contrast DID fail!", SN);
  2240. Log.WriteErrorLog(ErrMsg);
  2241. goto end; ;
  2242. }
  2243. }
  2244. }
  2245. else
  2246. {
  2247. SetfailStatus(m_readdid);
  2248. ErrMsg = string.Format("{0} read DID fail!", SN);
  2249. Log.WriteErrorLog(ErrMsg);
  2250. goto end;
  2251. }
  2252. }
  2253. else
  2254. {
  2255. SetfailStatus(m_checkdid);
  2256. ErrMsg = string.Format("{0} check DID fail!", SN);
  2257. Log.WriteErrorLog(ErrMsg);
  2258. goto end;
  2259. }
  2260. }
  2261. else
  2262. {
  2263. SetfailStatus(m_writedid);
  2264. ErrMsg = string.Format("{0} Write DID fail!", SN);
  2265. Log.WriteErrorLog(ErrMsg);
  2266. goto end;
  2267. }
  2268. keyInfo.DID.result = true;
  2269. }
  2270. //Eth_Mac抄写
  2271. if (WriteMac.Checked)
  2272. {
  2273. string mac = keyInfo.Mac.data.Replace("-", "");
  2274. if (FunctionSettingNow.MITVEnable == true)
  2275. mac = keyInfo.Mac.data.Replace(":", "");
  2276. if (!CommonMethod.IsNumberAndWord(mac))
  2277. {
  2278. ErrMsg = string.Format("Mac format error!\r\n{0}", mac);
  2279. Log.WriteErrorLog(ErrMsg);
  2280. goto end;
  2281. }
  2282. byte[] MacData = SerialInit.HexToByte(mac);
  2283. Log.WriteInfoLog("Write Mac...");
  2284. if (SerialCMD.SetMAC(TVPort, MacData, out result, out data, out error, SerailDelay))
  2285. {
  2286. SetsuccessStatus(m_writemac);
  2287. Log.WriteInfoLog("Check Mac...");
  2288. if (cfg_writecheck.MacCheckcheck ? SerialCMD.CheckMAC(TVPort, out result, out data, out error, SerailDelay) : true)
  2289. {
  2290. SetsuccessStatus(m_checkmac);
  2291. Log.WriteInfoLog("Read Mac...");
  2292. if (cfg_readcheck.MacReadcheck ? SerialCMD.GetMAC(TVPort, out result, out data, out error, SerailDelay) : true)
  2293. {
  2294. if (cfg_readcheck.MacReadcheck)
  2295. {
  2296. if (SerialInit.BytesCompare_Base64(data, MacData))
  2297. {
  2298. SetsuccessStatus(m_readmac);
  2299. }
  2300. else
  2301. {
  2302. SetfailStatus(m_readmac);
  2303. ErrMsg = string.Format("{0} contrast Mac fail!", SN);
  2304. Log.WriteErrorLog(ErrMsg);
  2305. goto end;
  2306. }
  2307. }
  2308. }
  2309. else
  2310. {
  2311. SetfailStatus(m_readmac);
  2312. ErrMsg = string.Format("{0} read Mac fail!", SN);
  2313. Log.WriteErrorLog(ErrMsg);
  2314. goto end;
  2315. }
  2316. }
  2317. else
  2318. {
  2319. SetfailStatus(m_checkmac);
  2320. ErrMsg = string.Format("{0} check Mac fail!", SN);
  2321. Log.WriteErrorLog(ErrMsg);
  2322. goto end;
  2323. }
  2324. }
  2325. else
  2326. {
  2327. SetfailStatus(m_writemac);
  2328. ErrMsg = string.Format("{0} Write Mac fail!", SN);
  2329. Log.WriteErrorLog(ErrMsg);
  2330. goto end;
  2331. }
  2332. keyInfo.Mac.result = true;
  2333. }
  2334. //WiFi_MAC抄写
  2335. if (WriteWifiMac.Checked)
  2336. {
  2337. string wifimac = keyInfo.WiFi_MAC.data.Replace("-", "");
  2338. if (FunctionSettingNow.MITVEnable == true)
  2339. wifimac = keyInfo.WiFi_MAC.data.Replace(":", "");
  2340. if (!CommonMethod.IsNumberAndWord(wifimac))
  2341. {
  2342. ErrMsg = string.Format("Wifi Mac format error!\r\n{0}", wifimac);
  2343. Log.WriteErrorLog(ErrMsg);
  2344. goto end;
  2345. }
  2346. byte[] WifiMacData = Encoding.ASCII.GetBytes(wifimac);
  2347. Log.WriteInfoLog("Write WifiMac...");
  2348. if (SerialCMD.SetFireTVWifiMac(TVPort, WifiMacData, out result, out data, out error, SerailDelay))
  2349. {
  2350. SetsuccessStatus(m_writeWifiMac);
  2351. Log.WriteInfoLog("Check WifiMac...");
  2352. if (cfg_writecheck.WifiMacCheckcheck ? SerialCMD.CheckFireTVWifiMac(TVPort, out result, out data, out error, SerailDelay) : true)
  2353. {
  2354. SetsuccessStatus(m_checkWifiMac);
  2355. Log.WriteInfoLog("Read WifiMac...");
  2356. if (cfg_readcheck.WifiMacReadcheck ? SerialCMD.GetFireTVWiFi_Mac(TVPort, out result, out data, out error, SerailDelay) : true)
  2357. {
  2358. if (cfg_readcheck.WifiMacReadcheck)
  2359. {
  2360. if (SerialInit.BytesCompare_Base64(data, WifiMacData))
  2361. {
  2362. SetsuccessStatus(m_readWifiMac);
  2363. }
  2364. else
  2365. {
  2366. SetfailStatus(m_readWifiMac);
  2367. ErrMsg = string.Format("{0} contrast Wifi Mac fail!", SN);
  2368. Log.WriteErrorLog(ErrMsg);
  2369. goto end;
  2370. }
  2371. }
  2372. }
  2373. else
  2374. {
  2375. SetfailStatus(m_readWifiMac);
  2376. ErrMsg = string.Format("{0} read Wifi Mac fail!", SN);
  2377. Log.WriteErrorLog(ErrMsg);
  2378. goto end;
  2379. }
  2380. }
  2381. else
  2382. {
  2383. SetfailStatus(m_checkWifiMac);
  2384. ErrMsg = string.Format("{0} check Wifi Mac fail!", SN);
  2385. Log.WriteErrorLog(ErrMsg);
  2386. goto end;
  2387. }
  2388. }
  2389. else
  2390. {
  2391. SetfailStatus(m_writeWifiMac);
  2392. ErrMsg = string.Format("{0} Write Wifi Mac fail!", SN);
  2393. Log.WriteErrorLog(ErrMsg);
  2394. goto end;
  2395. }
  2396. keyInfo.WiFi_MAC.result = true;
  2397. }
  2398. //BT_MAC抄写
  2399. if (WriteBTMac.Checked)
  2400. {
  2401. string btmac = keyInfo.BT_MAC.data.Replace("-", "");
  2402. if (FunctionSettingNow.MITVEnable == true)
  2403. btmac = keyInfo.BT_MAC.data.Replace(":", "");
  2404. if (!CommonMethod.IsNumberAndWord(btmac))
  2405. {
  2406. ErrMsg = string.Format("BTMac format error!\r\n{0}", btmac);
  2407. Log.WriteErrorLog(ErrMsg);
  2408. goto end;
  2409. }
  2410. byte[] BTMacData = Encoding.ASCII.GetBytes(btmac);
  2411. Log.WriteInfoLog("Write BTMac...");
  2412. if (SerialCMD.SetFireTVBTMac(TVPort, BTMacData, out result, out data, out error, SerailDelay))
  2413. {
  2414. SetsuccessStatus(m_writeBTMac);
  2415. Log.WriteInfoLog("Check BTMac...");
  2416. if (cfg_writecheck.BTMacCheckcheck ? SerialCMD.CheckFireTVBTMac(TVPort, out result, out data, out error, SerailDelay) : true)
  2417. {
  2418. SetsuccessStatus(m_checkBTMac);
  2419. Log.WriteInfoLog("Read BTMac...");
  2420. if (cfg_readcheck.BTMacReadcheck ? SerialCMD.GetFireTVBT_Mac(TVPort, out result, out data, out error, SerailDelay) : true)
  2421. {
  2422. if (cfg_readcheck.BTMacReadcheck)
  2423. {
  2424. if (SerialInit.BytesCompare_Base64(data, BTMacData))
  2425. {
  2426. SetsuccessStatus(m_readBTMac);
  2427. }
  2428. else
  2429. {
  2430. SetfailStatus(m_readBTMac);
  2431. ErrMsg = string.Format("{0} contrast BT Mac fail!", SN);
  2432. Log.WriteErrorLog(ErrMsg);
  2433. goto end;
  2434. }
  2435. }
  2436. }
  2437. else
  2438. {
  2439. SetfailStatus(m_readBTMac);
  2440. ErrMsg = string.Format("{0} read BT Mac fail!", SN);
  2441. Log.WriteErrorLog(ErrMsg);
  2442. goto end;
  2443. }
  2444. }
  2445. else
  2446. {
  2447. SetfailStatus(m_checkBTMac);
  2448. ErrMsg = string.Format("{0} check BT Mac fail!", SN);
  2449. Log.WriteErrorLog(ErrMsg);
  2450. goto end;
  2451. }
  2452. }
  2453. else
  2454. {
  2455. SetfailStatus(m_writeBTMac);
  2456. ErrMsg = string.Format("{0} Write BT Mac fail!", SN);
  2457. Log.WriteErrorLog(ErrMsg);
  2458. goto end;
  2459. }
  2460. keyInfo.BT_MAC.result = true;
  2461. }
  2462. //PEK抄写
  2463. if (WritePEK.Checked)
  2464. {
  2465. if (!CommonMethod.IsNumberAndWord(keyInfo.PEK.data))
  2466. {
  2467. ErrMsg = string.Format("PEK format error!\r\n{0}", keyInfo.PEK.data);
  2468. Log.WriteErrorLog(ErrMsg);
  2469. goto end;
  2470. }
  2471. byte[] PEKData = SerialInit.HexToByte(keyInfo.PEK.data);
  2472. Log.WriteInfoLog("Write PEK...");
  2473. if (SerialCMD.SetFireTVPEK(TVPort, PEKData, out result, out data, out error, SerailDelay))
  2474. {
  2475. SetsuccessStatus(m_writePEK);
  2476. Log.WriteInfoLog("Check PEK...");
  2477. if (cfg_writecheck.PEKCheckcheck ? SerialCMD.CheckFireTVPEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2478. {
  2479. SetsuccessStatus(m_checkPEK);
  2480. Log.WriteInfoLog("Read PEK...");
  2481. if (cfg_readcheck.PEKReadcheck ? SerialCMD.ReadFireTVPEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2482. {
  2483. if (cfg_readcheck.PEKReadcheck)
  2484. {
  2485. if (SerialInit.BytesCompare_Base64(data, PEKData))
  2486. {
  2487. SetsuccessStatus(m_readPEK);
  2488. }
  2489. else
  2490. {
  2491. SetfailStatus(m_readPEK);
  2492. ErrMsg = string.Format("{0} contrast PEK fail!", SN);
  2493. Log.WriteErrorLog(ErrMsg);
  2494. goto end;
  2495. }
  2496. }
  2497. }
  2498. else
  2499. {
  2500. SetfailStatus(m_readPEK);
  2501. ErrMsg = string.Format("{0} read PEK fail!", SN);
  2502. Log.WriteErrorLog(ErrMsg);
  2503. goto end;
  2504. }
  2505. }
  2506. else
  2507. {
  2508. SetfailStatus(m_checkPEK);
  2509. ErrMsg = string.Format("{0} check PEK fail!", SN);
  2510. Log.WriteErrorLog(ErrMsg);
  2511. goto end;
  2512. }
  2513. }
  2514. else
  2515. {
  2516. SetfailStatus(m_writePEK);
  2517. ErrMsg = string.Format("{0} Write PEK fail!", SN);
  2518. Log.WriteErrorLog(ErrMsg);
  2519. goto end;
  2520. }
  2521. keyInfo.PEK.result = true;
  2522. }
  2523. // DAK 抄写;
  2524. if (WriteDAK.Checked)
  2525. {
  2526. if (!CommonMethod.IsNumberAndWord(keyInfo.DAK.data))
  2527. {
  2528. ErrMsg = string.Format("DAK format error!\r\n{0}", keyInfo.DAK.data);
  2529. Log.WriteErrorLog(ErrMsg);
  2530. goto end;
  2531. }
  2532. byte[] DAKData = SerialInit.HexToByte(keyInfo.DAK.data);
  2533. Log.WriteInfoLog("Write DAK...");
  2534. if (SerialCMD.SetFireTVDAK(TVPort, DAKData, out result, out data, out error, SerailDelay))
  2535. {
  2536. SetsuccessStatus(m_writeDAK);
  2537. Log.WriteInfoLog("Check DAK...");
  2538. if (cfg_writecheck.DAKCheckcheck ? SerialCMD.CheckFireTVDAK(TVPort, out result, out data, out error, SerailDelay) : true)
  2539. {
  2540. SetsuccessStatus(m_checkDAK);
  2541. }
  2542. else
  2543. {
  2544. SetfailStatus(m_checkDAK);
  2545. ErrMsg = string.Format("{0} check DAK fail!", SN);
  2546. Log.WriteErrorLog(ErrMsg);
  2547. goto end;
  2548. }
  2549. }
  2550. else
  2551. {
  2552. SetfailStatus(m_writeDAK);
  2553. ErrMsg = string.Format("{0} Write DAK fail!", SN);
  2554. Log.WriteErrorLog(ErrMsg);
  2555. goto end;
  2556. }
  2557. keyInfo.DAK.result = true;
  2558. }
  2559. //LEK抄写
  2560. if (WriteLEK.Checked)
  2561. {
  2562. if (!CommonMethod.IsNumberAndWord(keyInfo.LEK.data))
  2563. {
  2564. ErrMsg = string.Format("LEK format error!\r\n{0}", keyInfo.LEK.data);
  2565. Log.WriteErrorLog(ErrMsg);
  2566. goto end;
  2567. }
  2568. byte[] LEKData = SerialInit.HexToByte(keyInfo.LEK.data);
  2569. Log.WriteInfoLog("Write LEK...");
  2570. if (SerialCMD.SetFireTVLEK(TVPort, LEKData, out result, out data, out error, SerailDelay))
  2571. {
  2572. SetsuccessStatus(m_writeLEK);
  2573. Log.WriteInfoLog("Check LEK...");
  2574. if (cfg_writecheck.LEKCheckcheck ? SerialCMD.CheckFireTVLEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2575. {
  2576. SetsuccessStatus(m_checkLEK);
  2577. Log.WriteInfoLog("Read LEK...");
  2578. if (cfg_readcheck.LEKReadcheck ? SerialCMD.ReadFireTVLEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2579. {
  2580. if (cfg_readcheck.LEKReadcheck)
  2581. {
  2582. if (SerialInit.BytesCompare_Base64(data, LEKData))
  2583. {
  2584. SetsuccessStatus(m_readLEK);
  2585. }
  2586. else
  2587. {
  2588. SetfailStatus(m_readLEK);
  2589. ErrMsg = string.Format("{0} contrast LEK fail!", SN);
  2590. Log.WriteErrorLog(ErrMsg);
  2591. goto end;
  2592. }
  2593. }
  2594. }
  2595. else
  2596. {
  2597. SetfailStatus(m_readLEK);
  2598. ErrMsg = string.Format("{0} read LEK fail!", SN);
  2599. Log.WriteErrorLog(ErrMsg);
  2600. goto end;
  2601. }
  2602. }
  2603. else
  2604. {
  2605. SetfailStatus(m_checkLEK);
  2606. ErrMsg = string.Format("{0} check LEK fail!", SN);
  2607. Log.WriteErrorLog(ErrMsg);
  2608. goto end;
  2609. }
  2610. }
  2611. else
  2612. {
  2613. SetfailStatus(m_writeLEK);
  2614. ErrMsg = string.Format("{0} Write LEK fail!", SN);
  2615. Log.WriteErrorLog(ErrMsg);
  2616. goto end;
  2617. }
  2618. keyInfo.LEK.result = true;
  2619. }
  2620. //HDCP KEY抄写
  2621. if (WriteHDCP.Checked)
  2622. {
  2623. if (!CommonMethod.IsNumberAndWord(keyInfo.HDCP.data))
  2624. {
  2625. ErrMsg = string.Format("HDCP format error!\r\n{0}", keyInfo.HDCP.data);
  2626. Log.WriteErrorLog(ErrMsg);
  2627. goto end;
  2628. }
  2629. byte[] HDCPData = SerialInit.HexToByte(keyInfo.HDCP.data);
  2630. Log.WriteInfoLog("Write HDCP...");
  2631. if (SerialCMD.SetHDCPKey(TVPort, HDCPData, out result, out data, out error, SerailDelay))
  2632. {
  2633. SetsuccessStatus(m_writehdcp);
  2634. Log.WriteInfoLog("Check HDCP...");
  2635. if (cfg_writecheck.HDCPCheckcheck ? SerialCMD.CheckHDCP(TVPort, out result, out data, out error, SerailDelay) : true)
  2636. {
  2637. SetsuccessStatus(m_checkhdcp);
  2638. Log.WriteInfoLog("Read HDCP...");
  2639. if (cfg_readcheck.HDCPReadcheck ? SerialCMD.GetHDCPKey(TVPort, out result, out data, out error, SerailDelay) : true)
  2640. {
  2641. if (cfg_readcheck.HDCPReadcheck)
  2642. {
  2643. if (SerialInit.BytesCompare_Base64(data, HDCPData))
  2644. {
  2645. SetsuccessStatus(m_readhdcp);
  2646. }
  2647. else
  2648. {
  2649. SetfailStatus(m_readhdcp);
  2650. ErrMsg = string.Format("{0} contrast HDCP fail!", SN);
  2651. Log.WriteErrorLog(ErrMsg);
  2652. goto end;
  2653. }
  2654. }
  2655. }
  2656. else
  2657. {
  2658. SetfailStatus(m_readhdcp);
  2659. ErrMsg = string.Format("{0} read HDCP fail!", SN);
  2660. Log.WriteErrorLog(ErrMsg);
  2661. goto end;
  2662. }
  2663. }
  2664. else
  2665. {
  2666. SetfailStatus(m_checkhdcp);
  2667. ErrMsg = string.Format("{0} check HDCP fail!", SN);
  2668. Log.WriteErrorLog(ErrMsg);
  2669. goto end;
  2670. }
  2671. }
  2672. else
  2673. {
  2674. SetfailStatus(m_writehdcp);
  2675. ErrMsg = string.Format("{0} Write HDCP fail!", SN);
  2676. Log.WriteErrorLog(ErrMsg);
  2677. goto end;
  2678. }
  2679. keyInfo.HDCP.result = true;
  2680. }
  2681. //HDCP22 KEY抄写
  2682. if (WriteHDCP22.Checked)
  2683. {
  2684. if (!CommonMethod.IsNumberAndWord(keyInfo.HDCP22.data))
  2685. {
  2686. ErrMsg = string.Format("HDCP22 format error!\r\n{0}", keyInfo.HDCP22.data);
  2687. Log.WriteErrorLog(ErrMsg);
  2688. goto end;
  2689. }
  2690. byte[] HDCP22Data = SerialInit.HexToByte(keyInfo.HDCP22.data);
  2691. Log.WriteInfoLog("Write HDCP22...");
  2692. if (SerialCMD.SetHDCPKey22(TVPort, HDCP22Data, out result, out data, out error, SerailDelay))
  2693. {
  2694. SetsuccessStatus(m_writehdcp22);
  2695. Log.WriteInfoLog("Check HDCP22...");
  2696. if (cfg_writecheck.HDCP22Checkcheck ? SerialCMD.CheckHDCP22(TVPort, out result, out data, out error, SerailDelay) : true)
  2697. {
  2698. SetsuccessStatus(m_checkhdcp22);
  2699. Log.WriteInfoLog("Read HDCP22...");
  2700. if (cfg_readcheck.HDCP22Readcheck ? SerialCMD.GetHDCPKey22(TVPort, out result, out data, out error, SerailDelay) : true)
  2701. {
  2702. if (cfg_readcheck.HDCP22Readcheck)
  2703. {
  2704. if (SerialInit.BytesCompare_Base64(data, HDCP22Data))
  2705. {
  2706. SetsuccessStatus(m_readhdcp22);
  2707. }
  2708. else
  2709. {
  2710. SetfailStatus(m_readhdcp22);
  2711. ErrMsg = string.Format("{0} contrast HDCP22 fail!", SN);
  2712. Log.WriteErrorLog(ErrMsg);
  2713. goto end;
  2714. }
  2715. }
  2716. }
  2717. else
  2718. {
  2719. SetfailStatus(m_readhdcp22);
  2720. ErrMsg = string.Format("{0} read HDCP22 fail!", SN);
  2721. Log.WriteErrorLog(ErrMsg);
  2722. goto end;
  2723. }
  2724. }
  2725. else
  2726. {
  2727. SetfailStatus(m_checkhdcp22);
  2728. ErrMsg = string.Format("{0} check HDCP22 fail!", SN);
  2729. Log.WriteErrorLog(ErrMsg);
  2730. goto end;
  2731. }
  2732. }
  2733. else
  2734. {
  2735. SetfailStatus(m_writehdcp22);
  2736. ErrMsg = string.Format("{0} Write HDCP22 fail!", SN);
  2737. Log.WriteErrorLog(ErrMsg);
  2738. goto end;
  2739. }
  2740. keyInfo.HDCP22.result = true;
  2741. }
  2742. //ESN KEY抄写
  2743. if (WriteESN.Checked)
  2744. {
  2745. if (!CommonMethod.IsNumberAndWord(keyInfo.ESN.data))
  2746. {
  2747. ErrMsg = string.Format("ESN format error!\r\n{0}", keyInfo.ESN.data);
  2748. Log.WriteErrorLog(ErrMsg);
  2749. goto end;
  2750. }
  2751. byte[] ESNData = SerialInit.HexToByte(keyInfo.ESN.data);
  2752. Log.WriteInfoLog("Write ESN...");
  2753. if (SerialCMD.SetNetflixESN(TVPort, ESNData, out result, out data, out error, SerailDelay))
  2754. {
  2755. SetsuccessStatus(m_writeesn);
  2756. Log.WriteInfoLog("Check ESN...");
  2757. if (cfg_writecheck.ESNCheckcheck ? SerialCMD.CheckNetflixESN(TVPort, out result, out data, out error, SerailDelay) : true)
  2758. {
  2759. SetsuccessStatus(m_checkesn);
  2760. Log.WriteInfoLog("Read ESN...");
  2761. if (cfg_readcheck.ESNReadcheck ? SerialCMD.GetNetflixESN(TVPort, out result, out data, out error, SerailDelay) : true)
  2762. {
  2763. if (cfg_readcheck.ESNReadcheck)
  2764. {
  2765. if (SerialInit.BytesCompare_Base64(data, ESNData))
  2766. {
  2767. SetsuccessStatus(m_readesn);
  2768. }
  2769. else
  2770. {
  2771. SetfailStatus(m_readesn);
  2772. ErrMsg = string.Format("{0} contrast ESN fail!", SN);
  2773. Log.WriteErrorLog(ErrMsg);
  2774. goto end;
  2775. }
  2776. }
  2777. }
  2778. else
  2779. {
  2780. SetfailStatus(m_readesn);
  2781. ErrMsg = string.Format("{0} read ESN fail!", SN);
  2782. Log.WriteErrorLog(ErrMsg);
  2783. goto end;
  2784. }
  2785. }
  2786. else
  2787. {
  2788. SetfailStatus(m_checkesn);
  2789. ErrMsg = string.Format("{0} check ESN fail!", SN);
  2790. Log.WriteErrorLog(ErrMsg);
  2791. goto end;
  2792. }
  2793. }
  2794. else
  2795. {
  2796. SetfailStatus(m_writeesn);
  2797. ErrMsg = string.Format("{0} Write ESN fail!", SN);
  2798. Log.WriteErrorLog(ErrMsg);
  2799. goto end;
  2800. }
  2801. }
  2802. //WiDi KEY抄写
  2803. if (WriteWiDi.Checked)
  2804. {
  2805. if (!CommonMethod.IsNumberAndWord(keyInfo.WiDi.data))
  2806. {
  2807. ErrMsg = string.Format("WiDi format error!\r\n{0}", keyInfo.WiDi.data);
  2808. Log.WriteErrorLog(ErrMsg);
  2809. goto end;
  2810. }
  2811. byte[] WiDiData = SerialInit.HexToByte(keyInfo.WiDi.data);
  2812. Log.WriteInfoLog("Write WiDi...");
  2813. if (SerialCMD.SetWidi(TVPort, WiDiData, out result, out data, out error, SerailDelay))
  2814. {
  2815. SetsuccessStatus(m_writewidi);
  2816. Log.WriteInfoLog("Check WiDi...");
  2817. if (cfg_writecheck.WiDiCheckcheck ? SerialCMD.CheckWidi(TVPort, out result, out data, out error, SerailDelay) : true)
  2818. {
  2819. SetsuccessStatus(m_checkwidi);
  2820. Log.WriteInfoLog("Read WiDi...");
  2821. if (cfg_readcheck.WiDiReadcheck ? SerialCMD.GetWidi(TVPort, out result, out data, out error, SerailDelay) : true)
  2822. {
  2823. if (cfg_readcheck.WiDiReadcheck)
  2824. {
  2825. if (SerialInit.BytesCompare_Base64(data, WiDiData))
  2826. {
  2827. SetsuccessStatus(m_readwidi);
  2828. }
  2829. else
  2830. {
  2831. SetfailStatus(m_readwidi);
  2832. ErrMsg = string.Format("{0} contrast WiDi fail!", SN);
  2833. Log.WriteErrorLog(ErrMsg);
  2834. goto end;
  2835. }
  2836. }
  2837. }
  2838. else
  2839. {
  2840. SetfailStatus(m_readwidi);
  2841. ErrMsg = string.Format("{0} read WiDi fail!", SN);
  2842. Log.WriteErrorLog(ErrMsg);
  2843. goto end;
  2844. }
  2845. }
  2846. else
  2847. {
  2848. SetfailStatus(m_checkwidi);
  2849. ErrMsg = string.Format("{0} check WiDi fail!", SN);
  2850. Log.WriteErrorLog(ErrMsg);
  2851. goto end;
  2852. }
  2853. }
  2854. else
  2855. {
  2856. SetfailStatus(m_writewidi);
  2857. ErrMsg = string.Format("{0} Write WiDi fail!", SN);
  2858. Log.WriteErrorLog(ErrMsg);
  2859. goto end;
  2860. }
  2861. keyInfo.WiDi.result = true;
  2862. }
  2863. //Youtube key抄写
  2864. if (WriteYouTube.Checked)
  2865. {
  2866. if (!CommonMethod.IsNumberAndWord(keyInfo.YouTube_KEY.data))
  2867. {
  2868. ErrMsg = string.Format("YouTube format error!\r\n{0}", keyInfo.YouTube_KEY.data);
  2869. Log.WriteErrorLog(ErrMsg);
  2870. goto end;
  2871. }
  2872. byte[] YouTubeData = SerialInit.HexToByte(keyInfo.YouTube_KEY.data);
  2873. Log.WriteInfoLog("Write YouTube key...");
  2874. if (SerialCMD.SetFireTVYoutube(TVPort, YouTubeData, out result, out data, out error, SerailDelay))
  2875. {
  2876. SetsuccessStatus(m_writeYouTube);
  2877. Log.WriteInfoLog("Check YouTube_KEY...");
  2878. if (cfg_writecheck.YouTubeCheckcheck ? SerialCMD.CheckFireTVYoutube(TVPort, out result, out data, out error, SerailDelay) : true)
  2879. {
  2880. SetsuccessStatus(m_checkYouTube);
  2881. Log.WriteInfoLog("Read YouTube_KEY...");
  2882. if (cfg_readcheck.YouTubeReadcheck ? SerialCMD.ReadFireTVYoutube(TVPort, out result, out data, out error, SerailDelay) : true)
  2883. {
  2884. if (cfg_readcheck.YouTubeReadcheck)
  2885. {
  2886. if (SerialInit.BytesCompare_Base64(data, YouTubeData))
  2887. {
  2888. SetsuccessStatus(m_readYouTube);
  2889. }
  2890. else
  2891. {
  2892. SetfailStatus(m_readYouTube);
  2893. ErrMsg = string.Format("{0} contrast YouTube_KEY fail!", SN);
  2894. Log.WriteErrorLog(ErrMsg);
  2895. goto end;
  2896. }
  2897. }
  2898. }
  2899. else
  2900. {
  2901. SetfailStatus(m_readYouTube);
  2902. ErrMsg = string.Format("{0} read YouTube_KEY fail!", SN);
  2903. Log.WriteErrorLog(ErrMsg);
  2904. goto end;
  2905. }
  2906. }
  2907. else
  2908. {
  2909. SetfailStatus(m_checkYouTube);
  2910. ErrMsg = string.Format("{0} check YouTube_KEY fail!", SN);
  2911. Log.WriteErrorLog(ErrMsg);
  2912. goto end;
  2913. }
  2914. }
  2915. else
  2916. {
  2917. SetfailStatus(m_writeYouTube);
  2918. ErrMsg = string.Format("{0} Write YouTube_KEY fail!", SN);
  2919. Log.WriteErrorLog(ErrMsg);
  2920. goto end;
  2921. }
  2922. keyInfo.YouTube_KEY.result = true;
  2923. }
  2924. //Widevine KEY抄写
  2925. if (WriteWidevine.Checked)
  2926. {
  2927. if (!CommonMethod.IsNumberAndWord(keyInfo.Widevine.data))
  2928. {
  2929. ErrMsg = string.Format("Widevine format error!\r\n{0}", keyInfo.Widevine.data);
  2930. Log.WriteErrorLog(ErrMsg);
  2931. goto end;
  2932. }
  2933. byte[] WidevineData = SerialInit.HexToByte(keyInfo.Widevine.data);
  2934. Log.WriteInfoLog("Write Widevine...");
  2935. if (SerialCMD.SetWidevine(TVPort, WidevineData, out result, out data, out error, SerailDelay))
  2936. {
  2937. SetsuccessStatus(m_writewidevine);
  2938. Log.WriteInfoLog("Check Widevine...");
  2939. if (cfg_writecheck.WidevineCheckcheck ? SerialCMD.CheckWidevine(TVPort, out result, out data, out error, SerailDelay) : true)
  2940. {
  2941. SetsuccessStatus(m_checkwidevine);
  2942. Log.WriteInfoLog("Read Widevine...");
  2943. if (cfg_readcheck.WidevineReadcheck ? SerialCMD.GetWidevine(TVPort, out result, out data, out error, SerailDelay) : true)
  2944. {
  2945. if (cfg_readcheck.WidevineReadcheck)
  2946. {
  2947. if (CommonMethod.CompareMD5(WidevineData, data))
  2948. {
  2949. SetsuccessStatus(m_readwidevine);
  2950. }
  2951. else
  2952. {
  2953. if (SerialInit.BytesCompare_Base64(data, WidevineData))
  2954. {
  2955. SetsuccessStatus(m_readwidevine);
  2956. }
  2957. else
  2958. {
  2959. SetfailStatus(m_readwidevine);
  2960. ErrMsg = string.Format("{0} contrast Widevine fail!", SN);
  2961. Log.WriteErrorLog(ErrMsg);
  2962. goto end;
  2963. }
  2964. }
  2965. }
  2966. }
  2967. else
  2968. {
  2969. SetfailStatus(m_readwidevine);
  2970. ErrMsg = string.Format("{0} read Widevine fail!", SN);
  2971. Log.WriteErrorLog(ErrMsg);
  2972. goto end;
  2973. }
  2974. }
  2975. else
  2976. {
  2977. SetfailStatus(m_checkwidevine);
  2978. ErrMsg = string.Format("{0} check Widevine fail!", SN);
  2979. Log.WriteErrorLog(ErrMsg);
  2980. goto end;
  2981. }
  2982. }
  2983. else
  2984. {
  2985. SetfailStatus(m_writewidevine);
  2986. ErrMsg = string.Format("{0} Write Widevine fail!", SN);
  2987. Log.WriteErrorLog(ErrMsg);
  2988. goto end;
  2989. }
  2990. keyInfo.Widevine.result = true;
  2991. }
  2992. //CI plus KEY抄写
  2993. if (WriteCiplus.Checked)
  2994. {
  2995. if (!CommonMethod.IsNumberAndWord(keyInfo.CI_plus.data))
  2996. {
  2997. ErrMsg = string.Format("CI_plus format error!\r\n{0}", keyInfo.CI_plus.data);
  2998. Log.WriteErrorLog(ErrMsg);
  2999. goto end;
  3000. }
  3001. byte[] CiplusData = SerialInit.HexToByte(keyInfo.CI_plus.data);
  3002. Log.WriteInfoLog("Write CI plus...");
  3003. if (SerialCMD.SetCiKey(TVPort, CiplusData, out result, out data, out error, SerailDelay))
  3004. {
  3005. SetsuccessStatus(m_writeci);
  3006. Log.WriteInfoLog("Check CI plus...");
  3007. if (cfg_writecheck.CI_plusCheckcheck ? SerialCMD.CheckCikey(TVPort, out result, out data, out error, SerailDelay) : true)
  3008. {
  3009. SetsuccessStatus(m_checkci);
  3010. Log.WriteInfoLog("Read CI plus...");
  3011. if (cfg_readcheck.CI_plusReadcheck ? SerialCMD.GetCiKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3012. {
  3013. if (cfg_readcheck.CI_plusReadcheck)
  3014. {
  3015. if (CommonMethod.CompareMD5(CiplusData, data))
  3016. {
  3017. SetsuccessStatus(m_readci);
  3018. }
  3019. else
  3020. {
  3021. if (SerialInit.BytesCompare_Base64(data, CiplusData))
  3022. {
  3023. SetsuccessStatus(m_readci);
  3024. }
  3025. else
  3026. {
  3027. SetfailStatus(m_readci);
  3028. ErrMsg = string.Format("{0} contrast CI plus fail!", SN);
  3029. Log.WriteErrorLog(ErrMsg);
  3030. goto end;
  3031. }
  3032. }
  3033. }
  3034. }
  3035. else
  3036. {
  3037. SetfailStatus(m_readci);
  3038. ErrMsg = string.Format("{0} read CI plus fail!", SN);
  3039. Log.WriteErrorLog(ErrMsg);
  3040. goto end;
  3041. }
  3042. }
  3043. else
  3044. {
  3045. SetfailStatus(m_checkci);
  3046. ErrMsg = string.Format("{0} check CI plus fail!", SN);
  3047. Log.WriteErrorLog(ErrMsg);
  3048. goto end;
  3049. }
  3050. }
  3051. else
  3052. {
  3053. SetfailStatus(m_writeci);
  3054. ErrMsg = string.Format("{0} Write CI plus fail!", SN);
  3055. Log.WriteErrorLog(ErrMsg);
  3056. goto end;
  3057. }
  3058. keyInfo.CI_plus.result = true;
  3059. }
  3060. //Attestation KEY抄写
  3061. if (WriteAttestation.Checked)
  3062. {
  3063. if (!CommonMethod.IsNumberAndWord(keyInfo.Attestation.data))
  3064. {
  3065. ErrMsg = string.Format("Attestation key format error!\r\n{0}", keyInfo.Attestation.data);
  3066. Log.WriteErrorLog(ErrMsg);
  3067. goto end;
  3068. }
  3069. byte[] AttestationData = SerialInit.HexToByte(keyInfo.Attestation.data);
  3070. Log.WriteInfoLog("Write Attestation key...");
  3071. if (SerialCMD.SetAttestationKey(TVPort, AttestationData, out result, out data, out error, SerailDelay))
  3072. {
  3073. SetsuccessStatus(m_writeattestation);
  3074. Log.WriteInfoLog("Check Attestation key...");
  3075. if (cfg_writecheck.AttestationCheckcheck ? SerialCMD.CheckAttestationKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3076. {
  3077. SetsuccessStatus(m_checkattestation);
  3078. Log.WriteInfoLog("Read Attestation key...");
  3079. if (cfg_readcheck.AttestationReadcheck ? SerialCMD.GetAttestationKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3080. {
  3081. if (cfg_readcheck.AttestationReadcheck)
  3082. {
  3083. if (CommonMethod.CompareMD5(AttestationData, data))
  3084. {
  3085. SetsuccessStatus(m_readattestation);
  3086. }
  3087. else
  3088. {
  3089. if (SerialInit.BytesCompare_Base64(data, AttestationData))
  3090. {
  3091. SetsuccessStatus(m_readattestation);
  3092. }
  3093. else
  3094. {
  3095. SetfailStatus(m_readattestation);
  3096. ErrMsg = string.Format("{0} contrast Attestation key fail!", SN);
  3097. Log.WriteErrorLog(ErrMsg);
  3098. goto end;
  3099. }
  3100. }
  3101. }
  3102. }
  3103. else
  3104. {
  3105. SetfailStatus(m_readattestation);
  3106. ErrMsg = string.Format("{0} read Attestation key fail!", SN);
  3107. Log.WriteErrorLog(ErrMsg);
  3108. goto end;
  3109. }
  3110. }
  3111. else
  3112. {
  3113. SetfailStatus(m_checkattestation);
  3114. ErrMsg = string.Format("{0} check Attestation key fail!", SN);
  3115. Log.WriteErrorLog(ErrMsg);
  3116. goto end;
  3117. }
  3118. }
  3119. else
  3120. {
  3121. SetfailStatus(m_writeattestation);
  3122. ErrMsg = string.Format("{0} Write Attestation key fail!", SN);
  3123. Log.WriteErrorLog(ErrMsg);
  3124. goto end;
  3125. }
  3126. keyInfo.Attestation.result = true;
  3127. }
  3128. //MGK KEY抄写
  3129. if (WriteMGK.Checked)
  3130. {
  3131. if (!CommonMethod.IsNumberAndWord(keyInfo.MGK.data))
  3132. {
  3133. ErrMsg = string.Format("MGK format error!\r\n{0}", keyInfo.MGK.data);
  3134. Log.WriteErrorLog(ErrMsg);
  3135. goto end;
  3136. }
  3137. byte[] MGKData = SerialInit.HexToByte(keyInfo.MGK.data);
  3138. Log.WriteInfoLog("Write MGK...");
  3139. if (SerialCMD.SetMGKKey(TVPort, MGKData, out result, out data, out error, SerailDelay))
  3140. {
  3141. SetsuccessStatus(m_writeMGK);
  3142. Log.WriteInfoLog("Check MGK...");
  3143. if (cfg_writecheck.MGKCheckcheck ? SerialCMD.CheckMGKkey(TVPort, out result, out data, out error, SerailDelay) : true)
  3144. {
  3145. SetsuccessStatus(m_checkMGK);
  3146. Log.WriteInfoLog("Read MGK...");
  3147. if (cfg_readcheck.MGKReadcheck ? SerialCMD.GetMGKKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3148. {
  3149. if (cfg_readcheck.MGKReadcheck)
  3150. {
  3151. if (CommonMethod.CompareMD5(MGKData, data))
  3152. {
  3153. SetsuccessStatus(m_readMGK);
  3154. }
  3155. else
  3156. {
  3157. if (SerialInit.BytesCompare_Base64(data, MGKData))
  3158. {
  3159. SetsuccessStatus(m_readMGK);
  3160. }
  3161. else
  3162. {
  3163. SetfailStatus(m_readMGK);
  3164. ErrMsg = string.Format("{0} contrast MGK fail!", SN);
  3165. Log.WriteErrorLog(ErrMsg);
  3166. goto end;
  3167. }
  3168. }
  3169. }
  3170. }
  3171. else
  3172. {
  3173. SetfailStatus(m_readMGK);
  3174. ErrMsg = string.Format("{0} read MGK fail!", SN);
  3175. Log.WriteErrorLog(ErrMsg);
  3176. goto end;
  3177. }
  3178. }
  3179. else
  3180. {
  3181. SetfailStatus(m_checkMGK);
  3182. ErrMsg = string.Format("{0} check MGK fail!", SN);
  3183. Log.WriteErrorLog(ErrMsg);
  3184. goto end;
  3185. }
  3186. }
  3187. else
  3188. {
  3189. SetfailStatus(m_writeMGK);
  3190. ErrMsg = string.Format("{0} Write MGK fail!", SN);
  3191. Log.WriteErrorLog(ErrMsg);
  3192. goto end;
  3193. }
  3194. keyInfo.MGK.result = true;
  3195. }
  3196. //Fairplay KEY抄写
  3197. if (WriteFairplay.Checked)
  3198. {
  3199. if (!CommonMethod.IsNumberAndWord(keyInfo.Fairplay.data))
  3200. {
  3201. ErrMsg = string.Format("Fairplay format error!\r\n{0}", keyInfo.Fairplay.data);
  3202. Log.WriteErrorLog(ErrMsg);
  3203. goto end;
  3204. }
  3205. byte[] FairplayData = SerialInit.HexToByte(keyInfo.Fairplay.data);
  3206. Log.WriteInfoLog("Write Fairplay...");
  3207. if (SerialCMD.SetFireTVFairplay(TVPort, FairplayData, out result, out data, out error, SerailDelay))
  3208. {
  3209. SetsuccessStatus(m_writeFairplay);
  3210. Log.WriteInfoLog("Check Fairplay...");
  3211. if (cfg_writecheck.FairplayCheckcheck ? SerialCMD.CheckFireTVFairplay(TVPort, out result, out data, out error, SerailDelay) : true)
  3212. {
  3213. SetsuccessStatus(m_checkFairplay);
  3214. Log.WriteInfoLog("Read Fairplay...");
  3215. if (cfg_readcheck.FairplayReadcheck ? SerialCMD.ReadFireTVFairplay(TVPort, out result, out data, out error, SerailDelay) : true)
  3216. {
  3217. if (cfg_readcheck.FairplayReadcheck)
  3218. {
  3219. if (SerialInit.BytesCompare_Base64(data, FairplayData))
  3220. {
  3221. SetsuccessStatus(m_readFairplay);
  3222. }
  3223. else
  3224. {
  3225. SetfailStatus(m_readFairplay);
  3226. ErrMsg = string.Format("{0} contrast Fairplay fail!", SN);
  3227. Log.WriteErrorLog(ErrMsg);
  3228. goto end;
  3229. }
  3230. }
  3231. }
  3232. else
  3233. {
  3234. SetfailStatus(m_readFairplay);
  3235. ErrMsg = string.Format("{0} read Fairplay fail!", SN);
  3236. Log.WriteErrorLog(ErrMsg);
  3237. goto end;
  3238. }
  3239. }
  3240. else
  3241. {
  3242. SetfailStatus(m_checkFairplay);
  3243. ErrMsg = string.Format("{0} check Fairplay fail!", SN);
  3244. Log.WriteErrorLog(ErrMsg);
  3245. goto end;
  3246. }
  3247. }
  3248. else
  3249. {
  3250. SetfailStatus(m_writeFairplay);
  3251. ErrMsg = string.Format("{0} Write Fairplay fail!", SN);
  3252. Log.WriteErrorLog(ErrMsg);
  3253. goto end;
  3254. }
  3255. keyInfo.Fairplay.result = true;
  3256. }
  3257. //ECP KEY抄写
  3258. if (WriteECP.Checked)
  3259. {
  3260. if (!CommonMethod.IsNumberAndWord(keyInfo.ECP.data))
  3261. {
  3262. ErrMsg = string.Format("ECP format error!\r\n{0}", keyInfo.ECP.data);
  3263. Log.WriteErrorLog(ErrMsg);
  3264. goto end;
  3265. }
  3266. byte[] ECPData = SerialInit.HexToByte(keyInfo.ECP.data);
  3267. Log.WriteInfoLog("Write ECP...");
  3268. if (SerialCMD.SetECP(TVPort, ECPData, out result, out data, out error, SerailDelay))
  3269. {
  3270. SetsuccessStatus(m_writeECP);
  3271. Log.WriteInfoLog("Check ECP...");
  3272. if (cfg_writecheck.ECPCheckcheck ? SerialCMD.CheckECP(TVPort, out result, out data, out error, SerailDelay) : true)
  3273. {
  3274. SetsuccessStatus(m_checkECP);
  3275. Log.WriteInfoLog("Read ECP...");
  3276. if (cfg_readcheck.ECPReadcheck ? SerialCMD.GetECP(TVPort, out result, out data, out error, SerailDelay) : true)
  3277. {
  3278. if (cfg_readcheck.ECPReadcheck)
  3279. {
  3280. if (SerialInit.BytesCompare_Base64(data, ECPData))
  3281. {
  3282. SetsuccessStatus(m_readECP);
  3283. }
  3284. else
  3285. {
  3286. SetfailStatus(m_readECP);
  3287. ErrMsg = string.Format("{0} contrast ECP fail!", SN);
  3288. Log.WriteErrorLog(ErrMsg);
  3289. goto end;
  3290. }
  3291. }
  3292. }
  3293. else
  3294. {
  3295. SetfailStatus(m_readECP);
  3296. ErrMsg = string.Format("{0} read ECP fail!", SN);
  3297. Log.WriteErrorLog(ErrMsg);
  3298. goto end;
  3299. }
  3300. }
  3301. else
  3302. {
  3303. SetfailStatus(m_checkECP);
  3304. ErrMsg = string.Format("{0} check ECP fail!", SN);
  3305. Log.WriteErrorLog(ErrMsg);
  3306. goto end;
  3307. }
  3308. }
  3309. else
  3310. {
  3311. SetfailStatus(m_writeECP);
  3312. ErrMsg = string.Format("{0} Write ECP fail!", SN);
  3313. Log.WriteErrorLog(ErrMsg);
  3314. goto end;
  3315. }
  3316. keyInfo.ECP.result = true;
  3317. }
  3318. //Playready抄写
  3319. if (WritePlayready.Checked)
  3320. {
  3321. if (!CommonMethod.IsNumberAndWord(keyInfo.Playready.data))
  3322. {
  3323. ErrMsg = string.Format("Playready format error!\r\n{0}", keyInfo.Playready.data);
  3324. Log.WriteErrorLog(ErrMsg);
  3325. goto end;
  3326. }
  3327. byte[] PlayreadyData = SerialInit.HexToByte(keyInfo.Playready.data);
  3328. Log.WriteInfoLog("Write Playready...");
  3329. if (SerialCMD.SetFireTVPlayready(TVPort, PlayreadyData, out result, out data, out error, SerailDelay))
  3330. {
  3331. SetsuccessStatus(m_writePlayready);
  3332. Log.WriteInfoLog("Check Playready...");
  3333. if (cfg_writecheck.PlayreadyCheckcheck ? SerialCMD.CheckFireTVPlayready(TVPort, out result, out data, out error, SerailDelay) : true)
  3334. {
  3335. SetsuccessStatus(m_checkPlayready);
  3336. Log.WriteInfoLog("Read Playready...");
  3337. if (cfg_readcheck.PlayreadyReadcheck ? SerialCMD.ReadFireTVPlayready(TVPort, out result, out data, out error, SerailDelay) : true)
  3338. {
  3339. if (cfg_readcheck.PlayreadyReadcheck)
  3340. {
  3341. if (CommonMethod.CompareMD5(PlayreadyData, data))
  3342. {
  3343. SetsuccessStatus(m_readPlayready);
  3344. }
  3345. else
  3346. {
  3347. if (SerialInit.BytesCompare_Base64(data, PlayreadyData))
  3348. {
  3349. SetsuccessStatus(m_readPlayready);
  3350. }
  3351. else
  3352. {
  3353. SetfailStatus(m_readPlayready);
  3354. ErrMsg = string.Format("{0} contrast Playready fail!", SN);
  3355. Log.WriteErrorLog(ErrMsg);
  3356. goto end;
  3357. }
  3358. }
  3359. }
  3360. }
  3361. else
  3362. {
  3363. SetfailStatus(m_readPlayready);
  3364. ErrMsg = string.Format("{0} read Playready fail!", SN);
  3365. Log.WriteErrorLog(ErrMsg);
  3366. goto end;
  3367. }
  3368. }
  3369. else
  3370. {
  3371. SetfailStatus(m_checkPlayready);
  3372. ErrMsg = string.Format("{0} check Playready fail!", SN);
  3373. Log.WriteErrorLog(ErrMsg);
  3374. goto end;
  3375. }
  3376. }
  3377. else
  3378. {
  3379. SetfailStatus(m_writePlayready);
  3380. ErrMsg = string.Format("{0} Write Playready fail!", SN);
  3381. Log.WriteErrorLog(ErrMsg);
  3382. goto end;
  3383. }
  3384. keyInfo.Playready.result = true;
  3385. }
  3386. //Hash抄写
  3387. if (WriteHash.Checked)
  3388. {
  3389. if (!CommonMethod.IsNumberAndWord(keyInfo.Hashkey.data))
  3390. {
  3391. ErrMsg = string.Format("Hash format error!\r\n{0}", keyInfo.Hashkey.data);
  3392. Log.WriteErrorLog(ErrMsg);
  3393. goto end;
  3394. }
  3395. byte[] HashData = SerialInit.HexToByte(keyInfo.Hashkey.data);
  3396. Log.WriteInfoLog("Write Hash...");
  3397. if (SerialCMD.SetFireTVHashkey(TVPort, HashData, out result, out data, out error, SerailDelay))
  3398. {
  3399. SetsuccessStatus(m_writeHash);
  3400. Log.WriteInfoLog("Check Hash...");
  3401. if (cfg_writecheck.HashCheckcheck ? SerialCMD.CheckFireTVHashkey(TVPort, out result, out data, out error, SerailDelay) : true)
  3402. {
  3403. SetsuccessStatus(m_checkHash);
  3404. Log.WriteInfoLog("Read Hash...");
  3405. if (cfg_readcheck.HashReadcheck ? SerialCMD.ReadFireTVHashkey(TVPort, out result, out data, out error, SerailDelay) : true)
  3406. {
  3407. if (cfg_readcheck.HashReadcheck)
  3408. {
  3409. if (SerialInit.BytesCompare_Base64(data, HashData))
  3410. {
  3411. SetsuccessStatus(m_readHash);
  3412. }
  3413. else
  3414. {
  3415. SetfailStatus(m_readHash);
  3416. ErrMsg = string.Format("{0} contrast Hash fail!", SN);
  3417. Log.WriteErrorLog(ErrMsg);
  3418. goto end;
  3419. }
  3420. }
  3421. }
  3422. else
  3423. {
  3424. SetfailStatus(m_readHash);
  3425. ErrMsg = string.Format("{0} read Hash fail!", SN);
  3426. Log.WriteErrorLog(ErrMsg);
  3427. goto end;
  3428. }
  3429. }
  3430. else
  3431. {
  3432. SetfailStatus(m_checkHash);
  3433. ErrMsg = string.Format("{0} check Hash fail!", SN);
  3434. Log.WriteErrorLog(ErrMsg);
  3435. goto end;
  3436. }
  3437. }
  3438. else
  3439. {
  3440. SetfailStatus(m_writeHash);
  3441. ErrMsg = string.Format("{0} Write Hash fail!", SN);
  3442. Log.WriteErrorLog(ErrMsg);
  3443. goto end;
  3444. }
  3445. keyInfo.Hashkey.result = true;
  3446. }
  3447. //频道预置
  3448. if (FunctionSettingNow.WriteChannel)
  3449. {
  3450. Log.WriteInfoLog("setting channel...");
  3451. if (SerialCMD.SetChannel(TVPort, FunctionSettingNow.ChannelCode, out result, out data, out error, SerailDelay))
  3452. {
  3453. /*
  3454. Log.WriteInfoLog("getting channel...");
  3455. if (SerialCMD.GetChannel(TVPort, out result, out data, out error))
  3456. {
  3457. if(SerialInit.BytesCompare_Base64(data, FunctionSettingNow.ChannelCode))
  3458. {
  3459. }
  3460. else
  3461. {
  3462. Log.WriteErrorLog(SN + " get different channel");
  3463. goto end;
  3464. }
  3465. }
  3466. else
  3467. {
  3468. Log.WriteErrorLog(SN + " fail to get channel");
  3469. goto end;
  3470. }*/
  3471. Log.WriteInfoLog(SN + " set channel success");
  3472. SetcolorStatus(ChannelText, Color.FromArgb(128, 255, 128));
  3473. }
  3474. else
  3475. {
  3476. ErrMsg = string.Format("{0} fail to set channel!", SN);
  3477. Log.WriteErrorLog(ErrMsg);
  3478. goto end;
  3479. }
  3480. }
  3481. //OSD语言设置
  3482. if (FunctionSettingNow.WriteOSD)
  3483. {
  3484. Log.WriteInfoLog("setting OSD language...");
  3485. if (SerialCMD.SetOSDLanguage(TVPort, FunctionSettingNow.OSDLCode, out result, out data, out error, SerailDelay))
  3486. {
  3487. if (cfg_readcheck.OSDReadcheck)
  3488. {
  3489. Log.WriteInfoLog("getting OSD language...");
  3490. if (SerialCMD.GetOSDLanguage(TVPort, out result, out data, out error, SerailDelay))
  3491. {
  3492. if (SerialInit.BytesCompare_Base64(data, FunctionSettingNow.OSDLCode))
  3493. {
  3494. SetcolorStatus(OSDText, Color.FromArgb(128, 255, 128));
  3495. }
  3496. else
  3497. {
  3498. ErrMsg = string.Format("{0} get different OSD language!", SN);
  3499. Log.WriteErrorLog(ErrMsg);
  3500. goto end;
  3501. }
  3502. }
  3503. else
  3504. {
  3505. ErrMsg = string.Format("{0} fail to get OSD language!", SN);
  3506. Log.WriteErrorLog(ErrMsg);
  3507. goto end;
  3508. }
  3509. }
  3510. else
  3511. Log.WriteInfoLog("skip read OSD language...");
  3512. }
  3513. else
  3514. {
  3515. ErrMsg = string.Format("{0} fail to set OSD language!", SN);
  3516. Log.WriteErrorLog(ErrMsg);
  3517. goto end;
  3518. }
  3519. }
  3520. //Shop语言设置
  3521. if (FunctionSettingNow.WriteSHOP)
  3522. {
  3523. Log.WriteInfoLog("setting SHOP language...");
  3524. if (SerialCMD.SetShopLanguage(TVPort, FunctionSettingNow.ShopLCode, out result, out data, out error, SerailDelay))
  3525. {
  3526. if (cfg_readcheck.SHOPReadcheck)
  3527. {
  3528. Log.WriteInfoLog("getting SHOP language...");
  3529. if (SerialCMD.GetShopLanguage(TVPort, out result, out data, out error, SerailDelay))
  3530. {
  3531. if (SerialInit.BytesCompare_Base64(data, FunctionSettingNow.ShopLCode))
  3532. {
  3533. SetcolorStatus(SHOPText, Color.FromArgb(128, 255, 128));
  3534. }
  3535. else
  3536. {
  3537. ErrMsg = string.Format("{0} get different SHOP language!", SN);
  3538. Log.WriteErrorLog(ErrMsg);
  3539. goto end;
  3540. }
  3541. }
  3542. else
  3543. {
  3544. ErrMsg = string.Format("{0} fail to get SHOP language!", SN);
  3545. Log.WriteErrorLog(ErrMsg);
  3546. goto end;
  3547. }
  3548. }
  3549. else
  3550. Log.WriteInfoLog("skip read SHOP language...");
  3551. }
  3552. else
  3553. {
  3554. ErrMsg = string.Format("{0} fail to set SHOP language!", SN);
  3555. Log.WriteErrorLog(ErrMsg);
  3556. goto end;
  3557. }
  3558. }
  3559. // EDID Pid抄写;
  3560. if (WriteEDIDPID.Checked)
  3561. {
  3562. // 4字节转成整数:0~65535,0x0000~0xffff;
  3563. if (Regex.IsMatch(keyInfo.EDIDPid.data, "^[A-Za-z0-9]{4}$"))
  3564. {
  3565. byte[] EDIDPidData = SerialInit.strToToHexByte(keyInfo.EDIDPid.data);
  3566. Log.WriteInfoLog("Write EDID Pid...");
  3567. if (SerialCMD.SetEDIDPid(TVPort, EDIDPidData, out result, out data, out error, SerailDelay))
  3568. {
  3569. SetsuccessStatus(m_writeEDIDPID);
  3570. Log.WriteInfoLog("Read EDID Pid...");
  3571. if (cfg_readcheck.EDIDPIDReadcheck ? SerialCMD.ReadEDIDPid(TVPort, out result, out data, out error, SerailDelay) : true)
  3572. {
  3573. if (cfg_readcheck.EDIDPIDReadcheck)
  3574. {
  3575. if (SerialInit.BytesCompare_Base64(data, EDIDPidData))
  3576. {
  3577. SetsuccessStatus(m_readEDIDPID);
  3578. }
  3579. else
  3580. {
  3581. SetfailStatus(m_readEDIDPID);
  3582. ErrMsg = string.Format("{0} contrast EDID PID fail!", SN);
  3583. Log.WriteErrorLog(ErrMsg);
  3584. goto end;
  3585. }
  3586. }
  3587. }
  3588. else
  3589. {
  3590. SetfailStatus(m_readEDIDPID);
  3591. ErrMsg = string.Format("{0} read EDID PID fail!", SN);
  3592. Log.WriteErrorLog(ErrMsg);
  3593. goto end;
  3594. }
  3595. }
  3596. else
  3597. {
  3598. SetfailStatus(m_writeEDIDPID);
  3599. ErrMsg = string.Format("{0} Write EDID PID fail!", SN);
  3600. Log.WriteErrorLog(ErrMsg);
  3601. goto end;
  3602. }
  3603. }
  3604. else
  3605. {
  3606. SetfailStatus(m_writeEDIDPID);
  3607. ErrMsg = string.Format("{0} The EDID PID Format Error!", SN);
  3608. Log.WriteErrorLog(ErrMsg);
  3609. goto end;
  3610. }
  3611. keyInfo.EDIDPid.result = true;
  3612. }
  3613. // EDID Mode Name抄写;
  3614. if (WriteEDIDName.Checked)
  3615. {
  3616. if (Regex.IsMatch(keyInfo.EDIDModelName.data, @"^[A-Za-z0-9][A-Za-z0-9_ -]{0,12}$"))
  3617. {
  3618. // 长度为13字节;
  3619. byte[] EDIDNameData = Encoding.ASCII.GetBytes(keyInfo.EDIDModelName.data);
  3620. Log.WriteInfoLog("Write EDID Mode Name...");
  3621. if (SerialCMD.SetEDIDModelName(TVPort, EDIDNameData, out result, out data, out error, SerailDelay))
  3622. {
  3623. SetsuccessStatus(m_writeEDIDName);
  3624. Log.WriteInfoLog("Read EDID Mode Name...");
  3625. if (cfg_readcheck.EDIDModeNameReadcheck ? SerialCMD.ReadEDIDModelName(TVPort, out result, out data, out error, SerailDelay) : true)
  3626. {
  3627. if (cfg_readcheck.EDIDModeNameReadcheck)
  3628. {
  3629. if (SerialInit.BytesCompare_Base64(data, EDIDNameData))
  3630. {
  3631. SetsuccessStatus(m_readEDIDName);
  3632. }
  3633. else
  3634. {
  3635. SetfailStatus(m_readEDIDName);
  3636. ErrMsg = string.Format("{0} contrast EDID Mode Name fail!", SN);
  3637. Log.WriteErrorLog(ErrMsg);
  3638. goto end;
  3639. }
  3640. }
  3641. }
  3642. else
  3643. {
  3644. SetfailStatus(m_readEDIDName);
  3645. ErrMsg = string.Format("{0} read EDID Mode Name fail!", SN);
  3646. Log.WriteErrorLog(ErrMsg);
  3647. goto end;
  3648. }
  3649. }
  3650. else
  3651. {
  3652. SetfailStatus(m_writeEDIDName);
  3653. ErrMsg = string.Format("{0} Write EDID Mode Name fail!", SN);
  3654. Log.WriteErrorLog(ErrMsg);
  3655. goto end;
  3656. }
  3657. }
  3658. else
  3659. {
  3660. SetfailStatus(m_writeEDIDName);
  3661. ErrMsg = string.Format("{0} The EDID Model Name Format Error!", SN);
  3662. Log.WriteErrorLog(ErrMsg);
  3663. goto end;
  3664. }
  3665. keyInfo.EDIDModelName.result = true;
  3666. }
  3667. // ACAS Key抄写;
  3668. if (WriteACASKey.Checked)
  3669. {
  3670. // 1.acas key抄写前,必须先抄写playreadkey;
  3671. // 2.将tool先抄写再抄写data;
  3672. Log.WriteInfoLog("Write ACAC Key...");
  3673. byte[] ACASKeyData = SerialInit.HexToByte(keyInfo.ACASKey_Data.data);
  3674. if (SerialCMD.SetACASKeyData(TVPort, ACASKeyData, out result, out data, out error, SerailDelay))
  3675. {
  3676. SetsuccessStatus(m_writeACASKey);
  3677. Log.WriteInfoLog("Check ACAS Key Data...");
  3678. if (cfg_writecheck.ACASKeyCheckcheck ? SerialCMD.CheckACASKeyData(TVPort, out result, out data, out error, SerailDelay) : true)
  3679. {
  3680. SetsuccessStatus(m_checkACASKey);
  3681. Log.WriteInfoLog("Read ACAS Key Data...");
  3682. if (cfg_readcheck.ACASKeyReadcheck ? SerialCMD.ReadACASKeyData(TVPort, out result, out data, out error, SerailDelay) : true)
  3683. {
  3684. if (cfg_readcheck.ACASKeyReadcheck)
  3685. {
  3686. if (CommonMethod.CompareMD5(ACASKeyData, data))
  3687. {
  3688. SetsuccessStatus(m_readACASKey);
  3689. }
  3690. else
  3691. {
  3692. SetfailStatus(m_readACASKey);
  3693. ErrMsg = string.Format("{0} contrast ACAS Key Data fail!", SN);
  3694. Log.WriteErrorLog(ErrMsg);
  3695. goto end;
  3696. }
  3697. }
  3698. }
  3699. else
  3700. {
  3701. SetfailStatus(m_readACASKey);
  3702. ErrMsg = string.Format("{0} read ACAS Key Data fail!", SN);
  3703. Log.WriteErrorLog(ErrMsg);
  3704. goto end;
  3705. }
  3706. }
  3707. else
  3708. {
  3709. SetfailStatus(m_checkACASKey);
  3710. ErrMsg = string.Format("{0} Check ACAS Key Data fail!", SN);
  3711. Log.WriteErrorLog(ErrMsg);
  3712. goto end;
  3713. }
  3714. }
  3715. else
  3716. {
  3717. SetfailStatus(m_writeACASKey);
  3718. ErrMsg = string.Format("{0} Write ACAS Key Data fail!", SN);
  3719. Log.WriteErrorLog(ErrMsg);
  3720. goto end;
  3721. }
  3722. keyInfo.ACASKey_Data.result = true;
  3723. }
  3724. //Project ID 抄写检查
  3725. if (ProjectIDNote.Text != LResource.SkipCovering)
  3726. {
  3727. Log.WriteInfoLog("Write projectID...");
  3728. if (ProjectIDNote.Text == LResource.Covering || ProjectIDNote.Text == LResource.SkipReadCheck)
  3729. {
  3730. SetspecificText(ProjectIDNote, ProjectIDNote.Text, Color.FromArgb(128, 255, 128));
  3731. byte[] param = CommonMethod.InttoBytelist(Convert.ToInt32(ProjectIDText.Text));
  3732. Log.WriteInfoLog("Set projectID...");
  3733. if (SerialCMD.SetProjectId(TVPort, param, out result, out data, out error, SerailDelay))
  3734. {
  3735. if (ProjectIDNote.Text != LResource.SkipReadCheck)
  3736. {
  3737. Log.WriteInfoLog("Check projectID...");
  3738. if (cfg_writedone.PIDWriteDelay > 0)
  3739. {
  3740. Thread.Sleep(cfg_writedone.PIDWriteDelay);//MS6586切完PID需要强制等待3s
  3741. }
  3742. if (SerialCMD.GetProjectID(TVPort, out result, out data, out error, SerailDelay, CommonMethod.IsEDIDCopy(midListNow)))
  3743. {
  3744. int readpid2 = CommonMethod.BytelisttoInt(data);
  3745. if (readpid2.ToString() != ProjectIDText.Text)
  3746. {
  3747. SetcolorStatus(ProjectIDText, Color.Red);
  3748. ErrMsg = SN + " read project id:" + readpid2.ToString() + "different from written: " + ProjectIDText.Text + " error";
  3749. Log.WriteErrorLog(ErrMsg);
  3750. goto end;
  3751. }
  3752. else
  3753. {
  3754. SetcolorStatus(ProjectIDText, Color.Green);
  3755. }
  3756. }
  3757. else
  3758. {
  3759. SetcolorStatus(ProjectIDText, Color.Red);
  3760. ErrMsg = string.Format("{0} get project id error!", SN);
  3761. Log.WriteErrorLog(ErrMsg);
  3762. goto end;
  3763. }
  3764. }
  3765. else
  3766. {
  3767. Log.WriteInfoLog("Skip check projectID...");
  3768. }
  3769. }
  3770. else
  3771. {
  3772. SetcolorStatus(ProjectIDText, Color.Red);
  3773. ErrMsg = string.Format("{0} set project id error!", SN);
  3774. Log.WriteErrorLog(ErrMsg);
  3775. goto end;
  3776. }
  3777. }
  3778. else
  3779. {
  3780. if (SerialCMD.GetProjectID(TVPort, out result, out data, out error, SerailDelay, CommonMethod.IsEDIDCopy(midListNow)))
  3781. {
  3782. int readpid = CommonMethod.BytelisttoInt(data);
  3783. if (readpid.ToString() != ProjectIDText.Text)
  3784. {
  3785. MessageBoxButtons messButton = MessageBoxButtons.YesNoCancel;
  3786. DialogResult dr = MessageBox.Show(LResource.MainboardPID + readpid.ToString() + LResource.DifferentFromSetting + "\r\n" + LResource.CoveringPID, LResource.Error, messButton);
  3787. if (dr == DialogResult.Yes)
  3788. {
  3789. SetspecificText(ProjectIDNote, LResource.Covering, Color.FromArgb(128, 255, 128));
  3790. byte[] param = CommonMethod.InttoBytelist(Convert.ToInt32(ProjectIDText.Text));
  3791. if (SerialCMD.SetProjectId(TVPort, param, out result, out data, out error, SerailDelay))
  3792. {
  3793. if (cfg_writedone.PIDWriteDelay > 0)
  3794. {
  3795. Thread.Sleep(cfg_writedone.PIDWriteDelay);//MS6586切完PID需要强制等待3s
  3796. }
  3797. Log.WriteInfoLog("Check projectID...");
  3798. if (SerialCMD.GetProjectID(TVPort, out result, out data, out error, SerailDelay, CommonMethod.IsEDIDCopy(midListNow)))
  3799. {
  3800. int readpid2 = CommonMethod.BytelisttoInt(data);
  3801. if (readpid2.ToString() != ProjectIDText.Text)
  3802. {
  3803. SetcolorStatus(ProjectIDText, Color.Red);
  3804. ErrMsg = SN + " read project id:" + readpid2.ToString() + "different from written: " + ProjectIDText.Text + " error";
  3805. Log.WriteErrorLog(ErrMsg);
  3806. goto end;
  3807. }
  3808. else
  3809. {
  3810. SetcolorStatus(ProjectIDText, Color.Green);
  3811. }
  3812. }
  3813. else
  3814. {
  3815. SetcolorStatus(ProjectIDText, Color.Red);
  3816. ErrMsg = string.Format("{0} get project id error!", SN);
  3817. Log.WriteErrorLog(ErrMsg);
  3818. goto end;
  3819. }
  3820. }
  3821. else
  3822. {
  3823. SetcolorStatus(ProjectIDText, Color.Red);
  3824. ErrMsg = string.Format("{0} set project id error!", SN);
  3825. Log.WriteErrorLog(ErrMsg);
  3826. goto end;
  3827. }
  3828. }
  3829. else if (dr == DialogResult.No)
  3830. {
  3831. SetspecificText(ProjectIDNote, LResource.SkipCovering, Color.Yellow);
  3832. SetcolorStatus(ProjectIDText, Color.Yellow);
  3833. }
  3834. else
  3835. {
  3836. SetspecificText(ProjectIDNote, readpid.ToString(), Color.Red);
  3837. SetcolorStatus(ProjectIDText, Color.Red);
  3838. goto end;
  3839. }
  3840. }
  3841. else
  3842. {
  3843. SetcolorStatus(ProjectIDText, Color.FromArgb(128, 255, 128));
  3844. }
  3845. }
  3846. else
  3847. {
  3848. ErrMsg = string.Format("{0} Read ProjectID fail!", SN);
  3849. Log.WriteErrorLog(ErrMsg);
  3850. goto end;
  3851. }
  3852. }
  3853. }
  3854. //检查ClientType
  3855. if (ClientTypeNote.Text != LResource.SkipChecking)
  3856. {
  3857. Log.WriteInfoLog("Read ClientType...");
  3858. if (SerialCMD.GetClientType(TVPort, out result, out data, out error, SerailDelay))
  3859. {
  3860. string ctype = Encoding.ASCII.GetString(data);
  3861. if (ctype != ClientTypeText.Text)
  3862. {
  3863. MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
  3864. DialogResult dr = MessageBox.Show(LResource.MainboardCType + ctype + LResource.differentfromserver + ClientTypeText.Text + "\r\n" + LResource.SkipCTypeChecking, LResource.Error, messButton);
  3865. if (dr == DialogResult.OK)
  3866. {
  3867. SetspecificText(ClientTypeNote, LResource.SkipChecking, Color.Yellow);
  3868. SetcolorStatus(ClientTypeText, Color.Yellow);
  3869. }
  3870. else
  3871. {
  3872. SetspecificText(ClientTypeNote, ctype, Color.Red);
  3873. SetcolorStatus(ClientTypeText, Color.Red);
  3874. goto end;
  3875. }
  3876. }
  3877. else
  3878. {
  3879. SetcolorStatus(ClientTypeText, Color.FromArgb(128, 255, 128));
  3880. }
  3881. }
  3882. else
  3883. {
  3884. ErrMsg = string.Format("{0} Read ClientType fail!", SN);
  3885. Log.WriteErrorLog(ErrMsg);
  3886. goto end;
  3887. }
  3888. }
  3889. //白平衡初始化
  3890. if (FunctionSettingNow.WBInit)
  3891. {
  3892. Log.WriteInfoLog("WhiteBalance init...");
  3893. if (SerialCMD.WBInit(TVPort, out result, out data, out error, SerailDelay))
  3894. {
  3895. }
  3896. else
  3897. {
  3898. ErrMsg = string.Format("{0} WhiteBalance ini fail!", SN);
  3899. Log.WriteErrorLog(ErrMsg);
  3900. goto end;
  3901. }
  3902. }
  3903. //白平衡赋值
  3904. if (FunctionSettingNow.WriteWB)
  3905. {
  3906. Log.WriteInfoLog("Set normal RGB...");
  3907. if (SerialCMD.SetWBNormal(TVPort, FunctionSettingNow.NormalRGB, out result, out data, out error, SerailDelay))
  3908. {
  3909. Log.WriteInfoLog("Set cool RGB...");
  3910. if (SerialCMD.SetWBCool(TVPort, FunctionSettingNow.CoolRGB, out result, out data, out error, SerailDelay))
  3911. {
  3912. Log.WriteInfoLog("Set warm RGB...");
  3913. if (SerialCMD.SetWBWarm(TVPort, FunctionSettingNow.WarmRGB, out result, out data, out error, SerailDelay))
  3914. {
  3915. SetcolorStatus(WBPathText, Color.FromArgb(128, 255, 128));
  3916. }
  3917. else
  3918. {
  3919. ErrMsg = string.Format("{0} Set warm RGB fail!", SN);
  3920. Log.WriteErrorLog(ErrMsg);
  3921. goto end;
  3922. }
  3923. }
  3924. else
  3925. {
  3926. ErrMsg = string.Format("{0} Set cool RGB fail!", SN);
  3927. Log.WriteErrorLog(ErrMsg);
  3928. goto end;
  3929. }
  3930. }
  3931. else
  3932. {
  3933. ErrMsg = string.Format("{0} Set normal RGB fail!", SN);
  3934. Log.WriteErrorLog(ErrMsg);
  3935. goto end;
  3936. }
  3937. }
  3938. //Roku客户服务信息抄写
  3939. if (midListNow.rokuCustomer != null)
  3940. {
  3941. string brand = midListNow.rokuCustomer.brand;
  3942. Log.WriteInfoLog("Write Roku brand...");
  3943. if (SerialCMD.SetROKUBrand(TVPort, Encoding.ASCII.GetBytes(brand), out result, out data, out error, SerailDelay))
  3944. {
  3945. Log.WriteInfoLog("Check Roku brand...");
  3946. if (SerialCMD.CheckROKUBrand(TVPort, out result, out data, out error, SerailDelay))
  3947. {
  3948. Log.WriteInfoLog("Read Roku brand...");
  3949. if (SerialCMD.GetROKUBrand(TVPort, out result, out data, out error, SerailDelay))
  3950. {
  3951. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(brand)))
  3952. {
  3953. Log.WriteInfoLog("ROKU brand 写入成功:" + Encoding.ASCII.GetString(data));
  3954. }
  3955. else
  3956. {
  3957. ErrMsg = string.Format("{0} Contrast ROKU brand fail!", SN);
  3958. Log.WriteErrorLog(ErrMsg);
  3959. goto end;
  3960. }
  3961. }
  3962. else
  3963. {
  3964. ErrMsg = string.Format("{0} Read ROKU brand fail!", SN);
  3965. Log.WriteErrorLog(ErrMsg);
  3966. goto end;
  3967. }
  3968. }
  3969. else
  3970. {
  3971. ErrMsg = string.Format("{0} Check ROKU brand fail!", SN);
  3972. Log.WriteErrorLog(ErrMsg);
  3973. goto end;
  3974. }
  3975. }
  3976. else
  3977. {
  3978. ErrMsg = string.Format("{0} Write ROKU brand fail!", SN);
  3979. Log.WriteErrorLog(ErrMsg);
  3980. goto end;
  3981. }
  3982. string model = midListNow.rokuCustomer.oemmodel;
  3983. Log.WriteInfoLog("Write Roku model...");
  3984. if (SerialCMD.SetModelName(TVPort, Encoding.ASCII.GetBytes(model), out result, out data, out error, SerailDelay))
  3985. {
  3986. Log.WriteInfoLog("Check Roku model...");
  3987. if (SerialCMD.CheckModelName(TVPort, out result, out data, out error, SerailDelay))
  3988. {
  3989. Log.WriteInfoLog("Read Roku model...");
  3990. if (SerialCMD.GetModelName(TVPort, out result, out data, out error, SerailDelay))
  3991. {
  3992. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(model)))
  3993. {
  3994. Log.WriteInfoLog("ROKU model 写入成功:" + Encoding.ASCII.GetString(data));
  3995. }
  3996. else
  3997. {
  3998. ErrMsg = string.Format("{0} Contrast ROKU model fail!", SN);
  3999. Log.WriteErrorLog(ErrMsg);
  4000. goto end;
  4001. }
  4002. }
  4003. else
  4004. {
  4005. ErrMsg = string.Format("{0} Read ROKU model fail!", SN);
  4006. Log.WriteErrorLog(ErrMsg);
  4007. goto end;
  4008. }
  4009. }
  4010. else
  4011. {
  4012. ErrMsg = string.Format("{0} Check ROKU model fail!", SN);
  4013. Log.WriteErrorLog(ErrMsg);
  4014. goto end;
  4015. }
  4016. }
  4017. else
  4018. {
  4019. ErrMsg = string.Format("{0} Write ROKU model fail!", SN);
  4020. Log.WriteErrorLog(ErrMsg);
  4021. goto end;
  4022. }
  4023. string[] dateInit = midListNow.rokuCustomer.productiondate.Split('-');
  4024. byte[] productdate = new byte[3] { Convert.ToByte(dateInit[0]), Convert.ToByte(dateInit[1]), Convert.ToByte(dateInit[2]) };
  4025. Log.WriteInfoLog("Write Roku production date...");
  4026. if (SerialCMD.SetROKUProductionDate(TVPort, productdate, out result, out data, out error, SerailDelay))
  4027. {
  4028. Log.WriteInfoLog("Check Roku production date...");
  4029. if (SerialCMD.CheckROKUProductionDate(TVPort, out result, out data, out error, SerailDelay))
  4030. {
  4031. Log.WriteInfoLog("Read Roku production date...");
  4032. if (SerialCMD.GetROKUProductionDate(TVPort, out result, out data, out error, SerailDelay))
  4033. {
  4034. string date = "20" + productdate[0].ToString() + "." + productdate[1].ToString() + ".WW" + productdate[2].ToString();
  4035. if (Encoding.ASCII.GetString(data) == date)
  4036. {
  4037. Log.WriteInfoLog("ROKU production date 写入成功:" + Encoding.ASCII.GetString(data));
  4038. }
  4039. else
  4040. {
  4041. ErrMsg = string.Format("{0} Contrast ROKU production fail!", SN);
  4042. Log.WriteErrorLog(ErrMsg);
  4043. goto end;
  4044. }
  4045. }
  4046. else
  4047. {
  4048. ErrMsg = string.Format("{0} Read ROKU production fail!", SN);
  4049. Log.WriteErrorLog(ErrMsg);
  4050. goto end;
  4051. }
  4052. }
  4053. else
  4054. {
  4055. ErrMsg = string.Format("{0} Check ROKU production fail!", SN);
  4056. Log.WriteErrorLog(ErrMsg);
  4057. goto end;
  4058. }
  4059. }
  4060. else
  4061. {
  4062. ErrMsg = string.Format("{0} Write ROKU production fail!", SN);
  4063. Log.WriteErrorLog(ErrMsg);
  4064. goto end;
  4065. }
  4066. string region = midListNow.rokuCustomer.region;
  4067. Log.WriteInfoLog("Write Roku region...");
  4068. if (SerialCMD.SetROKURegion(TVPort, Encoding.ASCII.GetBytes(region), out result, out data, out error, SerailDelay))
  4069. {
  4070. Log.WriteInfoLog("Check Roku region...");
  4071. if (SerialCMD.CheckROKURegion(TVPort, out result, out data, out error, SerailDelay))
  4072. {
  4073. Log.WriteInfoLog("Read Roku region...");
  4074. if (SerialCMD.GetROKURegion(TVPort, out result, out data, out error, SerailDelay))
  4075. {
  4076. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(region)))
  4077. {
  4078. Log.WriteInfoLog("ROKU region 写入成功:" + Encoding.ASCII.GetString(data));
  4079. }
  4080. else
  4081. {
  4082. ErrMsg = string.Format("{0} Contrast ROKU region fail!", SN);
  4083. Log.WriteErrorLog(ErrMsg);
  4084. goto end;
  4085. }
  4086. }
  4087. else
  4088. {
  4089. ErrMsg = string.Format("{0} Read ROKU region fail!", SN);
  4090. Log.WriteErrorLog(ErrMsg);
  4091. goto end;
  4092. }
  4093. }
  4094. else
  4095. {
  4096. ErrMsg = string.Format("{0} Check ROKU region fail!", SN);
  4097. Log.WriteErrorLog(ErrMsg);
  4098. goto end;
  4099. }
  4100. }
  4101. else
  4102. {
  4103. ErrMsg = string.Format("{0} Write ROKU region fail!", SN);
  4104. Log.WriteErrorLog(ErrMsg);
  4105. goto end;
  4106. }
  4107. string phone = midListNow.rokuCustomer.supportphone;
  4108. Log.WriteInfoLog("Write Roku phone...");
  4109. if (SerialCMD.SetROKUSupportPhone(TVPort, Encoding.ASCII.GetBytes(phone), out result, out data, out error, SerailDelay))
  4110. {
  4111. Log.WriteInfoLog("Check Roku phone...");
  4112. if (SerialCMD.CheckROKUSupportPhone(TVPort, out result, out data, out error, SerailDelay))
  4113. {
  4114. Log.WriteInfoLog("Read Roku phone...");
  4115. if (SerialCMD.GetROKUSupportPhone(TVPort, out result, out data, out error, SerailDelay))
  4116. {
  4117. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(phone)))
  4118. {
  4119. Log.WriteInfoLog("ROKU phone 写入成功:" + Encoding.ASCII.GetString(data));
  4120. }
  4121. else
  4122. {
  4123. ErrMsg = string.Format("{0} Contrast ROKU phone fail!", SN);
  4124. Log.WriteErrorLog(ErrMsg);
  4125. goto end;
  4126. }
  4127. }
  4128. else
  4129. {
  4130. ErrMsg = string.Format("{0} Read ROKU phone fail!", SN);
  4131. Log.WriteErrorLog(ErrMsg);
  4132. goto end;
  4133. }
  4134. }
  4135. else
  4136. {
  4137. ErrMsg = string.Format("{0} Check ROKU phone fail!", SN);
  4138. Log.WriteErrorLog(ErrMsg);
  4139. goto end;
  4140. }
  4141. }
  4142. else
  4143. {
  4144. ErrMsg = string.Format("{0} Write ROKU phone fail!", SN);
  4145. Log.WriteErrorLog(ErrMsg);
  4146. goto end;
  4147. }
  4148. string url = midListNow.rokuCustomer.supporturl;
  4149. Log.WriteInfoLog("Write Roku url...");
  4150. if (SerialCMD.SetROKUSupportURL(TVPort, Encoding.ASCII.GetBytes(url), out result, out data, out error, SerailDelay))
  4151. {
  4152. Log.WriteInfoLog("Check Roku url...");
  4153. if (SerialCMD.CheckROKUSupportURL(TVPort, out result, out data, out error, SerailDelay))
  4154. {
  4155. Log.WriteInfoLog("Read Roku url...");
  4156. if (SerialCMD.GetROKUSupportURL(TVPort, out result, out data, out error, SerailDelay))
  4157. {
  4158. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(url)))
  4159. {
  4160. Log.WriteInfoLog("ROKU url 写入成功:" + Encoding.ASCII.GetString(data));
  4161. }
  4162. else
  4163. {
  4164. ErrMsg = string.Format("{0} Contrast ROKU url fail!", SN);
  4165. Log.WriteErrorLog(ErrMsg);
  4166. goto end;
  4167. }
  4168. }
  4169. else
  4170. {
  4171. ErrMsg = string.Format("{0} Read ROKU url fail!", SN);
  4172. Log.WriteErrorLog(ErrMsg);
  4173. goto end;
  4174. }
  4175. }
  4176. else
  4177. {
  4178. ErrMsg = string.Format("{0} Check ROKU url fail!", SN);
  4179. Log.WriteErrorLog(ErrMsg);
  4180. goto end;
  4181. }
  4182. }
  4183. else
  4184. {
  4185. ErrMsg = string.Format("{0} Write ROKU url fail!", SN);
  4186. Log.WriteErrorLog(ErrMsg);
  4187. goto end;
  4188. }
  4189. if (midListNow.rokuCustomer.remotetype.Length > 0 && midListNow.rokuCustomer.remotetype != "null")
  4190. {
  4191. byte[] remotetype = new byte[1] { Convert.ToByte(midListNow.rokuCustomer.remotetype) };
  4192. Log.WriteInfoLog("Write Roku remotetype...");
  4193. if (SerialCMD.SetROKURemoteType(TVPort, remotetype, out result, out data, out error, SerailDelay))
  4194. {
  4195. Log.WriteInfoLog("Check Roku remotetype...");
  4196. if (SerialCMD.CheckROKURemoteType(TVPort, out result, out data, out error, SerailDelay))
  4197. {
  4198. Log.WriteInfoLog("Read Roku remotetype...");
  4199. if (SerialCMD.GetROKURemoteType(TVPort, out result, out data, out error, SerailDelay))
  4200. {
  4201. if (SerialInit.BytesCompare_Base64(data, remotetype))
  4202. {
  4203. Log.WriteInfoLog("ROKU remotetype 写入成功:" + Encoding.ASCII.GetString(data));
  4204. }
  4205. else
  4206. {
  4207. ErrMsg = string.Format("{0} Contrast ROKU remotetype fail!", SN);
  4208. Log.WriteErrorLog(ErrMsg);
  4209. goto end;
  4210. }
  4211. }
  4212. else
  4213. {
  4214. ErrMsg = string.Format("{0} Read ROKU remotetype fail!", SN);
  4215. Log.WriteErrorLog(ErrMsg);
  4216. goto end;
  4217. }
  4218. }
  4219. else
  4220. {
  4221. ErrMsg = string.Format("{0} Check ROKU remotetype fail!", SN);
  4222. Log.WriteErrorLog(ErrMsg);
  4223. goto end;
  4224. }
  4225. }
  4226. else
  4227. {
  4228. ErrMsg = string.Format("{0} Write ROKU remotetype fail!", SN);
  4229. Log.WriteErrorLog(ErrMsg);
  4230. goto end;
  4231. }
  4232. }
  4233. SetcolorStatus(ProductMsg_Text, Color.FromArgb(128, 255, 128));
  4234. }
  4235. // DSN抄写;
  4236. if (WriteDSN.Checked)
  4237. {
  4238. if (FunctionSettingNow.MITVEnable)
  4239. {// 小米的DSN抄写不用这么多处理;
  4240. if (!CommonMethod.IsNumberAndWord(keyInfo.DSN.data))
  4241. {
  4242. ErrMsg = string.Format("DSN format error!\r\n{0}", keyInfo.DSN.data);
  4243. Log.WriteErrorLog(ErrMsg);
  4244. goto end;
  4245. }
  4246. byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(keyInfo.DSN.data);
  4247. Log.WriteInfoLog("Write DSN...");
  4248. if (SerialCMD.SetFireTVDSN(TVPort, DSNData, out result, out data, out error, SerailDelay))
  4249. {
  4250. SetsuccessStatus(m_writeDSN);
  4251. Log.WriteInfoLog("Check DSN...");
  4252. if (cfg_writecheck.DSNCheckcheck ? SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4253. {
  4254. SetsuccessStatus(m_checkDSN);
  4255. Log.WriteInfoLog("Read DSN...");
  4256. if (cfg_readcheck.DSNReadcheck ? SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4257. {
  4258. if (SerialInit.BytesCompare_Base64(data, DSNData))
  4259. {
  4260. SetsuccessStatus(m_readDSN);
  4261. //DSN读取别对成功
  4262. }
  4263. else
  4264. {
  4265. SetfailStatus(m_readDSN);
  4266. ErrMsg = string.Format("{0} contrast DSN fail!", SN);
  4267. Log.WriteErrorLog(ErrMsg);
  4268. goto end;
  4269. }
  4270. }
  4271. else
  4272. {
  4273. SetfailStatus(m_readDSN);
  4274. ErrMsg = string.Format("{0} read DSN fail!", SN);
  4275. Log.WriteErrorLog(ErrMsg);
  4276. goto end;
  4277. }
  4278. }
  4279. else
  4280. {
  4281. SetfailStatus(m_checkDSN);
  4282. ErrMsg = string.Format("{0} check DSN fail!", SN);
  4283. Log.WriteErrorLog(ErrMsg);
  4284. goto end;
  4285. }
  4286. }
  4287. else
  4288. {
  4289. SetfailStatus(m_writeDSN);
  4290. ErrMsg = string.Format("{0} Write DSN fail!", SN);
  4291. Log.WriteErrorLog(ErrMsg);
  4292. goto end;
  4293. }
  4294. }
  4295. else
  4296. {// 如果是G客户,要在抄写其他key前时行fsn+psn查重处理;
  4297. if (!CommonMethod.IsNumberAndWord(keyInfo.DSN.data))
  4298. {
  4299. ErrMsg = string.Format("DSN format error!\r\n{0}", keyInfo.DSN.data);
  4300. Log.WriteErrorLog(ErrMsg);
  4301. goto end;
  4302. }
  4303. byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(keyInfo.DSN.data);
  4304. Log.WriteInfoLog("Write DSN...");
  4305. if (SerialCMD.SetFireTVDSN(TVPort, DSNData, out result, out data, out error, SerailDelay))
  4306. {
  4307. SetsuccessStatus(m_writeDSN);
  4308. Log.WriteInfoLog("Check DSN...");
  4309. if (cfg_writecheck.DSNCheckcheck ? SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4310. {
  4311. SetsuccessStatus(m_checkDSN);
  4312. Log.WriteInfoLog("Read DSN...");
  4313. if (cfg_readcheck.DSNReadcheck ? SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4314. {
  4315. if (SerialInit.BytesCompare_Base64(data, DSNData))
  4316. {
  4317. //DSN读取别对成功
  4318. SetsuccessStatus(m_readDSN);
  4319. }
  4320. else
  4321. {
  4322. SetfailStatus(m_readDSN);
  4323. ErrMsg = string.Format("{0} contrast DSN fail!", SN);
  4324. Log.WriteErrorLog(ErrMsg);
  4325. goto end;
  4326. }
  4327. }
  4328. else
  4329. {
  4330. SetfailStatus(m_readDSN);
  4331. ErrMsg = string.Format("{0} read DSN fail!", SN);
  4332. Log.WriteErrorLog(ErrMsg);
  4333. goto end;
  4334. }
  4335. }
  4336. else
  4337. {
  4338. SetfailStatus(m_checkDSN);
  4339. ErrMsg = string.Format("{0} check DSN fail!", SN);
  4340. Log.WriteErrorLog(ErrMsg);
  4341. goto end;
  4342. }
  4343. }
  4344. else
  4345. {
  4346. SetfailStatus(m_writeDSN);
  4347. ErrMsg = string.Format("{0} Write DSN fail!", SN);
  4348. Log.WriteErrorLog(ErrMsg);
  4349. goto end;
  4350. }
  4351. }
  4352. keyInfo.DSN.result = true;
  4353. }
  4354. #region 小米FireTV功能;
  4355. if (FunctionSettingNow.MITVEnable)
  4356. {
  4357. // 读取PSN;
  4358. if (SerialCMD.ReadFireTVPSN(TVPort, out result, out data, out error, SerailDelay))
  4359. {
  4360. _MiKey._PSN = Encoding.ASCII.GetString(data);
  4361. }
  4362. else
  4363. {
  4364. ErrMsg = string.Format("读取PSN失败 {0}", error);
  4365. Log.WriteErrorLog(ErrMsg);
  4366. goto end;
  4367. }
  4368. // CVT抄写: Hashkey、HDCP_KEY1.4、HDCP2.2_KEY、CI_PLUS_KEY、ECP_KEY、FVP
  4369. // 激活FVP;
  4370. byte[] FVPData = new byte[] { };
  4371. if (!SerialCMD.ActiveMiFireTVFVP(TVPort, FVPData, out result, out data, out error, SerailDelay))
  4372. {
  4373. ErrMsg = string.Format("激活FVP失败 {0}", error);
  4374. Log.WriteErrorLog(ErrMsg);
  4375. goto end;
  4376. }
  4377. SetsuccessStatus(m_writeFVP);
  4378. if (!SerialCMD.CheckMiFireTVFVP(TVPort, out result, out data, out error, SerailDelay))
  4379. {
  4380. ErrMsg = string.Format("Check FVP失败 {0}", error);
  4381. Log.WriteErrorLog(ErrMsg);
  4382. goto end;
  4383. }
  4384. SetsuccessStatus(m_checkFVP);
  4385. if (cfg_writecheck.HashCheckcheck ? !SerialCMD.CheckFireTVHashkey(TVPort, out result, out data, out error, SerailDelay) : false)
  4386. {
  4387. ErrMsg = string.Format("Check Hashkey失败 {0}", error);
  4388. Log.WriteErrorLog(ErrMsg);
  4389. goto end;
  4390. }
  4391. if (cfg_writecheck.CI_plusCheckcheck ? !SerialCMD.CheckCikey(TVPort, out result, out data, out error, SerailDelay) : false)
  4392. {
  4393. ErrMsg = string.Format("Check Cikey失败 {0}", error);
  4394. Log.WriteErrorLog(ErrMsg);
  4395. goto end;
  4396. }
  4397. if (cfg_writecheck.ECPCheckcheck ? !SerialCMD.CheckECP(TVPort, out result, out data, out error, SerailDelay) : false)
  4398. {
  4399. ErrMsg = string.Format("Check Cikey失败 {0}", error);
  4400. Log.WriteErrorLog(ErrMsg);
  4401. goto end;
  4402. }
  4403. if (cfg_writecheck.HDCPCheckcheck ? !SerialCMD.CheckHDCP(TVPort, out result, out data, out error, SerailDelay) : false)
  4404. {
  4405. ErrMsg = string.Format("Check HDCP 失败 {0}", error);
  4406. Log.WriteErrorLog(ErrMsg);
  4407. goto end;
  4408. }
  4409. if (cfg_writecheck.HDCP22Checkcheck ? !SerialCMD.CheckHDCP22(TVPort, out result, out data, out error, SerailDelay) : false)
  4410. {
  4411. ErrMsg = string.Format("Check HDCP22 失败 {0}", error);
  4412. Log.WriteErrorLog(ErrMsg);
  4413. goto end;
  4414. }
  4415. // 读取HDCP;
  4416. if (cfg_readcheck.HDCPReadcheck ? !SerialCMD.GetHDCPKey(TVPort, out result, out data, out error, SerailDelay) : false)
  4417. {
  4418. ErrMsg = string.Format("读取HDCP失败 {0}", error);
  4419. Log.WriteErrorLog(ErrMsg);
  4420. goto end;
  4421. }
  4422. _MiKey._HDCP14 = cfg_readcheck.HDCPReadcheck ? data.Length : 0;
  4423. // 读取HDCP;
  4424. if (cfg_readcheck.HDCP22Readcheck ? !SerialCMD.GetHDCPKey22(TVPort, out result, out data, out error, SerailDelay) : false)
  4425. {
  4426. ErrMsg = string.Format("读取HDCP22失败 {0}", error);
  4427. Log.WriteErrorLog(ErrMsg);
  4428. goto end;
  4429. }
  4430. _MiKey._HDCP22 = cfg_readcheck.HDCP22Readcheck ? data.Length : 0;
  4431. }
  4432. #endregion
  4433. // 生成IDM报文;
  4434. keycontent = GenerateReportInfo();
  4435. //自定义指令发送
  4436. if (FunctionSettingNow.CustomCMD != null)
  4437. {
  4438. if (FunctionSettingNow.CustomCMD.Count > 0)
  4439. {
  4440. foreach (string cmd in FunctionSettingNow.CustomCMD.Values)
  4441. {
  4442. byte[] Cmddata = SerialInit.HexToByte(cmd);
  4443. TVPort.Write(Cmddata, 0, Cmddata.Count());
  4444. Thread.Sleep(500);
  4445. }
  4446. }
  4447. }
  4448. #region 波兰工厂DHA功能-抄写所有Key后执行Trigger和Check指令;
  4449. if (FunctionSettingNow.DHA == true)
  4450. {
  4451. Log.WriteInfoLog("Start to Trigger DHA...");
  4452. if (SerialCMD.TriggerDHA(TVPort, out result, out data, out error, SerailDelay))
  4453. {
  4454. Thread.Sleep(FunctionSettingNow.CheckDHAWaitTime);
  4455. Log.WriteInfoLog("Start to Check DHA...");
  4456. if (!SerialCMD.CheckDHA(TVPort, out result, out data, out error, SerailDelay))
  4457. {
  4458. ErrMsg = string.Format("{0} Check DHA Fail", SN);
  4459. Log.WriteErrorLog(ErrMsg);
  4460. goto end;
  4461. }
  4462. }
  4463. else
  4464. {
  4465. ErrMsg = string.Format("{0} Trigger DHA Fail", SN);
  4466. Log.WriteErrorLog(ErrMsg);
  4467. goto end;
  4468. }
  4469. }
  4470. #endregion
  4471. //数据上传
  4472. if (midListNow.host == "LocalPC" && !preloadNow)
  4473. {// 离线抄写
  4474. if (GetLocalKeyCount.DeleteLocalKeys(keypath, keyStream, keyReader))
  4475. {
  4476. TestResult = 1;
  4477. UploadCopyCount();
  4478. LocalTxtRecord.LocalRecord(keycontent + "sversionid=" + localmidList.version + "&clienttype=" + localmidList.clienttype + "&ordernum=" + orderNow + "\r\n", orderNow);
  4479. }
  4480. else
  4481. {
  4482. ErrMsg = "Fail to delete local keys";
  4483. Log.WriteErrorLog(ErrMsg);
  4484. goto end;
  4485. }
  4486. }
  4487. else if (preloadNow)
  4488. {// 预绑定抄写;
  4489. //更新DB抄写状态
  4490. if (SQLiteHelper.UpdateCopyStatus(localDBNow, SN, out string copydate))
  4491. {
  4492. UploadCopyCount();
  4493. TestResult = 1;
  4494. }
  4495. else
  4496. {
  4497. ErrMsg = string.Format("{0} update copy record fail!", SN);
  4498. Log.WriteErrorLog(ErrMsg);
  4499. goto end;
  4500. }
  4501. //上传抄写状态
  4502. if (midListNow.host != "LocalPC")
  4503. CommonMethod.UploadPreloadCopyResult(MidAddressNow.host, copydate, SN, localDBNow, errorDBNow, false, "", FunctionSettingNow.ReportTimeOut);
  4504. }
  4505. else if (!CommonMethod.HTTPChecker(midListNow.host))
  4506. {
  4507. Log.WriteGetKeyLog("Order:" + orderNow + " host is null,scanning sn:" + SN);
  4508. TestResult = 1;
  4509. UploadCopyCount();
  4510. UpdateKeys(midListNow.keytype, false);
  4511. }
  4512. else
  4513. {// 在线抄写;
  4514. if (WriteDID.Checked)
  4515. {
  4516. if (CommonMethod.UploadCopyResult(keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow, midListNow.host + "/report.do?", errorDBNow, orderNow, false, "", FunctionSettingNow.ReportTimeOut))
  4517. TestResult = 1;
  4518. else
  4519. {
  4520. TestResult = 0;
  4521. UploadCopyCount();
  4522. ErrMsg = "上报结果到MID系统失败";
  4523. Log.WriteErrorLog(ErrMsg);
  4524. UpdateKeys(midListNow.keytype, false);
  4525. goto end;
  4526. }
  4527. }
  4528. else
  4529. {
  4530. if (SN.Trim().Length > 0)
  4531. {
  4532. keycontent += "nodid=true&";
  4533. if (CommonMethod.UploadCopyResult(keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow, midListNow.host + "/report.do?", errorDBNow, orderNow, false, "", FunctionSettingNow.ReportTimeOut))
  4534. TestResult = 1;
  4535. else
  4536. {
  4537. TestResult = 0;
  4538. UploadCopyCount();
  4539. ErrMsg = "上报结果到MID系统失败";
  4540. Log.WriteErrorLog(ErrMsg);
  4541. UpdateKeys(midListNow.keytype, false);
  4542. goto end;
  4543. }
  4544. }
  4545. else
  4546. {
  4547. LocalTxtRecord.LocalRecord(midListNow.host + "/report.do?\r\n" + keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow + "\r\n\r\n", orderNow);
  4548. if (FunctionSettingNow.AllowNoScanning)
  4549. {
  4550. TestResult = 1;
  4551. }
  4552. else
  4553. {
  4554. ErrMsg = "未扫码启动数据抄写";
  4555. Log.WriteErrorLog(ErrMsg);
  4556. MessageBox.Show("You must scan to start the burning!");
  4557. TestResult = 0;
  4558. }
  4559. }
  4560. }
  4561. // 上报完成后,更新本地数据库Key的数量;
  4562. UploadCopyCount();
  4563. // 同时,在线更新Key数量;
  4564. UpdateKeys(midListNow.keytype, false);
  4565. }
  4566. if (FunctionSettingNow.ExportSNACASID)
  4567. {
  4568. SerialCMD.ReadJapaneseACASID(TVPort, out result, out data, out error, SerailDelay);
  4569. CommonMethod.ExportSNACASID(orderNow, SN, Encoding.ASCII.GetString(data));
  4570. }
  4571. #region 小米FireTV功能;
  4572. if (FunctionSettingNow.MITVEnable)
  4573. {
  4574. if (!ReportMIInfo(out error))
  4575. {
  4576. TestResult = 0;
  4577. ErrMsg = string.Format("{0} ReportMIInfo ini fail! {1}", SN, error);
  4578. Log.WriteErrorLog(ErrMsg);
  4579. goto end;
  4580. }
  4581. }
  4582. #endregion
  4583. Thread.Sleep(FunctionSettingNow.Wait_after_completion);
  4584. SetsuccessStatus(ResultStatus);
  4585. end:
  4586. #region 只有惠州工厂才启用G客户防呆措施;
  4587. if (FunctionSettingNow.NTF)
  4588. {
  4589. string strLastResult = "";
  4590. string strLastSN = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastGSN", "");
  4591. if (strLastSN.Equals(SN, StringComparison.OrdinalIgnoreCase))
  4592. {
  4593. if (TestResult == 0)
  4594. {
  4595. int lastCount = 0;
  4596. // 更新连续测试中累计失败的次数
  4597. string strFailCount = CommonMethod.ReadProfileString("MOKAFactoryTools", "GFailCount", "0");
  4598. int.TryParse(strFailCount, out lastCount);
  4599. CommonMethod.WriteProfileString("MOKAFactoryTools", "GFailCount", (++lastCount).ToString());
  4600. if (lastCount >= 2)
  4601. {// 累计2次Fail;
  4602. ShowVerifyDelegate("累计2次测试失败,禁止再测试,请做好坏机标记");
  4603. }
  4604. }
  4605. // 获取上一次抄写状态;
  4606. strLastResult = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastGResult", "");
  4607. // 更新抄写结果;
  4608. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastGResult", TestResult != 0 ? "1" : "0");
  4609. }
  4610. else
  4611. {
  4612. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastGSN", SN);
  4613. // 重置连续测试中累计失败的次数为0;
  4614. CommonMethod.WriteProfileString("MOKAFactoryTools", "GFailCount", TestResult == 0 ? "1" : "0");
  4615. // 更新抄写状态;
  4616. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastGResult", TestResult != 0 ? "1" : "0");
  4617. // 如果是试产NTF,且第一次测试就Fail,提示再测试多一次;
  4618. if (TestResult == 0 && nOrderType == 0)
  4619. {
  4620. Log.WriteErrorLog("试产订单:请再测试一次\r\n第一次测试为FAIL,请再测试确认结果!");
  4621. ShowVerifyDelegate("试产订单:请再测试一次\r\n第一次测试为FAIL,请再测试确认结果!");
  4622. }
  4623. }
  4624. if (strLastResult.ToString().Equals("0") && (TestResult == 1) && (nOrderType == 0))
  4625. {
  4626. // 上次抄写是失败,这次是成功的,试产NTF要再次要求抄写一次才能上报AMTest.
  4627. ErrMsg = "试产订单:请再测试一次\r\n上一次测试为FAIL,需要连续2次PASS,请再测试确认结果!";
  4628. Log.WriteErrorLog(ErrMsg);
  4629. ShowVerifyDelegate(ErrMsg);
  4630. // 仍设置为失败;
  4631. TestResult = 2;
  4632. }
  4633. if (!ntfBLL.SetDataBuringResult(FunctionSettingNow.Line, FunctionSettingNow.Station, SN, keyInfo.DSN, TestResult == 0 ? false : true, strLastSN, nOrderType, TestResult == 0 ? ErrMsg : ""))
  4634. {
  4635. //ntf失败,也需要提示;
  4636. ErrMsg = string.Format("统计NTF失败:{0}", SN);
  4637. Log.WriteErrorLog(ErrMsg);
  4638. TestResult = 0;
  4639. }
  4640. else
  4641. {
  4642. if ((TestResult == 1) && ntfBLL.ResultType.Equals("NTF", StringComparison.OrdinalIgnoreCase))
  4643. {
  4644. // TestResut == 0 && TestResut == 2时,也不提示NTF;
  4645. ErrMsg = string.Format("结果类型为NTF,请将产品做好NTF标记:{0}", SN);
  4646. ShowVerifyDelegate(ErrMsg);
  4647. }
  4648. }
  4649. if (TestResult != 2)
  4650. { // 上报抄写结果到MES系统中;
  4651. string strOutMsg;
  4652. string returnObject;
  4653. 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))
  4654. {
  4655. ErrMsg = string.Format("上报抄写结果到MES失败,请紧急处理:{0}", strOutMsg);
  4656. Log.WriteErrorLog(ErrMsg);
  4657. // 上报MES失败,重置为False
  4658. TestResult = 0;
  4659. }
  4660. // 将测试结果保存到Kayla要求的csv文件中;
  4661. CommonMethod.GeneratKaylaData(FunctionSettingNow.Line, FunctionSettingNow.Station, OrderText.Text, SN, startTime, DateTime.Now, returnObject, keyInfo, TestResult != 0 ? true : false);
  4662. }
  4663. }
  4664. #endregion
  4665. if (TestResult == 0)
  4666. {
  4667. if (ErrMsg == "")
  4668. ErrMsg = error;
  4669. SetfailStatus(ResultStatus);
  4670. if (midListNow.host == "LocalPC" && !preloadNow)
  4671. {
  4672. GetLocalKeyCount.UnlockLocalKeys(keypath, keyStream, keyReader);
  4673. }
  4674. // 启动NG弹框功能;
  4675. ShowVerifyDelegate(ErrMsg);
  4676. Thread.Sleep(300);
  4677. }
  4678. if (midListNow.host == "LocalPC" && !preloadNow)
  4679. {
  4680. GetLocalKeysCount();
  4681. }
  4682. timer1.Stop();
  4683. usingTime = 0;
  4684. EnableText(SNText);
  4685. EnableButton(BtnClickstart);
  4686. SN = "";
  4687. }
  4688. /// <summary>
  4689. /// 显示白平衡配置
  4690. /// </summary>
  4691. /// <param name="sender"></param>
  4692. /// <param name="e"></param>
  4693. private void OnBtnWBView(object sender, EventArgs e)
  4694. {
  4695. SNText.Focus();
  4696. if (FunctionSettingNow.WriteWB)
  4697. {
  4698. 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]);
  4699. }
  4700. else
  4701. {
  4702. MessageBox.Show(LResource.WBNoSet);
  4703. }
  4704. }
  4705. /// <summary>
  4706. /// 更新key的状态
  4707. /// </summary>
  4708. /// <param name="keys">GetMIDInfo的keytype字典</param>
  4709. /// <returns></returns>
  4710. public bool UpdateKeys(Dictionary<string, string> keys, bool autokey)
  4711. {
  4712. if (keys.ContainsKey("DeviceID"))
  4713. {
  4714. if (cfg_writedone.DIDWrite_YesNo)
  4715. SetCheckboxStatus(WriteDID, true);
  4716. UpdateKeyCountOnline("DeviceID", midListNow.clienttype, autokey);
  4717. }
  4718. if (keys.ContainsKey("MAC"))
  4719. {
  4720. if (cfg_writedone.MacWrite_YesNo)
  4721. SetCheckboxStatus(WriteMac, true);
  4722. UpdateKeyCountOnline("MAC", keys["MAC"], autokey);
  4723. }
  4724. if (keys.ContainsKey("HDCP_KEY"))
  4725. {
  4726. if (cfg_writedone.HDCPWrite_YesNo)
  4727. SetCheckboxStatus(WriteHDCP, true);
  4728. UpdateKeyCountOnline("HDCP_KEY", keys["HDCP_KEY"], autokey);
  4729. }
  4730. if (keys.ContainsKey("CI_PLUS_KEY"))
  4731. {
  4732. if (cfg_writedone.CI_plusWrite_YesNo)
  4733. SetCheckboxStatus(WriteCiplus, true);
  4734. UpdateKeyCountOnline("CI_PLUS_KEY", keys["CI_PLUS_KEY"], autokey);
  4735. }
  4736. if (keys.ContainsKey("WiDi"))
  4737. {
  4738. if (cfg_writedone.WiDiWrite_YesNo)
  4739. SetCheckboxStatus(WriteWiDi, true);
  4740. UpdateKeyCountOnline("WiDi", keys["WiDi"], autokey);
  4741. }
  4742. if (keys.ContainsKey("Widevine_KEY"))
  4743. {
  4744. if (cfg_writedone.WidevineWrite_YesNo)
  4745. SetCheckboxStatus(WriteWidevine, true);
  4746. UpdateKeyCountOnline("Widevine_KEY", keys["Widevine_KEY"], autokey);
  4747. }
  4748. if (keys.ContainsKey("HDCP2.2_KEY"))
  4749. {
  4750. if (cfg_writedone.HDCP22Write_YesNo)
  4751. SetCheckboxStatus(WriteHDCP22, true);
  4752. UpdateKeyCountOnline("HDCP2.2_KEY", keys["HDCP2.2_KEY"], autokey);
  4753. }
  4754. if (keys.ContainsKey("NETFILX_ESN"))
  4755. {
  4756. if (cfg_writedone.ESNWrite_YesNo)
  4757. SetCheckboxStatus(WriteESN, true);
  4758. UpdateKeyCountOnline("NETFILX_ESN", keys["NETFILX_ESN"], autokey);
  4759. }
  4760. if (keys.ContainsKey("Attestation_key"))
  4761. {
  4762. if (cfg_writedone.AttestationWrite_YesNo)
  4763. SetCheckboxStatus(WriteAttestation, true);
  4764. UpdateKeyCountOnline("Attestation_key", keys["Attestation_key"], autokey);
  4765. }
  4766. if (keys.ContainsKey("MGK_KEY"))
  4767. {
  4768. if (cfg_writedone.MGKWrite_YesNo)
  4769. SetCheckboxStatus(WriteMGK, true);
  4770. UpdateKeyCountOnline("MGK_KEY", keys["MGK_KEY"], autokey);
  4771. }
  4772. if (keys.ContainsKey("Fairplay_KEY"))
  4773. {
  4774. if (cfg_writedone.FairplayWrite_YesNo)
  4775. SetCheckboxStatus(WriteFairplay, true);
  4776. UpdateKeyCountOnline("Fairplay_KEY", keys["Fairplay_KEY"], autokey);
  4777. }
  4778. if (keys.ContainsKey("ECP_KEY"))
  4779. {
  4780. if (cfg_writedone.ECPWrite_YesNo)
  4781. SetCheckboxStatus(WriteECP, true);
  4782. UpdateKeyCountOnline("ECP_KEY", keys["ECP_KEY"], autokey);
  4783. }
  4784. if (keys.ContainsKey("WiFi_MAC"))
  4785. {
  4786. if (cfg_writedone.WifiMacWrite_YesNo)
  4787. SetCheckboxStatus(WriteWifiMac, true);
  4788. UpdateKeyCountOnline("WiFi_MAC", keys["WiFi_MAC"], autokey);
  4789. }
  4790. if (keys.ContainsKey("BT_MAC"))
  4791. {
  4792. if (cfg_writedone.BTMacWrite_YesNo)
  4793. SetCheckboxStatus(WriteBTMac, true);
  4794. UpdateKeyCountOnline("BT_MAC", keys["BT_MAC"], autokey);
  4795. }
  4796. if (keys.ContainsKey("LEK"))
  4797. {
  4798. if (cfg_writedone.LEKWrite_YesNo)
  4799. SetCheckboxStatus(WriteLEK, true);
  4800. UpdateKeyCountOnline("LEK", keys["LEK"], false);
  4801. }
  4802. if (keys.ContainsKey("PEK"))
  4803. {
  4804. if (cfg_writedone.PEKWrite_YesNo)
  4805. SetCheckboxStatus(WritePEK, true);
  4806. UpdateKeyCountOnline("PEK", keys["PEK"], false);
  4807. }
  4808. if (keys.ContainsKey("PlayReady_key"))
  4809. {
  4810. if (cfg_writedone.PlayreadyWrite_YesNo)
  4811. SetCheckboxStatus(WritePlayready, true);
  4812. UpdateKeyCountOnline("PlayReady_key", keys["PlayReady_key"], false);
  4813. }
  4814. if (keys.ContainsKey("Hashkey"))
  4815. {
  4816. if (cfg_writedone.HashWrite_YesNo)
  4817. SetCheckboxStatus(WriteHash, true);
  4818. UpdateKeyCountOnline("Hashkey", keys["Hashkey"], false);
  4819. }
  4820. if (keys.ContainsKey("YouTube_KEY"))
  4821. {
  4822. if (cfg_writedone.YouTubeWrite_YesNo)
  4823. SetCheckboxStatus(WriteYouTube, true);
  4824. UpdateKeyCountOnline("YouTube_KEY", keys["YouTube_KEY"], false);
  4825. }
  4826. if (keys.ContainsKey("DSN"))
  4827. {
  4828. if (cfg_writedone.DSNWrite_YesNo)
  4829. SetCheckboxStatus(WriteDSN, true);
  4830. }
  4831. if (keys.ContainsKey("edid_pid"))
  4832. {
  4833. if (cfg_writedone.EDIDPIDWrite_YesNo)
  4834. SetCheckboxStatus(WriteEDIDPID, true);
  4835. }
  4836. if (keys.ContainsKey("edid_model_name"))
  4837. {
  4838. if (cfg_writedone.EDIDModeNameWrite_YesNo)
  4839. SetCheckboxStatus(WriteEDIDName, true);
  4840. }
  4841. if (keys.ContainsKey("ACAS_KEY"))
  4842. {
  4843. if (cfg_writedone.ACASKeyWrite_YesNo)
  4844. SetCheckboxStatus(WriteACASKey, true);
  4845. UpdateKeyCountOnline("ACAS_KEY", keys["ACAS_KEY"], false);
  4846. }
  4847. if (keys.ContainsKey("DAK"))
  4848. {
  4849. if (cfg_writedone.DAKWrite_YesNo)
  4850. SetCheckboxStatus(WriteDAK, true);
  4851. UpdateKeyCountOnline("DAK", keys["DAK"], false);
  4852. }
  4853. return true;
  4854. }
  4855. /// <summary>
  4856. /// 在线获取key数量,更新Keycount
  4857. /// </summary>
  4858. /// <param name="key">key种类</param>
  4859. /// <param name="keytype">key的具体类型</param>
  4860. /// <returns></returns>
  4861. public bool UpdateKeyCountOnline(string key, string keytype, bool autokey)
  4862. {
  4863. return true;
  4864. }
  4865. /// <summary>
  4866. /// 获取订单可用key余量
  4867. /// </summary>
  4868. /// <param name="order">订单号</param>
  4869. /// <returns></returns>
  4870. public bool GetOrderRemainKeyCount(string order)
  4871. {
  4872. string url = midListNow.host;
  4873. string url1;
  4874. string count;
  4875. string code;
  4876. string desc;
  4877. if (!CommonMethod.HTTPChecker(url))
  4878. return false;
  4879. HttpHelper http = new HttpHelper();
  4880. HttpItem item = new HttpItem()
  4881. {
  4882. Encoding = Encoding.Default,
  4883. Method = "post",
  4884. ContentType = "application/x-www-form-urlencoded",
  4885. Timeout = 3000
  4886. };
  4887. url1 = url + "/getAvailableKeyCount.do?";
  4888. item.URL = url1;
  4889. item.Postdata = "ordernum=" + order;
  4890. HttpResult result = http.GetHtml(item);
  4891. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  4892. {
  4893. Log.WriteGetKeyLog("\r\nGetOrderRemainKeyCount count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  4894. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  4895. {
  4896. availableCount = count.Replace(",", "");
  4897. }
  4898. else
  4899. {
  4900. availableCount = "unknow";
  4901. CommonMethod.ReportErrormsg("Fail to parse GetOrderRemainKeyCount", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  4902. }
  4903. }
  4904. else
  4905. {
  4906. availableCount = "unknow";
  4907. CommonMethod.ReportErrormsg("Fail to get GetOrderRemainKeyCount", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  4908. return false;
  4909. }
  4910. return true;
  4911. }
  4912. /// <summary>
  4913. /// 按键触发在线抄写
  4914. /// 注意:此按键的作用是给不需要输入SN号的工厂使用;
  4915. /// </summary>
  4916. /// <param name="sender"></param>
  4917. /// <param name="e"></param>
  4918. private void OnBtnClickStart(object sender, EventArgs e)
  4919. {
  4920. SN = ""; // SN置为空,用于不需要扫码SN的某些工厂;
  4921. keyInfo = new KeyInfo();
  4922. if (preloadNow)
  4923. {
  4924. MessageBox.Show(LResource.PreloadError, LResource.Error);
  4925. return;
  4926. }
  4927. SetInitialStatus();
  4928. BtnClickstart.Enabled = false;
  4929. SNText.Enabled = false;
  4930. Onlinemode();
  4931. }
  4932. /// <summary>
  4933. /// 在线获取key的方式抄写
  4934. /// </summary>
  4935. public void Onlinemode()
  4936. {
  4937. keyInfo.DID.enable = WriteDID.Checked = (WriteDID.Checked && m_writedid.Text != LResource.Skip);
  4938. keyInfo.Mac.enable = WriteMac.Checked = (WriteMac.Checked && m_writemac.Text != LResource.Skip);
  4939. keyInfo.HDCP.enable = WriteHDCP.Checked = (WriteHDCP.Checked && m_writehdcp.Text != LResource.Skip);
  4940. keyInfo.HDCP22.enable = WriteHDCP22.Checked = (WriteHDCP22.Checked && m_writehdcp22.Text != LResource.Skip);
  4941. keyInfo.WiDi.enable = WriteWiDi.Checked = (WriteWiDi.Checked && m_writewidi.Text != LResource.Skip);
  4942. keyInfo.Widevine.enable = WriteWidevine.Checked = (WriteWidevine.Checked && m_writewidevine.Text != LResource.Skip);
  4943. keyInfo.ESN.enable = WriteESN.Checked = (WriteESN.Checked && m_writeesn.Text != LResource.Skip);
  4944. keyInfo.CI_plus.enable = WriteCiplus.Checked = (WriteCiplus.Checked && m_writeci.Text != LResource.Skip);
  4945. keyInfo.Attestation.enable = WriteAttestation.Checked = (WriteAttestation.Checked && m_writeattestation.Text != LResource.Skip);
  4946. keyInfo.MGK.enable = WriteMGK.Checked = (WriteMGK.Checked && m_writeMGK.Text != LResource.Skip);
  4947. keyInfo.WiFi_MAC.enable = WriteWifiMac.Checked = (WriteWifiMac.Checked && m_writeWifiMac.Text != LResource.Skip);
  4948. keyInfo.BT_MAC.enable = WriteBTMac.Checked = (WriteBTMac.Checked && m_writeBTMac.Text != LResource.Skip);
  4949. keyInfo.ECP.enable = WriteECP.Checked = (WriteECP.Checked && m_writeECP.Text != LResource.Skip);
  4950. keyInfo.LEK.enable = WriteLEK.Checked = (WriteLEK.Checked && m_writeLEK.Text != LResource.Skip);
  4951. keyInfo.PEK.enable = WritePEK.Checked = (WritePEK.Checked && m_writePEK.Text != LResource.Skip);
  4952. keyInfo.Playready.enable = WritePlayready.Checked = (WritePlayready.Checked && m_writePlayready.Text != LResource.Skip);
  4953. keyInfo.Hashkey.enable = WriteHash.Checked = (WriteHash.Checked && m_writeHash.Text != LResource.Skip);
  4954. keyInfo.YouTube_KEY.enable = WriteYouTube.Checked = (WriteYouTube.Checked && m_writeYouTube.Text != LResource.Skip);
  4955. keyInfo.EDIDPid.enable = WriteEDIDPID.Checked = (WriteEDIDPID.Checked && m_writeEDIDPID.Text != LResource.Skip);
  4956. keyInfo.EDIDModelName.enable = WriteEDIDName.Checked = (WriteEDIDName.Checked && m_writeEDIDName.Text != LResource.Skip);
  4957. keyInfo.ACASKey_Data.enable = WriteACASKey.Checked = (WriteACASKey.Checked && m_writeACASKey.Text != LResource.Skip);
  4958. keyInfo.DAK.enable = WriteDAK.Checked = (WriteDAK.Checked && WriteDAK.Text != LResource.Skip);
  4959. bool preloadresult = false;
  4960. preloadresult = true;
  4961. timer1.Start();
  4962. UpdateKeys(midListNow.keytype, true);
  4963. WritekeyThread = new Thread(Writekey);
  4964. WritekeyThread.Start();
  4965. if (!preloadresult)
  4966. {
  4967. SNText.Enabled = true;
  4968. }
  4969. }
  4970. /// <summary>
  4971. /// 更新订单抄写数量
  4972. /// </summary>
  4973. /// <returns></returns>
  4974. public bool UploadCopyCount()
  4975. {
  4976. return (SQLiteHelper.UpdateProductionNum(errorDBNow, orderNow));
  4977. }
  4978. /// <summary>
  4979. /// 获取定制化抄写信息
  4980. /// </summary>
  4981. /// <param name="sender"></param>
  4982. /// <param name="e"></param>
  4983. private void OnBtnOtherView(object sender, EventArgs e)
  4984. {
  4985. if (midListNow.rokuCustomer != null)
  4986. 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);
  4987. else
  4988. MessageBox.Show("null");
  4989. }
  4990. /// <summary>
  4991. /// 获取本地key数量
  4992. /// </summary>
  4993. public void GetLocalKeysCount()
  4994. {
  4995. int didnum;
  4996. if (GetLocalKeyCount.GetLocalDidCount(orderNow, out didnum, ref localmidList, errorDBNow))
  4997. {
  4998. SetCheckboxStatus(WriteDID, true);
  4999. if (didnum != -1)
  5000. SetKeyCountStatus(DIDCount, didnum.ToString(), 0);
  5001. else
  5002. SetKeyCountStatus(DIDCount, "Read error", 1);
  5003. }
  5004. int macnum;
  5005. if (GetLocalKeyCount.GetLocalMacCount(orderNow, out macnum, ref localmidList, errorDBNow))
  5006. {
  5007. SetCheckboxStatus(WriteMac, true);
  5008. if (macnum != -1)
  5009. SetKeyCountStatus(MacCount, macnum.ToString(), 0);
  5010. else
  5011. SetKeyCountStatus(MacCount, "Read error", 1);
  5012. }
  5013. int hdcpnum;
  5014. if (GetLocalKeyCount.GetLocalHDCPKEYCount(orderNow, out hdcpnum))
  5015. {
  5016. SetCheckboxStatus(WriteHDCP, true);
  5017. if (hdcpnum != -1)
  5018. SetKeyCountStatus(HDCPCount, hdcpnum.ToString(), 0);
  5019. else
  5020. SetKeyCountStatus(HDCPCount, "Read error", 1);
  5021. }
  5022. int widinum;
  5023. if (GetLocalKeyCount.GetLocalWiDiCount(orderNow, out widinum))
  5024. {
  5025. SetCheckboxStatus(WriteWiDi, true);
  5026. if (widinum != -1)
  5027. SetKeyCountStatus(WidiCount, widinum.ToString(), 0);
  5028. else
  5029. SetKeyCountStatus(WidiCount, "Read error", 1);
  5030. }
  5031. int hdcp22num;
  5032. if (GetLocalKeyCount.GetLocalHDCPKEY22Count(orderNow, out hdcp22num))
  5033. {
  5034. SetCheckboxStatus(WriteHDCP22, true);
  5035. if (hdcp22num != -1)
  5036. SetKeyCountStatus(HDCP22Count, hdcp22num.ToString(), 0);
  5037. else
  5038. SetKeyCountStatus(HDCP22Count, "Read error", 1);
  5039. }
  5040. int esnnum;
  5041. if (GetLocalKeyCount.GetLocalESNCount(orderNow, out esnnum))
  5042. {
  5043. SetCheckboxStatus(WriteESN, true);
  5044. if (esnnum != -1)
  5045. SetKeyCountStatus(ESNCount, esnnum.ToString(), 0);
  5046. else
  5047. SetKeyCountStatus(ESNCount, "Read error", 1);
  5048. }
  5049. int widevinenum;
  5050. if (GetLocalKeyCount.GetLocalWidevineCount(orderNow, out widevinenum))
  5051. {
  5052. SetCheckboxStatus(WriteWidevine, true);
  5053. if (widevinenum != -1)
  5054. SetKeyCountStatus(WideVineCount, widevinenum.ToString(), 0);
  5055. else
  5056. SetKeyCountStatus(WideVineCount, "Read error", 1);
  5057. }
  5058. int cinum;
  5059. if (GetLocalKeyCount.GetLocalCIKEYCount(orderNow, out cinum))
  5060. {
  5061. SetCheckboxStatus(WriteCiplus, true);
  5062. if (cinum != -1)
  5063. SetKeyCountStatus(CICount, cinum.ToString(), 0);
  5064. else
  5065. SetKeyCountStatus(CICount, "Read error", 1);
  5066. }
  5067. int mgknum;
  5068. if (GetLocalKeyCount.GetLocalMGKCount(orderNow, out mgknum))
  5069. {
  5070. SetCheckboxStatus(WriteMGK, true);
  5071. if (mgknum != -1)
  5072. SetKeyCountStatus(MGKCount, mgknum.ToString(), 0);
  5073. else
  5074. SetKeyCountStatus(MGKCount, "Read error", 1);
  5075. }
  5076. int attestationnum;
  5077. if (GetLocalKeyCount.GetLocalAttestationCount(orderNow, out attestationnum))
  5078. {
  5079. SetCheckboxStatus(WriteAttestation, true);
  5080. if (attestationnum != -1)
  5081. SetKeyCountStatus(AttestationCount, attestationnum.ToString(), 0);
  5082. else
  5083. SetKeyCountStatus(AttestationCount, "Read error", 1);
  5084. }
  5085. int fairplaynum;
  5086. if (GetLocalKeyCount.GetLocalFairplayCount(orderNow, out fairplaynum))
  5087. {
  5088. SetCheckboxStatus(WriteFairplay, true);
  5089. if (fairplaynum != -1)
  5090. SetKeyCountStatus(FairplayCount, fairplaynum.ToString(), 0);
  5091. else
  5092. SetKeyCountStatus(FairplayCount, "Read error", 1);
  5093. }
  5094. int leknum;
  5095. fireTVKey.LEK = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "LEK", out leknum);
  5096. int peknum;
  5097. fireTVKey.PEK = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "PEK", out peknum);
  5098. int palyreadynum;
  5099. fireTVKey.Playready = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "Playready", out palyreadynum);
  5100. int hashkeynum;
  5101. fireTVKey.Hashkey = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "Hashkey", out hashkeynum);
  5102. }
  5103. /// <summary>
  5104. /// 抄写用时计数
  5105. /// </summary>
  5106. /// <param name="sender"></param>
  5107. /// <param name="e"></param>
  5108. private void timer1_Tick(object sender, EventArgs e)
  5109. {
  5110. usingTime += 1;
  5111. UsingTime_Text.Text = usingTime.ToString();
  5112. }
  5113. /// <summary>
  5114. /// 取消SN扫描框聚焦
  5115. /// </summary>
  5116. /// <param name="sender"></param>
  5117. /// <param name="e"></param>
  5118. private void SNText_DoubleClick(object sender, EventArgs e)
  5119. {
  5120. FocusMark = false;
  5121. this.CaptionBackColorTop = Color.RoyalBlue;
  5122. this.CaptionBackColorBottom = Color.Cyan;
  5123. this.Refresh();
  5124. }
  5125. /// <summary>
  5126. /// 强制刷新抄写线程
  5127. /// </summary>
  5128. private void OnBtnRefresh(object sender, EventArgs e)
  5129. {
  5130. usingTime = 0;
  5131. EnableText(SNText);
  5132. EnableButton(BtnClickstart);
  5133. SN = "";
  5134. keyInfo = new KeyInfo();
  5135. SetInitialStatus();
  5136. if (WritekeyThread != null)
  5137. {
  5138. if (WritekeyThread.IsAlive)
  5139. {
  5140. WritekeyThread.Abort();
  5141. if (timer1.Enabled)
  5142. {
  5143. timer1.Stop();
  5144. }
  5145. while (WritekeyThread.ThreadState != System.Threading.ThreadState.Aborted)
  5146. {
  5147. Thread.Sleep(100);
  5148. }
  5149. }
  5150. }
  5151. UsingTime_Text.Text = "0";
  5152. GC.Collect();
  5153. MessageBox.Show(LResource.RefreshPanel);
  5154. }
  5155. /// <summary>
  5156. /// 显示订单key可用余量
  5157. /// </summary>
  5158. /// <param name="sender"></param>
  5159. /// <param name="e"></param>
  5160. private void OrderText_MouseEnter(object sender, EventArgs e)
  5161. {
  5162. toolTip1.SetToolTip(OrderText, LResource.AvailableKey + availableCount);
  5163. }
  5164. }
  5165. }