OperationPanel.cs 266 KB

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