RecipesCompareTwoViewModel.cs 118 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049
  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
  977. {
  978. if (StepListB == null || StepListB.Count == 0)
  979. {
  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 = -1;
  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. if (bIndex + 1 < StepListB.Count)
  1045. {
  1046. for (int i = bIndex + 1; i < StepListB.Count; i++)
  1047. {
  1048. var bStep = new TwoStepDataItem();
  1049. bStep.AStepNumber = "";
  1050. bStep.AStepName = "";
  1051. bStep.BStepNumber = StepListB[i].StepNumber;
  1052. bStep.BStepName = StepListB[i].StepName;
  1053. bStep.IsDiff = StepListB[i].IsDiff;
  1054. StepList.Add(bStep);
  1055. }
  1056. }
  1057. }
  1058. }
  1059. SelectedTwoTableData = tempTable;
  1060. }
  1061. public void LoadData(string selectedRecipePath, bool isSelectA, bool isCurrent, bool isFullPath)
  1062. {
  1063. var array = selectedRecipePath.Split(new char[] { '\\' });
  1064. string recipeName = array[array.Length - 1];
  1065. XmlDocument doc = isSelectA ? _domA : _domB;
  1066. string prefixPath = (isSelectA ? RecipeA : RecipeB).Replace(recipeName, "");
  1067. var _recipeProvider = new RecipeProvider();
  1068. string recipeContent;
  1069. if (isSelectA)
  1070. {
  1071. recipeContent = isFullPath ? _recipeProvider.LoadRecipeByFullPath(selectedRecipePath) : _recipeProvider.LoadRecipe(prefixPath, recipeName, false);
  1072. }
  1073. else
  1074. {
  1075. if (isCurrent)
  1076. {
  1077. recipeContent = _recipeProvider.LoadRecipe(prefixPath, recipeName);
  1078. }
  1079. else
  1080. {
  1081. recipeContent = _recipeProvider.LoadRestoreRecipe(prefixPath, recipeName);
  1082. }
  1083. }
  1084. if (string.IsNullOrEmpty(recipeContent))
  1085. {
  1086. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  1087. return;
  1088. }
  1089. if (isSelectA)
  1090. {
  1091. BackInnerXmlTextA.Clear();
  1092. if (BackInnerXmlTextB.Count > 0)
  1093. {
  1094. string dataXml = BackInnerXmlTextB[0];
  1095. BackInnerXmlTextB.Clear();
  1096. BackInnerXmlTextB.Add(dataXml);
  1097. }
  1098. }
  1099. else
  1100. {
  1101. BackInnerXmlTextB.Clear();
  1102. if (BackInnerXmlTextA.Count > 0)
  1103. {
  1104. string dataXml = BackInnerXmlTextA[0];
  1105. BackInnerXmlTextA.Clear();
  1106. BackInnerXmlTextA.Add(dataXml);
  1107. }
  1108. }
  1109. if (isSelectA)
  1110. {
  1111. _pathPrefixA = prefixPath;
  1112. _mapLineTextA = new Dictionary<string, LineDataItem>();
  1113. BackInnerXmlTextA.Add(recipeContent);
  1114. }
  1115. else
  1116. {
  1117. _pathPrefixB = prefixPath;
  1118. _mapLineTextB = new Dictionary<string, LineDataItem>();
  1119. BackInnerXmlTextB.Add(recipeContent);
  1120. }
  1121. LoadrecipeContentData(recipeContent, isSelectA);
  1122. }
  1123. public void LoadData(string path, string content, bool isSelectA, bool isCurrent)
  1124. {
  1125. var array = path.Split(new char[] { '\\' });
  1126. string recipeName = array[array.Length - 1];
  1127. string prefixPath = (isSelectA ? RecipeA : RecipeB).Replace(recipeName, "");
  1128. string recipeContent = content;
  1129. if (string.IsNullOrEmpty(recipeContent))
  1130. {
  1131. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  1132. return;
  1133. }
  1134. if (isSelectA)
  1135. {
  1136. BackInnerXmlTextA.Clear();
  1137. if (BackInnerXmlTextB.Count > 0)
  1138. {
  1139. string dataXml = BackInnerXmlTextB[0];
  1140. BackInnerXmlTextB.Clear();
  1141. BackInnerXmlTextB.Add(dataXml);
  1142. }
  1143. }
  1144. else
  1145. {
  1146. BackInnerXmlTextB.Clear();
  1147. if (BackInnerXmlTextA.Count > 0)
  1148. {
  1149. string dataXml = BackInnerXmlTextA[0];
  1150. BackInnerXmlTextA.Clear();
  1151. BackInnerXmlTextA.Add(dataXml);
  1152. }
  1153. }
  1154. if (isSelectA)
  1155. {
  1156. _pathPrefixA = prefixPath;
  1157. _mapLineTextA = new Dictionary<string, LineDataItem>();
  1158. BackInnerXmlTextA.Add(recipeContent);
  1159. }
  1160. else
  1161. {
  1162. _pathPrefixB = prefixPath;
  1163. _mapLineTextB = new Dictionary<string, LineDataItem>();
  1164. BackInnerXmlTextB.Add(recipeContent);
  1165. }
  1166. LoadrecipeContentData(recipeContent, isSelectA);
  1167. }
  1168. public void LoadTableData(string selectedRecipePath, bool isSelectA, bool isCurrent, bool isFullPath)
  1169. {
  1170. var array = selectedRecipePath.Split(new char[] { '\\' });
  1171. string recipeName = array[array.Length - 1];
  1172. XmlDocument doc = isSelectA ? _domA : _domB;
  1173. string prefixPath = (isSelectA ? RecipeA : RecipeB).Replace(recipeName, "");
  1174. var _recipeProvider = new RecipeProvider();
  1175. string recipeContent;
  1176. if (isSelectA)
  1177. {
  1178. recipeContent = isFullPath ? _recipeProvider.LoadRecipeByFullPath(selectedRecipePath) : _recipeProvider.LoadRecipe(prefixPath, recipeName, false);
  1179. }
  1180. else
  1181. {
  1182. if (isCurrent)
  1183. {
  1184. recipeContent = _recipeProvider.LoadRecipe(prefixPath, recipeName);
  1185. }
  1186. else
  1187. {
  1188. recipeContent = _recipeProvider.LoadRestoreRecipe(prefixPath, recipeName);
  1189. }
  1190. }
  1191. if (string.IsNullOrEmpty(recipeContent))
  1192. {
  1193. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  1194. return;
  1195. }
  1196. if (isSelectA)
  1197. {
  1198. _pathPrefixA = prefixPath;
  1199. }
  1200. else
  1201. {
  1202. _pathPrefixB = prefixPath;
  1203. }
  1204. LoadTableRecipeContentData(recipeContent, isSelectA);
  1205. }
  1206. public void LoadTableData(string path, string content, bool isSelectA, bool isCurrent)
  1207. {
  1208. var array = path.Split(new char[] { '\\' });
  1209. string recipeName = array[array.Length - 1];
  1210. string prefixPath = (isSelectA ? RecipeA : RecipeB).Replace(recipeName, "");
  1211. string recipeContent = content;
  1212. if (string.IsNullOrEmpty(recipeContent))
  1213. {
  1214. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  1215. return;
  1216. }
  1217. if (isSelectA)
  1218. {
  1219. _pathPrefixA = prefixPath;
  1220. }
  1221. else
  1222. {
  1223. _pathPrefixB = prefixPath;
  1224. }
  1225. LoadTableRecipeContentData(recipeContent, isSelectA);
  1226. }
  1227. public void StepGridSelectionChangedA()
  1228. {
  1229. //if (StepSelectionA == null)
  1230. //{
  1231. // ParamListA.Clear();
  1232. // NotifyOfPropertyChange(nameof(ParamListA));
  1233. // return;
  1234. //}
  1235. //if (_mapStepParamA.ContainsKey(StepSelectionA.StepNumber))
  1236. //{
  1237. // ParamListA = _mapStepParamA[StepSelectionA.StepNumber];
  1238. // foreach (ParamDataItem item in ParamListA)
  1239. // {
  1240. // item.IsHidden = (!item.IsDiff && !item.IsExtra && IsShowDiffParams) ? true : false;
  1241. // }
  1242. // NotifyOfPropertyChange(nameof(ParamListA));
  1243. // NotifyOfPropertyChange(nameof(StepSelectionA));
  1244. // StepSelectionA.InvokePropertyChanged();
  1245. //}
  1246. }
  1247. private void LoadrecipeContentData(string recipeContent, bool isSelectA)
  1248. {
  1249. XmlDocument doc = isSelectA ? _domA : _domB;
  1250. if (isSelectA)
  1251. {
  1252. _mapLineTextA = new Dictionary<string, LineDataItem>();
  1253. //BackInnerXmlTextA.Add(recipeContent);
  1254. }
  1255. else
  1256. {
  1257. _mapLineTextB = new Dictionary<string, LineDataItem>();
  1258. //BackInnerXmlTextB.Add(recipeContent);
  1259. }
  1260. string[] allText = recipeContent.Split(new string[] { "\r\n" }, StringSplitOptions.None);
  1261. int number = 0;
  1262. ObservableCollection<LineDataItem> lineData = new ObservableCollection<LineDataItem>();
  1263. foreach (string lineText in allText)
  1264. {
  1265. LineDataItem line = new LineDataItem();
  1266. line.LineNumber = (++number).ToString();
  1267. line.LineText = lineText;
  1268. if (!string.IsNullOrEmpty(lineText))
  1269. {
  1270. lineData.Add(line);
  1271. if (isSelectA)
  1272. {
  1273. _mapLineTextA[line.LineNumber] = line;
  1274. }
  1275. else
  1276. {
  1277. _mapLineTextB[line.LineNumber] = line;
  1278. }
  1279. }
  1280. }
  1281. doc.LoadXml(recipeContent);
  1282. ObservableCollection<StepDataItem> stepData = new ObservableCollection<StepDataItem>();
  1283. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  1284. if (nodeSteps == null)
  1285. nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Step");
  1286. foreach (XmlNode nodeStep in nodeSteps)
  1287. {
  1288. ObservableCollection<ParamDataItem> paramData = new ObservableCollection<ParamDataItem>();
  1289. StepDataItem step = new StepDataItem();
  1290. foreach (XmlAttribute attr in nodeStep.Attributes)
  1291. {
  1292. if (attr.Name == "StepNo")
  1293. step.StepNumber = attr.Value;
  1294. else if (attr.Name == "Name")
  1295. step.StepName = attr.Value;
  1296. else
  1297. {
  1298. if (!attr.Name.Contains("IsSaved"))
  1299. {
  1300. ParamDataItem param = new ParamDataItem();
  1301. param.ParamName = attr.Name;
  1302. param.ParamValue = attr.Value;
  1303. paramData.Add(param);
  1304. }
  1305. }
  1306. }
  1307. stepData.Add(step);
  1308. if (isSelectA)
  1309. {
  1310. _mapStepParamA[step.StepNumber] = paramData;
  1311. }
  1312. else
  1313. {
  1314. _mapStepParamB[step.StepNumber] = paramData;
  1315. }
  1316. }
  1317. if (isSelectA)
  1318. {
  1319. StepListA = new ObservableCollection<StepDataItem>(stepData.OrderBy(x => int.Parse(x.StepNumber)));
  1320. NotifyOfPropertyChange(nameof(StepListA));
  1321. WholeListA = new ObservableCollection<LineDataItem>(lineData.OrderBy(x => int.Parse(x.LineNumber)));
  1322. NotifyOfPropertyChange(nameof(WholeListA));
  1323. }
  1324. else
  1325. {
  1326. StepListB = new ObservableCollection<StepDataItem>(stepData.OrderBy(x => int.Parse(x.StepNumber)));
  1327. NotifyOfPropertyChange(nameof(StepListB));
  1328. WholeListB = new ObservableCollection<LineDataItem>(lineData.OrderBy(x => int.Parse(x.LineNumber)));
  1329. NotifyOfPropertyChange(nameof(WholeListB));
  1330. }
  1331. }
  1332. private void LoadTableRecipeContentData(string recipeContent, bool isSelectA)
  1333. {
  1334. XmlDocument doc = isSelectA ? _domA : _domB;
  1335. string[] allText = recipeContent.Split(new string[] { "\r\n" }, StringSplitOptions.None);
  1336. int number = 0;
  1337. doc.LoadXml(recipeContent);
  1338. XmlNodeList nodeTables = doc.SelectNodes($"Aitex/TableRecipeData/Tables/Table");
  1339. if (isSelectA)
  1340. {
  1341. tableStepListA.Clear();
  1342. _mapTableStepParamA.Clear();
  1343. }
  1344. else
  1345. {
  1346. tableStepListB.Clear();
  1347. _mapTableStepParamB.Clear();
  1348. }
  1349. foreach (XmlNode nodeTable in nodeTables)
  1350. {
  1351. TableDataItem tableDataItem = new TableDataItem();
  1352. foreach (XmlAttribute attrTable in nodeTable.Attributes)
  1353. {
  1354. switch (attrTable.Name)
  1355. {
  1356. case "Index":
  1357. tableDataItem.TableIndex = attrTable.Value;
  1358. break;
  1359. case "Name":
  1360. tableDataItem.TableName = attrTable.Value;
  1361. break;
  1362. case "EndStatus":
  1363. tableDataItem.EndStatus = attrTable.Value;
  1364. break;
  1365. default:
  1366. break;
  1367. }
  1368. }
  1369. XmlNodeList nodeSteps = nodeTable.SelectNodes("Step");
  1370. ObservableCollection<StepDataItem> stepData = new ObservableCollection<StepDataItem>();
  1371. Dictionary<string, ObservableCollection<ParamDataItem>> _tempMapStepParamA = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  1372. Dictionary<string, ObservableCollection<ParamDataItem>> _tempMapStepParamB = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  1373. foreach (XmlNode nodeStep in nodeSteps)
  1374. {
  1375. ObservableCollection<ParamDataItem> paramData = new ObservableCollection<ParamDataItem>();
  1376. StepDataItem step = new StepDataItem();
  1377. foreach (XmlAttribute attr in nodeStep.Attributes)
  1378. {
  1379. if (attr.Name == "StepNo")
  1380. step.StepNumber = attr.Value;
  1381. else if (attr.Name == "Name")
  1382. step.StepName = attr.Value;
  1383. else
  1384. {
  1385. if (!attr.Name.Contains("IsSaved"))
  1386. {
  1387. ParamDataItem param = new ParamDataItem();
  1388. param.ParamName = attr.Name;
  1389. param.ParamValue = attr.Value;
  1390. paramData.Add(param);
  1391. }
  1392. }
  1393. }
  1394. stepData.Add(step);
  1395. if (isSelectA)
  1396. {
  1397. _mapStepParamA[step.StepNumber] = paramData;
  1398. _tempMapStepParamA[step.StepNumber] = paramData;
  1399. }
  1400. else
  1401. {
  1402. _mapStepParamB[step.StepNumber] = paramData;
  1403. _tempMapStepParamB[step.StepNumber] = paramData;
  1404. }
  1405. }
  1406. if (isSelectA)
  1407. {
  1408. var tableTemp = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == tableDataItem.TableIndex);
  1409. if (tableTemp != null)
  1410. {
  1411. _mapTableStepParamA[tableTemp] = _tempMapStepParamA;
  1412. }
  1413. else
  1414. {
  1415. _mapTableStepParamA.Add(tableDataItem, _tempMapStepParamA);
  1416. }
  1417. int tbIndex = 1;
  1418. int.TryParse(tableDataItem.TableIndex, out tbIndex);
  1419. if (tableStepListA.Keys.Contains(tbIndex))
  1420. {
  1421. tableStepListA[tbIndex] = stepData;
  1422. }
  1423. else
  1424. {
  1425. tableStepListA.Add(tbIndex, stepData);
  1426. }
  1427. }
  1428. else
  1429. {
  1430. var tableTemp = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == tableDataItem.TableIndex);
  1431. if (tableTemp != null)
  1432. {
  1433. _mapTableStepParamB[tableTemp] = _tempMapStepParamB;
  1434. }
  1435. else
  1436. {
  1437. _mapTableStepParamB.Add(tableDataItem, _tempMapStepParamB);
  1438. }
  1439. int tbIndex = 1;
  1440. int.TryParse(tableDataItem.TableIndex, out tbIndex);
  1441. if (tableStepListB.Keys.Contains(tbIndex))
  1442. {
  1443. tableStepListB[tbIndex] = stepData;
  1444. }
  1445. else
  1446. {
  1447. tableStepListB.Add(tbIndex, stepData);
  1448. }
  1449. }
  1450. }
  1451. }
  1452. public void ParamGridSelectionChangedB()
  1453. {
  1454. if (ParamSelectionB == null)
  1455. {
  1456. return;
  1457. }
  1458. NotifyOfPropertyChange(nameof(ParamSelectionB));
  1459. ParamSelectionB.InvokePropertyChanged();
  1460. }
  1461. public void WholeGridSelectionChangedA()
  1462. {
  1463. if (LineSelectionA == null)
  1464. {
  1465. return;
  1466. }
  1467. NotifyOfPropertyChange(nameof(LineSelectionA));
  1468. LineSelectionA.InvokePropertyChanged();
  1469. }
  1470. public void WholeGridSelectionChangedB()
  1471. {
  1472. if (LineSelectionB == null)
  1473. {
  1474. return;
  1475. }
  1476. NotifyOfPropertyChange(nameof(LineSelectionB));
  1477. LineSelectionB.InvokePropertyChanged();
  1478. }
  1479. public void SaveLineA()
  1480. {
  1481. if (LineSelectionA == null)
  1482. return;
  1483. foreach (LineDataItem lineDataItem in WholeListA)
  1484. {
  1485. if (lineDataItem.LineNumber == LineSelectionA.LineNumber)
  1486. {
  1487. lineDataItem.LineText = LineSelectionA.LineText;
  1488. break;
  1489. }
  1490. }
  1491. string recipeContent = "";
  1492. for (int i = 0; i < WholeListA.Count; i++)
  1493. {
  1494. recipeContent += WholeListA[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  1495. }
  1496. CopyToInnerXml(recipeContent, true);
  1497. LoadrecipeContentData(recipeContent, true);
  1498. Recompare();
  1499. SyncShowDiffSteps(IsShowDiffSteps);
  1500. }
  1501. public void SaveLineB()
  1502. {
  1503. if (LineSelectionB == null)
  1504. return;
  1505. foreach (LineDataItem lineDataItem in WholeListB)
  1506. {
  1507. if (lineDataItem.LineNumber == LineSelectionB.LineNumber)
  1508. {
  1509. lineDataItem.LineText = LineSelectionB.LineText;
  1510. break;
  1511. }
  1512. }
  1513. string recipeContent = "";
  1514. for (int i = 0; i < WholeListB.Count; i++)
  1515. {
  1516. recipeContent += WholeListB[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  1517. }
  1518. CopyToInnerXml(recipeContent, false);
  1519. LoadrecipeContentData(recipeContent, false);
  1520. Recompare();
  1521. SyncShowDiffSteps(IsShowDiffSteps);
  1522. }
  1523. private void Recompare()
  1524. {
  1525. if (IsCompareBySName)
  1526. {
  1527. RecompareStepByName();
  1528. }
  1529. RecompareWhole();
  1530. }
  1531. private void RecompareStepByStep()
  1532. {
  1533. if (StepListA == null || StepListB == null)
  1534. return;
  1535. var stepAMaxNumber = (StepListA == null || StepListA.Count() == 0) ? 0 : StepListA.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1536. var stepBMaxNumber = (StepListB == null || StepListB.Count() == 0) ? 0 : StepListB.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1537. int stepMaxNumber = stepAMaxNumber > stepBMaxNumber ? stepAMaxNumber : stepBMaxNumber;
  1538. for (int i = 0; i < stepMaxNumber + 1; i++)
  1539. {
  1540. 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());
  1541. 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());
  1542. if (getStepA != null && getStepB != null)
  1543. {
  1544. if (getStepA.StepName == getStepB.StepName)
  1545. getStepA.IsDiffName = getStepB.IsDiffName = false;
  1546. else
  1547. getStepA.IsDiffName = getStepB.IsDiffName = true;
  1548. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(i.ToString()) ? _mapStepParamA[i.ToString()] : null;
  1549. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(i.ToString()) ? _mapStepParamB[i.ToString()] : null;
  1550. bool isDiff = false;
  1551. bool IsExtra = true;
  1552. if (paramA != null && paramB == null)
  1553. {
  1554. foreach (var pa in paramA)
  1555. {
  1556. pa.IsExtra = true;
  1557. pa.IsDiff = false;
  1558. }
  1559. }
  1560. else if (paramA == null && paramB != null)
  1561. {
  1562. foreach (var pb in paramB)
  1563. {
  1564. pb.IsExtra = true;
  1565. pb.IsDiff = false;
  1566. }
  1567. }
  1568. else if (paramA != null && paramB != null)
  1569. {
  1570. foreach (var pa in paramA)
  1571. {
  1572. var getParam = paramB.Where(pb => pb.ParamName == pa.ParamName).FirstOrDefault();
  1573. if (getParam != null)
  1574. {
  1575. pa.IsExtra = false;
  1576. getParam.IsExtra = false;
  1577. getParam.IsDiff = pa.IsDiff = (pa.ParamValue != getParam.ParamValue);
  1578. if (pa.ParamValue != getParam.ParamValue)
  1579. {
  1580. isDiff = true;
  1581. }
  1582. }
  1583. }
  1584. getStepA.IsExtra = getStepB.IsExtra = false;
  1585. }
  1586. if (paramA != null)
  1587. {
  1588. foreach (var pa in paramA)
  1589. {
  1590. pa.InvokePropertyChanged();
  1591. }
  1592. }
  1593. if (paramB != null)
  1594. {
  1595. foreach (var pb in paramB)
  1596. {
  1597. pb.InvokePropertyChanged();
  1598. }
  1599. }
  1600. getStepA.IsDiff = getStepB.IsDiff = isDiff;
  1601. getStepA.IsHidden = getStepB.IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1602. getStepA.InvokePropertyChanged();
  1603. getStepB.InvokePropertyChanged();
  1604. }
  1605. else if (getStepA == null && getStepB != null)
  1606. {
  1607. getStepB.IsExtra = true;
  1608. getStepB.IsDiff = false;
  1609. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(getStepB.StepNumber) ? _mapStepParamB[getStepB.StepNumber] : null;
  1610. foreach (var pb in paramB)
  1611. {
  1612. pb.IsExtra = false;
  1613. pb.IsDiff = false;
  1614. pb.InvokePropertyChanged();
  1615. }
  1616. getStepB.InvokePropertyChanged();
  1617. continue;
  1618. }
  1619. else if (getStepA != null && getStepB == null)
  1620. {
  1621. getStepA.IsExtra = true;
  1622. getStepA.IsDiff = false;
  1623. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(getStepA.StepNumber) ? _mapStepParamA[getStepA.StepNumber] : null;
  1624. foreach (var pa in paramA)
  1625. {
  1626. pa.IsExtra = false;
  1627. pa.IsDiff = false;
  1628. pa.InvokePropertyChanged();
  1629. }
  1630. getStepA.InvokePropertyChanged();
  1631. continue;
  1632. }
  1633. else
  1634. {
  1635. continue;
  1636. }
  1637. }
  1638. NotifyOfPropertyChange(nameof(StepListA));
  1639. NotifyOfPropertyChange(nameof(StepListB));
  1640. }
  1641. private void RecompareStepByName()
  1642. {
  1643. if (StepListA == null || StepListB == null)
  1644. return;
  1645. var stepAMaxNumber = (StepListA == null || StepListA.Count() == 0) ? 0 : StepListA.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1646. var stepBMaxNumber = (StepListB == null || StepListB.Count() == 0) ? 0 : StepListB.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1647. int stepMaxNumber = stepAMaxNumber > stepBMaxNumber ? stepAMaxNumber : stepBMaxNumber;
  1648. foreach (var getStepA in StepListA)
  1649. {
  1650. StepDataItem getStepB = (StepListB.Where(x => x.StepName == getStepA.StepName) == null ? null : StepListB.Where(x => x.StepName == getStepA.StepName).FirstOrDefault());
  1651. if (getStepB == null)
  1652. {
  1653. getStepA.IsDiff = false;
  1654. getStepA.IsExtra = true;
  1655. continue;
  1656. }
  1657. getStepA.IsDiffName = getStepB.IsDiffName = true;
  1658. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(getStepA.StepNumber) ? _mapStepParamA[getStepA.StepNumber] : null;
  1659. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(getStepB.StepNumber) ? _mapStepParamB[getStepB.StepNumber] : null;
  1660. bool isDiff = false;
  1661. bool IsExtra = true;
  1662. if (paramA != null && paramB == null)
  1663. {
  1664. foreach (var pa in paramA)
  1665. {
  1666. pa.IsExtra = true;
  1667. pa.IsDiff = false;
  1668. }
  1669. }
  1670. else if (paramA == null && paramB != null)
  1671. {
  1672. foreach (var pb in paramB)
  1673. {
  1674. pb.IsExtra = true;
  1675. pb.IsDiff = false;
  1676. }
  1677. }
  1678. else if (paramA != null && paramB != null)
  1679. {
  1680. foreach (var pa in paramA)
  1681. {
  1682. var getParam = paramB.Where(pb => pb.ParamName == pa.ParamName).FirstOrDefault();
  1683. if (getParam != null)
  1684. {
  1685. pa.IsExtra = false;
  1686. getParam.IsExtra = false;
  1687. getParam.IsDiff = pa.IsDiff = (pa.ParamValue != getParam.ParamValue);
  1688. if (pa.ParamValue != getParam.ParamValue)
  1689. {
  1690. isDiff = true;
  1691. }
  1692. }
  1693. }
  1694. getStepA.IsExtra = getStepB.IsExtra = false;
  1695. }
  1696. if (paramA != null)
  1697. {
  1698. foreach (var pa in paramA)
  1699. {
  1700. pa.InvokePropertyChanged();
  1701. }
  1702. }
  1703. if (paramB != null)
  1704. {
  1705. foreach (var pb in paramB)
  1706. {
  1707. pb.InvokePropertyChanged();
  1708. }
  1709. }
  1710. getStepA.IsDiff = getStepB.IsDiff = isDiff;
  1711. getStepA.IsHidden = getStepB.IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1712. getStepA.InvokePropertyChanged();
  1713. getStepB.InvokePropertyChanged();
  1714. }
  1715. foreach (var getStepB in StepListB)
  1716. {
  1717. StepDataItem getStepA = (StepListA.Where(x => x.StepName == getStepB.StepName) == null ? null : StepListA.Where(x => x.StepName == getStepB.StepName).FirstOrDefault());
  1718. if (getStepA == null)
  1719. {
  1720. getStepB.IsDiff = false;
  1721. getStepB.IsExtra = true;
  1722. continue;
  1723. }
  1724. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(getStepA.StepNumber) ? _mapStepParamA[getStepA.StepNumber] : null;
  1725. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(getStepB.StepNumber) ? _mapStepParamB[getStepB.StepNumber] : null;
  1726. bool isDiff = false;
  1727. foreach (var pb in paramB)
  1728. {
  1729. var getParam = paramA.Where(p => p.ParamName == pb.ParamName).FirstOrDefault();
  1730. if (getParam != null)
  1731. {
  1732. pb.IsExtra = false;
  1733. getParam.IsExtra = false;
  1734. getParam.IsDiff = pb.IsDiff = (pb.ParamValue != getParam.ParamValue);
  1735. if (pb.ParamValue != getParam.ParamValue)
  1736. {
  1737. isDiff = true;
  1738. }
  1739. getParam.IsDiff = pb.IsDiff = (pb.ParamValue != getParam.ParamValue);
  1740. }
  1741. pb.InvokePropertyChanged();
  1742. }
  1743. getStepB.IsExtra = false;
  1744. getStepB.IsDiff = isDiff;
  1745. getStepB.InvokePropertyChanged();
  1746. }
  1747. NotifyOfPropertyChange(nameof(StepListA));
  1748. NotifyOfPropertyChange(nameof(StepListB));
  1749. }
  1750. private void RecompareTableByName()
  1751. {
  1752. for (int i = 1; i < 21; i++)
  1753. {
  1754. ObservableCollection<StepDataItem> _stepListA = null;
  1755. ObservableCollection<StepDataItem> _stepListB = null;
  1756. if (tableStepListA.Keys.Contains(i))
  1757. {
  1758. _stepListA = tableStepListA[i];
  1759. }
  1760. if (tableStepListB.Keys.Contains(i))
  1761. {
  1762. _stepListB = tableStepListB[i];
  1763. }
  1764. if (_stepListA == null || _stepListB == null)
  1765. return;
  1766. var stepAMaxNumber = (_stepListA == null || _stepListA.Count() == 0) ? 0 : _stepListA.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1767. var stepBMaxNumber = (_stepListB == null || _stepListB.Count() == 0) ? 0 : _stepListB.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1768. int stepMaxNumber = stepAMaxNumber > stepBMaxNumber ? stepAMaxNumber : stepBMaxNumber;
  1769. foreach (var getStepA in _stepListA)
  1770. {
  1771. StepDataItem getStepB = (_stepListB.Where(x => x.StepName == getStepA.StepName) == null ? null : _stepListB.Where(x => x.StepName == getStepA.StepName).FirstOrDefault());
  1772. if (getStepB == null)
  1773. {
  1774. getStepA.IsDiff = false;
  1775. getStepA.IsExtra = true;
  1776. continue;
  1777. }
  1778. getStepA.IsDiffName = getStepB.IsDiffName = true;
  1779. var tempA = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1780. ObservableCollection<ParamDataItem> paramA = tempA != null && _mapTableStepParamA[tempA].ContainsKey(getStepA.StepNumber) ? _mapTableStepParamA[tempA][getStepA.StepNumber] : null;
  1781. var tempB = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1782. ObservableCollection<ParamDataItem> paramB = tempB != null && _mapTableStepParamB[tempB].ContainsKey(getStepB.StepNumber) ? _mapTableStepParamB[tempB][getStepB.StepNumber] : null;
  1783. bool isDiff = false;
  1784. bool IsExtra = true;
  1785. if (paramA != null && paramB == null)
  1786. {
  1787. foreach (var pa in paramA)
  1788. {
  1789. pa.IsExtra = true;
  1790. pa.IsDiff = false;
  1791. }
  1792. }
  1793. else if (paramA == null && paramB != null)
  1794. {
  1795. foreach (var pb in paramB)
  1796. {
  1797. pb.IsExtra = true;
  1798. pb.IsDiff = false;
  1799. }
  1800. }
  1801. else if (paramA != null && paramB != null)
  1802. {
  1803. foreach (var pa in paramA)
  1804. {
  1805. var getParam = paramB.Where(pb => pb.ParamName == pa.ParamName).FirstOrDefault();
  1806. if (getParam != null)
  1807. {
  1808. pa.IsExtra = false;
  1809. getParam.IsExtra = false;
  1810. getParam.IsDiff = pa.IsDiff = (pa.ParamValue != getParam.ParamValue);
  1811. if (pa.ParamValue != getParam.ParamValue)
  1812. {
  1813. isDiff = true;
  1814. }
  1815. }
  1816. }
  1817. getStepA.IsExtra = getStepB.IsExtra = false;
  1818. }
  1819. if (paramA != null)
  1820. {
  1821. foreach (var pa in paramA)
  1822. {
  1823. pa.InvokePropertyChanged();
  1824. }
  1825. }
  1826. if (paramB != null)
  1827. {
  1828. foreach (var pb in paramB)
  1829. {
  1830. pb.InvokePropertyChanged();
  1831. }
  1832. }
  1833. getStepA.IsDiff = getStepB.IsDiff = isDiff;
  1834. getStepA.IsHidden = getStepB.IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1835. //getStepA.InvokePropertyChanged();
  1836. //getStepB.InvokePropertyChanged();
  1837. }
  1838. foreach (var getStepB in _stepListB)
  1839. {
  1840. StepDataItem getStepA = (_stepListA.Where(x => x.StepName == getStepB.StepName) == null ? null : _stepListA.Where(x => x.StepName == getStepB.StepName).FirstOrDefault());
  1841. if (getStepA == null)
  1842. {
  1843. getStepB.IsDiff = false;
  1844. getStepB.IsExtra = true;
  1845. continue;
  1846. }
  1847. var tempA = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1848. ObservableCollection<ParamDataItem> paramA = tempA != null && _mapTableStepParamA[tempA].ContainsKey(getStepA.StepNumber) ? _mapTableStepParamA[tempA][getStepA.StepNumber] : null;
  1849. var tempB = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1850. ObservableCollection<ParamDataItem> paramB = tempB != null && _mapTableStepParamB[tempB].ContainsKey(getStepB.StepNumber) ? _mapTableStepParamB[tempB][getStepB.StepNumber] : null;
  1851. bool isDiff = false;
  1852. foreach (var pb in paramB)
  1853. {
  1854. var getParam = paramA.Where(p => p.ParamName == pb.ParamName).FirstOrDefault();
  1855. if (getParam != null)
  1856. {
  1857. pb.IsExtra = false;
  1858. getParam.IsExtra = false;
  1859. getParam.IsDiff = pb.IsDiff = (pb.ParamValue != getParam.ParamValue);
  1860. if (pb.ParamValue != getParam.ParamValue)
  1861. {
  1862. isDiff = true;
  1863. }
  1864. getParam.IsDiff = pb.IsDiff = (pb.ParamValue != getParam.ParamValue);
  1865. }
  1866. pb.InvokePropertyChanged();
  1867. }
  1868. getStepB.IsExtra = false;
  1869. getStepB.IsDiff = isDiff;
  1870. getStepB.InvokePropertyChanged();
  1871. }
  1872. var tempParA = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1873. var tempParB = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == i.ToString());
  1874. if (tempParA != null) tempParA.IsDiff = _stepListA?.Where(x => x.IsDiff).Count() == 0 ? false : true;
  1875. if (tempParB != null) tempParB.IsDiff = _stepListB?.Where(x => x.IsDiff).Count() == 0 ? false : true;
  1876. }
  1877. NotifyOfPropertyChange(nameof(StepListA));
  1878. NotifyOfPropertyChange(nameof(StepListB));
  1879. }
  1880. //private void RecompareStep()
  1881. //{
  1882. // if (StepListA == null || StepListB == null)
  1883. // return;
  1884. // int i = 0;
  1885. // for (i = 0; i < StepListA.Count && i < StepListB.Count; i++)
  1886. // {
  1887. // if (StepListA[i].StepName == StepListB[i].StepName)
  1888. // StepListA[i].IsDiffName = StepListB[i].IsDiffName = false;
  1889. // else
  1890. // StepListA[i].IsDiffName = StepListB[i].IsDiffName = true;
  1891. // ObservableCollection<ParamDataItem> paramA = _mapStepParamA[StepListA[i].StepNumber];
  1892. // ObservableCollection<ParamDataItem> paramB = _mapStepParamB[StepListB[i].StepNumber];
  1893. // bool isDiff = false;
  1894. // bool IsExtra = true;
  1895. // foreach (var pa in paramA)
  1896. // {
  1897. // pa.IsExtra = true;
  1898. // }
  1899. // foreach (var pb in paramB)
  1900. // {
  1901. // pb.IsExtra = true;
  1902. // }
  1903. // foreach (var pa in paramA)
  1904. // {
  1905. // foreach (var pb in paramB)
  1906. // {
  1907. // if (pb.ParamName == pa.ParamName)
  1908. // {
  1909. // pb.IsExtra = false;
  1910. // pa.IsExtra = false;
  1911. // pb.IsDiff = pa.IsDiff = (pa.ParamValue != pb.ParamValue);
  1912. // if (pa.IsDiff)
  1913. // isDiff = true;
  1914. // break;
  1915. // }
  1916. // }
  1917. // }
  1918. // foreach (var pa in paramA)
  1919. // {
  1920. // pa.InvokePropertyChanged();
  1921. // }
  1922. // foreach (var pb in paramB)
  1923. // {
  1924. // pb.InvokePropertyChanged();
  1925. // }
  1926. // StepListA[i].IsDiff = StepListB[i].IsDiff = isDiff;
  1927. // StepListA[i].IsExtra = StepListB[i].IsExtra = false;
  1928. // StepListA[i].IsHidden = StepListB[i].IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1929. // StepListA[i].InvokePropertyChanged();
  1930. // StepListB[i].InvokePropertyChanged();
  1931. // }
  1932. // for (int j = i; j < StepListA.Count; j++)
  1933. // {
  1934. // StepListA[j].IsDiff = false;
  1935. // StepListA[j].IsExtra = true;
  1936. // StepListA[j].InvokePropertyChanged();
  1937. // foreach (var pa in _mapStepParamA[StepListA[j].StepNumber])
  1938. // {
  1939. // pa.InvokePropertyChanged();
  1940. // }
  1941. // }
  1942. // for (int k = i; k < StepListB.Count; k++)
  1943. // {
  1944. // StepListB[k].IsDiff = false;
  1945. // StepListB[k].IsExtra = true;
  1946. // WholeListB[k].InvokePropertyChanged();
  1947. // _mapLineTextB[WholeListB[k].LineNumber].InvokePropertyChanged();
  1948. // foreach (var pb in _mapStepParamB[StepListB[k].StepNumber])
  1949. // {
  1950. // pb.InvokePropertyChanged();
  1951. // }
  1952. // }
  1953. // NotifyOfPropertyChange(nameof(StepListA));
  1954. // NotifyOfPropertyChange(nameof(StepListB));
  1955. //}
  1956. private void RecompareWhole()
  1957. {
  1958. if (WholeListA == null || WholeListB == null)
  1959. return;
  1960. int i = 0;
  1961. for (i = 0; i < WholeListA.Count && i < WholeListB.Count; i++)
  1962. {
  1963. LineDataItem lineA = _mapLineTextA[WholeListA[i].LineNumber];
  1964. LineDataItem lineB = _mapLineTextB[WholeListB[i].LineNumber];
  1965. bool isDiff = false;
  1966. lineB.IsDiff = lineA.IsDiff = (lineA.LineText != lineB.LineText);
  1967. if (lineA.IsDiff)
  1968. isDiff = true;
  1969. WholeListA[i].IsDiff = WholeListB[i].IsDiff = isDiff;
  1970. WholeListA[i].IsExtra = WholeListB[i].IsExtra = false;
  1971. _mapLineTextA[WholeListA[i].LineNumber].IsDiff = _mapLineTextB[WholeListB[i].LineNumber].IsDiff = isDiff;
  1972. _mapLineTextA[WholeListA[i].LineNumber].IsExtra = _mapLineTextB[WholeListB[i].LineNumber].IsExtra = false;
  1973. lineA.InvokePropertyChanged();
  1974. lineB.InvokePropertyChanged();
  1975. WholeListA[i].InvokePropertyChanged();
  1976. WholeListB[i].InvokePropertyChanged();
  1977. }
  1978. for (int j = i; j < WholeListA.Count; j++)
  1979. {
  1980. WholeListA[j].IsDiff = false;
  1981. WholeListA[j].IsExtra = true;
  1982. _mapLineTextA[WholeListA[j].LineNumber].IsDiff = false;
  1983. _mapLineTextA[WholeListA[j].LineNumber].IsExtra = true;
  1984. if (!(_mapLineTextA[WholeListA[j].LineNumber].LineText.Contains("<Step StepNo") || _mapLineTextA[WholeListA[j].LineNumber].LineText.Contains("<Moudule Name")))
  1985. {
  1986. WholeListA[j].IsDiff = false;
  1987. WholeListA[j].IsExtra = false;
  1988. }
  1989. WholeListA[j].InvokePropertyChanged();
  1990. _mapLineTextA[WholeListA[j].LineNumber].InvokePropertyChanged();
  1991. }
  1992. for (int k = i; k < WholeListB.Count; k++)
  1993. {
  1994. WholeListB[k].IsDiff = false;
  1995. WholeListB[k].IsExtra = true;
  1996. _mapLineTextB[WholeListB[k].LineNumber].IsDiff = false;
  1997. _mapLineTextB[WholeListB[k].LineNumber].IsExtra = true;
  1998. if (!(_mapLineTextB[WholeListB[k].LineNumber].LineText.Contains("<Step StepNo") || _mapLineTextB[WholeListB[k].LineNumber].LineText.Contains("<Moudule Name")))
  1999. {
  2000. WholeListB[k].IsDiff = false;
  2001. WholeListB[k].IsExtra = false;
  2002. }
  2003. WholeListB[k].InvokePropertyChanged();
  2004. _mapLineTextB[WholeListB[k].LineNumber].InvokePropertyChanged();
  2005. }
  2006. NotifyOfPropertyChange(nameof(WholeListA));
  2007. NotifyOfPropertyChange(nameof(WholeListB));
  2008. }
  2009. private void SyncStepSelection(TwoStepDataItem stepData)
  2010. {
  2011. if (stepData == null)
  2012. return;
  2013. var getStepA = StepListA.Where(x => x.StepName == stepData.AStepName).FirstOrDefault();
  2014. var getStepB = StepListB.Where(x => x.StepName == stepData.BStepName).FirstOrDefault();
  2015. if (getStepA == null && getStepB == null)
  2016. {
  2017. ParamList.Clear();
  2018. return;
  2019. }
  2020. else if (getStepA != null && getStepB == null)
  2021. {
  2022. ParamListA = _mapStepParamA[getStepA.StepNumber];
  2023. foreach (var item in ParamListA)
  2024. {
  2025. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  2026. if (par != null)
  2027. {
  2028. par.AParamValue = item.ParamValue;
  2029. par.IsDiff = false;
  2030. par.IsExtra = item.IsExtra;
  2031. par.BParamValue = "--";
  2032. }
  2033. else
  2034. {
  2035. TwoParamDataItem param = new TwoParamDataItem();
  2036. param.ParamName = item.ParamName;
  2037. param.AParamValue = item.ParamValue;
  2038. param.IsDiff = item.IsDiff;
  2039. param.IsExtra = item.IsExtra;
  2040. param.BParamValue = "--";
  2041. ParamList.Add(param);
  2042. }
  2043. }
  2044. }
  2045. else if (getStepA == null && getStepB != null)
  2046. {
  2047. ParamListB = _mapStepParamB[getStepB.StepNumber];
  2048. foreach (var item in ParamListB)
  2049. {
  2050. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  2051. if (par != null)
  2052. {
  2053. par.BParamValue = item.ParamValue;
  2054. par.IsDiff = false;
  2055. par.IsExtra = item.IsExtra;
  2056. par.AParamValue = "--";
  2057. }
  2058. else
  2059. {
  2060. var param = new TwoParamDataItem();
  2061. param.ParamName = item.ParamName;
  2062. param.BParamValue = item.ParamValue;
  2063. param.IsDiff = item.IsDiff;
  2064. param.IsExtra = item.IsExtra;
  2065. param.AParamValue = "--";
  2066. ParamList.Add(param);
  2067. }
  2068. }
  2069. }
  2070. else
  2071. {
  2072. ParamListA = _mapStepParamA[getStepA.StepNumber];
  2073. ParamListB = _mapStepParamB[getStepB.StepNumber];
  2074. foreach (var item in ParamListA)
  2075. {
  2076. var bValue = ParamListB.FirstOrDefault(x => x.ParamName == item.ParamName)?.ParamValue;
  2077. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  2078. if (par != null)
  2079. {
  2080. par.AParamValue = item.ParamValue;
  2081. par.IsDiff = item.IsDiff;
  2082. par.IsExtra = item.IsExtra;
  2083. if (bValue != null)
  2084. {
  2085. par.BParamValue = bValue;
  2086. }
  2087. else
  2088. {
  2089. par.BParamValue = "--";
  2090. }
  2091. }
  2092. else
  2093. {
  2094. var param = new TwoParamDataItem();
  2095. param.ParamName = item.ParamName;
  2096. param.AParamValue = item.ParamValue;
  2097. param.IsDiff = item.IsDiff;
  2098. param.IsExtra = item.IsExtra;
  2099. if (bValue != null)
  2100. {
  2101. param.BParamValue = bValue;
  2102. }
  2103. else
  2104. {
  2105. param.BParamValue = "--";
  2106. }
  2107. ParamList.Add(param);
  2108. }
  2109. }
  2110. }
  2111. //NotifyOfPropertyChange(nameof(StepSelection));
  2112. //StepSelection.InvokePropertyChanged();
  2113. }
  2114. private void SyncTableStepSelection(TwoStepDataItem stepData)
  2115. {
  2116. if (stepData == null)
  2117. return;
  2118. var getStepA = tableStepListA[SelectTableIndex].Where(x => x.StepName == stepData.AStepName).FirstOrDefault();
  2119. var getStepB = tableStepListB[SelectTableIndex].Where(x => x.StepName == stepData.BStepName).FirstOrDefault();
  2120. if (getStepA == null && getStepB == null)
  2121. {
  2122. ParamList.Clear();
  2123. return;
  2124. }
  2125. else if (getStepA != null && getStepB == null)
  2126. {
  2127. var tempPar = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == SelectTableIndex.ToString());
  2128. ParamListA.Clear();
  2129. if (tempPar != null)
  2130. {
  2131. _mapTableStepParamA[tempPar][getStepA.StepNumber].ToList().ForEach(x => ParamListA.Add(x));
  2132. }
  2133. foreach (var item in ParamListA)
  2134. {
  2135. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  2136. if (par != null)
  2137. {
  2138. par.AParamValue = item.ParamValue;
  2139. par.IsDiff = false;
  2140. par.IsExtra = item.IsExtra;
  2141. par.BParamValue = "--";
  2142. }
  2143. else
  2144. {
  2145. TwoParamDataItem param = new TwoParamDataItem();
  2146. param.ParamName = item.ParamName;
  2147. param.AParamValue = item.ParamValue;
  2148. param.IsDiff = item.IsDiff;
  2149. param.IsExtra = item.IsExtra;
  2150. param.BParamValue = "--";
  2151. ParamList.Add(param);
  2152. }
  2153. }
  2154. }
  2155. else if (getStepA == null && getStepB != null)
  2156. {
  2157. var tempPar = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == SelectTableIndex.ToString());
  2158. ParamListB.Clear();
  2159. if (tempPar != null)
  2160. {
  2161. _mapTableStepParamB[tempPar][getStepB.StepNumber].ToList().ForEach(x => ParamListB.Add(x));
  2162. }
  2163. foreach (var item in ParamListB)
  2164. {
  2165. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  2166. if (par != null)
  2167. {
  2168. par.BParamValue = item.ParamValue;
  2169. par.IsDiff = false;
  2170. par.IsExtra = item.IsExtra;
  2171. par.AParamValue = "--";
  2172. }
  2173. else
  2174. {
  2175. var param = new TwoParamDataItem();
  2176. param.ParamName = item.ParamName;
  2177. param.BParamValue = item.ParamValue;
  2178. param.IsDiff = item.IsDiff;
  2179. param.IsExtra = item.IsExtra;
  2180. param.AParamValue = "--";
  2181. ParamList.Add(param);
  2182. }
  2183. }
  2184. }
  2185. else
  2186. {
  2187. var tempPar = _mapTableStepParamA.Keys.FirstOrDefault(x => x.TableIndex == SelectTableIndex.ToString());
  2188. ParamListA.Clear();
  2189. if (tempPar != null)
  2190. {
  2191. _mapTableStepParamA[tempPar][getStepA.StepNumber].ToList().ForEach(x => ParamListA.Add(x));
  2192. }
  2193. var tempParB = _mapTableStepParamB.Keys.FirstOrDefault(x => x.TableIndex == SelectTableIndex.ToString());
  2194. ParamListB.Clear();
  2195. if (tempParB != null)
  2196. {
  2197. _mapTableStepParamB[tempParB][getStepB.StepNumber].ToList().ForEach(x => ParamListB.Add(x));
  2198. }
  2199. foreach (var item in ParamListA)
  2200. {
  2201. var bValue = ParamListB.FirstOrDefault(x => x.ParamName == item.ParamName)?.ParamValue;
  2202. var par = ParamList.FirstOrDefault(x => x.ParamName == item.ParamName);
  2203. if (par != null)
  2204. {
  2205. par.AParamValue = item.ParamValue;
  2206. par.IsExtra = item.IsExtra;
  2207. if (bValue != null)
  2208. {
  2209. par.IsDiff = item.ParamValue != bValue;
  2210. par.BParamValue = bValue;
  2211. }
  2212. else
  2213. {
  2214. par.BParamValue = "--";
  2215. }
  2216. }
  2217. else
  2218. {
  2219. var param = new TwoParamDataItem();
  2220. param.ParamName = item.ParamName;
  2221. param.AParamValue = item.ParamValue;
  2222. param.IsDiff = item.IsDiff;
  2223. param.IsExtra = item.IsExtra;
  2224. if (bValue != null)
  2225. {
  2226. param.BParamValue = bValue;
  2227. }
  2228. else
  2229. {
  2230. param.BParamValue = "--";
  2231. }
  2232. ParamList.Add(param);
  2233. }
  2234. }
  2235. }
  2236. //NotifyOfPropertyChange(nameof(StepSelection));
  2237. //StepSelection.InvokePropertyChanged();
  2238. }
  2239. private void SyncParamSelection(ParamDataItem paramData, bool isSelectA)
  2240. {
  2241. try
  2242. {
  2243. if (paramData == null)
  2244. return;
  2245. if (isSelectA)
  2246. {
  2247. if (IsCompareBySName)
  2248. {
  2249. //var getSameStepName = StepListA.Where(x => x.StepName == StepSelectionB.StepName).FirstOrDefault();
  2250. //if (getSameStepName == null) return;
  2251. //if (_mapStepParamA.ContainsKey(getSameStepName.StepNumber))
  2252. //{
  2253. // ParamListA = _mapStepParamA[getSameStepName.StepNumber];
  2254. // NotifyOfPropertyChange(nameof(ParamListA));
  2255. //}
  2256. //else
  2257. // return;
  2258. //foreach (var item in ParamListA)
  2259. //{
  2260. // if (item.ParamName == paramData.ParamName)
  2261. // {
  2262. // _paramSelectionA = item;
  2263. // NotifyOfPropertyChange(nameof(ParamSelectionA));
  2264. // ParamSelectionA.InvokePropertyChanged();
  2265. // }
  2266. //}
  2267. }
  2268. }
  2269. else
  2270. {
  2271. //if (IsCompareByStep)
  2272. //{
  2273. // if (ParamListB == null)
  2274. // {
  2275. // if (_mapStepParamB.ContainsKey(StepSelectionA.StepNumber))
  2276. // {
  2277. // ParamListB = _mapStepParamB[StepSelectionA.StepNumber];
  2278. // NotifyOfPropertyChange(nameof(ParamListB));
  2279. // }
  2280. // else
  2281. // return;
  2282. // }
  2283. // foreach (var item in ParamListB)
  2284. // {
  2285. // if (item.ParamName == paramData.ParamName)
  2286. // {
  2287. // _paramSelectionB = item;
  2288. // NotifyOfPropertyChange(nameof(ParamSelectionB));
  2289. // ParamSelectionB.InvokePropertyChanged();
  2290. // }
  2291. // }
  2292. //}
  2293. //if (IsCompareBySName)
  2294. //{
  2295. // if (ParamListB == null)
  2296. // {
  2297. // var getSameStepName = StepListB.Where(x => x.StepName == StepSelectionA.StepName).FirstOrDefault();
  2298. // if (_mapStepParamB.ContainsKey(getSameStepName.StepNumber))
  2299. // {
  2300. // ParamListB = _mapStepParamB[getSameStepName.StepNumber];
  2301. // NotifyOfPropertyChange(nameof(ParamListB));
  2302. // }
  2303. // else
  2304. // return;
  2305. // }
  2306. // foreach (var item in ParamListB)
  2307. // {
  2308. // if (item.ParamName == paramData.ParamName)
  2309. // {
  2310. // _paramSelectionB = item;
  2311. // NotifyOfPropertyChange(nameof(ParamSelectionB));
  2312. // ParamSelectionB.InvokePropertyChanged();
  2313. // }
  2314. // }
  2315. //}
  2316. }
  2317. }
  2318. catch (Exception ex)
  2319. {
  2320. LOG.Write(ex.Message);
  2321. }
  2322. }
  2323. private void SyncLineSelection(LineDataItem lineData, bool isSelectA)
  2324. {
  2325. if (lineData == null)
  2326. return;
  2327. if (isSelectA)
  2328. {
  2329. foreach (var item in WholeListA)
  2330. {
  2331. if (item.LineNumber == lineData.LineNumber)
  2332. {
  2333. _lineSelectionA = item;
  2334. NotifyOfPropertyChange(nameof(LineSelectionA));
  2335. LineSelectionA.InvokePropertyChanged();
  2336. }
  2337. }
  2338. }
  2339. else
  2340. {
  2341. foreach (var item in WholeListB)
  2342. {
  2343. if (item.LineNumber == lineData.LineNumber)
  2344. {
  2345. _lineSelectionB = item;
  2346. NotifyOfPropertyChange(nameof(LineSelectionB));
  2347. LineSelectionB.InvokePropertyChanged();
  2348. }
  2349. }
  2350. }
  2351. }
  2352. public void RemoveA()
  2353. {
  2354. RemoveRecipe(true);
  2355. }
  2356. public void RemoveB()
  2357. {
  2358. RemoveRecipe(false);
  2359. }
  2360. private void RemoveSelectB()
  2361. {
  2362. StepListB?.Clear();
  2363. ParamListB?.Clear();
  2364. WholeListB?.Clear();
  2365. RecipeB = string.Empty;
  2366. _mapStepParamB?.Clear();
  2367. _paramSelectionB = null;
  2368. NotifyOfPropertyChange(nameof(StepListB));
  2369. NotifyOfPropertyChange(nameof(ParamListB));
  2370. NotifyOfPropertyChange(nameof(RecipeB));
  2371. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  2372. NotifyOfPropertyChange(nameof(ParamSelectionB));
  2373. }
  2374. private void RemoveRecipe(bool isSelectA)
  2375. {
  2376. if (!DialogBox.Confirm($"Are you sure you want to remove the recipe? \r\n{RecipeB}"))
  2377. return;
  2378. if (isSelectA)
  2379. {
  2380. StepListA?.Clear();
  2381. ParamListA?.Clear();
  2382. WholeListA?.Clear();
  2383. RecipeA = string.Empty;
  2384. _mapStepParamA?.Clear();
  2385. NotifyOfPropertyChange(nameof(StepListA));
  2386. NotifyOfPropertyChange(nameof(ParamListA));
  2387. NotifyOfPropertyChange(nameof(RecipeA));
  2388. NotifyOfPropertyChange(nameof(EnableButtonRemoveA));
  2389. }
  2390. else
  2391. {
  2392. StepListB?.Clear();
  2393. ParamListB?.Clear();
  2394. WholeListB?.Clear();
  2395. RecipeB = string.Empty;
  2396. _mapStepParamB?.Clear();
  2397. _paramSelectionB = null;
  2398. NotifyOfPropertyChange(nameof(StepListB));
  2399. NotifyOfPropertyChange(nameof(ParamListB));
  2400. NotifyOfPropertyChange(nameof(RecipeB));
  2401. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  2402. NotifyOfPropertyChange(nameof(ParamSelectionB));
  2403. }
  2404. }
  2405. private void DeleteInnerXml(bool isSelectA)
  2406. {
  2407. try
  2408. {
  2409. XmlDocument docTo = isSelectA ? _domA : _domB;
  2410. //XmlNode nodeModule = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='PM1']");{_module}
  2411. // doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  2412. XmlNodeList nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  2413. if (nodeSteps == null)
  2414. nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Step");
  2415. List<XmlNode> oldNodeSteps = new List<XmlNode>();
  2416. foreach (XmlNode nodeTemp in nodeSteps)
  2417. {
  2418. oldNodeSteps.Add(nodeTemp.Clone());
  2419. }
  2420. XmlNodeList backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/BakeStep");
  2421. if (backSteps == null)
  2422. backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/BakeStep");
  2423. List<XmlNode> oldBackNodeSteps = new List<XmlNode>();
  2424. foreach (XmlNode nodeTemp in backSteps)
  2425. {
  2426. oldBackNodeSteps.Add(nodeTemp.Clone());
  2427. }
  2428. XmlNode stepsNode = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='PM1']/Step").ParentNode;
  2429. stepsNode.RemoveAll();
  2430. (stepsNode as XmlElement).SetAttribute("Name", "PM1"); //微釜的recipe为什么都是PM1?,如果recipe改了,此处要改回(stepsNode as XmlElement).SetAttribute("Name", _module);
  2431. ObservableCollection<StepDataItem> stepListTo = isSelectA ? StepListA : StepListB;
  2432. if (stepsNode == null)
  2433. {
  2434. return;
  2435. }
  2436. foreach (StepDataItem item in stepListTo)
  2437. {
  2438. XmlElement DeviceTree = docTo.CreateElement("Step");
  2439. DeviceTree.SetAttribute("StepNo", item.StepNumber.ToString());
  2440. DeviceTree.SetAttribute("Name", item.StepName);
  2441. stepsNode.AppendChild(DeviceTree);
  2442. }
  2443. foreach (XmlNode nodeStep in stepsNode)
  2444. {
  2445. string stepNumber = nodeStep.Attributes["StepNo"].Value;
  2446. ObservableCollection<ParamDataItem> paramList =
  2447. isSelectA ? _mapStepParamA[stepNumber] : _mapStepParamB[stepNumber];
  2448. foreach (var param in paramList)
  2449. {
  2450. (nodeStep as XmlElement).SetAttribute(param.ParamName, param.ParamValue);
  2451. }
  2452. }
  2453. foreach (XmlNode nodeStep in backSteps)
  2454. {
  2455. stepsNode.AppendChild(nodeStep);
  2456. }
  2457. string backText = getXmlText(isSelectA ? _domA : _domB);
  2458. LoadrecipeContentData(backText, isSelectA);
  2459. Recompare();
  2460. SyncShowDiffSteps(IsShowDiffSteps);
  2461. if (isSelectA)
  2462. {
  2463. BackInnerXmlTextA.Add(backText);
  2464. }
  2465. else
  2466. {
  2467. BackInnerXmlTextB.Add(backText);
  2468. }
  2469. }
  2470. catch (Exception ex)
  2471. {
  2472. LOG.Write(ex.Message);
  2473. }
  2474. }
  2475. public void SelectedRecipeTable()
  2476. {
  2477. ItemsSelectDialogViewModel itemsSelectDialogViewModel = new ItemsSelectDialogViewModel();
  2478. itemsSelectDialogViewModel.Items.Clear();
  2479. var tables = _mapTableStepParamA.Keys;
  2480. foreach (var item in tables)
  2481. {
  2482. TwoTableDataItem twoTableDataItem = new TwoTableDataItem();
  2483. int tableIndex = -1;
  2484. int.TryParse(item.TableIndex, out tableIndex);
  2485. if (tableIndex != -1)
  2486. {
  2487. twoTableDataItem.Index = tableIndex;
  2488. twoTableDataItem.ATableName = item.TableName;
  2489. var tablesB = _mapTableStepParamB.Keys;
  2490. var tableB = tablesB.FirstOrDefault(x => x.TableIndex == item.TableIndex);
  2491. if (tableB != null)
  2492. {
  2493. twoTableDataItem.BTableName = tableB.TableName;
  2494. twoTableDataItem.IsDiff = tableB.IsDiff;
  2495. }
  2496. itemsSelectDialogViewModel.Items.Add(twoTableDataItem);
  2497. }
  2498. }
  2499. WindowManager wm = new WindowManager();
  2500. bool? bret = wm.ShowDialog(itemsSelectDialogViewModel);
  2501. if ((bool)bret)
  2502. {
  2503. var item = itemsSelectDialogViewModel.SelectedItem;
  2504. SelectedTwoTableData = item;
  2505. SelectTableIndex = item.Index;
  2506. GetTableStepList(true, item.Index);
  2507. GetTableStepList(false, item.Index);
  2508. SyncShowDiffSteps(IsShowDiffSteps);
  2509. if (StepList != null && StepList.Count > 0)
  2510. SyncTableStepSelection(StepList[0]);
  2511. SyncShowDiffParams(_isShowDiffParams);
  2512. }
  2513. }
  2514. private string getXmlText(XmlDocument xmlDocument)
  2515. {
  2516. (new RecipeProvider()).SaveRecipe("", "RecipeTemp", xmlDocument.InnerXml);
  2517. var _recipeProvider = new RecipeProvider();
  2518. var recipeContent = _recipeProvider.LoadRecipe("", "RecipeTemp", false);
  2519. return recipeContent;
  2520. }
  2521. public void LineCopyToLeft(LineDataItem lineData)
  2522. {
  2523. LineCopy(lineData, false);
  2524. }
  2525. public void LineCopyToRight(LineDataItem lineData)
  2526. {
  2527. LineCopy(lineData, true);
  2528. }
  2529. public void LineCopy(LineDataItem lineData, bool isFromA)
  2530. {
  2531. try
  2532. {
  2533. LineDataItem lineFrom = lineData;
  2534. ObservableCollection<LineDataItem> lineListTo = isFromA ? WholeListB : WholeListA;
  2535. Dictionary<string, LineDataItem> mapFrom = isFromA ? _mapLineTextA : _mapLineTextB;
  2536. Dictionary<string, LineDataItem> mapTo = isFromA ? _mapLineTextB : _mapLineTextA;
  2537. var tempLine = lineListTo.Where(x => x.LineNumber == lineFrom.LineNumber).FirstOrDefault();
  2538. if (tempLine != null)
  2539. {
  2540. tempLine.LineText = lineFrom.LineText;
  2541. tempLine.IsDiff = lineFrom.IsDiff = false;
  2542. tempLine.IsExtra = lineFrom.IsExtra = false;
  2543. }
  2544. string recipeContent = "";
  2545. if (isFromA)
  2546. {
  2547. for (int i = 0; i < WholeListB.Count; i++)
  2548. {
  2549. recipeContent += WholeListB[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  2550. }
  2551. }
  2552. else
  2553. {
  2554. for (int i = 0; i < WholeListA.Count; i++)
  2555. {
  2556. recipeContent += WholeListA[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  2557. }
  2558. }
  2559. CopyToInnerXml(recipeContent, !isFromA);
  2560. LoadrecipeContentData(recipeContent, !isFromA);
  2561. Recompare();
  2562. SyncShowDiffSteps(IsShowDiffSteps);
  2563. }
  2564. catch (Exception ex)
  2565. {
  2566. LOG.Write(ex.Message);
  2567. }
  2568. }
  2569. private void CopyToInnerXml(string recipeContent, bool isSelectA)
  2570. {
  2571. XmlDocument doc = isSelectA ? _domA : _domB;
  2572. doc.InnerXml = recipeContent;
  2573. if (isSelectA)
  2574. {
  2575. BackInnerXmlTextA.Add(recipeContent);
  2576. }
  2577. else
  2578. {
  2579. BackInnerXmlTextB.Add(recipeContent);
  2580. }
  2581. }
  2582. public void SaveA()
  2583. {
  2584. Save(true);
  2585. }
  2586. public void SaveB()
  2587. {
  2588. Save(false);
  2589. }
  2590. private void Save(bool isSelectA)
  2591. {
  2592. XmlDocument doc = isSelectA ? _domA : _domB;
  2593. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  2594. if (nodeSteps == null)
  2595. nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Step");
  2596. if (isSelectA)
  2597. {
  2598. (new RecipeProvider()).SaveRecipe("", RecipeA, doc.InnerXml);
  2599. }
  2600. else
  2601. {
  2602. (new RecipeProvider()).SaveRecipe("", RecipeB, doc.InnerXml);
  2603. }
  2604. }
  2605. private bool _isStepModel = true;
  2606. public bool IsStepModel
  2607. {
  2608. get { return _isStepModel; }
  2609. set
  2610. {
  2611. _isStepModel = value;
  2612. _isWholeModel = !_isStepModel;
  2613. StepVisibility = _isStepModel ? Visibility.Visible : Visibility.Hidden;
  2614. WholeVisibility = _isWholeModel ? Visibility.Visible : Visibility.Hidden;
  2615. InvokePropertyChanged(nameof(IsStepModel));
  2616. InvokePropertyChanged(nameof(IsWholeModel));
  2617. InvokePropertyChanged(nameof(StepVisibility));
  2618. InvokePropertyChanged(nameof(WholeVisibility));
  2619. }
  2620. }
  2621. private bool _isWholeModel;
  2622. public bool IsWholeModel
  2623. {
  2624. get { return _isWholeModel; }
  2625. set
  2626. {
  2627. _isWholeModel = value;
  2628. _isStepModel = !_isWholeModel;
  2629. StepVisibility = _isStepModel ? Visibility.Visible : Visibility.Hidden;
  2630. WholeVisibility = _isWholeModel ? Visibility.Visible : Visibility.Hidden;
  2631. InvokePropertyChanged(nameof(IsWholeModel));
  2632. InvokePropertyChanged(nameof(IsStepModel));
  2633. InvokePropertyChanged(nameof(StepVisibility));
  2634. InvokePropertyChanged(nameof(WholeVisibility));
  2635. }
  2636. }
  2637. public Visibility StepVisibility
  2638. {
  2639. get; set;
  2640. }
  2641. public Visibility WholeVisibility
  2642. {
  2643. get; set;
  2644. }
  2645. private bool _isShowDiffSteps;
  2646. public bool IsShowDiffSteps
  2647. {
  2648. get { return _isShowDiffSteps; }
  2649. set
  2650. {
  2651. _isShowDiffSteps = value;
  2652. _isShowAllSteps = !_isShowDiffSteps;
  2653. SyncShowDiffSteps(_isShowDiffSteps);
  2654. InvokePropertyChanged(nameof(IsShowDiffSteps));
  2655. InvokePropertyChanged(nameof(IsShowAllSteps));
  2656. }
  2657. }
  2658. private bool _isShowAllSteps = true;
  2659. public bool IsShowAllSteps
  2660. {
  2661. get { return _isShowAllSteps; }
  2662. set
  2663. {
  2664. _isShowAllSteps = value;
  2665. _isShowDiffSteps = !_isShowAllSteps;
  2666. SyncShowDiffSteps(_isShowDiffSteps);
  2667. InvokePropertyChanged(nameof(IsShowAllSteps));
  2668. InvokePropertyChanged(nameof(IsShowDiffSteps));
  2669. }
  2670. }
  2671. private bool _isShowDiffParams;
  2672. public bool IsShowDiffParams
  2673. {
  2674. get { return _isShowDiffParams; }
  2675. set
  2676. {
  2677. _isShowDiffParams = value;
  2678. SyncShowDiffParams(_isShowDiffParams);
  2679. _isShowAllParams = !_isShowDiffParams;
  2680. InvokePropertyChanged(nameof(IsShowDiffParams));
  2681. InvokePropertyChanged(nameof(IsShowAllParams));
  2682. }
  2683. }
  2684. private bool _isShowAllParams = true;
  2685. public bool IsShowAllParams
  2686. {
  2687. get { return _isShowAllParams; }
  2688. set
  2689. {
  2690. _isShowAllParams = value;
  2691. _isShowDiffParams = !_isShowAllParams;
  2692. SyncShowDiffParams(_isShowDiffParams);
  2693. InvokePropertyChanged(nameof(IsShowDiffParams));
  2694. InvokePropertyChanged(nameof(IsShowAllParams));
  2695. }
  2696. }
  2697. private bool _isCompareBySName = true;
  2698. public bool IsCompareBySName
  2699. {
  2700. get { return _isCompareBySName; }
  2701. set
  2702. {
  2703. _isCompareBySName = value;
  2704. Recompare();
  2705. SyncShowDiffSteps(_isShowDiffSteps);
  2706. InvokePropertyChanged(nameof(IsCompareBySName));
  2707. }
  2708. }
  2709. private void SyncShowDiffSteps(bool isShowDiffSteps)
  2710. {
  2711. if (StepListA == null || StepListB == null)
  2712. return;
  2713. foreach (var item in StepList)
  2714. {
  2715. item.IsHidden = (IsShowDiffSteps ? (item.IsDiff == false && item.IsExtra == false) : false);
  2716. }
  2717. NotifyOfPropertyChange(nameof(StepList));
  2718. }
  2719. private void SyncShowDiffParams(bool isShowDiffParams)
  2720. {
  2721. if (ParamListA == null || ParamListB == null)
  2722. return;
  2723. if (isShowDiffParams)
  2724. {
  2725. foreach (var item in ParamList)
  2726. {
  2727. if (item.IsDiff == false && item.IsExtra == false)
  2728. {
  2729. item.IsHidden = isShowDiffParams;
  2730. }
  2731. else
  2732. {
  2733. item.IsHidden = false;
  2734. }
  2735. }
  2736. }
  2737. else
  2738. {
  2739. foreach (var item in ParamList)
  2740. {
  2741. item.IsHidden = isShowDiffParams;
  2742. }
  2743. }
  2744. NotifyOfPropertyChange(nameof(ParamList));
  2745. }
  2746. }
  2747. }