OperationPanel.cs 274 KB

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