OperationPanel.cs 281 KB

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