200 lines
5.8 KiB
C#
200 lines
5.8 KiB
C#
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<PipeDiameterOfThickness> BoreList { get; set; }
|
|
|
|
public DataStorage()
|
|
{
|
|
strType = string.Empty;
|
|
strLaggingType = string.Empty;
|
|
dblLaggingThickness = 20.0;
|
|
bisNew = false;
|
|
BoreList = new List<PipeDiameterOfThickness>();
|
|
}
|
|
public DataStorage(string Type, string laggingType, double laggingThickness,bool isNew)
|
|
{
|
|
strType = Type;
|
|
strLaggingType = laggingType;
|
|
dblLaggingThickness = laggingThickness;
|
|
bisNew = isNew;
|
|
BoreList = new List<PipeDiameterOfThickness>();
|
|
}
|
|
|
|
}
|
|
[XmlInclude(typeof(DataStorage))]
|
|
public class TblDataStorage
|
|
{
|
|
[XmlArray(ElementName = "DataStorage_List")]
|
|
[XmlArrayItem(ElementName = "DataStorage")]
|
|
public Dictionary<string, Dictionary<string, List<DataStorage>>> m_table = null;
|
|
public TblDataStorage()
|
|
{
|
|
m_table = new Dictionary<string, Dictionary<string, List<DataStorage>>>();
|
|
}
|
|
public void AddCategory(string strName)
|
|
{
|
|
m_table.Add(strName, new Dictionary<string, List<DataStorage>>());
|
|
m_table[strName].Add("pipe", new List<DataStorage>());
|
|
m_table[strName].Add("duct", new List<DataStorage>());
|
|
}
|
|
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<string, Dictionary<string, List<DataStorage>>> GetTable()
|
|
{
|
|
return m_table;
|
|
}
|
|
|
|
public List<DataStorage> 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<Dictionary<string, Dictionary<string, List<DataStorage>>>>(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<InsulationType> m_table = null;
|
|
public TblInsulationType()
|
|
{
|
|
m_table = new List<InsulationType>();
|
|
}
|
|
public void Add(string strType)
|
|
{
|
|
m_table.Add(new InsulationType(idx, strType));
|
|
idx++;
|
|
}
|
|
public void Remove(string pipeType)
|
|
{
|
|
//m_table.Remove();
|
|
}
|
|
|
|
public List<InsulationType> 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<PipeDiameterOfThickness> m_table = null;
|
|
public TblPipeDiameterOfThickness()
|
|
{
|
|
m_table = new List<PipeDiameterOfThickness>();
|
|
}
|
|
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<PipeDiameterOfThickness> GetTable()
|
|
{
|
|
return m_table;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|