ChangeReportServices.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using System.Transactions;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.StudentManage.StudentChange;
  12. using EMIS.DataLogic.StudentManage.StudentChange;
  13. namespace EMIS.CommonLogic.StudentManage.StudentChange
  14. {
  15. public class ChangeReportServices : BaseServices, IChangeReportServices
  16. {
  17. public ChangeReportDAL ChangeReportDAL { get; set; }
  18. /// <summary>
  19. /// 查询对应的异动报表信息ChangeReportView
  20. /// </summary>
  21. /// <param name="configuretView"></param>
  22. /// <param name="pageIndex"></param>
  23. /// <param name="pageSize"></param>
  24. /// <returns></returns>
  25. public IGridResultSet<ChangeReportView> GetChangeReportViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
  26. {
  27. Expression<Func<CF_DifferentDynamicReport, bool>> exp = (x => true);
  28. var query = ChangeReportDAL.GetChangeReportViewQueryable(exp);
  29. //查询条件
  30. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  31. {
  32. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  33. }
  34. return query.OrderBy(x => x.Code).ToGridResultSet<ChangeReportView>(pageIndex, pageSize);
  35. }
  36. /// <summary>
  37. /// 查询对应的异动报表信息List
  38. /// </summary>
  39. /// <param name="configuretView"></param>
  40. /// <returns></returns>
  41. public IList<ChangeReportView> GetChangeReportViewList(ConfiguretView configuretView)
  42. {
  43. Expression<Func<CF_DifferentDynamicReport, bool>> exp = (x => true);
  44. var query = ChangeReportDAL.GetChangeReportViewQueryable(exp);
  45. //查询条件
  46. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  47. {
  48. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  49. }
  50. return query.OrderBy(x => x.Code).ToList();
  51. }
  52. /// <summary>
  53. /// 查询对应的异动报表信息ChangeReportView(根据异动报表ID)
  54. /// </summary>
  55. /// <param name="changeReportID"></param>
  56. /// <returns></returns>
  57. public ChangeReportView GetChangeReportView(Guid? changeReportID)
  58. {
  59. try
  60. {
  61. var changeReportView = ChangeReportDAL.GetChangeReportViewQueryable(x => x.ChangeReportID == changeReportID).SingleOrDefault();
  62. return changeReportView;
  63. }
  64. catch (Exception ex)
  65. {
  66. throw new Exception(ex.Message);
  67. }
  68. }
  69. /// <summary>
  70. /// 编辑(新增、修改)
  71. /// </summary>
  72. /// <param name="changeReportView"></param>
  73. public void ChangeReportEdit(ChangeReportView changeReportView)
  74. {
  75. try
  76. {
  77. var changeReportVerify = ChangeReportDAL.ChangeReportRepository.GetList(x => x.ChangeReportID != changeReportView.ChangeReportID
  78. && (x.Code == changeReportView.Code || x.Name == changeReportView.Name)).FirstOrDefault();
  79. if (changeReportVerify == null)
  80. {
  81. if (changeReportView.ChangeReportID != Guid.Empty)
  82. {
  83. var changeReport = ChangeReportDAL.ChangeReportRepository.GetList(x => x.ChangeReportID == changeReportView.ChangeReportID).SingleOrDefault();
  84. if (changeReport == null)
  85. {
  86. throw new Exception("数据有误,请核查。");
  87. }
  88. else
  89. {
  90. changeReport.Code = changeReportView.Code;
  91. changeReport.Name = changeReportView.Name;
  92. changeReport.Url = changeReportView.Url;
  93. }
  94. }
  95. else
  96. {
  97. var newChangeReport = new CF_DifferentDynamicReport();
  98. newChangeReport.ChangeReportID = Guid.NewGuid();
  99. newChangeReport.Code = changeReportView.Code;
  100. newChangeReport.Name = changeReportView.Name;
  101. newChangeReport.Url = changeReportView.Url;
  102. UnitOfWork.Add(newChangeReport);
  103. }
  104. }
  105. else
  106. {
  107. throw new Exception("已存在相同的异动报表(报表代码或报表名称唯一),请核查。");
  108. }
  109. UnitOfWork.Commit();
  110. }
  111. catch (Exception ex)
  112. {
  113. throw new Exception(ex.Message);
  114. }
  115. }
  116. /// <summary>
  117. /// 删除
  118. /// </summary>
  119. /// <param name="changeReportIDs"></param>
  120. /// <returns></returns>
  121. public bool ChangeReportDelete(List<Guid?> changeReportIDs)
  122. {
  123. try
  124. {
  125. UnitOfWork.Delete<CF_DifferentDynamicReport>(x => changeReportIDs.Contains(x.ChangeReportID));
  126. return true;
  127. }
  128. catch (Exception)
  129. {
  130. throw;
  131. }
  132. }
  133. }
  134. }