DalInfoCode.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* ==============================================================================
  2. * 功能描述:组件编码
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/1/17 10:11:41
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using SAGA.DotNetUtils.Serializer;
  12. using SAGA.MBI.Common;
  13. using SAGA.MBI.FileStream;
  14. using SAGA.MBI.Model;
  15. namespace SAGA.MBI.DataArrange
  16. {
  17. /// <summary>
  18. /// DalEquipCode
  19. /// </summary>
  20. class DalInfoCode
  21. {
  22. /// <summary>
  23. /// 初始化组件对照表
  24. /// </summary>
  25. public static void Init()
  26. {
  27. var codes=new List<ComponentCodeToInputType>();
  28. codes.Add(new ComponentCodeToInputType(){ComponentCode = "A1",InputType = "TextBox_Double_A1" });
  29. codes.Add(new ComponentCodeToInputType() { ComponentCode = "A2", InputType = "Textbox_DoubleUnit_A2" });
  30. codes.Add(new ComponentCodeToInputType() { ComponentCode = "B1", InputType = "TextBox_String_B1" });
  31. codes.Add(new ComponentCodeToInputType() { ComponentCode = "C5", InputType = "DataTime_Date_C5" });
  32. codes.Add(new ComponentCodeToInputType() { ComponentCode = "D1", InputType = "Enum_D1" });
  33. string path = MBIConst.MBIDataDictionaryPath;
  34. string fileName = "ComponentCodeToInputType.xml";
  35. SerializerByXml.SerializeAndSave(path, fileName, codes);
  36. }
  37. /// <summary>
  38. /// 读取组件对照表
  39. /// </summary>
  40. /// <returns></returns>
  41. [CacheAspect]
  42. public static List<ComponentCodeToInputType> Read()
  43. {
  44. string path = MBIConst.MBIDataDictionaryPath;
  45. string fileName = "ComponentCodeToInputType.xml";
  46. return SerializerByXml.DeserializeList<ComponentCodeToInputType>(path, fileName);
  47. }
  48. /// <summary>
  49. /// 由组件编码获取Revit输入类型
  50. /// </summary>
  51. /// <param name="componentCode"></param>
  52. /// <returns></returns>
  53. public static string GetInputType(string componentCode)
  54. {
  55. var codes = Read();
  56. var item = codes.FirstOrDefault(t => t.ComponentCode == componentCode);
  57. return item?.InputType;
  58. }
  59. }
  60. }