OperationPanel.cs 246 KB

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