mic_script_step_param_BLL.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using PaintDotNet.DbOpreate.DbDalFactory;
  2. using PaintDotNet.DbOpreate.DbIDal;
  3. using PaintDotNet.DbOpreate.DbModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PaintDotNet.DbOpreate.DbBll
  10. {
  11. public class mic_script_step_param_BLL
  12. {
  13. private static Imic_script_step_param mic_script_step_param_BL = DataAccess.Createmic_script_step_param();
  14. #region 基础功能
  15. /// <summary>
  16. /// 添加信息
  17. /// <param name="model">实体</param>
  18. /// </summary>
  19. /// <returns></returns>
  20. public static bool Add(mic_script_step_param model)
  21. {
  22. return mic_script_step_param_BL.Add(model);
  23. }
  24. /// <summary>
  25. /// 删除信息
  26. /// <param name="id">主键</param>
  27. /// </summary>
  28. /// <returns></returns>
  29. public static bool Del(int id)
  30. {
  31. return mic_script_step_param_BL.Del(id);
  32. }
  33. /// <summary>
  34. /// 获得信息
  35. /// <param name="id">主键</param>
  36. /// </summary>
  37. /// <returns></returns>
  38. public static mic_script_step_param FindDefault(int id)
  39. {
  40. return mic_script_step_param_BL.FindDefault(id);
  41. }
  42. /// <summary>
  43. /// 更新信息
  44. /// <param name="model">实体</param>
  45. /// </summary>
  46. /// <returns></returns>
  47. public static bool Update(mic_script_step_param model)
  48. {
  49. return mic_script_step_param_BL.Update(model);
  50. }
  51. /// <summary>
  52. /// 获得所有信息
  53. /// </summary>
  54. /// <returns></returns>
  55. public static List<mic_script_step_param> FindAll()
  56. {
  57. return mic_script_step_param_BL.FindAll();
  58. }
  59. #endregion 基础功能
  60. #region 扩展接口
  61. /// <summary>
  62. /// 根据脚本id查询所有参数
  63. /// </summary>
  64. /// <param name="script_id"></param>
  65. /// <returns></returns>
  66. public static List<mic_script_step_param> FindAllByScriptId(int script_id)
  67. {
  68. List<mic_script_step_param> lst = mic_script_step_param_BL.FindAllByScriptId(script_id);
  69. //格式化数据库的数据到应用内参数格式
  70. foreach (mic_script_step_param item in lst)
  71. {
  72. if (item.param_type == (int)Base.Dtryt.Choise)
  73. {
  74. int valueC;
  75. if (int.TryParse(item.param_value.ToString(), out valueC))
  76. item.value = valueC;
  77. else if (item.param_value.ToString() != "")//适配晶粒度-选择辅助线
  78. item.value = item.param_value.ToString();
  79. else
  80. item.value = 1;
  81. }
  82. if (item.param_type == (int)Base.Dtryt.Interger)
  83. {
  84. int valueC;
  85. if (int.TryParse(item.param_value.ToString(), out valueC))
  86. item.value = valueC;
  87. else
  88. item.value = 0;
  89. }
  90. else if (item.param_type == (int)Base.Dtryt.Array)
  91. {
  92. int valueC;
  93. if (int.TryParse(item.param_value.ToString(), out valueC))
  94. item.value = valueC;
  95. else
  96. item.value = 0;
  97. }
  98. else if (item.param_type == (int)Base.Dtryt.Boolean)
  99. {
  100. bool valueC;
  101. if (Boolean.TryParse(item.param_value.ToString(), out valueC))
  102. item.value = valueC;
  103. else
  104. item.value = item.param_value.ToString().Equals("0");
  105. }
  106. else if (item.param_type == (int)Base.Dtryt.DecimalScope)
  107. {
  108. string[] valuelst = item.param_value.Split(',');
  109. List<double> listV = new List<double>();
  110. foreach (string str in valuelst)
  111. {
  112. double outV;
  113. if (double.TryParse(str, out outV))
  114. listV.Add(outV);
  115. else
  116. listV.Add(0);
  117. }
  118. item.value = listV;
  119. }
  120. else if (item.param_type == (int)Base.Dtryt.Color)
  121. {
  122. int valueC;
  123. if (int.TryParse(item.param_value.ToString(), out valueC))
  124. item.value = valueC;
  125. else
  126. item.value = -65536;
  127. }
  128. }
  129. return lst;
  130. }
  131. #endregion 扩展接口
  132. }
  133. }