using KMBIM.Revit.Tools.Cmd.Insulation; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization.Json; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; namespace KMBIM.Revit.Tools.LogicClass { public class DataStorage { public string strType { get; set; } public string strLaggingType { get; set; } public double dblLaggingThickness { get; set; } [JsonIgnore] public bool bisNew { get; set; } public List BoreList { get; set; } public DataStorage() { strType = string.Empty; strLaggingType = string.Empty; dblLaggingThickness = 20.0; bisNew = false; BoreList = new List(); } public DataStorage(string Type, string laggingType, double laggingThickness,bool isNew) { strType = Type; strLaggingType = laggingType; dblLaggingThickness = laggingThickness; bisNew = isNew; BoreList = new List(); } } [XmlInclude(typeof(DataStorage))] public class TblDataStorage { [XmlArray(ElementName = "DataStorage_List")] [XmlArrayItem(ElementName = "DataStorage")] public Dictionary>> m_table = null; public TblDataStorage() { m_table = new Dictionary>>(); } public void AddCategory(string strName) { m_table.Add(strName, new Dictionary>()); m_table[strName].Add("pipe", new List()); m_table[strName].Add("duct", new List()); } public void Add(string strCategoryName,bool bisPipe,string pipeType, string laggingType, double laggingThickness, bool isNew = false) { if (bisPipe) { m_table[strCategoryName]["pipe"].Add(new DataStorage(pipeType, laggingType, laggingThickness, isNew)); } else { m_table[strCategoryName]["duct"].Add(new DataStorage(pipeType, laggingType, laggingThickness, isNew)); } } public DataStorage Find(string strCategoryName, bool bisPipe, string Type) { if (bisPipe) return m_table[strCategoryName]["pipe"].Find(x => x.strType == Type); else return m_table[strCategoryName]["duct"].Find(x => x.strType == Type); return null; } public void Remove(string strCategoryName) { m_table.Remove(strCategoryName); } public void Remove (string strCategoryName, bool bisPipe, string Type) { if (bisPipe) m_table[strCategoryName]["pipe"].Remove(m_table[strCategoryName]["pipe"].Find(x => x.strType == Type)); else m_table[strCategoryName]["duct"].Remove(m_table[strCategoryName]["duct"].Find(x => x.strType == Type)); } public Dictionary>> GetTable() { return m_table; } public List GetTable(string strCategoryName, bool bisPipe) { if (bisPipe) return m_table[strCategoryName]["pipe"]; else return m_table[strCategoryName]["duct"]; return null; } public string toJson() { return JsonConvert.SerializeObject(m_table); } public void LoadJson(string json) { m_table = JsonConvert.DeserializeObject>>>(json); } } public class InsulationType { public int index { get; set; } public string strType { get; set; } public InsulationType() { index = 0; strType = string.Empty; } public InsulationType(int idx ,string Type) { index = idx; strType = Type; } } public class TblInsulationType { int idx = 0; private List m_table = null; public TblInsulationType() { m_table = new List(); } public void Add(string strType) { m_table.Add(new InsulationType(idx, strType)); idx++; } public void Remove(string pipeType) { //m_table.Remove(); } public List GetTable() { return m_table; } } public class PipeDiameterOfThickness { public int nDiameter { get; set; } public double dblThickness { get; set; } public PipeDiameterOfThickness() { nDiameter = 0; dblThickness = 0; } public PipeDiameterOfThickness(int ndia, int thick) { nDiameter = ndia; dblThickness = thick; } } public class TblPipeDiameterOfThickness { int idx = 0; private List m_table = null; public TblPipeDiameterOfThickness() { m_table = new List(); } public void Add(int dia , int thick) { m_table.Add(new PipeDiameterOfThickness(dia, thick)); idx++; } public void Remove(string pipeType) { //m_table.Remove(); } public List GetTable() { return m_table; } } }