RecipesCompareTwoViewModel.cs 115 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940
  1. using Aitex.Core.RT.Log;
  2. using Caliburn.Micro;
  3. using FurnaceUI.Client.Dialog;
  4. using FurnaceUI.Views.Editors;
  5. using MECF.Framework.Common.CommonData;
  6. using MECF.Framework.Common.DataCenter;
  7. using MECF.Framework.UI.Client.CenterViews.Editors;
  8. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  9. using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
  10. using MECF.Framework.UI.Client.ClientBase;
  11. using OpenSEMI.ClientBase;
  12. using RecipeEditorLib.RecipeModel.Params;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Collections.ObjectModel;
  16. using System.Linq;
  17. using System.Text.RegularExpressions;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. using System.Xml;
  21. namespace FurnaceUI.Views.Recipes
  22. {
  23. public class TwoStepDataItem : CompareItem
  24. {
  25. public string AStepNumber { get; set; }
  26. private string _aStepName;
  27. public string AStepName
  28. {
  29. get => _aStepName;
  30. set
  31. {
  32. _aStepName = value;
  33. InvokePropertyChanged("AStepName");
  34. }
  35. }
  36. public string BStepNumber { get; set; }
  37. public string BStepName { get; set; }
  38. }
  39. public class TwoParamDataItem : CompareItem
  40. {
  41. private string _paramName;
  42. public string ParamName
  43. {
  44. get => _paramName;
  45. set
  46. {
  47. _paramName = value;
  48. InvokePropertyChanged("_paramName");
  49. }
  50. }
  51. private string _aParamValue;
  52. public string AParamValue
  53. {
  54. get => _aParamValue;
  55. set
  56. {
  57. _aParamValue = value;
  58. InvokePropertyChanged("AParamValue");
  59. }
  60. }
  61. private string _bParamValue;
  62. public string BParamValue
  63. {
  64. get => _bParamValue;
  65. set
  66. {
  67. _bParamValue = value;
  68. InvokePropertyChanged("BParamValue");
  69. }
  70. }
  71. }
  72. public class TableDataItem : CompareItem
  73. {
  74. public string TableIndex { get; set; }
  75. public string TableName { get; set; }
  76. public string EndStatus { get; set; }
  77. }
  78. public class TwoTableDataItem : CompareItem
  79. {
  80. public int Index { get; set; }
  81. public string ATableName { get; set; }
  82. public string BTableName { get; set; }
  83. }
  84. public class RecipesCompareTwoViewModel : ModuleUiViewModelBase
  85. {
  86. private string _module = "PM1";
  87. public ObservableCollection<ProcessTypeFileItem> ProcessTypeFileList { get; set; }
  88. public ObservableCollection<string> ChamberType { get; set; }
  89. public ObservableCollection<string> RecipeProcessType { get; set; }
  90. public int ChamberTypeIndexSelection { get; set; }
  91. public int _processTypeIndexSelection;
  92. public int ProcessTypeIndexSelection
  93. {
  94. get { return _processTypeIndexSelection; }
  95. set { _processTypeIndexSelection = value; NotifyOfPropertyChange("ProcessTypeIndexSelection"); }
  96. }
  97. public string CurrentChamberType
  98. {
  99. get
  100. {
  101. return ChamberType[ChamberTypeIndexSelection];
  102. }
  103. }
  104. public string SelectedRecipeType { get; set; }
  105. private string _currentProcessType;
  106. public string CurrentProcessType
  107. {
  108. get
  109. {
  110. if (ProcessTypeIndexSelection < 0)
  111. ProcessTypeIndexSelection = 0;
  112. if (ProcessTypeFileList.Count == 0)
  113. return "Process";
  114. return ProcessTypeFileList[ProcessTypeIndexSelection].ProcessType;
  115. }
  116. set { _currentProcessType = CurrentProcessType; NotifyOfPropertyChange("CurrentProcessType"); }
  117. }
  118. public ObservableCollection<TwoStepDataItem> StepList { get; set; } = new ObservableCollection<TwoStepDataItem>();
  119. public ObservableCollection<TwoParamDataItem> ParamList { get; set; } = new ObservableCollection<TwoParamDataItem>();
  120. //-------------------------A Properties
  121. public ObservableCollection<StepDataItem> StepListA { get; set; }
  122. public ObservableCollection<ParamDataItem> ParamListA { get; set; }
  123. public ObservableCollection<LineDataItem> WholeListA { get; set; }
  124. public string RecipeA { get; set; }
  125. private XmlDocument _domA = new XmlDocument();
  126. private string _pathPrefixA;
  127. private Dictionary<string, ObservableCollection<ParamDataItem>> _mapStepParamA = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  128. private Dictionary<TableDataItem, Dictionary<string, ObservableCollection<ParamDataItem>>> _mapTableStepParamA = new Dictionary<TableDataItem, Dictionary<string, ObservableCollection<ParamDataItem>>>();
  129. private Dictionary<string, LineDataItem> _mapLineTextA = new Dictionary<string, LineDataItem>();
  130. private List<string> BackInnerXmlTextA = new List<string>();
  131. private bool _isChangedA { get; set; }
  132. public bool EnableButtonRemoveA
  133. {
  134. get { return !string.IsNullOrEmpty(RecipeA); }
  135. }
  136. public bool EnableButtonUndoA
  137. {
  138. get { return false; }
  139. }
  140. public bool EnableButtonSaveA
  141. {
  142. get { return false; }
  143. }
  144. private Visibility _paramVisibility;
  145. public Visibility ParamVisibility
  146. {
  147. get => _paramVisibility;
  148. set
  149. {
  150. _paramVisibility = value;
  151. NotifyOfPropertyChange(nameof(ParamVisibility));
  152. }
  153. }
  154. private TwoStepDataItem _stepSelection;
  155. public TwoStepDataItem StepSelection
  156. {
  157. get
  158. {
  159. return _stepSelection;
  160. }
  161. set
  162. {
  163. if (!BtnTableIsEnabled)
  164. {
  165. SyncStepSelection(value);
  166. }
  167. else
  168. {
  169. SyncTableStepSelection(value);
  170. }
  171. SyncShowDiffParams(_isShowDiffParams);
  172. _stepSelection = value;
  173. ParamSelection = null;
  174. NotifyOfPropertyChange(nameof(StepSelection));
  175. }
  176. }
  177. private TwoParamDataItem _paramSelection;
  178. public TwoParamDataItem ParamSelection
  179. {
  180. get
  181. {
  182. return _paramSelection;
  183. }
  184. set
  185. {
  186. _paramSelection = value;
  187. if (value == null)
  188. {
  189. ParamVisibility = Visibility.Hidden;
  190. }
  191. else
  192. {
  193. ParamVisibility = Visibility.Visible;
  194. }
  195. NotifyOfPropertyChange(nameof(ParamSelection));
  196. }
  197. }
  198. //private ParamDataItem _paramSelectionA;
  199. //public ParamDataItem ParamSelectionA
  200. //{
  201. // get
  202. // {
  203. // return _paramSelectionA;
  204. // }
  205. // set
  206. // {
  207. // SyncParamSelection(value, false);
  208. // _paramSelectionA = value;
  209. // }
  210. //}
  211. private LineDataItem _lineSelectionA;
  212. public LineDataItem LineSelectionA
  213. {
  214. get
  215. {
  216. return _lineSelectionA;
  217. }
  218. set
  219. {
  220. SyncLineSelection(value, false);
  221. _lineSelectionA = value;
  222. }
  223. }
  224. //-------------------------B Properties-------------------------------------------------------------
  225. public ObservableCollection<StepDataItem> StepListB { get; set; }
  226. public ObservableCollection<ParamDataItem> ParamListB { get; set; }
  227. public ObservableCollection<LineDataItem> WholeListB { get; set; }
  228. public string RecipeB { get; set; }
  229. private XmlDocument _domB = new XmlDocument();
  230. private string _pathPrefixB;
  231. private Dictionary<string, ObservableCollection<ParamDataItem>> _mapStepParamB = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  232. private Dictionary<TableDataItem, Dictionary<string, ObservableCollection<ParamDataItem>>> _mapTableStepParamB = new Dictionary<TableDataItem, Dictionary<string, ObservableCollection<ParamDataItem>>>();
  233. private Dictionary<string, LineDataItem> _mapLineTextB = new Dictionary<string, LineDataItem>();
  234. private List<string> BackInnerXmlTextB = new List<string>();
  235. private string BaseTextB = "";
  236. private bool _isChangedB { get; set; }
  237. public bool EnableButtonRemoveB
  238. {
  239. get { return !string.IsNullOrEmpty(RecipeB); }
  240. }
  241. public bool EnableButtonUndoB
  242. {
  243. get { return false; }
  244. }
  245. public bool EnableButtonSaveB
  246. {
  247. get { return false; }
  248. }
  249. private ParamDataItem _paramSelectionB;
  250. public ParamDataItem ParamSelectionB
  251. {
  252. get
  253. {
  254. return _paramSelectionB;
  255. }
  256. set
  257. {
  258. SyncParamSelection(value, true);
  259. _paramSelectionB = value;
  260. }
  261. }
  262. private LineDataItem _lineSelectionB;
  263. public LineDataItem LineSelectionB
  264. {
  265. get
  266. {
  267. return _lineSelectionB;
  268. }
  269. set
  270. {
  271. SyncLineSelection(value, true);
  272. _lineSelectionB = value;
  273. }
  274. }
  275. private bool _isCurrentSelected = true;
  276. public bool IsCurrentSelected
  277. {
  278. get => _isCurrentSelected;
  279. set
  280. {
  281. _isCurrentSelected = value;
  282. NotifyOfPropertyChange(nameof(IsCurrentSelected));
  283. NotifyOfPropertyChange(nameof(ChkboxString));
  284. }
  285. }
  286. public string ChkboxString
  287. {
  288. get
  289. {
  290. if (_isCurrentSelected)
  291. {
  292. return "Current";
  293. }
  294. else
  295. {
  296. return "History";
  297. }
  298. }
  299. }
  300. private bool _btnTableIsEnabled = false;
  301. public bool BtnTableIsEnabled
  302. {
  303. get => _btnTableIsEnabled;
  304. set
  305. {
  306. _btnTableIsEnabled = value;
  307. NotifyOfPropertyChange(nameof(BtnTableIsEnabled));
  308. }
  309. }
  310. private TwoTableDataItem _selectedTwoTableData;
  311. public TwoTableDataItem SelectedTwoTableData
  312. {
  313. get => _selectedTwoTableData;
  314. set
  315. {
  316. _selectedTwoTableData = value;
  317. NotifyOfPropertyChange(nameof(SelectedTwoTableData));
  318. }
  319. }
  320. Dictionary<int, ObservableCollection<StepDataItem>> tableStepListA = new Dictionary<int, ObservableCollection<StepDataItem>>();
  321. Dictionary<int, ObservableCollection<StepDataItem>> tableStepListB = new Dictionary<int, ObservableCollection<StepDataItem>>();
  322. /// <summary>
  323. /// IsVisibilityEdit
  324. /// </summary>
  325. public bool IsVisibilityEdit
  326. {
  327. get { return _isVisibilityEdit; }
  328. set { _isVisibilityEdit = value;
  329. NotifyOfPropertyChange(nameof(IsVisibilityEdit)); }
  330. }
  331. private bool _isVisibilityEdit = true;
  332. public string TimeA
  333. {
  334. get { return _timeA; }
  335. set
  336. {
  337. _timeA = value;
  338. NotifyOfPropertyChange("TimeA");
  339. }
  340. }
  341. private string _timeA = string.Empty;
  342. public string TimeB
  343. {
  344. get { return _timeB; }
  345. set
  346. {
  347. _timeB = value;
  348. NotifyOfPropertyChange("TimeB");
  349. }
  350. }
  351. private string _timeB = string.Empty;
  352. public int SelectTableIndex { get; set; } = 1;
  353. public RecipesCompareTwoViewModel()
  354. {
  355. StepListA = new ObservableCollection<StepDataItem>();
  356. ParamListA = new ObservableCollection<ParamDataItem>();
  357. WholeListA = new ObservableCollection<LineDataItem>();
  358. StepListB = new ObservableCollection<StepDataItem>();
  359. ParamListB = new ObservableCollection<ParamDataItem>();
  360. WholeListB = new ObservableCollection<LineDataItem>();
  361. }
  362. public RecipesCompareTwoViewModel(ShowRecipeHistory showRecipeHistoryA, ShowRecipeHistory showRecipeHistoryB)
  363. {
  364. IsVisibilityEdit = false;
  365. StepListA = new ObservableCollection<StepDataItem>();
  366. ParamListA = new ObservableCollection<ParamDataItem>();
  367. WholeListA = new ObservableCollection<LineDataItem>();
  368. StepListB = new ObservableCollection<StepDataItem>();
  369. ParamListB = new ObservableCollection<ParamDataItem>();
  370. WholeListB = new ObservableCollection<LineDataItem>();
  371. if (showRecipeHistoryA != null && showRecipeHistoryB != null)
  372. {
  373. TimeA = showRecipeHistoryA.LastRevisionTime.ToString("yyyy-MM-dd HH:mm:ss");
  374. TimeB = showRecipeHistoryB.LastRevisionTime.ToString("yyyy-MM-dd HH:mm:ss");
  375. RecipeA = showRecipeHistoryA.Recipe_Path;
  376. RecipeB = showRecipeHistoryB.Recipe_Path;
  377. LoadData(showRecipeHistoryA.Recipe_Path, true, true, false);
  378. LoadData(showRecipeHistoryB.Recipe_Path, false, true, false);
  379. Recompare();
  380. GetStepList();
  381. SyncShowDiffSteps(IsShowDiffSteps);
  382. }
  383. }
  384. protected override void OnInitialize()
  385. {
  386. base.OnInitialize();
  387. var chamberType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedChamberType");
  388. if (chamberType == null)
  389. {
  390. ChamberType = new ObservableCollection<string>() { "Default" };
  391. }
  392. else
  393. {
  394. ChamberType = new ObservableCollection<string>(((string)(chamberType)).Split(','));
  395. }
  396. ChamberTypeIndexSelection = 0;
  397. //Etch:Process,Clean,Chuck,Dechuck;CVD:Process,Clean;
  398. //var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  399. //if (processType == null)
  400. //{
  401. // RecipeProcessType = new ObservableCollection<string>() { "Process" };
  402. //}
  403. //else
  404. //{
  405. // RecipeProcessType = new ObservableCollection<string>(((string)processType).Split(','));
  406. //}
  407. RecipeProcessType = new ObservableCollection<string>();
  408. var processType = QueryDataClient.Instance.Service.GetConfig("System.CompareRecipeType");
  409. if (processType != null)
  410. {
  411. var sss = ((string)processType).Split(';');
  412. foreach (var item in sss)
  413. {
  414. RecipeProcessType.Add(item);
  415. }
  416. }
  417. ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  418. UpdateProcessTypeFileList();
  419. }
  420. protected override void OnActivate()
  421. {
  422. base.OnActivate();
  423. }
  424. protected override void OnDeactivate(bool close)
  425. {
  426. base.OnDeactivate(close);
  427. }
  428. protected override void OnViewLoaded(object view)
  429. {
  430. base.OnViewLoaded(view);
  431. if (((RecipesCompareTwoView)view).CboRecipeType.Items.Count > 0)
  432. {
  433. ((RecipesCompareTwoView)view).CboRecipeType.SelectedIndex = 0;
  434. }
  435. }
  436. public void SelectChangedRecipeType(SelectionChangedEventArgs eventArgs)
  437. {
  438. string recipeType = null;
  439. recipeType = eventArgs.AddedItems[0].ToString();
  440. if (recipeType == "sub" || recipeType == "alarm" || recipeType == "abort" || recipeType == "idle" || recipeType == "reset")
  441. {
  442. BtnTableIsEnabled = true;
  443. }
  444. else
  445. {
  446. BtnTableIsEnabled = false;
  447. }
  448. }
  449. public void UpdateProcessTypeFileList()
  450. {
  451. ProcessTypeFileList.Clear();
  452. for (int i = 0; i < RecipeProcessType.Count; i++)
  453. {
  454. var type = new ProcessTypeFileItem();
  455. type.ProcessType = RecipeProcessType[i];
  456. var prefix = $"{ChamberType[ChamberTypeIndexSelection]}\\{RecipeProcessType[i]}";
  457. ProcessTypeFileList.Add(type);
  458. }
  459. while (ProcessTypeFileList.Count > RecipeProcessType.Count)
  460. {
  461. ProcessTypeFileList.RemoveAt(0);
  462. }
  463. }
  464. public void SelectA()
  465. {
  466. SelectRecipe(true);
  467. }
  468. public void SelectB()
  469. {
  470. SelectRecipe(false);
  471. //if (IsCurrentSelected)
  472. //{
  473. // SelectBCurrent();
  474. //}
  475. //else
  476. //{
  477. // SelectBHistory();
  478. //}
  479. }
  480. public void SelectBHistory()
  481. {
  482. // SelectRecipe(false);
  483. try
  484. {
  485. RecipeCompareSelectDialogViewModel dialog = new RecipeCompareSelectDialogViewModel();
  486. dialog.DisplayName = "Select Recipe";
  487. SystemName = _module;
  488. dialog.IsSelectedA = false;
  489. var recipeProvider = new RecipeProvider();
  490. dialog.Chambers.Clear();
  491. recipeProvider.RestoreRecipeFolderList().ForEach(x => dialog.Chambers.Add(x));
  492. string[] recipeProcessType = null;
  493. if (string.IsNullOrEmpty(SelectedRecipeType))
  494. {
  495. var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  496. if (processType == null)
  497. {
  498. processType = "Process";
  499. }
  500. var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  501. recipeProcessType = ((string)processType).Split(',');
  502. }
  503. else
  504. {
  505. recipeProcessType = new string[] { SelectedRecipeType };
  506. }
  507. string[] partsType1 = new string[] { };
  508. string[] partsType2 = new string[] { };
  509. for (int i = 0; i < recipeProcessType.Length; i++)
  510. {
  511. var type = new ProcessTypeFileItem();
  512. type.ProcessType = recipeProcessType[i];
  513. var prefix = $"Furnace\\{recipeProcessType[i]}";
  514. var recipes = recipeProvider.GetXmlRecipeList(prefix, false);
  515. string[] parts = Regex.Split(recipes, "<");
  516. if (i == 0)
  517. {
  518. partsType1 = parts;
  519. }
  520. else if (i == 1)
  521. {
  522. partsType2 = parts;
  523. }
  524. string recipeChamber;
  525. recipeChamber = "<" + parts[1];
  526. foreach (string part in parts)
  527. {
  528. if (part.Contains($".{SystemName}"))
  529. {
  530. string temp = part.Replace($".{SystemName}", string.Empty);
  531. recipeChamber += "<" + temp;
  532. }
  533. }
  534. if (parts.Length > 2)
  535. {
  536. recipeChamber += "<" + parts[parts.Length - 1];
  537. }
  538. type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipeChamber)[0].Files;
  539. ProcessTypeFileList.Add(type);
  540. }
  541. dialog.ProcessTypeFileList = ProcessTypeFileList;
  542. WindowManager wm = new WindowManager();
  543. bool? bret = wm.ShowDialog(dialog);
  544. if (!(bool)bret)
  545. return;
  546. _module = dialog.SelectedChamber;
  547. string suffix = $".{_module}";
  548. string dialogResult = dialog.DialogResult;
  549. bool isFullPath = false;
  550. if (dialogResult.Contains(".rcp"))
  551. isFullPath = true;
  552. string recipeName = dialogResult;
  553. RecipeB = recipeName;
  554. NotifyOfPropertyChange(nameof(RecipeB));
  555. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  556. if (string.IsNullOrEmpty(RecipeB))
  557. {
  558. string[] recipe2 = RecipeB.Split('\\'); string r2 = recipe2[0];
  559. }
  560. LoadData(recipeName, false, false, isFullPath);
  561. Recompare();
  562. SyncShowDiffSteps(IsShowDiffSteps);
  563. }
  564. catch (Exception ex)
  565. {
  566. throw;
  567. }
  568. }
  569. public void SelectBCurrent()
  570. {
  571. try
  572. {
  573. RecipeCompareSelectDialogViewModel dialog = new RecipeCompareSelectDialogViewModel();
  574. dialog.DisplayName = "Select Recipe";
  575. SystemName = _module;
  576. var recipeProvider = new RecipeProvider();
  577. var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  578. if (processType == null)
  579. {
  580. processType = "Process";
  581. }
  582. var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  583. string[] recipeProcessType = ((string)processType).Split(',');
  584. string[] partsType1 = new string[] { };
  585. string[] partsType2 = new string[] { };
  586. for (int i = 0; i < recipeProcessType.Length; i++)
  587. {
  588. var type = new ProcessTypeFileItem();
  589. type.ProcessType = recipeProcessType[i];
  590. var prefix = $"Furnace\\{recipeProcessType[i]}";
  591. type.FileListByProcessType = RecipeSequenceTreeBuilder.GetFileNodeParameterList(prefix);
  592. ProcessTypeFileList.Add(type);
  593. }
  594. dialog.ProcessTypeFileList = ProcessTypeFileList;
  595. WindowManager wm = new WindowManager();
  596. bool? bret = wm.ShowDialog(dialog);
  597. if (!(bool)bret)
  598. return;
  599. _module = dialog.SelectedChamber;
  600. string suffix = $".{_module}";
  601. string dialogResult = dialog.DialogResult;
  602. bool isFullPath = false;
  603. if (dialogResult.Contains(".rcp"))
  604. isFullPath = true;
  605. string recipeName = dialogResult;
  606. RecipeB = recipeName;
  607. NotifyOfPropertyChange(nameof(RecipeB));
  608. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  609. if (!string.IsNullOrEmpty(RecipeA) && !string.IsNullOrEmpty(RecipeB))
  610. {
  611. string[] recipe1 = RecipeA.Split('\\'); string r1 = recipe1[0];
  612. string[] recipe2 = RecipeB.Split('\\'); string r2 = recipe2[0];
  613. if (r1 != r2)
  614. {
  615. if (MessageBoxResult.Yes != MessageBox.Show($"腔体类型不一致! \n 是否继续比较 ?", "", MessageBoxButton.YesNo, MessageBoxImage.Information))
  616. {
  617. RemoveSelectB();
  618. return;
  619. }
  620. }
  621. }
  622. LoadData(recipeName, false, true, isFullPath);
  623. Recompare();
  624. GetStepList();
  625. SyncShowDiffSteps(IsShowDiffSteps);
  626. }
  627. catch (Exception ex)
  628. {
  629. LOG.Error(ex.Message);
  630. }
  631. }
  632. private void SelectRecipe(bool isSelectA)
  633. {
  634. if (!BtnTableIsEnabled)
  635. {
  636. NoTableRecipe(isSelectA);
  637. }
  638. else
  639. {
  640. TableRecipe(isSelectA);
  641. }
  642. }
  643. private void NoTableRecipe(bool isSelectA)
  644. {
  645. try
  646. {
  647. RecipeCompareSelectDialogViewModel dialog = new RecipeCompareSelectDialogViewModel();
  648. dialog.DisplayName = "Select Recipe";
  649. SystemName = _module;
  650. var recipeProvider = new RecipeProvider();
  651. string[] recipeProcessType = null;
  652. var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  653. if (string.IsNullOrEmpty(SelectedRecipeType))
  654. {
  655. var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  656. if (processType == null)
  657. {
  658. processType = "Process";
  659. }
  660. recipeProcessType = ((string)processType).Split(',');
  661. }
  662. else
  663. {
  664. recipeProcessType = new string[] { SelectedRecipeType };
  665. }
  666. string[] partsType1 = new string[] { };
  667. string[] partsType2 = new string[] { };
  668. for (int i = 0; i < recipeProcessType.Length; i++)
  669. {
  670. var type = new ProcessTypeFileItem();
  671. type.ProcessType = recipeProcessType[i];
  672. var prefix = $"Furnace\\{recipeProcessType[i]}";
  673. var recipes = recipeProvider.GetXmlRecipeList(prefix, false);
  674. type.FileListByProcessType = RecipeSequenceTreeBuilder.GetFileNodeParameterList(prefix);
  675. ProcessTypeFileList.Add(type);
  676. }
  677. dialog.ProcessTypeFileList = ProcessTypeFileList;
  678. WindowManager wm = new WindowManager();
  679. bool? bret = wm.ShowDialog(dialog);
  680. if (!(bool)bret)
  681. return;
  682. _module = dialog.SelectedChamber;
  683. string suffix = $".{_module}";
  684. string dialogResult = dialog.DialogResult;
  685. bool isFullPath = false;
  686. if (dialogResult.Contains(".rcp"))
  687. isFullPath = true;
  688. string recipeName = dialogResult;
  689. if (isSelectA)
  690. {
  691. RecipeA = recipeName;
  692. NotifyOfPropertyChange(nameof(RecipeA));
  693. NotifyOfPropertyChange(nameof(EnableButtonRemoveA));
  694. }
  695. else
  696. {
  697. RecipeB = recipeName;
  698. NotifyOfPropertyChange(nameof(RecipeB));
  699. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  700. }
  701. if (!string.IsNullOrEmpty(RecipeA) && !string.IsNullOrEmpty(RecipeB))
  702. {
  703. string[] recipe1 = RecipeA.Split('\\'); string r1 = recipe1[0];
  704. string[] recipe2 = RecipeB.Split('\\'); string r2 = recipe2[0];
  705. if (r1 != r2)
  706. {
  707. if (MessageBoxResult.Yes != MessageBox.Show($"腔体类型不一致! \n 是否继续比较 ?", "", MessageBoxButton.YesNo, MessageBoxImage.Information))
  708. {
  709. RemoveSelectB();
  710. return;
  711. }
  712. }
  713. }
  714. LoadData(recipeName, isSelectA, true, isFullPath);
  715. Recompare();
  716. GetStepList();
  717. SyncShowDiffSteps(IsShowDiffSteps);
  718. }
  719. catch (Exception ex)
  720. {
  721. throw;
  722. }
  723. }
  724. private void TableRecipe(bool isSelectA)
  725. {
  726. try
  727. {
  728. RecipeCompareSelectDialogViewModel dialog = new RecipeCompareSelectDialogViewModel();
  729. dialog.DisplayName = "Select Recipe";
  730. SystemName = _module;
  731. var recipeProvider = new RecipeProvider();
  732. string recipeProcessType = null;
  733. var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  734. if (string.IsNullOrEmpty(SelectedRecipeType))
  735. {
  736. //弹出告警消息
  737. return;
  738. }
  739. else
  740. {
  741. recipeProcessType = SelectedRecipeType;
  742. }
  743. string[] partsType1 = new string[] { };
  744. string[] partsType2 = new string[] { };
  745. var type = new ProcessTypeFileItem();
  746. type.ProcessType = recipeProcessType;
  747. var prefix = $"Furnace\\{recipeProcessType}";
  748. var recipes = recipeProvider.GetXmlRecipeList(prefix, false);
  749. type.FileListByProcessType = RecipeSequenceTreeBuilder.GetFileNodeParameterList(prefix);
  750. ProcessTypeFileList.Add(type);
  751. dialog.ProcessTypeFileList = ProcessTypeFileList;
  752. WindowManager wm = new WindowManager();
  753. bool? bret = wm.ShowDialog(dialog);
  754. if (!(bool)bret)
  755. return;
  756. _module = dialog.SelectedChamber;
  757. string suffix = $".{_module}";
  758. string dialogResult = dialog.DialogResult;
  759. bool isFullPath = false;
  760. if (dialogResult.Contains(".rcp"))
  761. isFullPath = true;
  762. string recipeName = dialogResult;
  763. if (isSelectA)
  764. {
  765. RecipeA = recipeName;
  766. NotifyOfPropertyChange(nameof(RecipeA));
  767. NotifyOfPropertyChange(nameof(EnableButtonRemoveA));
  768. }
  769. else
  770. {
  771. RecipeB = recipeName;
  772. NotifyOfPropertyChange(nameof(RecipeB));
  773. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  774. }
  775. if (!string.IsNullOrEmpty(RecipeA) && !string.IsNullOrEmpty(RecipeB))
  776. {
  777. string[] recipe1 = RecipeA.Split('\\'); string r1 = recipe1[0];
  778. string[] recipe2 = RecipeB.Split('\\'); string r2 = recipe2[0];
  779. if (r1 != r2)
  780. {
  781. if (MessageBoxResult.Yes != MessageBox.Show($"腔体类型不一致! \n 是否继续比较 ?", "", MessageBoxButton.YesNo, MessageBoxImage.Information))
  782. {
  783. RemoveSelectB();
  784. return;
  785. }
  786. }
  787. }
  788. LoadTableData(recipeName, isSelectA, true, isFullPath);
  789. RecompareTableByName();
  790. GetTableStepList(isSelectA);
  791. SyncShowDiffSteps(IsShowDiffSteps);
  792. }
  793. catch (Exception ex)
  794. {
  795. throw;
  796. }
  797. }
  798. public void GetStepList()
  799. {
  800. StepList.Clear();
  801. if (StepListA == null || StepListA.Count == 0)
  802. {
  803. if (StepListB == null || StepListB.Count == 0)
  804. { return; }
  805. else
  806. {
  807. foreach (var item in StepListB)
  808. {
  809. var tempStep = new TwoStepDataItem();
  810. tempStep.BStepNumber = item.StepNumber;
  811. tempStep.BStepName = item.StepName;
  812. tempStep.IsDiff = item.IsDiff;
  813. StepList.Add(tempStep);
  814. }
  815. }
  816. }
  817. else
  818. {
  819. if (StepListB == null || StepListB.Count == 0)
  820. {
  821. foreach (var item in StepListA)
  822. {
  823. var tempStep = new TwoStepDataItem();
  824. tempStep.AStepNumber = item.StepNumber;
  825. tempStep.AStepName = item.StepName;
  826. tempStep.IsDiff = item.IsDiff;
  827. StepList.Add(tempStep);
  828. }
  829. }
  830. else
  831. {
  832. int bIndex = 0;
  833. int oldIndex = 0;
  834. foreach (var item in StepListA)
  835. {
  836. var tempB = StepListB.FirstOrDefault(x => x.StepName == item.StepName);
  837. if (tempB != null)
  838. {
  839. bIndex = StepListB.IndexOf(tempB);
  840. if (bIndex != 0 && bIndex != oldIndex + 1)
  841. {
  842. for (int i = oldIndex + 1; i < bIndex; i++)
  843. {
  844. var bStep = new TwoStepDataItem();
  845. bStep.AStepNumber = "";
  846. bStep.AStepName = "";
  847. bStep.BStepNumber = StepListB[i].StepNumber;
  848. bStep.BStepName = StepListB[i].StepName;
  849. bStep.IsDiff = false;
  850. StepList.Add(bStep);
  851. }
  852. }
  853. if (oldIndex > bIndex)
  854. {
  855. var tempStepA = new TwoStepDataItem();
  856. tempStepA.AStepNumber = item.StepNumber;
  857. tempStepA.AStepName = item.StepName;
  858. tempStepA.IsDiff = false;
  859. StepList.Add(tempStepA);
  860. continue;
  861. }
  862. else
  863. {
  864. oldIndex = bIndex;
  865. }
  866. var tempStep = new TwoStepDataItem();
  867. tempStep.AStepNumber = item.StepNumber;
  868. tempStep.AStepName = item.StepName;
  869. tempStep.BStepNumber = tempB.StepNumber;
  870. tempStep.BStepName = tempB.StepName;
  871. tempStep.IsDiff = tempB.IsDiff;
  872. StepList.Add(tempStep);
  873. }
  874. else
  875. {
  876. var tempStep = new TwoStepDataItem();
  877. tempStep.AStepNumber = item.StepNumber;
  878. tempStep.AStepName = item.StepName;
  879. tempStep.IsDiff = item.IsDiff;
  880. tempStep.BStepNumber = "";
  881. tempStep.BStepName = "";
  882. StepList.Add(tempStep);
  883. }
  884. }
  885. if (bIndex + 1 < StepListB.Count)
  886. {
  887. for (int i = bIndex + 1; i < StepListB.Count; i++)
  888. {
  889. var bStep = new TwoStepDataItem();
  890. bStep.AStepNumber = "";
  891. bStep.AStepName = "";
  892. bStep.BStepNumber = StepListB[i].StepNumber;
  893. bStep.BStepName = StepListB[i].StepName;
  894. bStep.IsDiff = StepListB[i].IsDiff;
  895. StepList.Add(bStep);
  896. }
  897. }
  898. }
  899. }
  900. }
  901. public void GetTableStepList(bool isSelectA, int tableInex = 1)
  902. {
  903. StepList.Clear();
  904. TwoTableDataItem tempTable = new TwoTableDataItem();
  905. tempTable.Index = tableInex;
  906. var tableA = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == tableInex.ToString());
  907. if (tableA != null)
  908. {
  909. tempTable.ATableName = tableA.TableName;
  910. }
  911. var tableB = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == tableInex.ToString());
  912. if (tableB != null)
  913. {
  914. tempTable.BTableName = tableB.TableName;
  915. }
  916. if (isSelectA)
  917. {
  918. StepListA.Clear();
  919. if (tableStepListA.Keys.Contains(tableInex))
  920. {
  921. (tableStepListA[tableInex].OrderBy(x => int.Parse(x.StepNumber))).ToList().ForEach(x => StepListA.Add(x));
  922. }
  923. NotifyOfPropertyChange(nameof(StepListA));
  924. }
  925. else
  926. {
  927. StepListB.Clear();
  928. if (tableStepListB.Keys.Contains(tableInex))
  929. {
  930. (tableStepListB[tableInex].OrderBy(x => int.Parse(x.StepNumber))).ToList().ForEach(x => StepListB.Add(x));
  931. }
  932. NotifyOfPropertyChange(nameof(StepListB));
  933. }
  934. if (StepListA == null || StepListA.Count == 0)
  935. {
  936. if (StepListB == null || StepListB.Count == 0)
  937. { return; }
  938. else
  939. {
  940. foreach (var item in StepListB)
  941. {
  942. var tempStep = new TwoStepDataItem();
  943. tempStep.BStepNumber = item.StepNumber;
  944. tempStep.BStepName = item.StepName;
  945. tempStep.IsDiff = item.IsDiff;
  946. StepList.Add(tempStep);
  947. }
  948. }
  949. }
  950. else
  951. {
  952. if (StepListB == null || StepListB.Count == 0)
  953. {
  954. foreach (var item in StepListA)
  955. {
  956. var tempStep = new TwoStepDataItem();
  957. tempStep.AStepNumber = item.StepNumber;
  958. tempStep.AStepName = item.StepName;
  959. tempStep.IsDiff = item.IsDiff;
  960. StepList.Add(tempStep);
  961. }
  962. }
  963. else
  964. {
  965. int bIndex = 0;
  966. int oldIndex = 0;
  967. foreach (var item in StepListA)
  968. {
  969. var tempB = StepListB.FirstOrDefault(x => x.StepName == item.StepName);
  970. if (tempB != null)
  971. {
  972. bIndex = StepListB.IndexOf(tempB);
  973. if (bIndex != 0 && bIndex != oldIndex + 1)
  974. {
  975. for (int i = oldIndex + 1; i < bIndex; i++)
  976. {
  977. var bStep = new TwoStepDataItem();
  978. bStep.AStepNumber = "";
  979. bStep.AStepName = "";
  980. bStep.BStepNumber = StepListB[i].StepNumber;
  981. bStep.BStepName = StepListB[i].StepName;
  982. bStep.IsDiff = false;
  983. StepList.Add(bStep);
  984. }
  985. }
  986. if (oldIndex > bIndex)
  987. {
  988. var tempStepA = new TwoStepDataItem();
  989. tempStepA.AStepNumber = item.StepNumber;
  990. tempStepA.AStepName = item.StepName;
  991. tempStepA.IsDiff = false;
  992. StepList.Add(tempStepA);
  993. continue;
  994. }
  995. else
  996. {
  997. oldIndex = bIndex;
  998. }
  999. var tempStep = new TwoStepDataItem();
  1000. tempStep.AStepNumber = item.StepNumber;
  1001. tempStep.AStepName = item.StepName;
  1002. tempStep.BStepNumber = tempB.StepNumber;
  1003. tempStep.BStepName = tempB.StepName;
  1004. tempStep.IsDiff = tempB.IsDiff;
  1005. StepList.Add(tempStep);
  1006. }
  1007. else
  1008. {
  1009. var tempStep = new TwoStepDataItem();
  1010. tempStep.AStepNumber = item.StepNumber;
  1011. tempStep.AStepName = item.StepName;
  1012. tempStep.IsDiff = item.IsDiff;
  1013. tempStep.BStepNumber = "";
  1014. tempStep.BStepName = "";
  1015. StepList.Add(tempStep);
  1016. }
  1017. }
  1018. if (bIndex + 1 < StepListB.Count)
  1019. {
  1020. for (int i = bIndex + 1; i < StepListB.Count; i++)
  1021. {
  1022. var bStep = new TwoStepDataItem();
  1023. bStep.AStepNumber = "";
  1024. bStep.AStepName = "";
  1025. bStep.BStepNumber = StepListB[i].StepNumber;
  1026. bStep.BStepName = StepListB[i].StepName;
  1027. bStep.IsDiff = StepListB[i].IsDiff;
  1028. StepList.Add(bStep);
  1029. }
  1030. }
  1031. }
  1032. }
  1033. SelectedTwoTableData = tempTable;
  1034. }
  1035. public void LoadData(string selectedRecipePath, bool isSelectA, bool isCurrent, bool isFullPath)
  1036. {
  1037. var array = selectedRecipePath.Split(new char[] { '\\' });
  1038. string recipeName = array[array.Length - 1];
  1039. XmlDocument doc = isSelectA ? _domA : _domB;
  1040. string prefixPath = (isSelectA ? RecipeA : RecipeB).Replace(recipeName, "");
  1041. var _recipeProvider = new RecipeProvider();
  1042. string recipeContent;
  1043. if (isSelectA)
  1044. {
  1045. recipeContent = isFullPath ? _recipeProvider.LoadRecipeByFullPath(selectedRecipePath) : _recipeProvider.LoadRecipe(prefixPath, recipeName, false);
  1046. }
  1047. else
  1048. {
  1049. if (isCurrent)
  1050. {
  1051. recipeContent = _recipeProvider.LoadRecipe(prefixPath, recipeName);
  1052. }
  1053. else
  1054. {
  1055. recipeContent = _recipeProvider.LoadRestoreRecipe(prefixPath, recipeName);
  1056. }
  1057. }
  1058. if (string.IsNullOrEmpty(recipeContent))
  1059. {
  1060. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  1061. return;
  1062. }
  1063. if (isSelectA)
  1064. {
  1065. BackInnerXmlTextA.Clear();
  1066. if (BackInnerXmlTextB.Count > 0)
  1067. {
  1068. string dataXml = BackInnerXmlTextB[0];
  1069. BackInnerXmlTextB.Clear();
  1070. BackInnerXmlTextB.Add(dataXml);
  1071. }
  1072. }
  1073. else
  1074. {
  1075. BackInnerXmlTextB.Clear();
  1076. if (BackInnerXmlTextA.Count > 0)
  1077. {
  1078. string dataXml = BackInnerXmlTextA[0];
  1079. BackInnerXmlTextA.Clear();
  1080. BackInnerXmlTextA.Add(dataXml);
  1081. }
  1082. }
  1083. if (isSelectA)
  1084. {
  1085. _pathPrefixA = prefixPath;
  1086. _mapLineTextA = new Dictionary<string, LineDataItem>();
  1087. BackInnerXmlTextA.Add(recipeContent);
  1088. }
  1089. else
  1090. {
  1091. _pathPrefixB = prefixPath;
  1092. _mapLineTextB = new Dictionary<string, LineDataItem>();
  1093. BackInnerXmlTextB.Add(recipeContent);
  1094. }
  1095. LoadrecipeContentData(recipeContent, isSelectA);
  1096. }
  1097. public void LoadTableData(string selectedRecipePath, bool isSelectA, bool isCurrent, bool isFullPath)
  1098. {
  1099. var array = selectedRecipePath.Split(new char[] { '\\' });
  1100. string recipeName = array[array.Length - 1];
  1101. XmlDocument doc = isSelectA ? _domA : _domB;
  1102. string prefixPath = (isSelectA ? RecipeA : RecipeB).Replace(recipeName, "");
  1103. var _recipeProvider = new RecipeProvider();
  1104. string recipeContent;
  1105. if (isSelectA)
  1106. {
  1107. recipeContent = isFullPath ? _recipeProvider.LoadRecipeByFullPath(selectedRecipePath) : _recipeProvider.LoadRecipe(prefixPath, recipeName, false);
  1108. }
  1109. else
  1110. {
  1111. if (isCurrent)
  1112. {
  1113. recipeContent = _recipeProvider.LoadRecipe(prefixPath, recipeName);
  1114. }
  1115. else
  1116. {
  1117. recipeContent = _recipeProvider.LoadRestoreRecipe(prefixPath, recipeName);
  1118. }
  1119. }
  1120. if (string.IsNullOrEmpty(recipeContent))
  1121. {
  1122. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  1123. return;
  1124. }
  1125. if (isSelectA)
  1126. {
  1127. _pathPrefixA = prefixPath;
  1128. }
  1129. else
  1130. {
  1131. _pathPrefixB = prefixPath;
  1132. }
  1133. LoadTableRecipeContentData(recipeContent, isSelectA);
  1134. }
  1135. public void StepGridSelectionChangedA()
  1136. {
  1137. //if (StepSelectionA == null)
  1138. //{
  1139. // ParamListA.Clear();
  1140. // NotifyOfPropertyChange(nameof(ParamListA));
  1141. // return;
  1142. //}
  1143. //if (_mapStepParamA.ContainsKey(StepSelectionA.StepNumber))
  1144. //{
  1145. // ParamListA = _mapStepParamA[StepSelectionA.StepNumber];
  1146. // foreach (ParamDataItem item in ParamListA)
  1147. // {
  1148. // item.IsHidden = (!item.IsDiff && !item.IsExtra && IsShowDiffParams) ? true : false;
  1149. // }
  1150. // NotifyOfPropertyChange(nameof(ParamListA));
  1151. // NotifyOfPropertyChange(nameof(StepSelectionA));
  1152. // StepSelectionA.InvokePropertyChanged();
  1153. //}
  1154. }
  1155. private void LoadrecipeContentData(string recipeContent, bool isSelectA)
  1156. {
  1157. XmlDocument doc = isSelectA ? _domA : _domB;
  1158. if (isSelectA)
  1159. {
  1160. _mapLineTextA = new Dictionary<string, LineDataItem>();
  1161. //BackInnerXmlTextA.Add(recipeContent);
  1162. }
  1163. else
  1164. {
  1165. _mapLineTextB = new Dictionary<string, LineDataItem>();
  1166. //BackInnerXmlTextB.Add(recipeContent);
  1167. }
  1168. string[] allText = recipeContent.Split(new string[] { "\r\n" }, StringSplitOptions.None);
  1169. int number = 0;
  1170. ObservableCollection<LineDataItem> lineData = new ObservableCollection<LineDataItem>();
  1171. foreach (string lineText in allText)
  1172. {
  1173. LineDataItem line = new LineDataItem();
  1174. line.LineNumber = (++number).ToString();
  1175. line.LineText = lineText;
  1176. if (!string.IsNullOrEmpty(lineText))
  1177. {
  1178. lineData.Add(line);
  1179. if (isSelectA)
  1180. {
  1181. _mapLineTextA[line.LineNumber] = line;
  1182. }
  1183. else
  1184. {
  1185. _mapLineTextB[line.LineNumber] = line;
  1186. }
  1187. }
  1188. }
  1189. doc.LoadXml(recipeContent);
  1190. ObservableCollection<StepDataItem> stepData = new ObservableCollection<StepDataItem>();
  1191. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  1192. if (nodeSteps == null)
  1193. nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Step");
  1194. foreach (XmlNode nodeStep in nodeSteps)
  1195. {
  1196. ObservableCollection<ParamDataItem> paramData = new ObservableCollection<ParamDataItem>();
  1197. StepDataItem step = new StepDataItem();
  1198. foreach (XmlAttribute attr in nodeStep.Attributes)
  1199. {
  1200. if (attr.Name == "StepNo")
  1201. step.StepNumber = attr.Value;
  1202. else if (attr.Name == "Name")
  1203. step.StepName = attr.Value;
  1204. else
  1205. {
  1206. if (!attr.Name.Contains("IsSaved"))
  1207. {
  1208. ParamDataItem param = new ParamDataItem();
  1209. param.ParamName = attr.Name;
  1210. param.ParamValue = attr.Value;
  1211. paramData.Add(param);
  1212. }
  1213. }
  1214. }
  1215. stepData.Add(step);
  1216. if (isSelectA)
  1217. {
  1218. _mapStepParamA[step.StepNumber] = paramData;
  1219. }
  1220. else
  1221. {
  1222. _mapStepParamB[step.StepNumber] = paramData;
  1223. }
  1224. }
  1225. if (isSelectA)
  1226. {
  1227. StepListA = new ObservableCollection<StepDataItem>(stepData.OrderBy(x => int.Parse(x.StepNumber)));
  1228. NotifyOfPropertyChange(nameof(StepListA));
  1229. WholeListA = new ObservableCollection<LineDataItem>(lineData.OrderBy(x => int.Parse(x.LineNumber)));
  1230. NotifyOfPropertyChange(nameof(WholeListA));
  1231. }
  1232. else
  1233. {
  1234. StepListB = new ObservableCollection<StepDataItem>(stepData.OrderBy(x => int.Parse(x.StepNumber)));
  1235. NotifyOfPropertyChange(nameof(StepListB));
  1236. WholeListB = new ObservableCollection<LineDataItem>(lineData.OrderBy(x => int.Parse(x.LineNumber)));
  1237. NotifyOfPropertyChange(nameof(WholeListB));
  1238. }
  1239. }
  1240. private void LoadTableRecipeContentData(string recipeContent, bool isSelectA)
  1241. {
  1242. XmlDocument doc = isSelectA ? _domA : _domB;
  1243. string[] allText = recipeContent.Split(new string[] { "\r\n" }, StringSplitOptions.None);
  1244. int number = 0;
  1245. doc.LoadXml(recipeContent);
  1246. XmlNodeList nodeTables = doc.SelectNodes($"Aitex/TableRecipeData/Tables/Table");
  1247. if (isSelectA)
  1248. {
  1249. tableStepListA.Clear();
  1250. _mapTableStepParamA.Clear();
  1251. }
  1252. else
  1253. {
  1254. tableStepListB.Clear();
  1255. _mapTableStepParamB.Clear();
  1256. }
  1257. foreach (XmlNode nodeTable in nodeTables)
  1258. {
  1259. TableDataItem tableDataItem = new TableDataItem();
  1260. foreach (XmlAttribute attrTable in nodeTable.Attributes)
  1261. {
  1262. switch (attrTable.Name)
  1263. {
  1264. case "Index":
  1265. tableDataItem.TableIndex = attrTable.Value;
  1266. break;
  1267. case "Name":
  1268. tableDataItem.TableName = attrTable.Value;
  1269. break;
  1270. case "EndStatus":
  1271. tableDataItem.EndStatus = attrTable.Value;
  1272. break;
  1273. default:
  1274. break;
  1275. }
  1276. }
  1277. XmlNodeList nodeSteps = nodeTable.SelectNodes("Step");
  1278. ObservableCollection<StepDataItem> stepData = new ObservableCollection<StepDataItem>();
  1279. Dictionary<string, ObservableCollection<ParamDataItem>> _tempMapStepParamA = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  1280. Dictionary<string, ObservableCollection<ParamDataItem>> _tempMapStepParamB = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  1281. foreach (XmlNode nodeStep in nodeSteps)
  1282. {
  1283. ObservableCollection<ParamDataItem> paramData = new ObservableCollection<ParamDataItem>();
  1284. StepDataItem step = new StepDataItem();
  1285. foreach (XmlAttribute attr in nodeStep.Attributes)
  1286. {
  1287. if (attr.Name == "StepNo")
  1288. step.StepNumber = attr.Value;
  1289. else if (attr.Name == "Name")
  1290. step.StepName = attr.Value;
  1291. else
  1292. {
  1293. if (!attr.Name.Contains("IsSaved"))
  1294. {
  1295. ParamDataItem param = new ParamDataItem();
  1296. param.ParamName = attr.Name;
  1297. param.ParamValue = attr.Value;
  1298. paramData.Add(param);
  1299. }
  1300. }
  1301. }
  1302. stepData.Add(step);
  1303. if (isSelectA)
  1304. {
  1305. _mapStepParamA[step.StepNumber] = paramData;
  1306. _tempMapStepParamA[step.StepNumber] = paramData;
  1307. }
  1308. else
  1309. {
  1310. _mapStepParamB[step.StepNumber] = paramData;
  1311. _tempMapStepParamB[step.StepNumber] = paramData;
  1312. }
  1313. }
  1314. if (isSelectA)
  1315. {
  1316. var tableTemp = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == tableDataItem.TableIndex);
  1317. if (tableTemp != null)
  1318. {
  1319. _mapTableStepParamA[tableTemp] = _tempMapStepParamA;
  1320. }
  1321. else
  1322. {
  1323. _mapTableStepParamA.Add(tableDataItem, _tempMapStepParamA);
  1324. }
  1325. int tbIndex = 1;
  1326. int.TryParse(tableDataItem.TableIndex, out tbIndex);
  1327. if (tableStepListA.Keys.Contains(tbIndex))
  1328. {
  1329. tableStepListA[tbIndex] = stepData;
  1330. }
  1331. else
  1332. {
  1333. tableStepListA.Add(tbIndex, stepData);
  1334. }
  1335. }
  1336. else
  1337. {
  1338. var tableTemp = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == tableDataItem.TableIndex);
  1339. if (tableTemp != null)
  1340. {
  1341. _mapTableStepParamB[tableTemp] = _tempMapStepParamB;
  1342. }
  1343. else
  1344. {
  1345. _mapTableStepParamB.Add(tableDataItem, _tempMapStepParamB);
  1346. }
  1347. int tbIndex = 1;
  1348. int.TryParse(tableDataItem.TableIndex, out tbIndex);
  1349. if (tableStepListB.Keys.Contains(tbIndex))
  1350. {
  1351. tableStepListB[tbIndex] = stepData;
  1352. }
  1353. else
  1354. {
  1355. tableStepListB.Add(tbIndex, stepData);
  1356. }
  1357. }
  1358. }
  1359. }
  1360. public void ParamGridSelectionChangedB()
  1361. {
  1362. if (ParamSelectionB == null)
  1363. {
  1364. return;
  1365. }
  1366. NotifyOfPropertyChange(nameof(ParamSelectionB));
  1367. ParamSelectionB.InvokePropertyChanged();
  1368. }
  1369. public void WholeGridSelectionChangedA()
  1370. {
  1371. if (LineSelectionA == null)
  1372. {
  1373. return;
  1374. }
  1375. NotifyOfPropertyChange(nameof(LineSelectionA));
  1376. LineSelectionA.InvokePropertyChanged();
  1377. }
  1378. public void WholeGridSelectionChangedB()
  1379. {
  1380. if (LineSelectionB == null)
  1381. {
  1382. return;
  1383. }
  1384. NotifyOfPropertyChange(nameof(LineSelectionB));
  1385. LineSelectionB.InvokePropertyChanged();
  1386. }
  1387. public void SaveLineA()
  1388. {
  1389. if (LineSelectionA == null)
  1390. return;
  1391. foreach (LineDataItem lineDataItem in WholeListA)
  1392. {
  1393. if (lineDataItem.LineNumber == LineSelectionA.LineNumber)
  1394. {
  1395. lineDataItem.LineText = LineSelectionA.LineText;
  1396. break;
  1397. }
  1398. }
  1399. string recipeContent = "";
  1400. for (int i = 0; i < WholeListA.Count; i++)
  1401. {
  1402. recipeContent += WholeListA[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  1403. }
  1404. CopyToInnerXml(recipeContent, true);
  1405. LoadrecipeContentData(recipeContent, true);
  1406. Recompare();
  1407. SyncShowDiffSteps(IsShowDiffSteps);
  1408. }
  1409. public void SaveLineB()
  1410. {
  1411. if (LineSelectionB == null)
  1412. return;
  1413. foreach (LineDataItem lineDataItem in WholeListB)
  1414. {
  1415. if (lineDataItem.LineNumber == LineSelectionB.LineNumber)
  1416. {
  1417. lineDataItem.LineText = LineSelectionB.LineText;
  1418. break;
  1419. }
  1420. }
  1421. string recipeContent = "";
  1422. for (int i = 0; i < WholeListB.Count; i++)
  1423. {
  1424. recipeContent += WholeListB[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  1425. }
  1426. CopyToInnerXml(recipeContent, false);
  1427. LoadrecipeContentData(recipeContent, false);
  1428. Recompare();
  1429. SyncShowDiffSteps(IsShowDiffSteps);
  1430. }
  1431. private void Recompare()
  1432. {
  1433. if (IsCompareBySName)
  1434. {
  1435. RecompareStepByName();
  1436. }
  1437. RecompareWhole();
  1438. }
  1439. private void RecompareStepByStep()
  1440. {
  1441. if (StepListA == null || StepListB == null)
  1442. return;
  1443. var stepAMaxNumber = (StepListA == null || StepListA.Count() == 0) ? 0 : StepListA.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1444. var stepBMaxNumber = (StepListB == null || StepListB.Count() == 0) ? 0 : StepListB.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1445. int stepMaxNumber = stepAMaxNumber > stepBMaxNumber ? stepAMaxNumber : stepBMaxNumber;
  1446. for (int i = 0; i < stepMaxNumber + 1; i++)
  1447. {
  1448. StepDataItem getStepA = (StepListA == null || StepListA.Count() == 0) ? null : (StepListA.Where(x => x.StepNumber == i.ToString()) == null ? null : StepListA.Where(x => x.StepNumber == i.ToString()).FirstOrDefault());
  1449. StepDataItem getStepB = (StepListB == null || StepListB.Count() == 0) ? null : (StepListB.Where(x => x.StepNumber == i.ToString()) == null ? null : StepListB.Where(x => x.StepNumber == i.ToString()).FirstOrDefault());
  1450. if (getStepA != null && getStepB != null)
  1451. {
  1452. if (getStepA.StepName == getStepB.StepName)
  1453. getStepA.IsDiffName = getStepB.IsDiffName = false;
  1454. else
  1455. getStepA.IsDiffName = getStepB.IsDiffName = true;
  1456. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(i.ToString()) ? _mapStepParamA[i.ToString()] : null;
  1457. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(i.ToString()) ? _mapStepParamB[i.ToString()] : null;
  1458. bool isDiff = false;
  1459. bool IsExtra = true;
  1460. if (paramA != null && paramB == null)
  1461. {
  1462. foreach (var pa in paramA)
  1463. {
  1464. pa.IsExtra = true;
  1465. pa.IsDiff = false;
  1466. }
  1467. }
  1468. else if (paramA == null && paramB != null)
  1469. {
  1470. foreach (var pb in paramB)
  1471. {
  1472. pb.IsExtra = true;
  1473. pb.IsDiff = false;
  1474. }
  1475. }
  1476. else if (paramA != null && paramB != null)
  1477. {
  1478. foreach (var pa in paramA)
  1479. {
  1480. var getParam = paramB.Where(pb => pb.ParamName == pa.ParamName).FirstOrDefault();
  1481. if (getParam != null)
  1482. {
  1483. pa.IsExtra = false;
  1484. getParam.IsExtra = false;
  1485. getParam.IsDiff = pa.IsDiff = (pa.ParamValue != getParam.ParamValue);
  1486. if (pa.ParamValue != getParam.ParamValue)
  1487. {
  1488. isDiff = true;
  1489. }
  1490. }
  1491. }
  1492. getStepA.IsExtra = getStepB.IsExtra = false;
  1493. }
  1494. if (paramA != null)
  1495. {
  1496. foreach (var pa in paramA)
  1497. {
  1498. pa.InvokePropertyChanged();
  1499. }
  1500. }
  1501. if (paramB != null)
  1502. {
  1503. foreach (var pb in paramB)
  1504. {
  1505. pb.InvokePropertyChanged();
  1506. }
  1507. }
  1508. getStepA.IsDiff = getStepB.IsDiff = isDiff;
  1509. getStepA.IsHidden = getStepB.IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1510. getStepA.InvokePropertyChanged();
  1511. getStepB.InvokePropertyChanged();
  1512. }
  1513. else if (getStepA == null && getStepB != null)
  1514. {
  1515. getStepB.IsExtra = true;
  1516. getStepB.IsDiff = false;
  1517. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(getStepB.StepNumber) ? _mapStepParamB[getStepB.StepNumber] : null;
  1518. foreach (var pb in paramB)
  1519. {
  1520. pb.IsExtra = false;
  1521. pb.IsDiff = false;
  1522. pb.InvokePropertyChanged();
  1523. }
  1524. getStepB.InvokePropertyChanged();
  1525. continue;
  1526. }
  1527. else if (getStepA != null && getStepB == null)
  1528. {
  1529. getStepA.IsExtra = true;
  1530. getStepA.IsDiff = false;
  1531. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(getStepA.StepNumber) ? _mapStepParamA[getStepA.StepNumber] : null;
  1532. foreach (var pa in paramA)
  1533. {
  1534. pa.IsExtra = false;
  1535. pa.IsDiff = false;
  1536. pa.InvokePropertyChanged();
  1537. }
  1538. getStepA.InvokePropertyChanged();
  1539. continue;
  1540. }
  1541. else
  1542. {
  1543. continue;
  1544. }
  1545. }
  1546. NotifyOfPropertyChange(nameof(StepListA));
  1547. NotifyOfPropertyChange(nameof(StepListB));
  1548. }
  1549. private void RecompareStepByName()
  1550. {
  1551. if (StepListA == null || StepListB == null)
  1552. return;
  1553. var stepAMaxNumber = (StepListA == null || StepListA.Count() == 0) ? 0 : StepListA.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1554. var stepBMaxNumber = (StepListB == null || StepListB.Count() == 0) ? 0 : StepListB.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1555. int stepMaxNumber = stepAMaxNumber > stepBMaxNumber ? stepAMaxNumber : stepBMaxNumber;
  1556. foreach (var getStepA in StepListA)
  1557. {
  1558. StepDataItem getStepB = (StepListB.Where(x => x.StepName == getStepA.StepName) == null ? null : StepListB.Where(x => x.StepName == getStepA.StepName).FirstOrDefault());
  1559. if (getStepB == null)
  1560. {
  1561. getStepA.IsDiff = false;
  1562. getStepA.IsExtra = true;
  1563. continue;
  1564. }
  1565. getStepA.IsDiffName = getStepB.IsDiffName = true;
  1566. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(getStepA.StepNumber) ? _mapStepParamA[getStepA.StepNumber] : null;
  1567. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(getStepB.StepNumber) ? _mapStepParamB[getStepB.StepNumber] : null;
  1568. bool isDiff = false;
  1569. bool IsExtra = true;
  1570. if (paramA != null && paramB == null)
  1571. {
  1572. foreach (var pa in paramA)
  1573. {
  1574. pa.IsExtra = true;
  1575. pa.IsDiff = false;
  1576. }
  1577. }
  1578. else if (paramA == null && paramB != null)
  1579. {
  1580. foreach (var pb in paramB)
  1581. {
  1582. pb.IsExtra = true;
  1583. pb.IsDiff = false;
  1584. }
  1585. }
  1586. else if (paramA != null && paramB != null)
  1587. {
  1588. foreach (var pa in paramA)
  1589. {
  1590. var getParam = paramB.Where(pb => pb.ParamName == pa.ParamName).FirstOrDefault();
  1591. if (getParam != null)
  1592. {
  1593. pa.IsExtra = false;
  1594. getParam.IsExtra = false;
  1595. getParam.IsDiff = pa.IsDiff = (pa.ParamValue != getParam.ParamValue);
  1596. if (pa.ParamValue != getParam.ParamValue)
  1597. {
  1598. isDiff = true;
  1599. }
  1600. }
  1601. }
  1602. getStepA.IsExtra = getStepB.IsExtra = false;
  1603. }
  1604. if (paramA != null)
  1605. {
  1606. foreach (var pa in paramA)
  1607. {
  1608. pa.InvokePropertyChanged();
  1609. }
  1610. }
  1611. if (paramB != null)
  1612. {
  1613. foreach (var pb in paramB)
  1614. {
  1615. pb.InvokePropertyChanged();
  1616. }
  1617. }
  1618. getStepA.IsDiff = getStepB.IsDiff = isDiff;
  1619. getStepA.IsHidden = getStepB.IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1620. getStepA.InvokePropertyChanged();
  1621. getStepB.InvokePropertyChanged();
  1622. }
  1623. foreach (var getStepB in StepListB)
  1624. {
  1625. StepDataItem getStepA = (StepListA.Where(x => x.StepName == getStepB.StepName) == null ? null : StepListA.Where(x => x.StepName == getStepB.StepName).FirstOrDefault());
  1626. if (getStepA == null)
  1627. {
  1628. getStepB.IsDiff = false;
  1629. getStepB.IsExtra = true;
  1630. continue;
  1631. }
  1632. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(getStepA.StepNumber) ? _mapStepParamA[getStepA.StepNumber] : null;
  1633. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(getStepB.StepNumber) ? _mapStepParamB[getStepB.StepNumber] : null;
  1634. bool isDiff = false;
  1635. foreach (var pb in paramB)
  1636. {
  1637. var getParam = paramA.Where(p => p.ParamName == pb.ParamName).FirstOrDefault();
  1638. if (getParam != null)
  1639. {
  1640. pb.IsExtra = false;
  1641. getParam.IsExtra = false;
  1642. getParam.IsDiff = pb.IsDiff = (pb.ParamValue != getParam.ParamValue);
  1643. if (pb.ParamValue != getParam.ParamValue)
  1644. {
  1645. isDiff = true;
  1646. }
  1647. getParam.IsDiff = pb.IsDiff = (pb.ParamValue != getParam.ParamValue);
  1648. }
  1649. pb.InvokePropertyChanged();
  1650. }
  1651. getStepB.IsExtra = false;
  1652. getStepB.IsDiff = isDiff;
  1653. getStepB.InvokePropertyChanged();
  1654. }
  1655. NotifyOfPropertyChange(nameof(StepListA));
  1656. NotifyOfPropertyChange(nameof(StepListB));
  1657. }
  1658. private void RecompareTableByName()
  1659. {
  1660. for (int i = 1; i < 21; i++)
  1661. {
  1662. ObservableCollection<StepDataItem> _stepListA = null;
  1663. ObservableCollection<StepDataItem> _stepListB = null;
  1664. if (tableStepListA.Keys.Contains(i))
  1665. {
  1666. _stepListA = tableStepListA[i];
  1667. }
  1668. if (tableStepListB.Keys.Contains(i))
  1669. {
  1670. _stepListB = tableStepListB[i];
  1671. }
  1672. if (_stepListA == null || _stepListB == null)
  1673. return;
  1674. var stepAMaxNumber = (_stepListA == null || _stepListA.Count() == 0) ? 0 : _stepListA.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1675. var stepBMaxNumber = (_stepListB == null || _stepListB.Count() == 0) ? 0 : _stepListB.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1676. int stepMaxNumber = stepAMaxNumber > stepBMaxNumber ? stepAMaxNumber : stepBMaxNumber;
  1677. foreach (var getStepA in _stepListA)
  1678. {
  1679. StepDataItem getStepB = (_stepListB.Where(x => x.StepName == getStepA.StepName) == null ? null : _stepListB.Where(x => x.StepName == getStepA.StepName).FirstOrDefault());
  1680. if (getStepB == null)
  1681. {
  1682. getStepA.IsDiff = false;
  1683. getStepA.IsExtra = true;
  1684. continue;
  1685. }
  1686. getStepA.IsDiffName = getStepB.IsDiffName = true;
  1687. var tempA = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1688. ObservableCollection<ParamDataItem> paramA = tempA != null && _mapTableStepParamA[tempA].ContainsKey(getStepA.StepNumber) ? _mapTableStepParamA[tempA][getStepA.StepNumber] : null;
  1689. var tempB = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1690. ObservableCollection<ParamDataItem> paramB = tempB != null && _mapTableStepParamB[tempB].ContainsKey(getStepB.StepNumber) ? _mapTableStepParamB[tempB][getStepB.StepNumber] : null;
  1691. bool isDiff = false;
  1692. bool IsExtra = true;
  1693. if (paramA != null && paramB == null)
  1694. {
  1695. foreach (var pa in paramA)
  1696. {
  1697. pa.IsExtra = true;
  1698. pa.IsDiff = false;
  1699. }
  1700. }
  1701. else if (paramA == null && paramB != null)
  1702. {
  1703. foreach (var pb in paramB)
  1704. {
  1705. pb.IsExtra = true;
  1706. pb.IsDiff = false;
  1707. }
  1708. }
  1709. else if (paramA != null && paramB != null)
  1710. {
  1711. foreach (var pa in paramA)
  1712. {
  1713. var getParam = paramB.Where(pb => pb.ParamName == pa.ParamName).FirstOrDefault();
  1714. if (getParam != null)
  1715. {
  1716. pa.IsExtra = false;
  1717. getParam.IsExtra = false;
  1718. getParam.IsDiff = pa.IsDiff = (pa.ParamValue != getParam.ParamValue);
  1719. if (pa.ParamValue != getParam.ParamValue)
  1720. {
  1721. isDiff = true;
  1722. }
  1723. }
  1724. }
  1725. getStepA.IsExtra = getStepB.IsExtra = false;
  1726. }
  1727. if (paramA != null)
  1728. {
  1729. foreach (var pa in paramA)
  1730. {
  1731. pa.InvokePropertyChanged();
  1732. }
  1733. }
  1734. if (paramB != null)
  1735. {
  1736. foreach (var pb in paramB)
  1737. {
  1738. pb.InvokePropertyChanged();
  1739. }
  1740. }
  1741. getStepA.IsDiff = getStepB.IsDiff = isDiff;
  1742. getStepA.IsHidden = getStepB.IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1743. //getStepA.InvokePropertyChanged();
  1744. //getStepB.InvokePropertyChanged();
  1745. }
  1746. foreach (var getStepB in _stepListB)
  1747. {
  1748. StepDataItem getStepA = (_stepListA.Where(x => x.StepName == getStepB.StepName) == null ? null : _stepListA.Where(x => x.StepName == getStepB.StepName).FirstOrDefault());
  1749. if (getStepA == null)
  1750. {
  1751. getStepB.IsDiff = false;
  1752. getStepB.IsExtra = true;
  1753. continue;
  1754. }
  1755. var tempA = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1756. ObservableCollection<ParamDataItem> paramA = tempA != null && _mapTableStepParamA[tempA].ContainsKey(getStepA.StepNumber) ? _mapTableStepParamA[tempA][getStepA.StepNumber] : null;
  1757. var tempB = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1758. ObservableCollection<ParamDataItem> paramB = tempB != null && _mapTableStepParamB[tempB].ContainsKey(getStepB.StepNumber) ? _mapTableStepParamB[tempB][getStepB.StepNumber] : null;
  1759. bool isDiff = false;
  1760. foreach (var pb in paramB)
  1761. {
  1762. var getParam = paramA.Where(p => p.ParamName == pb.ParamName).FirstOrDefault();
  1763. if (getParam != null)
  1764. {
  1765. pb.IsExtra = false;
  1766. getParam.IsExtra = false;
  1767. getParam.IsDiff = pb.IsDiff = (pb.ParamValue != getParam.ParamValue);
  1768. if (pb.ParamValue != getParam.ParamValue)
  1769. {
  1770. isDiff = true;
  1771. }
  1772. getParam.IsDiff = pb.IsDiff = (pb.ParamValue != getParam.ParamValue);
  1773. }
  1774. pb.InvokePropertyChanged();
  1775. }
  1776. getStepB.IsExtra = false;
  1777. getStepB.IsDiff = isDiff;
  1778. getStepB.InvokePropertyChanged();
  1779. }
  1780. var tempParA = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1781. var tempParB = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1782. if (tempParA != null) tempParA.IsDiff = _stepListA?.Where(x => x.IsDiff).Count() == 0 ? false : true;
  1783. if (tempParB != null) tempParB.IsDiff = _stepListB?.Where(x => x.IsDiff).Count() == 0 ? false : true;
  1784. }
  1785. NotifyOfPropertyChange(nameof(StepListA));
  1786. NotifyOfPropertyChange(nameof(StepListB));
  1787. }
  1788. //private void RecompareStep()
  1789. //{
  1790. // if (StepListA == null || StepListB == null)
  1791. // return;
  1792. // int i = 0;
  1793. // for (i = 0; i < StepListA.Count && i < StepListB.Count; i++)
  1794. // {
  1795. // if (StepListA[i].StepName == StepListB[i].StepName)
  1796. // StepListA[i].IsDiffName = StepListB[i].IsDiffName = false;
  1797. // else
  1798. // StepListA[i].IsDiffName = StepListB[i].IsDiffName = true;
  1799. // ObservableCollection<ParamDataItem> paramA = _mapStepParamA[StepListA[i].StepNumber];
  1800. // ObservableCollection<ParamDataItem> paramB = _mapStepParamB[StepListB[i].StepNumber];
  1801. // bool isDiff = false;
  1802. // bool IsExtra = true;
  1803. // foreach (var pa in paramA)
  1804. // {
  1805. // pa.IsExtra = true;
  1806. // }
  1807. // foreach (var pb in paramB)
  1808. // {
  1809. // pb.IsExtra = true;
  1810. // }
  1811. // foreach (var pa in paramA)
  1812. // {
  1813. // foreach (var pb in paramB)
  1814. // {
  1815. // if (pb.ParamName == pa.ParamName)
  1816. // {
  1817. // pb.IsExtra = false;
  1818. // pa.IsExtra = false;
  1819. // pb.IsDiff = pa.IsDiff = (pa.ParamValue != pb.ParamValue);
  1820. // if (pa.IsDiff)
  1821. // isDiff = true;
  1822. // break;
  1823. // }
  1824. // }
  1825. // }
  1826. // foreach (var pa in paramA)
  1827. // {
  1828. // pa.InvokePropertyChanged();
  1829. // }
  1830. // foreach (var pb in paramB)
  1831. // {
  1832. // pb.InvokePropertyChanged();
  1833. // }
  1834. // StepListA[i].IsDiff = StepListB[i].IsDiff = isDiff;
  1835. // StepListA[i].IsExtra = StepListB[i].IsExtra = false;
  1836. // StepListA[i].IsHidden = StepListB[i].IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1837. // StepListA[i].InvokePropertyChanged();
  1838. // StepListB[i].InvokePropertyChanged();
  1839. // }
  1840. // for (int j = i; j < StepListA.Count; j++)
  1841. // {
  1842. // StepListA[j].IsDiff = false;
  1843. // StepListA[j].IsExtra = true;
  1844. // StepListA[j].InvokePropertyChanged();
  1845. // foreach (var pa in _mapStepParamA[StepListA[j].StepNumber])
  1846. // {
  1847. // pa.InvokePropertyChanged();
  1848. // }
  1849. // }
  1850. // for (int k = i; k < StepListB.Count; k++)
  1851. // {
  1852. // StepListB[k].IsDiff = false;
  1853. // StepListB[k].IsExtra = true;
  1854. // WholeListB[k].InvokePropertyChanged();
  1855. // _mapLineTextB[WholeListB[k].LineNumber].InvokePropertyChanged();
  1856. // foreach (var pb in _mapStepParamB[StepListB[k].StepNumber])
  1857. // {
  1858. // pb.InvokePropertyChanged();
  1859. // }
  1860. // }
  1861. // NotifyOfPropertyChange(nameof(StepListA));
  1862. // NotifyOfPropertyChange(nameof(StepListB));
  1863. //}
  1864. private void RecompareWhole()
  1865. {
  1866. if (WholeListA == null || WholeListB == null)
  1867. return;
  1868. int i = 0;
  1869. for (i = 0; i < WholeListA.Count && i < WholeListB.Count; i++)
  1870. {
  1871. LineDataItem lineA = _mapLineTextA[WholeListA[i].LineNumber];
  1872. LineDataItem lineB = _mapLineTextB[WholeListB[i].LineNumber];
  1873. bool isDiff = false;
  1874. lineB.IsDiff = lineA.IsDiff = (lineA.LineText != lineB.LineText);
  1875. if (lineA.IsDiff)
  1876. isDiff = true;
  1877. WholeListA[i].IsDiff = WholeListB[i].IsDiff = isDiff;
  1878. WholeListA[i].IsExtra = WholeListB[i].IsExtra = false;
  1879. _mapLineTextA[WholeListA[i].LineNumber].IsDiff = _mapLineTextB[WholeListB[i].LineNumber].IsDiff = isDiff;
  1880. _mapLineTextA[WholeListA[i].LineNumber].IsExtra = _mapLineTextB[WholeListB[i].LineNumber].IsExtra = false;
  1881. lineA.InvokePropertyChanged();
  1882. lineB.InvokePropertyChanged();
  1883. WholeListA[i].InvokePropertyChanged();
  1884. WholeListB[i].InvokePropertyChanged();
  1885. }
  1886. for (int j = i; j < WholeListA.Count; j++)
  1887. {
  1888. WholeListA[j].IsDiff = false;
  1889. WholeListA[j].IsExtra = true;
  1890. _mapLineTextA[WholeListA[j].LineNumber].IsDiff = false;
  1891. _mapLineTextA[WholeListA[j].LineNumber].IsExtra = true;
  1892. if (!(_mapLineTextA[WholeListA[j].LineNumber].LineText.Contains("<Step StepNo") || _mapLineTextA[WholeListA[j].LineNumber].LineText.Contains("<Moudule Name")))
  1893. {
  1894. WholeListA[j].IsDiff = false;
  1895. WholeListA[j].IsExtra = false;
  1896. }
  1897. WholeListA[j].InvokePropertyChanged();
  1898. _mapLineTextA[WholeListA[j].LineNumber].InvokePropertyChanged();
  1899. }
  1900. for (int k = i; k < WholeListB.Count; k++)
  1901. {
  1902. WholeListB[k].IsDiff = false;
  1903. WholeListB[k].IsExtra = true;
  1904. _mapLineTextB[WholeListB[k].LineNumber].IsDiff = false;
  1905. _mapLineTextB[WholeListB[k].LineNumber].IsExtra = true;
  1906. if (!(_mapLineTextB[WholeListB[k].LineNumber].LineText.Contains("<Step StepNo") || _mapLineTextB[WholeListB[k].LineNumber].LineText.Contains("<Moudule Name")))
  1907. {
  1908. WholeListB[k].IsDiff = false;
  1909. WholeListB[k].IsExtra = false;
  1910. }
  1911. WholeListB[k].InvokePropertyChanged();
  1912. _mapLineTextB[WholeListB[k].LineNumber].InvokePropertyChanged();
  1913. }
  1914. NotifyOfPropertyChange(nameof(WholeListA));
  1915. NotifyOfPropertyChange(nameof(WholeListB));
  1916. }
  1917. private void SyncStepSelection(TwoStepDataItem stepData)
  1918. {
  1919. if (stepData == null)
  1920. return;
  1921. var getStepA = StepListA.Where(x => x.StepName == stepData.AStepName).FirstOrDefault();
  1922. var getStepB = StepListB.Where(x => x.StepName == stepData.BStepName).FirstOrDefault();
  1923. if (getStepA == null && getStepB == null)
  1924. {
  1925. ParamList.Clear();
  1926. return;
  1927. }
  1928. else if (getStepA != null && getStepB == null)
  1929. {
  1930. ParamListA = _mapStepParamA[getStepA.StepNumber];
  1931. foreach (var item in ParamListA)
  1932. {
  1933. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  1934. if (par != null)
  1935. {
  1936. par.AParamValue = item.ParamValue;
  1937. par.IsDiff = false;
  1938. par.IsExtra = item.IsExtra;
  1939. par.BParamValue = "--";
  1940. }
  1941. else
  1942. {
  1943. TwoParamDataItem param = new TwoParamDataItem();
  1944. param.ParamName = item.ParamName;
  1945. param.AParamValue = item.ParamValue;
  1946. param.IsDiff = item.IsDiff;
  1947. param.IsExtra = item.IsExtra;
  1948. param.BParamValue = "--";
  1949. ParamList.Add(param);
  1950. }
  1951. }
  1952. }
  1953. else if (getStepA == null && getStepB != null)
  1954. {
  1955. ParamListB = _mapStepParamB[getStepB.StepNumber];
  1956. foreach (var item in ParamListB)
  1957. {
  1958. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  1959. if (par != null)
  1960. {
  1961. par.BParamValue = item.ParamValue;
  1962. par.IsDiff = false;
  1963. par.IsExtra = item.IsExtra;
  1964. par.AParamValue = "--";
  1965. }
  1966. else
  1967. {
  1968. var param = new TwoParamDataItem();
  1969. param.ParamName = item.ParamName;
  1970. param.BParamValue = item.ParamValue;
  1971. param.IsDiff = item.IsDiff;
  1972. param.IsExtra = item.IsExtra;
  1973. param.AParamValue = "--";
  1974. ParamList.Add(param);
  1975. }
  1976. }
  1977. }
  1978. else
  1979. {
  1980. ParamListA = _mapStepParamA[getStepA.StepNumber];
  1981. ParamListB = _mapStepParamB[getStepB.StepNumber];
  1982. foreach (var item in ParamListA)
  1983. {
  1984. var bValue = ParamListB.FirstOrDefault(x => x.ParamName == item.ParamName)?.ParamValue;
  1985. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  1986. if (par != null)
  1987. {
  1988. par.AParamValue = item.ParamValue;
  1989. par.IsDiff = item.IsDiff;
  1990. par.IsExtra = item.IsExtra;
  1991. if (bValue != null)
  1992. {
  1993. par.BParamValue = bValue;
  1994. }
  1995. else
  1996. {
  1997. par.BParamValue = "--";
  1998. }
  1999. }
  2000. else
  2001. {
  2002. var param = new TwoParamDataItem();
  2003. param.ParamName = item.ParamName;
  2004. param.AParamValue = item.ParamValue;
  2005. param.IsDiff = item.IsDiff;
  2006. param.IsExtra = item.IsExtra;
  2007. if (bValue != null)
  2008. {
  2009. param.BParamValue = bValue;
  2010. }
  2011. else
  2012. {
  2013. param.BParamValue = "--";
  2014. }
  2015. ParamList.Add(param);
  2016. }
  2017. }
  2018. }
  2019. //NotifyOfPropertyChange(nameof(StepSelection));
  2020. //StepSelection.InvokePropertyChanged();
  2021. }
  2022. private void SyncTableStepSelection(TwoStepDataItem stepData)
  2023. {
  2024. if (stepData == null)
  2025. return;
  2026. var getStepA = tableStepListA[SelectTableIndex].Where(x => x.StepName == stepData.AStepName).FirstOrDefault();
  2027. var getStepB = tableStepListB[SelectTableIndex].Where(x => x.StepName == stepData.BStepName).FirstOrDefault();
  2028. if (getStepA == null && getStepB == null)
  2029. {
  2030. ParamList.Clear();
  2031. return;
  2032. }
  2033. else if (getStepA != null && getStepB == null)
  2034. {
  2035. var tempPar = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == SelectTableIndex.ToString());
  2036. ParamListA.Clear();
  2037. if (tempPar != null)
  2038. {
  2039. _mapTableStepParamA[tempPar][getStepA.StepNumber].ToList().ForEach(x => ParamListA.Add(x));
  2040. }
  2041. foreach (var item in ParamListA)
  2042. {
  2043. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  2044. if (par != null)
  2045. {
  2046. par.AParamValue = item.ParamValue;
  2047. par.IsDiff = false;
  2048. par.IsExtra = item.IsExtra;
  2049. par.BParamValue = "--";
  2050. }
  2051. else
  2052. {
  2053. TwoParamDataItem param = new TwoParamDataItem();
  2054. param.ParamName = item.ParamName;
  2055. param.AParamValue = item.ParamValue;
  2056. param.IsDiff = item.IsDiff;
  2057. param.IsExtra = item.IsExtra;
  2058. param.BParamValue = "--";
  2059. ParamList.Add(param);
  2060. }
  2061. }
  2062. }
  2063. else if (getStepA == null && getStepB != null)
  2064. {
  2065. var tempPar = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == SelectTableIndex.ToString());
  2066. ParamListB.Clear();
  2067. if (tempPar != null)
  2068. {
  2069. _mapTableStepParamB[tempPar][getStepB.StepNumber].ToList().ForEach(x => ParamListB.Add(x));
  2070. }
  2071. foreach (var item in ParamListB)
  2072. {
  2073. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  2074. if (par != null)
  2075. {
  2076. par.BParamValue = item.ParamValue;
  2077. par.IsDiff = false;
  2078. par.IsExtra = item.IsExtra;
  2079. par.AParamValue = "--";
  2080. }
  2081. else
  2082. {
  2083. var param = new TwoParamDataItem();
  2084. param.ParamName = item.ParamName;
  2085. param.BParamValue = item.ParamValue;
  2086. param.IsDiff = item.IsDiff;
  2087. param.IsExtra = item.IsExtra;
  2088. param.AParamValue = "--";
  2089. ParamList.Add(param);
  2090. }
  2091. }
  2092. }
  2093. else
  2094. {
  2095. var tempPar = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == SelectTableIndex.ToString());
  2096. ParamListA.Clear();
  2097. if (tempPar != null)
  2098. {
  2099. _mapTableStepParamA[tempPar][getStepA.StepNumber].ToList().ForEach(x => ParamListA.Add(x));
  2100. }
  2101. var tempParB = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == SelectTableIndex.ToString());
  2102. ParamListB.Clear();
  2103. if (tempParB != null)
  2104. {
  2105. _mapTableStepParamB[tempParB][getStepB.StepNumber].ToList().ForEach(x => ParamListB.Add(x));
  2106. }
  2107. foreach (var item in ParamListA)
  2108. {
  2109. var bValue = ParamListB.FirstOrDefault(x => x.ParamName == item.ParamName)?.ParamValue;
  2110. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  2111. if (par != null)
  2112. {
  2113. par.AParamValue = item.ParamValue;
  2114. par.IsExtra = item.IsExtra;
  2115. if (bValue != null)
  2116. {
  2117. par.IsDiff = item.ParamValue != bValue;
  2118. par.BParamValue = bValue;
  2119. }
  2120. else
  2121. {
  2122. par.BParamValue = "--";
  2123. }
  2124. }
  2125. else
  2126. {
  2127. var param = new TwoParamDataItem();
  2128. param.ParamName = item.ParamName;
  2129. param.AParamValue = item.ParamValue;
  2130. param.IsDiff = item.IsDiff;
  2131. param.IsExtra = item.IsExtra;
  2132. if (bValue != null)
  2133. {
  2134. param.BParamValue = bValue;
  2135. }
  2136. else
  2137. {
  2138. param.BParamValue = "--";
  2139. }
  2140. ParamList.Add(param);
  2141. }
  2142. }
  2143. }
  2144. //NotifyOfPropertyChange(nameof(StepSelection));
  2145. //StepSelection.InvokePropertyChanged();
  2146. }
  2147. private void SyncParamSelection(ParamDataItem paramData, bool isSelectA)
  2148. {
  2149. try
  2150. {
  2151. if (paramData == null)
  2152. return;
  2153. if (isSelectA)
  2154. {
  2155. if (IsCompareBySName)
  2156. {
  2157. //var getSameStepName = StepListA.Where(x => x.StepName == StepSelectionB.StepName).FirstOrDefault();
  2158. //if (getSameStepName == null) return;
  2159. //if (_mapStepParamA.ContainsKey(getSameStepName.StepNumber))
  2160. //{
  2161. // ParamListA = _mapStepParamA[getSameStepName.StepNumber];
  2162. // NotifyOfPropertyChange(nameof(ParamListA));
  2163. //}
  2164. //else
  2165. // return;
  2166. //foreach (var item in ParamListA)
  2167. //{
  2168. // if (item.ParamName == paramData.ParamName)
  2169. // {
  2170. // _paramSelectionA = item;
  2171. // NotifyOfPropertyChange(nameof(ParamSelectionA));
  2172. // ParamSelectionA.InvokePropertyChanged();
  2173. // }
  2174. //}
  2175. }
  2176. }
  2177. else
  2178. {
  2179. //if (IsCompareByStep)
  2180. //{
  2181. // if (ParamListB == null)
  2182. // {
  2183. // if (_mapStepParamB.ContainsKey(StepSelectionA.StepNumber))
  2184. // {
  2185. // ParamListB = _mapStepParamB[StepSelectionA.StepNumber];
  2186. // NotifyOfPropertyChange(nameof(ParamListB));
  2187. // }
  2188. // else
  2189. // return;
  2190. // }
  2191. // foreach (var item in ParamListB)
  2192. // {
  2193. // if (item.ParamName == paramData.ParamName)
  2194. // {
  2195. // _paramSelectionB = item;
  2196. // NotifyOfPropertyChange(nameof(ParamSelectionB));
  2197. // ParamSelectionB.InvokePropertyChanged();
  2198. // }
  2199. // }
  2200. //}
  2201. //if (IsCompareBySName)
  2202. //{
  2203. // if (ParamListB == null)
  2204. // {
  2205. // var getSameStepName = StepListB.Where(x => x.StepName == StepSelectionA.StepName).FirstOrDefault();
  2206. // if (_mapStepParamB.ContainsKey(getSameStepName.StepNumber))
  2207. // {
  2208. // ParamListB = _mapStepParamB[getSameStepName.StepNumber];
  2209. // NotifyOfPropertyChange(nameof(ParamListB));
  2210. // }
  2211. // else
  2212. // return;
  2213. // }
  2214. // foreach (var item in ParamListB)
  2215. // {
  2216. // if (item.ParamName == paramData.ParamName)
  2217. // {
  2218. // _paramSelectionB = item;
  2219. // NotifyOfPropertyChange(nameof(ParamSelectionB));
  2220. // ParamSelectionB.InvokePropertyChanged();
  2221. // }
  2222. // }
  2223. //}
  2224. }
  2225. }
  2226. catch (Exception ex)
  2227. {
  2228. LOG.Write(ex.Message);
  2229. }
  2230. }
  2231. private void SyncLineSelection(LineDataItem lineData, bool isSelectA)
  2232. {
  2233. if (lineData == null)
  2234. return;
  2235. if (isSelectA)
  2236. {
  2237. foreach (var item in WholeListA)
  2238. {
  2239. if (item.LineNumber == lineData.LineNumber)
  2240. {
  2241. _lineSelectionA = item;
  2242. NotifyOfPropertyChange(nameof(LineSelectionA));
  2243. LineSelectionA.InvokePropertyChanged();
  2244. }
  2245. }
  2246. }
  2247. else
  2248. {
  2249. foreach (var item in WholeListB)
  2250. {
  2251. if (item.LineNumber == lineData.LineNumber)
  2252. {
  2253. _lineSelectionB = item;
  2254. NotifyOfPropertyChange(nameof(LineSelectionB));
  2255. LineSelectionB.InvokePropertyChanged();
  2256. }
  2257. }
  2258. }
  2259. }
  2260. public void RemoveA()
  2261. {
  2262. RemoveRecipe(true);
  2263. }
  2264. public void RemoveB()
  2265. {
  2266. RemoveRecipe(false);
  2267. }
  2268. private void RemoveSelectB()
  2269. {
  2270. StepListB?.Clear();
  2271. ParamListB?.Clear();
  2272. WholeListB?.Clear();
  2273. RecipeB = string.Empty;
  2274. _mapStepParamB?.Clear();
  2275. _paramSelectionB = null;
  2276. NotifyOfPropertyChange(nameof(StepListB));
  2277. NotifyOfPropertyChange(nameof(ParamListB));
  2278. NotifyOfPropertyChange(nameof(RecipeB));
  2279. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  2280. NotifyOfPropertyChange(nameof(ParamSelectionB));
  2281. }
  2282. private void RemoveRecipe(bool isSelectA)
  2283. {
  2284. if (!DialogBox.Confirm($"Are you sure you want to remove the recipe? \r\n{RecipeB}"))
  2285. return;
  2286. if (isSelectA)
  2287. {
  2288. StepListA?.Clear();
  2289. ParamListA?.Clear();
  2290. WholeListA?.Clear();
  2291. RecipeA = string.Empty;
  2292. _mapStepParamA?.Clear();
  2293. NotifyOfPropertyChange(nameof(StepListA));
  2294. NotifyOfPropertyChange(nameof(ParamListA));
  2295. NotifyOfPropertyChange(nameof(RecipeA));
  2296. NotifyOfPropertyChange(nameof(EnableButtonRemoveA));
  2297. }
  2298. else
  2299. {
  2300. StepListB?.Clear();
  2301. ParamListB?.Clear();
  2302. WholeListB?.Clear();
  2303. RecipeB = string.Empty;
  2304. _mapStepParamB?.Clear();
  2305. _paramSelectionB = null;
  2306. NotifyOfPropertyChange(nameof(StepListB));
  2307. NotifyOfPropertyChange(nameof(ParamListB));
  2308. NotifyOfPropertyChange(nameof(RecipeB));
  2309. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  2310. NotifyOfPropertyChange(nameof(ParamSelectionB));
  2311. }
  2312. }
  2313. private void DeleteInnerXml(bool isSelectA)
  2314. {
  2315. try
  2316. {
  2317. XmlDocument docTo = isSelectA ? _domA : _domB;
  2318. //XmlNode nodeModule = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='PM1']");{_module}
  2319. // doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  2320. XmlNodeList nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  2321. if (nodeSteps == null)
  2322. nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Step");
  2323. List<XmlNode> oldNodeSteps = new List<XmlNode>();
  2324. foreach (XmlNode nodeTemp in nodeSteps)
  2325. {
  2326. oldNodeSteps.Add(nodeTemp.Clone());
  2327. }
  2328. XmlNodeList backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/BakeStep");
  2329. if (backSteps == null)
  2330. backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/BakeStep");
  2331. List<XmlNode> oldBackNodeSteps = new List<XmlNode>();
  2332. foreach (XmlNode nodeTemp in backSteps)
  2333. {
  2334. oldBackNodeSteps.Add(nodeTemp.Clone());
  2335. }
  2336. XmlNode stepsNode = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='PM1']/Step").ParentNode;
  2337. stepsNode.RemoveAll();
  2338. (stepsNode as XmlElement).SetAttribute("Name", "PM1"); //微釜的recipe为什么都是PM1?,如果recipe改了,此处要改回(stepsNode as XmlElement).SetAttribute("Name", _module);
  2339. ObservableCollection<StepDataItem> stepListTo = isSelectA ? StepListA : StepListB;
  2340. if (stepsNode == null)
  2341. {
  2342. return;
  2343. }
  2344. foreach (StepDataItem item in stepListTo)
  2345. {
  2346. XmlElement DeviceTree = docTo.CreateElement("Step");
  2347. DeviceTree.SetAttribute("StepNo", item.StepNumber.ToString());
  2348. DeviceTree.SetAttribute("Name", item.StepName);
  2349. stepsNode.AppendChild(DeviceTree);
  2350. }
  2351. foreach (XmlNode nodeStep in stepsNode)
  2352. {
  2353. string stepNumber = nodeStep.Attributes["StepNo"].Value;
  2354. ObservableCollection<ParamDataItem> paramList =
  2355. isSelectA ? _mapStepParamA[stepNumber] : _mapStepParamB[stepNumber];
  2356. foreach (var param in paramList)
  2357. {
  2358. (nodeStep as XmlElement).SetAttribute(param.ParamName, param.ParamValue);
  2359. }
  2360. }
  2361. foreach (XmlNode nodeStep in backSteps)
  2362. {
  2363. stepsNode.AppendChild(nodeStep);
  2364. }
  2365. string backText = getXmlText(isSelectA ? _domA : _domB);
  2366. LoadrecipeContentData(backText, isSelectA);
  2367. Recompare();
  2368. SyncShowDiffSteps(IsShowDiffSteps);
  2369. if (isSelectA)
  2370. {
  2371. BackInnerXmlTextA.Add(backText);
  2372. }
  2373. else
  2374. {
  2375. BackInnerXmlTextB.Add(backText);
  2376. }
  2377. }
  2378. catch (Exception ex)
  2379. {
  2380. LOG.Write(ex.Message);
  2381. }
  2382. }
  2383. public void SelectedRecipeTable()
  2384. {
  2385. ItemsSelectDialogViewModel itemsSelectDialogViewModel = new ItemsSelectDialogViewModel();
  2386. itemsSelectDialogViewModel.Items.Clear();
  2387. var tables = _mapTableStepParamA.Keys;
  2388. foreach (var item in tables)
  2389. {
  2390. TwoTableDataItem twoTableDataItem = new TwoTableDataItem();
  2391. int tableIndex = -1;
  2392. int.TryParse(item.TableIndex, out tableIndex);
  2393. if (tableIndex != -1)
  2394. {
  2395. twoTableDataItem.Index = tableIndex;
  2396. twoTableDataItem.ATableName = item.TableName;
  2397. var tablesB = _mapTableStepParamB.Keys;
  2398. var tableB = tablesB.FirstOrDefault(x => x.TableIndex == item.TableIndex);
  2399. if (tableB != null)
  2400. {
  2401. twoTableDataItem.BTableName = tableB.TableName;
  2402. twoTableDataItem.IsDiff = tableB.IsDiff;
  2403. }
  2404. itemsSelectDialogViewModel.Items.Add(twoTableDataItem);
  2405. }
  2406. }
  2407. WindowManager wm = new WindowManager();
  2408. bool? bret = wm.ShowDialog(itemsSelectDialogViewModel);
  2409. if ((bool)bret)
  2410. {
  2411. var item = itemsSelectDialogViewModel.SelectedItem;
  2412. SelectedTwoTableData = item;
  2413. SelectTableIndex = item.Index;
  2414. GetTableStepList(true, item.Index);
  2415. GetTableStepList(false, item.Index);
  2416. SyncShowDiffSteps(IsShowDiffSteps);
  2417. if (StepList != null && StepList.Count > 0)
  2418. SyncTableStepSelection(StepList[0]);
  2419. SyncShowDiffParams(_isShowDiffParams);
  2420. }
  2421. }
  2422. private string getXmlText(XmlDocument xmlDocument)
  2423. {
  2424. (new RecipeProvider()).SaveRecipe("", "RecipeTemp", xmlDocument.InnerXml);
  2425. var _recipeProvider = new RecipeProvider();
  2426. var recipeContent = _recipeProvider.LoadRecipe("", "RecipeTemp", false);
  2427. return recipeContent;
  2428. }
  2429. public void LineCopyToLeft(LineDataItem lineData)
  2430. {
  2431. LineCopy(lineData, false);
  2432. }
  2433. public void LineCopyToRight(LineDataItem lineData)
  2434. {
  2435. LineCopy(lineData, true);
  2436. }
  2437. public void LineCopy(LineDataItem lineData, bool isFromA)
  2438. {
  2439. try
  2440. {
  2441. LineDataItem lineFrom = lineData;
  2442. ObservableCollection<LineDataItem> lineListTo = isFromA ? WholeListB : WholeListA;
  2443. Dictionary<string, LineDataItem> mapFrom = isFromA ? _mapLineTextA : _mapLineTextB;
  2444. Dictionary<string, LineDataItem> mapTo = isFromA ? _mapLineTextB : _mapLineTextA;
  2445. var tempLine = lineListTo.Where(x => x.LineNumber == lineFrom.LineNumber).FirstOrDefault();
  2446. if (tempLine != null)
  2447. {
  2448. tempLine.LineText = lineFrom.LineText;
  2449. tempLine.IsDiff = lineFrom.IsDiff = false;
  2450. tempLine.IsExtra = lineFrom.IsExtra = false;
  2451. }
  2452. string recipeContent = "";
  2453. if (isFromA)
  2454. {
  2455. for (int i = 0; i < WholeListB.Count; i++)
  2456. {
  2457. recipeContent += WholeListB[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  2458. }
  2459. }
  2460. else
  2461. {
  2462. for (int i = 0; i < WholeListA.Count; i++)
  2463. {
  2464. recipeContent += WholeListA[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  2465. }
  2466. }
  2467. CopyToInnerXml(recipeContent, !isFromA);
  2468. LoadrecipeContentData(recipeContent, !isFromA);
  2469. Recompare();
  2470. SyncShowDiffSteps(IsShowDiffSteps);
  2471. }
  2472. catch (Exception ex)
  2473. {
  2474. LOG.Write(ex.Message);
  2475. }
  2476. }
  2477. private void CopyToInnerXml(string recipeContent, bool isSelectA)
  2478. {
  2479. XmlDocument doc = isSelectA ? _domA : _domB;
  2480. doc.InnerXml = recipeContent;
  2481. if (isSelectA)
  2482. {
  2483. BackInnerXmlTextA.Add(recipeContent);
  2484. }
  2485. else
  2486. {
  2487. BackInnerXmlTextB.Add(recipeContent);
  2488. }
  2489. }
  2490. public void SaveA()
  2491. {
  2492. Save(true);
  2493. }
  2494. public void SaveB()
  2495. {
  2496. Save(false);
  2497. }
  2498. private void Save(bool isSelectA)
  2499. {
  2500. XmlDocument doc = isSelectA ? _domA : _domB;
  2501. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  2502. if (nodeSteps == null)
  2503. nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Step");
  2504. if (isSelectA)
  2505. {
  2506. (new RecipeProvider()).SaveRecipe("", RecipeA, doc.InnerXml);
  2507. }
  2508. else
  2509. {
  2510. (new RecipeProvider()).SaveRecipe("", RecipeB, doc.InnerXml);
  2511. }
  2512. }
  2513. private bool _isStepModel = true;
  2514. public bool IsStepModel
  2515. {
  2516. get { return _isStepModel; }
  2517. set
  2518. {
  2519. _isStepModel = value;
  2520. _isWholeModel = !_isStepModel;
  2521. StepVisibility = _isStepModel ? Visibility.Visible : Visibility.Hidden;
  2522. WholeVisibility = _isWholeModel ? Visibility.Visible : Visibility.Hidden;
  2523. InvokePropertyChanged(nameof(IsStepModel));
  2524. InvokePropertyChanged(nameof(IsWholeModel));
  2525. InvokePropertyChanged(nameof(StepVisibility));
  2526. InvokePropertyChanged(nameof(WholeVisibility));
  2527. }
  2528. }
  2529. private bool _isWholeModel;
  2530. public bool IsWholeModel
  2531. {
  2532. get { return _isWholeModel; }
  2533. set
  2534. {
  2535. _isWholeModel = value;
  2536. _isStepModel = !_isWholeModel;
  2537. StepVisibility = _isStepModel ? Visibility.Visible : Visibility.Hidden;
  2538. WholeVisibility = _isWholeModel ? Visibility.Visible : Visibility.Hidden;
  2539. InvokePropertyChanged(nameof(IsWholeModel));
  2540. InvokePropertyChanged(nameof(IsStepModel));
  2541. InvokePropertyChanged(nameof(StepVisibility));
  2542. InvokePropertyChanged(nameof(WholeVisibility));
  2543. }
  2544. }
  2545. public Visibility StepVisibility
  2546. {
  2547. get; set;
  2548. }
  2549. public Visibility WholeVisibility
  2550. {
  2551. get; set;
  2552. }
  2553. private bool _isShowDiffSteps;
  2554. public bool IsShowDiffSteps
  2555. {
  2556. get { return _isShowDiffSteps; }
  2557. set
  2558. {
  2559. _isShowDiffSteps = value;
  2560. _isShowAllSteps = !_isShowDiffSteps;
  2561. SyncShowDiffSteps(_isShowDiffSteps);
  2562. InvokePropertyChanged(nameof(IsShowDiffSteps));
  2563. InvokePropertyChanged(nameof(IsShowAllSteps));
  2564. }
  2565. }
  2566. private bool _isShowAllSteps = true;
  2567. public bool IsShowAllSteps
  2568. {
  2569. get { return _isShowAllSteps; }
  2570. set
  2571. {
  2572. _isShowAllSteps = value;
  2573. _isShowDiffSteps = !_isShowAllSteps;
  2574. SyncShowDiffSteps(_isShowDiffSteps);
  2575. InvokePropertyChanged(nameof(IsShowAllSteps));
  2576. InvokePropertyChanged(nameof(IsShowDiffSteps));
  2577. }
  2578. }
  2579. private bool _isShowDiffParams;
  2580. public bool IsShowDiffParams
  2581. {
  2582. get { return _isShowDiffParams; }
  2583. set
  2584. {
  2585. _isShowDiffParams = value;
  2586. SyncShowDiffParams(_isShowDiffParams);
  2587. _isShowAllParams = !_isShowDiffParams;
  2588. InvokePropertyChanged(nameof(IsShowDiffParams));
  2589. InvokePropertyChanged(nameof(IsShowAllParams));
  2590. }
  2591. }
  2592. private bool _isShowAllParams = true;
  2593. public bool IsShowAllParams
  2594. {
  2595. get { return _isShowAllParams; }
  2596. set
  2597. {
  2598. _isShowAllParams = value;
  2599. _isShowDiffParams = !_isShowAllParams;
  2600. SyncShowDiffParams(_isShowDiffParams);
  2601. InvokePropertyChanged(nameof(IsShowDiffParams));
  2602. InvokePropertyChanged(nameof(IsShowAllParams));
  2603. }
  2604. }
  2605. private bool _isCompareBySName = true;
  2606. public bool IsCompareBySName
  2607. {
  2608. get { return _isCompareBySName; }
  2609. set
  2610. {
  2611. _isCompareBySName = value;
  2612. Recompare();
  2613. SyncShowDiffSteps(_isShowDiffSteps);
  2614. InvokePropertyChanged(nameof(IsCompareBySName));
  2615. }
  2616. }
  2617. private void SyncShowDiffSteps(bool isShowDiffSteps)
  2618. {
  2619. if (StepListA == null || StepListB == null)
  2620. return;
  2621. foreach (var item in StepList)
  2622. {
  2623. item.IsHidden = (IsShowDiffSteps ? (item.IsDiff == false && item.IsExtra == false) : false);
  2624. }
  2625. NotifyOfPropertyChange(nameof(StepList));
  2626. }
  2627. private void SyncShowDiffParams(bool isShowDiffParams)
  2628. {
  2629. if (ParamListA == null || ParamListB == null)
  2630. return;
  2631. if (isShowDiffParams)
  2632. {
  2633. foreach (var item in ParamList)
  2634. {
  2635. if (item.IsDiff == false && item.IsExtra == false)
  2636. {
  2637. item.IsHidden = isShowDiffParams;
  2638. }
  2639. else
  2640. {
  2641. item.IsHidden = false;
  2642. }
  2643. }
  2644. }
  2645. else
  2646. {
  2647. foreach (var item in ParamList)
  2648. {
  2649. item.IsHidden = isShowDiffParams;
  2650. }
  2651. }
  2652. NotifyOfPropertyChange(nameof(ParamList));
  2653. }
  2654. }
  2655. }