OperationPanel.cs 246 KB

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