SOCScoreServices.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.DataLogic.DQPSystem;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.ViewModel.DQPSystem;
  10. using EMIS.ViewModel;
  11. using EMIS.Entities;
  12. using EMIS.CommonLogic.SystemServices;
  13. using EMIS.ViewModel.ScoreManage;
  14. using EMIS.DataLogic.ScoreManage;
  15. namespace EMIS.CommonLogic.DQPSystem
  16. {
  17. public class SOCScoreServices : BaseServices, ISOCScoreServices
  18. {
  19. public SOCScoreDAL SOCScoreDAL { get; set; }
  20. public Lazy<IRoleServices> RoleServices { get; set; }
  21. public FinalExaminationDAL FinalExaminationDAL { get; set; }
  22. public IGridResultSet<SOCCourseScoreView> GetSOCCourseScoreViewList(ConfiguretView courseScoreConditionView, Guid? schoolyearID, Guid? collegeID,
  23. int? year, int? standardID, Guid? classmajorID, Guid? coursematerialID, int? pageIndex, int? pageSize)
  24. {
  25. Expression<Func<DQP_SOC, bool>> socExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  26. Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
  27. Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
  28. Expression<Func<CF_Classmajor, bool>> classExp = (x => true);
  29. Expression<Func<DQP_SOCDetail, bool>> detailExp = (x => true);
  30. if (schoolyearID.HasValue)
  31. {
  32. socExp = socExp.And(x => x.SchoolyearID == schoolyearID);
  33. }
  34. if (collegeID.HasValue)
  35. {
  36. facultyExp = facultyExp.And(x => x.CollegeID == collegeID);
  37. }
  38. if (year.HasValue)
  39. {
  40. gradeExp = gradeExp.And(x => x.GradeID == year);
  41. }
  42. if (standardID.HasValue)
  43. {
  44. facultyExp = facultyExp.And(x => x.StandardID == standardID);
  45. }
  46. if (classmajorID.HasValue)
  47. {
  48. classExp = classExp.And(x => x.ClassmajorID == classmajorID);
  49. }
  50. if (coursematerialID.HasValue)
  51. {
  52. socExp = socExp.And(x => x.CoursematerialID == coursematerialID);
  53. }
  54. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  55. var role = RoleServices.Value.GetEnabledTeacherRoleViewList();
  56. var teacherRole = role.Where(x => x.RoleName == "教师");
  57. if (curUser.RoleID == teacherRole.FirstOrDefault().RoleID)
  58. {
  59. detailExp = detailExp.And(x => x.CreateUserID == curUser.UserID);
  60. }
  61. var query = SOCScoreDAL.GetSOCCourseScoreViewQueryable(socExp, detailExp, facultyExp, gradeExp, classExp);
  62. if (!string.IsNullOrEmpty(courseScoreConditionView.ConditionValue) && !string.IsNullOrEmpty(courseScoreConditionView.Attribute))
  63. query = query.DynamicWhere(courseScoreConditionView.Attribute, courseScoreConditionView.Condition, courseScoreConditionView.ConditionValue);
  64. query = this.GetQueryByDataRangeByCollege(query);
  65. query = query.OrderByDescending(x => x.SchoolyearCode)
  66. .ThenBy(x => x.CourseCode)
  67. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  68. .ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
  69. .ThenBy(x => x.LoginID)
  70. .ThenBy(x => x.CourseCode);
  71. return query.ToGridResultSet(pageIndex, pageSize);
  72. }
  73. public List<SOCCourseScoreView> GetSOCCourseScoreViewList(ConfiguretView courseScoreConditionView, Guid? schoolyearID, Guid? collegeID,
  74. int? year, int? standardID, Guid? classmajorID, Guid? coursematerialID)
  75. {
  76. Expression<Func<DQP_SOC, bool>> socExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  77. Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
  78. Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
  79. Expression<Func<CF_Classmajor, bool>> classExp = (x => true);
  80. Expression<Func<DQP_SOCDetail, bool>> detailExp = (x => true);
  81. if (schoolyearID.HasValue)
  82. {
  83. socExp = socExp.And(x => x.SchoolyearID == schoolyearID);
  84. }
  85. if (collegeID.HasValue)
  86. {
  87. facultyExp = facultyExp.And(x => x.CollegeID == collegeID);
  88. }
  89. if (year.HasValue)
  90. {
  91. gradeExp = gradeExp.And(x => x.GradeID == year);
  92. }
  93. if (standardID.HasValue)
  94. {
  95. facultyExp = facultyExp.And(x => x.StandardID == standardID);
  96. }
  97. if (classmajorID.HasValue)
  98. {
  99. classExp = classExp.And(x => x.ClassmajorID == classmajorID);
  100. }
  101. if (coursematerialID.HasValue)
  102. {
  103. socExp = socExp.And(x => x.CoursematerialID == coursematerialID);
  104. }
  105. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  106. var role = RoleServices.Value.GetEnabledTeacherRoleViewList();
  107. var teacherRole = role.Where(x => x.RoleName == "教师");
  108. if (curUser.RoleID == teacherRole.FirstOrDefault().RoleID)
  109. {
  110. detailExp = detailExp.And(x => x.CreateUserID == curUser.UserID);
  111. }
  112. var query = SOCScoreDAL.GetSOCCourseScoreViewQueryable(socExp, detailExp, facultyExp, gradeExp, classExp);
  113. if (!string.IsNullOrEmpty(courseScoreConditionView.ConditionValue) && !string.IsNullOrEmpty(courseScoreConditionView.Attribute))
  114. query = query.DynamicWhere(courseScoreConditionView.Attribute, courseScoreConditionView.Condition, courseScoreConditionView.ConditionValue);
  115. query = this.GetQueryByDataRangeByCollege(query);
  116. query = query.OrderByDescending(x => x.SchoolyearCode)
  117. .ThenBy(x => x.CourseCode)
  118. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  119. .ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
  120. .ThenBy(x => x.LoginID)
  121. .ThenBy(x => x.CourseCode);
  122. return query.ToList();
  123. }
  124. public List<SOCCourseScoreView> GetScoreBySOCScore(Guid? finalExaminationID)
  125. {
  126. Expression<Func<DQP_SOC, bool>> socExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  127. Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
  128. Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
  129. Expression<Func<CF_Classmajor, bool>> classExp = (x => true);
  130. Expression<Func<DQP_SOCDetail, bool>> detailExp = (x => true);
  131. var final = FinalExaminationDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationID, (x => x.ER_FinalExaminationStudent));
  132. if (final != null)
  133. {
  134. socExp = socExp.And(x => x.SchoolyearID == final.SchoolyearID);
  135. socExp = socExp.And(x => x.CoursematerialID == final.CoursematerialID);
  136. socExp = socExp.And(x => x.DepartmentID == final.DepartmentID);
  137. if (final.HandleModeID.HasValue)
  138. {
  139. socExp = socExp.And(x => x.HandleModeID == final.HandleModeID);
  140. }
  141. //socExp = socExp.And(x => x.OptionalCourseTypeID == final);
  142. var query = SOCScoreDAL.GetSOCCourseScoreViewQueryable(socExp, detailExp, facultyExp, gradeExp, classExp);
  143. var studentIDList = final.ER_FinalExaminationStudent.Select(x => x.UserID).ToList();
  144. query = query.Where(x => studentIDList.Contains(x.UserID) && x.TotalScore != null);
  145. return query.ToList();
  146. }
  147. else
  148. {
  149. return new List<SOCCourseScoreView>();
  150. }
  151. }
  152. }
  153. }