OperationPanel.cs 272 KB

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