123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace FurnaceUI.Views.Scheduled
- {
- public class ScheduledSCValue
- {
- protected Dictionary<string, Tuple<object, PropertyInfo>> _fieldMap =
- new Dictionary<string, Tuple<object, PropertyInfo>>();
- public ScheduledSCValue()
- {
- }
- public List<string> GetKeys()
- {
- return _fieldMap.Keys.ToList();
- }
- public void AddKey(string key)
- {
- PropertyInfo[] property = typeof(ScheduledSCValue).GetProperties();
- foreach (PropertyInfo fiGroup in property)
- {
- object objGroup = fiGroup.GetValue(this, null);
- foreach (PropertyInfo fiItem in objGroup.GetType().GetProperties())
- {
- string name = String.Format("{0}_{1}", fiGroup.Name, fiItem.Name);
- if (key == name)
- {
- _fieldMap[name] = Tuple.Create(objGroup, fiItem);
- return;
- }
- }
- }
- }
- public virtual void SetKeys()
- {
- }
- public void SetKeys(Type type, string prefix, object objParent)
- {
- Dictionary<string, object> items = new Dictionary<string, object>();
- PropertyInfo[] property = type.GetProperties();
- foreach (PropertyInfo fiGroup in property)
- {
- var ttt = fiGroup.PropertyType;
- object obj = null;
- if (objParent != null)
- obj = fiGroup.GetValue(objParent, null);
- if (ttt != typeof(double) && ttt != typeof(string) && ttt != typeof(bool) && ttt != typeof(int))
- {
- string fiGroupName = fiGroup.Name;
- SetKeys(ttt, prefix + fiGroupName + "_", obj);
- continue;
- }
- string name = $"{prefix}{fiGroup.Name}".Replace("_", ".");
- if (_fieldMap.Keys.Contains(name))
- {
- _fieldMap[name] = Tuple.Create(objParent, fiGroup);
- }
- else
- {
- _fieldMap.Add(name, Tuple.Create(objParent, fiGroup));
- }
- }
- }
- public virtual Dictionary<string, string> GetScValue(string type, string filter)
- {
- Dictionary<string, string> result = new Dictionary<string, string>();
- foreach (var tuple in _fieldMap)
- {
- if (tuple.Key.Contains(filter))
- {
- result.Add(tuple.Key, tuple.Value.Item2.GetValue(tuple.Value.Item1).ToString());
- }
- }
- return result;
- }
- public virtual void SetParameterValue(MECF.Framework.Common.Utilities.Parameter parameter)
- { }
- public void RetrieveAll()
- {
- SetKeys();
- }
- public void Update(Dictionary<string, object> result)
- {
- if (result == null) return;
- foreach (KeyValuePair<string, object> item in result)
- {
- if (_fieldMap.ContainsKey(item.Key))
- {
- Update(item.Key, item.Value.ToString());
- //_fieldMap[item.Key].Item2.SetValue(_fieldMap[item.Key].Item1, item.Value, null);
- }
- }
- }
- public void Update(string key, string value)
- {
- if (!_fieldMap.ContainsKey(key))
- return;
- if (_fieldMap[key].Item1 == null)
- return;
- try
- {
- if (_fieldMap[key].Item2.PropertyType == typeof(double))
- {
- _fieldMap[key].Item2.SetValue(_fieldMap[key].Item1, Convert.ToDouble(value));
- }
- else if (_fieldMap[key].Item2.PropertyType == typeof(int))
- {
- _fieldMap[key].Item2.SetValue(_fieldMap[key].Item1, Convert.ToInt32(value));
- }
- else if (_fieldMap[key].Item2.PropertyType == typeof(string))
- {
- _fieldMap[key].Item2.SetValue(_fieldMap[key].Item1, value);
- }
- else if (_fieldMap[key].Item2.PropertyType == typeof(bool))
- {
- _fieldMap[key].Item2.SetValue(_fieldMap[key].Item1, Convert.ToBoolean(value));
- }
- }
- catch (Exception ex)
- {
- }
- }
- public Dictionary<string, object> GetValue()
- {
- Dictionary<string, object> result = new Dictionary<string, object>();
- foreach (var item in _fieldMap)
- {
- result[item.Key] = item.Value.Item2.GetValue(item.Value.Item1, null);
- }
- return result;
- }
-
-
-
- }
- public class ScheduledSC : ScheduledSCValue
- {
- public ScheduledConfig System_SetUp { get; set; }
- public ScheduledSC()
- {
- System_SetUp = new ScheduledConfig();
- }
- public class ScheduledConfig
- {
- public Carrier Carrier { get; set; } = new Carrier();
- public Boat Boat { get; set; } = new Boat();
- public Conditioning Conditioning { get; set; } = new Conditioning();
- }
- public class Carrier
- {
- public Carrier_OutLineAndDetail SideDymmy { get; set; }
- public Carrier_OutLineAndDetail FillDymmy { get; set; }
- }
-
- public class Carrier_OutLineAndDetail
- {
- public Carrier_OutLines OutLine { get; set; }
- public Carrier_Details Detail { get; set; }
- }
- public class Carrier_OutLines
- {
- public OutLine No1 { get; set; }
- public OutLine No2 { get; set; }
- public OutLine No3 { get; set; }
- public OutLine No4 { get; set; }
- }
- public class Carrier_Details
- {
- public Detail No1 { get; set; }
- public Detail No2 { get; set; }
- public Detail No3 { get; set; }
- public Detail No4 { get; set; }
- }
- public class Boat
- {
- public Boat_OutLines OutLine { get; set; }
- public Boat_Details Detail { get; set; }
- }
- public class Boat_OutLines
- {
- public OutLine No1 { get; set; }
- public OutLine No2 { get; set; }
- public OutLine No3 { get; set; }
- public OutLine No4 { get; set; }
- public OutLine No5 { get; set; }
- }
- public class Boat_Details
- {
- public Detail No1 { get; set; }
- public Detail No2 { get; set; }
- public Detail No3 { get; set; }
- public Detail No4 { get; set; }
- public Detail No5 { get; set; }
- }
- public class Conditioning
- {
- public Conditioning_OutLines OutLine { get; set; }
- public Conditioning_Details Detail { get; set; }
- }
- public class Conditioning_OutLines
- {
- public OutLine No1 { get; set; }
- public OutLine No2 { get; set; }
- }
- public class Conditioning_Details
- {
- public Detail No1 { get; set; }
- public Detail No2 { get; set; }
- }
- public class Reactor
- {
- public Recipe_OutLineAndDetail Recipe { get; set; }
- public StepRunFreq_OutLineAndDetail StepRunFreq { get; set; }
- public StepRunTime_OutLineAndDetail StepRunTime { get; set; }
- public StepThickness_OutLineAndDetail StepThickness { get; set; }
- }
- public class Recipe_OutLineAndDetail
- {
- public Recipe_OutLines OutLine { get; set; }
- public Recipe_Details Detail { get; set; }
- }
- public class Recipe_OutLines
- {
- public OutLine No1 { get; set; }
- public OutLine No2 { get; set; }
- }
- public class Recipe_Details
- {
- public Detail No1 { get; set; }
- public Detail No2 { get; set; }
- }
- public class StepRunFreq_OutLineAndDetail
- {
- public StepRunFreq_OutLines OutLine { get; set; }
- public StepRunFreq_Details Detail { get; set; }
- }
- public class StepRunFreq_OutLines
- {
- public OutLine No1 { get; set; }
- public OutLine No2 { get; set; }
- public OutLine No3 { get; set; }
- }
- public class StepRunFreq_Details
- {
- public Detail No1 { get; set; }
- public Detail No2 { get; set; }
- public Detail No3 { get; set; }
- }
- public class StepRunTime_OutLineAndDetail
- {
- public StepRunTime_OutLines OutLine { get; set; }
- public StepRunTime_Details Detail { get; set; }
- }
- public class StepRunTime_OutLines
- {
- public OutLine No1 { get; set; }
- public OutLine No2 { get; set; }
- public OutLine No3 { get; set; }
- public OutLine No4 { get; set; }
- public OutLine No5 { get; set; }
- public OutLine No6 { get; set; }
- public OutLine No7 { get; set; }
- public OutLine No8 { get; set; }
- public OutLine No9 { get; set; }
- public OutLine No10 { get; set; }
- }
- public class StepRunTime_Details
- {
- public Detail No1 { get; set; }
- public Detail No2 { get; set; }
- public Detail No3 { get; set; }
- public Detail No4 { get; set; }
- public Detail No5 { get; set; }
- public Detail No6 { get; set; }
- public Detail No7 { get; set; }
- public Detail No8 { get; set; }
- public Detail No9 { get; set; }
- public Detail No10 { get; set; }
- }
- public class StepThickness_OutLineAndDetail
- {
- public StepThickness_OutLines OutLine { get; set; }
- public StepThickness_Details Detail { get; set; }
- }
- public class StepThickness_OutLines
- {
- public OutLine No1 { get; set; }
- public OutLine No2 { get; set; }
- public OutLine No3 { get; set; }
- public OutLine No4 { get; set; }
- public OutLine No5 { get; set; }
- public OutLine No6 { get; set; }
- public OutLine No7 { get; set; }
- public OutLine No8 { get; set; }
- public OutLine No9 { get; set; }
- public OutLine No10 { get; set; }
- }
- public class StepThickness_Details
- {
- public Detail No1 { get; set; }
- public Detail No2 { get; set; }
- public Detail No3 { get; set; }
- public Detail No4 { get; set; }
- public Detail No5 { get; set; }
- public Detail No6 { get; set; }
- public Detail No7 { get; set; }
- public Detail No8 { get; set; }
- public Detail No9 { get; set; }
- public Detail No10 { get; set; }
- }
- public override void SetKeys()
- {
- _fieldMap.Clear();
- SetKeys(typeof(ScheduledSC), "", this);
- }
- public void SetKeys(Type type, string prefix, object objParent)
- {
- Dictionary<string, object> items = new Dictionary<string, object>();
- PropertyInfo[] property = type.GetProperties();
- foreach (PropertyInfo fiGroup in property)
- {
- var ttt = fiGroup.PropertyType;
- object obj = null;
- if (objParent != null)
- obj = fiGroup.GetValue(objParent, null);
- if (ttt != typeof(double) && ttt != typeof(string) && ttt != typeof(bool) && ttt != typeof(int) && ttt != typeof(DateTime))
- {
- string fiGroupName = fiGroup.Name;
- SetKeys(ttt, prefix + fiGroupName + "_", obj);
- continue;
- }
- string name = $"{prefix}{fiGroup.Name}".Replace("_", ".");
- if (_fieldMap.Keys.Contains(name))
- {
- _fieldMap[name] = Tuple.Create(objParent, fiGroup);
- }
- else
- {
- _fieldMap.Add(name, Tuple.Create(objParent, fiGroup));
- }
- }
- }
- }
- public class OutLine
- {
- private int _no;
- public int No
- {
- get => _no;
- set
- {
- _no = value;
- }
- }
- private string _maintenanceName;
- public string MaintenanceName
- {
- get => _maintenanceName;
- set
- {
- _maintenanceName = value;
- }
- }
- private string _maintenanceItem;
- public string MaintenanceItem
- {
- get => _maintenanceItem;
- set
- {
- _maintenanceItem = value;
- }
- }
- private double _currentValue;
- public double CurrentValue
- {
- get => _currentValue;
- set
- {
- _currentValue = value;
- }
- }
- private double _schedulingStartValue;
- public double SchedulingStartValue
- {
- get => _schedulingStartValue;
- set
- {
- _schedulingStartValue = value;
- }
- }
- private double _maintenanceLimitValue;
- public double MaintenanceLimitValue
- {
- get => _maintenanceLimitValue;
- set
- {
- _maintenanceLimitValue = value;
- }
- }
- private string _unit;
- public string Unit
- {
- get => _unit;
- set
- {
- _unit = value;
- }
- }
- private string _maintenanceProcessing;
- public string MaintenanceProcessing
- {
- get => _maintenanceProcessing;
- set
- {
- _maintenanceProcessing = value;
- }
- }
- }
- public class Detail
- {
- private int _no;
- public int No
- {
- get => _no;
- set
- {
- _no = value;
- }
- }
- private string _maintenanceName;
- public string MaintenanceName
- {
- get => _maintenanceName;
- set
- {
- _maintenanceName = value;
- }
- }
- private string _maintenanceJobName;
- public string MaintenanceJobName
- {
- get => _maintenanceJobName;
- set
- {
- _maintenanceJobName = value;
- }
- }
- private string _maintenanceItem;
- public string MaintenanceItem
- {
- get => _maintenanceItem;
- set
- {
- _maintenanceItem = value;
- }
- }
- private string _status;
- public string Status
- {
- get => _status;
- set
- {
- _status = value;
- }
- }
- private double _currentValue;
- public double CurrentValue
- {
- get => _currentValue;
- set
- {
- _currentValue = value;
- }
- }
- private double _schedulingStartValue;
- public double SchedulingStartValue
- {
- get => _schedulingStartValue;
- set
- {
- _schedulingStartValue = value;
- }
- }
- private double _maintenanceLimitValue;
- public double MaintenanceLimitValue
- {
- get => _maintenanceLimitValue;
- set
- {
- _maintenanceLimitValue = value;
- }
- }
- private string _unit;
- public string Unit
- {
- get => _unit;
- set
- {
- _unit = value;
- }
- }
- private string _maintenanceProcessing;
- public string MaintenanceProcessing
- {
- get => _maintenanceProcessing;
- set
- {
- _maintenanceProcessing = value;
- }
- }
- private DateTime _maintenanceExecutionDate;
- public DateTime MaintenanceExecutionDate
- {
- get => _maintenanceExecutionDate;
- set
- {
- _maintenanceExecutionDate = value;
- }
- }
- }
- }
|