RecipesCompareTwoViewModel.cs 118 KB

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