OperationPanel.cs 246 KB

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