RoadFlow2.1 临时演示

WorkFlowButtons.cs 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Linq;
  5. namespace RoadFlow.Platform
  6. {
  7. public class WorkFlowButtons
  8. {
  9. private RoadFlow.Data.Interface.IWorkFlowButtons dataWorkFlowButtons;
  10. public WorkFlowButtons()
  11. {
  12. this.dataWorkFlowButtons = Data.Factory.Factory.GetWorkFlowButtons();
  13. }
  14. /// <summary>
  15. /// 新增
  16. /// </summary>
  17. public int Add(RoadFlow.Data.Model.WorkFlowButtons model)
  18. {
  19. return dataWorkFlowButtons.Add(model);
  20. }
  21. /// <summary>
  22. /// 更新
  23. /// </summary>
  24. public int Update(RoadFlow.Data.Model.WorkFlowButtons model)
  25. {
  26. return dataWorkFlowButtons.Update(model);
  27. }
  28. /// <summary>
  29. /// 查询所有记录
  30. /// </summary>
  31. /// <param name="fromCache">是否从缓存获取</param>
  32. /// <returns></returns>
  33. public List<RoadFlow.Data.Model.WorkFlowButtons> GetAll(bool fromCache=false)
  34. {
  35. if (fromCache)
  36. {
  37. string key = RoadFlow.Utility.Keys.CacheKeys.WorkFlowButtons.ToString();
  38. object obj = RoadFlow.Cache.IO.Opation.Get(key);
  39. if (obj != null && obj is List<RoadFlow.Data.Model.WorkFlowButtons>)
  40. {
  41. return obj as List<RoadFlow.Data.Model.WorkFlowButtons>;
  42. }
  43. else
  44. {
  45. var list = dataWorkFlowButtons.GetAll();
  46. RoadFlow.Cache.IO.Opation.Set(key, list);
  47. return list;
  48. }
  49. }
  50. else
  51. {
  52. return dataWorkFlowButtons.GetAll();
  53. }
  54. }
  55. /// <summary>
  56. /// 查询单条记录
  57. /// </summary>
  58. public RoadFlow.Data.Model.WorkFlowButtons Get(Guid id, bool fromCache=false)
  59. {
  60. if (fromCache)
  61. {
  62. var all = GetAll(true);
  63. var button = all.Find(p => p.ID == id);
  64. return button == null ? dataWorkFlowButtons.Get(id) : button;
  65. }
  66. else
  67. {
  68. return dataWorkFlowButtons.Get(id);
  69. }
  70. }
  71. /// <summary>
  72. /// 删除
  73. /// </summary>
  74. public int Delete(Guid id)
  75. {
  76. return dataWorkFlowButtons.Delete(id);
  77. }
  78. /// <summary>
  79. /// 查询记录条数
  80. /// </summary>
  81. public long GetCount()
  82. {
  83. return dataWorkFlowButtons.GetCount();
  84. }
  85. /// <summary>
  86. /// 清除缓存
  87. /// </summary>
  88. public void ClearCache()
  89. {
  90. string key = RoadFlow.Utility.Keys.CacheKeys.WorkFlowButtons.ToString();
  91. RoadFlow.Cache.IO.Opation.Remove(key);
  92. }
  93. /// <summary>
  94. /// 查询最大排序
  95. /// </summary>
  96. public int GetMaxSort()
  97. {
  98. return dataWorkFlowButtons.GetMaxSort();
  99. }
  100. }
  101. }