OperationPanel.cs 252 KB

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