OperationPanel.cs 270 KB

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