OperationPanel.cs 274 KB

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