OperationPanel.cs 273 KB

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