ResitServices.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using Bowin.Common.Linq;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.ViewModel;
  9. using EMIS.ViewModel.ScoreManage;
  10. using EMIS.DataLogic.ScoreManage;
  11. using EMIS.Entities;
  12. namespace EMIS.CommonLogic.ScoreManage
  13. {
  14. public class ResitServices : BaseServices, IResitServices
  15. {
  16. public ResitDAL ResitDAL { get; set; }
  17. public IGridResultSet<ResitView> GetResitViewGrid(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID,
  18. Guid? examinationTypeID, Guid? examinationProjectID, int? examinationSubjectID, int? schoolAreaID, Guid? collegeID,
  19. int? yearID, int? standardID, Guid? classmajorID, int? pageIndex, int? pageSize)
  20. {
  21. Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
  22. Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
  23. Expression<Func<ER_ExaminationScore, bool>> scoreExp = (x => true);
  24. Expression<Func<CF_Facultymajor, bool>> facutyExp = (x => true);
  25. Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
  26. Expression<Func<CF_Student, bool>> studentExp = (x => true);
  27. if (schoolyearID.HasValue)
  28. {
  29. batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID);
  30. }
  31. if (examinationBatchID.HasValue)
  32. {
  33. batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID);
  34. }
  35. if (examinationTypeID.HasValue)
  36. {
  37. projectExp = projectExp.And(x => x.ExaminationTypeID == examinationTypeID);
  38. }
  39. if (examinationProjectID.HasValue)
  40. {
  41. projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID);
  42. }
  43. if (examinationSubjectID.HasValue)
  44. {
  45. scoreExp = scoreExp.And(x => x.ExaminationSubjectID == examinationSubjectID);
  46. }
  47. if (schoolAreaID.HasValue)
  48. {
  49. gradeExp = gradeExp.And(x => x.SchoolAreaID == schoolAreaID);
  50. }
  51. if (collegeID.HasValue)
  52. {
  53. facutyExp = facutyExp.And(x => x.CollegeID == collegeID);
  54. }
  55. if (yearID.HasValue)
  56. {
  57. gradeExp = gradeExp.And(x => x.SchoolyearID == yearID);
  58. }
  59. if (standardID.HasValue)
  60. {
  61. facutyExp = facutyExp.And(x => x.StandardID == standardID);
  62. }
  63. if (classmajorID.HasValue)
  64. {
  65. studentExp = studentExp.And(x => x.ClassmajorID == classmajorID);
  66. }
  67. var query = ResitDAL.GetResitViewQueryable(batchExp, projectExp, scoreExp, facutyExp, gradeExp, studentExp);
  68. if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
  69. {
  70. query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
  71. }
  72. var result = GetQueryByDataRangeByCollege(query);
  73. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(result)).OrderByDescending(x => x.SchoolyearCode)
  74. .ThenBy(x => x.ExaminationBatchName)
  75. .ThenBy(x => x.ExaminationTypeName)
  76. .ThenBy(x => x.ExaminationProjectName)
  77. .ThenBy(x => x.ClassmajorName)
  78. .ThenBy(x => x.ExaminationSubjectID)
  79. .ThenBy(x => x.UserName)
  80. .ToGridResultSet(pageIndex, pageSize);
  81. }
  82. public List<ResitView> GetResitViewList(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, int? examinationSubjectID, int? schoolAreaID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID)
  83. {
  84. Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
  85. Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
  86. Expression<Func<ER_ExaminationScore, bool>> scoreExp = (x => true);
  87. Expression<Func<CF_Facultymajor, bool>> facutyExp = (x => true);
  88. Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
  89. Expression<Func<CF_Student, bool>> studentExp = (x => true);
  90. if (schoolyearID.HasValue)
  91. {
  92. batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID);
  93. }
  94. if (examinationBatchID.HasValue)
  95. {
  96. batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID);
  97. }
  98. if (examinationTypeID.HasValue)
  99. {
  100. projectExp = projectExp.And(x => x.ExaminationTypeID == examinationTypeID);
  101. }
  102. if (examinationProjectID.HasValue)
  103. {
  104. projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID);
  105. }
  106. if (examinationSubjectID.HasValue)
  107. {
  108. scoreExp = scoreExp.And(x => x.ExaminationSubjectID == examinationSubjectID);
  109. }
  110. if (schoolAreaID.HasValue)
  111. {
  112. gradeExp = gradeExp.And(x => x.SchoolAreaID == schoolAreaID);
  113. }
  114. if (collegeID.HasValue)
  115. {
  116. facutyExp = facutyExp.And(x => x.CollegeID == collegeID);
  117. }
  118. if (yearID.HasValue)
  119. {
  120. gradeExp = gradeExp.And(x => x.SchoolyearID == yearID);
  121. }
  122. if (standardID.HasValue)
  123. {
  124. facutyExp = facutyExp.And(x => x.StandardID == standardID);
  125. }
  126. if (classmajorID.HasValue)
  127. {
  128. studentExp = studentExp.And(x => x.ClassmajorID == classmajorID);
  129. }
  130. var query = ResitDAL.GetResitViewQueryable(batchExp, projectExp, scoreExp, facutyExp, gradeExp, studentExp);
  131. if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
  132. {
  133. query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
  134. }
  135. var result = GetQueryByDataRangeByCollege(query);
  136. return result.OrderByDescending(x => x.SchoolyearCode)
  137. .ThenBy(x => x.ExaminationBatchName)
  138. .ThenBy(x => x.ExaminationTypeName)
  139. .ThenBy(x => x.ExaminationProjectName)
  140. .ThenBy(x => x.ClassmajorName)
  141. .ThenBy(x => x.ExaminationSubjectID)
  142. .ThenBy(x => x.UserName)
  143. .ToList();
  144. }
  145. }
  146. }