123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904 |
- using System.ComponentModel;
- using System.Reflection;
- using WCS.Entity.Protocol.DataStructure;
- using WCS.Entity.Protocol.Protocol.DataStructure;
- using WMS.Info.Models.WCSDeviceMonitor;
- namespace WMS.BZWeb.Extensions
- {
- public static class WCSPTDBAttributeExtensions
- {
- public static DBDetail GetAttributesDBDetail(this SRMData obj)
- {
- DBDetail dBDetail = new DBDetail() { DBName = new List<string>(), DBDatas = new Dictionary<string, List<DBData>>() };
- List<DBData> list = new List<DBData>();
- if (obj.D521 != null)
- {
- var WCS_SRM521IntefaceType = obj.D521?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_SRM521IntefaceProperties = WCS_SRM521IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D521?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_SRM521IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_SRM521IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB521_" + pi.Name;
- var abc = pi.GetValue(obj.D521, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB521");
- dBDetail.DBDatas.Add("DB521", list);
- }
- if (obj.D520 != null)
- {
- var WCS_SRM520IntefaceType = obj.D520?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_SRM520IntefaceProperties = WCS_SRM520IntefaceType?.GetProperties();
- list = new List<DBData>();
- foreach (PropertyInfo pi in obj.D520?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_SRM520IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_SRM520IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB520_" + pi.Name;
- var abc = pi.GetValue(obj.D520, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB520");
- dBDetail.DBDatas.Add("DB520", list);
- }
- if (obj.D537 != null)
- {
- list = new List<DBData>();
- var WCS_SRM537IntefaceType = obj.D537?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_SRM537IntefaceProperties = WCS_SRM537IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D537?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_SRM537IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_SRM537IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB537_" + pi.Name;
- var abc = pi.GetValue(obj.D537, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB537");
- dBDetail.DBDatas.Add("DB537", list);
- }
- return dBDetail;
- }
- public static DBDetail GetAttributesDBDetail(this StationData obj)
- {
- DBDetail dBDetail = new DBDetail() { DBName = new List<string>(), DBDatas = new Dictionary<string, List<DBData>>() };
- List<DBData> list = new List<DBData>();
- if (obj.D521 != null)
- {
- var WCS_Station521IntefaceType = obj.D521?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station521IntefaceProperties = WCS_Station521IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D521?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station521IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station521IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB521_" + pi.Name;
- var abc = pi.GetValue(obj.D521, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB521");
- dBDetail.DBDatas.Add("DB521", list);
- }
- if (obj.D520 != null)
- {
- list = new List<DBData>();
- var WCS_Station520IntefaceType = obj.D520?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station520IntefaceProperties = WCS_Station520IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D520?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station520IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station520IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB520_" + pi.Name;
- var abc = pi.GetValue(obj.D520, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB520");
- dBDetail.DBDatas.Add("DB520", list);
- }
- if (obj.D523 != null)
- {
- list = new List<DBData>();
- var WCS_Station523IntefaceType = obj.D523?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station523IntefaceProperties = WCS_Station523IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D523?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station523IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station523IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB523_" + pi.Name;
- var abc = pi.GetValue(obj.D523, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB523");
- dBDetail.DBDatas.Add("DB523", list);
- }
- if (obj.D524 != null)
- {
- list = new List<DBData>();
- var WCS_Station524IntefaceType = obj.D524?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station524IntefaceProperties = WCS_Station524IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D524?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station524IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station524IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB524_" + pi.Name;
- var abc = pi.GetValue(obj.D524, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB524");
- dBDetail.DBDatas.Add("DB524", list);
- }
- if (obj.D525 != null)
- {
- //var d525lists = new List<D525Model>();
- //for (int i = 0; i < 50; i++)
- //{
- // D525Model d525Model = new D525Model();
- // foreach (PropertyInfo pi in d525Model.GetType()?.GetProperties())
- // {
- // var proName = pi.Name + i;
- // var d525value = obj.D525.GetType()?.GetProperties().FirstOrDefault(o => o.Name == proName)?.GetValue(obj.D525);
- // pi.SetValue(d525Model, d525value);
- // }
- // d525lists.Add(d525Model);
- //}
- //dBDetail.DBName.Add("DB525");
- //dBDetail.D525Datas.Add("DB525", d525lists);
- list = new List<DBData>();
- var WCS_Station525IntefaceType = obj.D525?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station525IntefaceProperties = WCS_Station525IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D525?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station525IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station525IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB525_" + pi.Name;
- var abc = pi.GetValue(obj.D525, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB525");
- dBDetail.DBDatas.Add("DB525", list);
- }
- if (obj.D530 != null)
- {
- list = new List<DBData>();
- var WCS_Station530IntefaceType = obj.D530?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station530IntefaceProperties = WCS_Station530IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D530?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station530IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station530IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB530_" + pi.Name;
- var abc = pi.GetValue(obj.D530, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB530");
- dBDetail.DBDatas.Add("DB530", list);
- }
- if (obj.D5531 != null)
- {
- list = new List<DBData>();
- var WCS_Station5531IntefaceType = obj.D5531?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station5531IntefaceProperties = WCS_Station5531IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D5531?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station5531IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station5531IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB5531_" + pi.Name;
- var abc = pi.GetValue(obj.D5531, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB5531");
- dBDetail.DBDatas.Add("DB5531", list);
- }
- if (obj.DR530 != null)
- {
- list = new List<DBData>();
- var WCS_StationDR530IntefaceType = obj.DR530?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_StationDR530IntefaceProperties = WCS_StationDR530IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.DR530?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_StationDR530IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_StationDR530IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DBDR530_" + pi.Name;
- var abc = pi.GetValue(obj.DR530, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DBDR530");
- dBDetail.DBDatas.Add("DBDR530", list);
- }
- if (obj.DR531 != null)
- {
- list = new List<DBData>();
- var WCS_StationDR531IntefaceType = obj.DR531?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_StationDR531IntefaceProperties = WCS_StationDR531IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.DR531?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_StationDR531IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_StationDR531IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DBDR531_" + pi.Name;
- var abc = pi.GetValue(obj.DR531, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DBDR531");
- dBDetail.DBDatas.Add("DBDR531", list);
- }
- if (obj.D80 != null)
- {
- var WCS_Station80IntefaceType = obj.D80?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station80IntefaceProperties = WCS_Station80IntefaceType?.GetProperties();
- list = new List<DBData>();
- foreach (PropertyInfo pi in obj.D80?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station80IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station80IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB80_" + pi.Name;
- var abc = pi.GetValue(obj.D80, null);
- //if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc?.ToString() });
- }
- dBDetail.DBName.Add("DB80");
- dBDetail.DBDatas.Add("DB80", list);
- }
- if (obj.D81 != null)
- {
- var WCS_Station81IntefaceType = obj.D81?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station81IntefaceProperties = WCS_Station81IntefaceType?.GetProperties();
- list = new List<DBData>();
- foreach (PropertyInfo pi in obj.D81?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station81IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station81IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB81_" + pi.Name;
- var abc = pi.GetValue(obj.D81, null);
- //if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc?.ToString() });
- }
- dBDetail.DBName.Add("DB81");
- dBDetail.DBDatas.Add("DB81", list);
- }
- if (obj.D83 != null)
- {
- var WCS_Station83IntefaceType = obj.D83?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station83IntefaceProperties = WCS_Station83IntefaceType?.GetProperties();
- list = new List<DBData>();
- foreach (PropertyInfo pi in obj.D83?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station83IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station83IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB83_" + pi.Name;
- var abc = pi.GetValue(obj.D83, null);
- //if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc?.ToString() });
- }
- dBDetail.DBName.Add("DB83");
- dBDetail.DBDatas.Add("DB83", list);
- }
- if (obj.D90 != null)
- {
- var WCS_Station90IntefaceType = obj.D90?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station90IntefaceProperties = WCS_Station90IntefaceType?.GetProperties();
- list = new List<DBData>();
- foreach (PropertyInfo pi in obj.D90?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station90IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station90IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB90_" + pi.Name;
- var abc = pi.GetValue(obj.D90, null);
- //if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc?.ToString() });
- }
- dBDetail.DBName.Add("DB90");
- dBDetail.DBDatas.Add("DB90", list);
- }
- if (obj.D91 != null)
- {
- var WCS_Station91IntefaceType = obj.D91?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station91IntefaceProperties = WCS_Station91IntefaceType?.GetProperties();
- list = new List<DBData>();
- foreach (PropertyInfo pi in obj.D91?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station91IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station91IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB91_" + pi.Name;
- var abc = pi.GetValue(obj.D91, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB91");
- dBDetail.DBDatas.Add("DB91", list);
- }
- return dBDetail;
- }
- public static DBDetail GetAttributesDBDetail(this RGVData obj)
- {
- DBDetail dBDetail = new DBDetail() { DBName = new List<string>(), DBDatas = new Dictionary<string, List<DBData>>() };
- List<DBData> list = new List<DBData>();
- if (obj.D521 != null)
- {
- var WCS_D521IntefaceType = obj.D521?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_D521IntefaceProperties = WCS_D521IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D521?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_D521IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_D521IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB521_" + pi.Name;
- var abc = pi.GetValue(obj.D521, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB521");
- dBDetail.DBDatas.Add("DB521", list);
- }
- if (obj.D520 != null)
- {
- list = new List<DBData>();
- var WCS_Station520IntefaceType = obj.D520?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_Station520IntefaceProperties = WCS_Station520IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D520?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_Station520IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_Station520IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB520_" + pi.Name;
- var abc = pi.GetValue(obj.D520, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB520");
- dBDetail.DBDatas.Add("DB520", list);
- }
- if (obj.D81 != null)
- {
- var WCS_D81IntefaceType = obj.D81?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_D81IntefaceProperties = WCS_D81IntefaceType?.GetProperties();
- list = new List<DBData>();
- foreach (PropertyInfo pi in obj.D81?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_D81IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_D81IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB81_" + pi.Name;
- var abc = pi.GetValue(obj.D81, null);
- //if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc?.ToString() });
- }
- dBDetail.DBName.Add("DB81");
- dBDetail.DBDatas.Add("DB81", list);
- }
- return dBDetail;
- }
- public static DBDetail GetAttributesDBDetail(this RobotData obj)
- {
- DBDetail dBDetail = new DBDetail() { DBName = new List<string>(), DBDatas = new Dictionary<string, List<DBData>>() };
- List<DBData> list = new List<DBData>();
- if (obj.D521 != null)
- {
- var WCS_D521IntefaceType = obj.D521?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_D521IntefaceProperties = WCS_D521IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D521?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_D521IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_D521IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB521_" + pi.Name;
- var abc = pi.GetValue(obj.D521, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB521");
- dBDetail.DBDatas.Add("DB521", list);
- }
- if (obj.D520 != null)
- {
- var WCS_SRM520IntefaceType = obj.D520?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_SRM520IntefaceProperties = WCS_SRM520IntefaceType?.GetProperties();
- list = new List<DBData>();
- foreach (PropertyInfo pi in obj.D520?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_SRM520IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_SRM520IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB520_" + pi.Name;
- var abc = pi.GetValue(obj.D520, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB520");
- dBDetail.DBDatas.Add("DB520", list);
- }
- if (obj.D522 != null)
- {
- list = new List<DBData>();
- var WCS_D522IntefaceType = obj.D522?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_D522IntefaceProperties = WCS_D522IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D522?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_D522IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_D522IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB522_" + pi.Name;
- var abc = pi.GetValue(obj.D522, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB522");
- dBDetail.DBDatas.Add("DB522", list);
- }
- return dBDetail;
- }
- public static DBDetail GetAttributesDBDetail(this TrussData obj)
- {
- DBDetail dBDetail = new DBDetail() { DBName = new List<string>(), DBDatas = new Dictionary<string, List<DBData>>() };
- List<DBData> list = new List<DBData>();
- if (obj.D521 != null)
- {
- var WCS_D521IntefaceType = obj.D521?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_D521IntefaceProperties = WCS_D521IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D521?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_D521IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_D521IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB521_" + pi.Name;
- var abc = pi.GetValue(obj.D521, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB521");
- dBDetail.DBDatas.Add("DB521", list);
- }
- if (obj.D520 != null)
- {
- var WCS_D520IntefaceType = obj.D520?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_D520IntefaceProperties = WCS_D520IntefaceType?.GetProperties();
- list = new List<DBData>();
- foreach (PropertyInfo pi in obj.D520?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_D520IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_D520IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB520_" + pi.Name;
- var abc = pi.GetValue(obj.D520, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB520");
- dBDetail.DBDatas.Add("DB520", list);
- }
- if (obj.D523 != null)
- {
- list = new List<DBData>();
- var WCS_D523IntefaceType = obj.D523?.GetType().GetInterfaces().FirstOrDefault(o => !o.Name.Contains("IProtocol"));
- var WCS_D523IntefaceProperties = WCS_D523IntefaceType?.GetProperties();
- foreach (PropertyInfo pi in obj.D523?.GetType()?.GetProperties())
- {
- string describle = string.Empty;
- if (WCS_D523IntefaceProperties != null)
- {
- foreach (PropertyInfo intefacePropertyInfo in WCS_D523IntefaceProperties)
- {
- if (pi.Name == intefacePropertyInfo.Name)
- {
- var descriptionAttribute = intefacePropertyInfo.GetCustomAttribute<DescriptionAttribute>();
- if (descriptionAttribute != null)
- {
- describle = descriptionAttribute.Description;
- }
- break;
- }
- }
- }
- string proname = "DB523_" + pi.Name;
- var abc = pi.GetValue(obj.D523, null);
- if (abc == null) continue;
- list.Add(new DBData { Name = proname, Desc = describle, Value = abc.ToString() });
- }
- dBDetail.DBName.Add("DB523");
- dBDetail.DBDatas.Add("DB523", list);
- }
- return dBDetail;
- }
- }
- }
|