OperationPanel.cs 274 KB

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