ScheduledSCValue.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace FurnaceUI.Views.Scheduled
  8. {
  9. public class ScheduledSCValue
  10. {
  11. protected Dictionary<string, Tuple<object, PropertyInfo>> _fieldMap =
  12. new Dictionary<string, Tuple<object, PropertyInfo>>();
  13. public ScheduledSCValue()
  14. {
  15. }
  16. public List<string> GetKeys()
  17. {
  18. return _fieldMap.Keys.ToList();
  19. }
  20. public void AddKey(string key)
  21. {
  22. PropertyInfo[] property = typeof(ScheduledSCValue).GetProperties();
  23. foreach (PropertyInfo fiGroup in property)
  24. {
  25. object objGroup = fiGroup.GetValue(this, null);
  26. foreach (PropertyInfo fiItem in objGroup.GetType().GetProperties())
  27. {
  28. string name = String.Format("{0}_{1}", fiGroup.Name, fiItem.Name);
  29. if (key == name)
  30. {
  31. _fieldMap[name] = Tuple.Create(objGroup, fiItem);
  32. return;
  33. }
  34. }
  35. }
  36. }
  37. public virtual void SetKeys()
  38. {
  39. }
  40. public void SetKeys(Type type, string prefix, object objParent)
  41. {
  42. Dictionary<string, object> items = new Dictionary<string, object>();
  43. PropertyInfo[] property = type.GetProperties();
  44. foreach (PropertyInfo fiGroup in property)
  45. {
  46. var ttt = fiGroup.PropertyType;
  47. object obj = null;
  48. if (objParent != null)
  49. obj = fiGroup.GetValue(objParent, null);
  50. if (ttt != typeof(double) && ttt != typeof(string) && ttt != typeof(bool) && ttt != typeof(int))
  51. {
  52. string fiGroupName = fiGroup.Name;
  53. SetKeys(ttt, prefix + fiGroupName + "_", obj);
  54. continue;
  55. }
  56. string name = $"{prefix}{fiGroup.Name}".Replace("_", ".");
  57. if (_fieldMap.Keys.Contains(name))
  58. {
  59. _fieldMap[name] = Tuple.Create(objParent, fiGroup);
  60. }
  61. else
  62. {
  63. _fieldMap.Add(name, Tuple.Create(objParent, fiGroup));
  64. }
  65. }
  66. }
  67. public virtual Dictionary<string, string> GetScValue(string type, string filter)
  68. {
  69. Dictionary<string, string> result = new Dictionary<string, string>();
  70. foreach (var tuple in _fieldMap)
  71. {
  72. if (tuple.Key.Contains(filter))
  73. {
  74. result.Add(tuple.Key, tuple.Value.Item2.GetValue(tuple.Value.Item1).ToString());
  75. }
  76. }
  77. return result;
  78. }
  79. public virtual void SetParameterValue(MECF.Framework.Common.Utilities.Parameter parameter)
  80. { }
  81. public void RetrieveAll()
  82. {
  83. SetKeys();
  84. }
  85. public void Update(Dictionary<string, object> result)
  86. {
  87. if (result == null) return;
  88. foreach (KeyValuePair<string, object> item in result)
  89. {
  90. if (_fieldMap.ContainsKey(item.Key))
  91. {
  92. Update(item.Key, item.Value.ToString());
  93. //_fieldMap[item.Key].Item2.SetValue(_fieldMap[item.Key].Item1, item.Value, null);
  94. }
  95. }
  96. }
  97. public void Update(string key, string value)
  98. {
  99. if (!_fieldMap.ContainsKey(key))
  100. return;
  101. if (_fieldMap[key].Item1 == null)
  102. return;
  103. try
  104. {
  105. if (_fieldMap[key].Item2.PropertyType == typeof(double))
  106. {
  107. _fieldMap[key].Item2.SetValue(_fieldMap[key].Item1, Convert.ToDouble(value));
  108. }
  109. else if (_fieldMap[key].Item2.PropertyType == typeof(int))
  110. {
  111. _fieldMap[key].Item2.SetValue(_fieldMap[key].Item1, Convert.ToInt32(value));
  112. }
  113. else if (_fieldMap[key].Item2.PropertyType == typeof(string))
  114. {
  115. _fieldMap[key].Item2.SetValue(_fieldMap[key].Item1, value);
  116. }
  117. else if (_fieldMap[key].Item2.PropertyType == typeof(bool))
  118. {
  119. _fieldMap[key].Item2.SetValue(_fieldMap[key].Item1, Convert.ToBoolean(value));
  120. }
  121. }
  122. catch (Exception ex)
  123. {
  124. }
  125. }
  126. public Dictionary<string, object> GetValue()
  127. {
  128. Dictionary<string, object> result = new Dictionary<string, object>();
  129. foreach (var item in _fieldMap)
  130. {
  131. result[item.Key] = item.Value.Item2.GetValue(item.Value.Item1, null);
  132. }
  133. return result;
  134. }
  135. }
  136. public class ScheduledSC : ScheduledSCValue
  137. {
  138. public ScheduledConfig System_SetUp { get; set; }
  139. public ScheduledSC()
  140. {
  141. System_SetUp = new ScheduledConfig();
  142. }
  143. public class ScheduledConfig
  144. {
  145. public Carrier Carrier { get; set; } = new Carrier();
  146. public Boat Boat { get; set; } = new Boat();
  147. public Conditioning Conditioning { get; set; } = new Conditioning();
  148. }
  149. public class Carrier
  150. {
  151. public Carrier_OutLineAndDetail SideDymmy { get; set; }
  152. public Carrier_OutLineAndDetail FillDymmy { get; set; }
  153. }
  154. public class Carrier_OutLineAndDetail
  155. {
  156. public Carrier_OutLines OutLine { get; set; }
  157. public Carrier_Details Detail { get; set; }
  158. }
  159. public class Carrier_OutLines
  160. {
  161. public OutLine No1 { get; set; }
  162. public OutLine No2 { get; set; }
  163. public OutLine No3 { get; set; }
  164. public OutLine No4 { get; set; }
  165. }
  166. public class Carrier_Details
  167. {
  168. public Detail No1 { get; set; }
  169. public Detail No2 { get; set; }
  170. public Detail No3 { get; set; }
  171. public Detail No4 { get; set; }
  172. }
  173. public class Boat
  174. {
  175. public Boat_OutLines OutLine { get; set; }
  176. public Boat_Details Detail { get; set; }
  177. }
  178. public class Boat_OutLines
  179. {
  180. public OutLine No1 { get; set; }
  181. public OutLine No2 { get; set; }
  182. public OutLine No3 { get; set; }
  183. public OutLine No4 { get; set; }
  184. public OutLine No5 { get; set; }
  185. }
  186. public class Boat_Details
  187. {
  188. public Detail No1 { get; set; }
  189. public Detail No2 { get; set; }
  190. public Detail No3 { get; set; }
  191. public Detail No4 { get; set; }
  192. public Detail No5 { get; set; }
  193. }
  194. public class Conditioning
  195. {
  196. public Conditioning_OutLines OutLine { get; set; }
  197. public Conditioning_Details Detail { get; set; }
  198. }
  199. public class Conditioning_OutLines
  200. {
  201. public OutLine No1 { get; set; }
  202. public OutLine No2 { get; set; }
  203. }
  204. public class Conditioning_Details
  205. {
  206. public Detail No1 { get; set; }
  207. public Detail No2 { get; set; }
  208. }
  209. public class Reactor
  210. {
  211. public Recipe_OutLineAndDetail Recipe { get; set; }
  212. public StepRunFreq_OutLineAndDetail StepRunFreq { get; set; }
  213. public StepRunTime_OutLineAndDetail StepRunTime { get; set; }
  214. public StepThickness_OutLineAndDetail StepThickness { get; set; }
  215. }
  216. public class Recipe_OutLineAndDetail
  217. {
  218. public Recipe_OutLines OutLine { get; set; }
  219. public Recipe_Details Detail { get; set; }
  220. }
  221. public class Recipe_OutLines
  222. {
  223. public OutLine No1 { get; set; }
  224. public OutLine No2 { get; set; }
  225. }
  226. public class Recipe_Details
  227. {
  228. public Detail No1 { get; set; }
  229. public Detail No2 { get; set; }
  230. }
  231. public class StepRunFreq_OutLineAndDetail
  232. {
  233. public StepRunFreq_OutLines OutLine { get; set; }
  234. public StepRunFreq_Details Detail { get; set; }
  235. }
  236. public class StepRunFreq_OutLines
  237. {
  238. public OutLine No1 { get; set; }
  239. public OutLine No2 { get; set; }
  240. public OutLine No3 { get; set; }
  241. }
  242. public class StepRunFreq_Details
  243. {
  244. public Detail No1 { get; set; }
  245. public Detail No2 { get; set; }
  246. public Detail No3 { get; set; }
  247. }
  248. public class StepRunTime_OutLineAndDetail
  249. {
  250. public StepRunTime_OutLines OutLine { get; set; }
  251. public StepRunTime_Details Detail { get; set; }
  252. }
  253. public class StepRunTime_OutLines
  254. {
  255. public OutLine No1 { get; set; }
  256. public OutLine No2 { get; set; }
  257. public OutLine No3 { get; set; }
  258. public OutLine No4 { get; set; }
  259. public OutLine No5 { get; set; }
  260. public OutLine No6 { get; set; }
  261. public OutLine No7 { get; set; }
  262. public OutLine No8 { get; set; }
  263. public OutLine No9 { get; set; }
  264. public OutLine No10 { get; set; }
  265. }
  266. public class StepRunTime_Details
  267. {
  268. public Detail No1 { get; set; }
  269. public Detail No2 { get; set; }
  270. public Detail No3 { get; set; }
  271. public Detail No4 { get; set; }
  272. public Detail No5 { get; set; }
  273. public Detail No6 { get; set; }
  274. public Detail No7 { get; set; }
  275. public Detail No8 { get; set; }
  276. public Detail No9 { get; set; }
  277. public Detail No10 { get; set; }
  278. }
  279. public class StepThickness_OutLineAndDetail
  280. {
  281. public StepThickness_OutLines OutLine { get; set; }
  282. public StepThickness_Details Detail { get; set; }
  283. }
  284. public class StepThickness_OutLines
  285. {
  286. public OutLine No1 { get; set; }
  287. public OutLine No2 { get; set; }
  288. public OutLine No3 { get; set; }
  289. public OutLine No4 { get; set; }
  290. public OutLine No5 { get; set; }
  291. public OutLine No6 { get; set; }
  292. public OutLine No7 { get; set; }
  293. public OutLine No8 { get; set; }
  294. public OutLine No9 { get; set; }
  295. public OutLine No10 { get; set; }
  296. }
  297. public class StepThickness_Details
  298. {
  299. public Detail No1 { get; set; }
  300. public Detail No2 { get; set; }
  301. public Detail No3 { get; set; }
  302. public Detail No4 { get; set; }
  303. public Detail No5 { get; set; }
  304. public Detail No6 { get; set; }
  305. public Detail No7 { get; set; }
  306. public Detail No8 { get; set; }
  307. public Detail No9 { get; set; }
  308. public Detail No10 { get; set; }
  309. }
  310. public override void SetKeys()
  311. {
  312. _fieldMap.Clear();
  313. SetKeys(typeof(ScheduledSC), "", this);
  314. }
  315. public void SetKeys(Type type, string prefix, object objParent)
  316. {
  317. Dictionary<string, object> items = new Dictionary<string, object>();
  318. PropertyInfo[] property = type.GetProperties();
  319. foreach (PropertyInfo fiGroup in property)
  320. {
  321. var ttt = fiGroup.PropertyType;
  322. object obj = null;
  323. if (objParent != null)
  324. obj = fiGroup.GetValue(objParent, null);
  325. if (ttt != typeof(double) && ttt != typeof(string) && ttt != typeof(bool) && ttt != typeof(int) && ttt != typeof(DateTime))
  326. {
  327. string fiGroupName = fiGroup.Name;
  328. SetKeys(ttt, prefix + fiGroupName + "_", obj);
  329. continue;
  330. }
  331. string name = $"{prefix}{fiGroup.Name}".Replace("_", ".");
  332. if (_fieldMap.Keys.Contains(name))
  333. {
  334. _fieldMap[name] = Tuple.Create(objParent, fiGroup);
  335. }
  336. else
  337. {
  338. _fieldMap.Add(name, Tuple.Create(objParent, fiGroup));
  339. }
  340. }
  341. }
  342. }
  343. public class OutLine
  344. {
  345. private int _no;
  346. public int No
  347. {
  348. get => _no;
  349. set
  350. {
  351. _no = value;
  352. }
  353. }
  354. private string _maintenanceName;
  355. public string MaintenanceName
  356. {
  357. get => _maintenanceName;
  358. set
  359. {
  360. _maintenanceName = value;
  361. }
  362. }
  363. private string _maintenanceItem;
  364. public string MaintenanceItem
  365. {
  366. get => _maintenanceItem;
  367. set
  368. {
  369. _maintenanceItem = value;
  370. }
  371. }
  372. private double _currentValue;
  373. public double CurrentValue
  374. {
  375. get => _currentValue;
  376. set
  377. {
  378. _currentValue = value;
  379. }
  380. }
  381. private double _schedulingStartValue;
  382. public double SchedulingStartValue
  383. {
  384. get => _schedulingStartValue;
  385. set
  386. {
  387. _schedulingStartValue = value;
  388. }
  389. }
  390. private double _maintenanceLimitValue;
  391. public double MaintenanceLimitValue
  392. {
  393. get => _maintenanceLimitValue;
  394. set
  395. {
  396. _maintenanceLimitValue = value;
  397. }
  398. }
  399. private string _unit;
  400. public string Unit
  401. {
  402. get => _unit;
  403. set
  404. {
  405. _unit = value;
  406. }
  407. }
  408. private string _maintenanceProcessing;
  409. public string MaintenanceProcessing
  410. {
  411. get => _maintenanceProcessing;
  412. set
  413. {
  414. _maintenanceProcessing = value;
  415. }
  416. }
  417. }
  418. public class Detail
  419. {
  420. private int _no;
  421. public int No
  422. {
  423. get => _no;
  424. set
  425. {
  426. _no = value;
  427. }
  428. }
  429. private string _maintenanceName;
  430. public string MaintenanceName
  431. {
  432. get => _maintenanceName;
  433. set
  434. {
  435. _maintenanceName = value;
  436. }
  437. }
  438. private string _maintenanceJobName;
  439. public string MaintenanceJobName
  440. {
  441. get => _maintenanceJobName;
  442. set
  443. {
  444. _maintenanceJobName = value;
  445. }
  446. }
  447. private string _maintenanceItem;
  448. public string MaintenanceItem
  449. {
  450. get => _maintenanceItem;
  451. set
  452. {
  453. _maintenanceItem = value;
  454. }
  455. }
  456. private string _status;
  457. public string Status
  458. {
  459. get => _status;
  460. set
  461. {
  462. _status = value;
  463. }
  464. }
  465. private double _currentValue;
  466. public double CurrentValue
  467. {
  468. get => _currentValue;
  469. set
  470. {
  471. _currentValue = value;
  472. }
  473. }
  474. private double _schedulingStartValue;
  475. public double SchedulingStartValue
  476. {
  477. get => _schedulingStartValue;
  478. set
  479. {
  480. _schedulingStartValue = value;
  481. }
  482. }
  483. private double _maintenanceLimitValue;
  484. public double MaintenanceLimitValue
  485. {
  486. get => _maintenanceLimitValue;
  487. set
  488. {
  489. _maintenanceLimitValue = value;
  490. }
  491. }
  492. private string _unit;
  493. public string Unit
  494. {
  495. get => _unit;
  496. set
  497. {
  498. _unit = value;
  499. }
  500. }
  501. private string _maintenanceProcessing;
  502. public string MaintenanceProcessing
  503. {
  504. get => _maintenanceProcessing;
  505. set
  506. {
  507. _maintenanceProcessing = value;
  508. }
  509. }
  510. private DateTime _maintenanceExecutionDate;
  511. public DateTime MaintenanceExecutionDate
  512. {
  513. get => _maintenanceExecutionDate;
  514. set
  515. {
  516. _maintenanceExecutionDate = value;
  517. }
  518. }
  519. }
  520. }