OperationPanel - 压测.cs 264 KB

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