OperationPanel.cs 266 KB

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