OperationPanel.cs 280 KB

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