SelectCourseListServices.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.EducationManage;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.DataLogic.SelectCourse.SelectCourseResult;
  8. using EMIS.DataLogic.SelectCourse;
  9. using EMIS.DataLogic.UniversityManage.SpecialtyClassManage;
  10. using System.Linq.Expressions;
  11. using EMIS.Entities;
  12. using Bowin.Common.Linq.Entity;
  13. using EMIS.ViewModel.SelectCourse.SelectCourseResult;
  14. using Bowin.Common.Linq;
  15. namespace EMIS.CommonLogic.SelectCourse.SelectCourseResult
  16. {
  17. public class SelectCourseListServices : BaseServices, ISelectCourseListServices
  18. {
  19. public EducationMissionClassDAL educationMissionClassDAL { get; set; }
  20. public MissionClassTeacherRepository missionClassTeacherRepository { get; set; }
  21. public SelectCourseResultDAL SelectCourseResultDAL { get; set; }
  22. public SelectCourseListDAL SelectCourseListDAL { get; set; }
  23. public OptionalCourseSettingDAL optionalCourseSettingDAL { get; set; }
  24. public ClassmajorDAL classmajorDAL { get; set; }
  25. public ExecutablePlanDAL ExecutablePlanDAL { get; set; }
  26. public OptionalCourseSettingDAL OptionalCourseSettingDAL { get; set; }
  27. public OpenControlSettingDAL OpenControlSettingDAL { get; set; }
  28. public ExecutableFreeSelectionCouseDAL ExecutableFreeSelectionCouseDAL { get; set; }
  29. public IStudentSelectCourseServices IStudentSelectCourseServices { get; set; }
  30. public IGridResultSet<SelectCourseListView> GetSelectCourseViewList
  31. (ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID,
  32. Guid? courseID, int? courseTypeID, int? selectCourseTypeID, int? isCreated, int? isOpened, int pageIndex, int pageSize)
  33. {
  34. Expression<Func<EM_ExecutableOptionalCourse, bool>> eocExp = (x => true);
  35. Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> efcExp = (x => true);
  36. var query = SelectCourseListDAL.GetSelectCourseListViewQueryable(eocExp, efcExp);
  37. //var query1 = SelectCourseResultDAL.GetSelectCourseResultTeacher(eocExp, efcExp);
  38. //var query2 = SelectCourseResultDAL.GetSelectCourseResultTeachingMode(eocExp, efcExp);
  39. if (schoolYearID.HasValue)
  40. {
  41. query = query.Where(x => x.SchoolyearID == schoolYearID);
  42. //query1 = query1.Where(x => x.SchoolyearID == schoolYearID);
  43. efcExp.And(x => x.SchoolyearID == schoolYearID);
  44. }
  45. if (collegeID.HasValue)
  46. {
  47. query = query.Where(x => x.CollegeID == collegeID);
  48. efcExp.And(x => x.CF_Department.CollegeID == collegeID);
  49. }
  50. if (courseID.HasValue)
  51. {
  52. query = query.Where(x => x.CoursematerialID == courseID);
  53. efcExp.And(x => x.EM_FreeSelectionCouse.CoursematerialID == courseID);
  54. }
  55. if (courseTypeID.HasValue)
  56. {
  57. query = query.Where(x => x.CourseTypeID == courseTypeID);
  58. //query1 = query1.Where(x => x.CourseTypeID == courseTypeID);
  59. efcExp.And(x => x.CourseTypeID == courseTypeID);
  60. }
  61. if (selectCourseTypeID.HasValue)
  62. {
  63. query = query.Where(x => x.SelectCourseType == selectCourseTypeID);
  64. //query1 = query1.Where(x => x.SelectCourseType == selectCourseTypeID);
  65. }
  66. if (isCreated.HasValue)
  67. {
  68. query = query.Where(x => x.RecordStatus == isCreated);
  69. efcExp.And(x => x.RecordStatus == isCreated);
  70. //if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes)
  71. // query = query.Where(x => x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
  72. //else if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsNo)
  73. // query = query.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
  74. }
  75. if (isOpened.HasValue)
  76. {
  77. query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
  78. //query1 = query1.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
  79. }
  80. //未提交状态不显示
  81. query = query.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
  82. //query1 = query1.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
  83. //query2 = query2.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
  84. //任选具体上课时间
  85. //var queryScheduling = SelectCourseListDAL.GetScheduling(efcExp).ToList();
  86. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  87. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  88. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SelectCourseType).ToGridResultSet<SelectCourseListView>(pageIndex, pageSize);
  89. //var teacher = query1.ToList().OrderBy(x => x.SelectCourseType);
  90. //var teachingMode = query2.ToList().OrderBy(x => x.SelectCourseType);
  91. //result.rows.ForEach(x => x.TeacherName = string.Join(",", teacher.Where(w => w.ID == x.ID).Select(w => w.TeacherName)));
  92. //if (queryScheduling.Count > 0)
  93. //{
  94. // var schedulingList = IStudentSelectCourseServices.GetWeekdayTimesSegmentName(queryScheduling);
  95. // result.rows.ForEach(x =>
  96. // {
  97. // var list = schedulingList.Where(w => w.ID == x.ID);
  98. // x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
  99. // });
  100. //}
  101. return result;
  102. }
  103. public List<SelectCourseListView> GetSelectCourseList
  104. (ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID,
  105. Guid? courseID, int? courseTypeID, int? selectCourseTypeID, int? isCreated, int? isOpened)
  106. {
  107. Expression<Func<EM_ExecutableOptionalCourse, bool>> eocExp = (x => true);
  108. Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> efcExp = (x => true);
  109. var query = SelectCourseListDAL.GetSelectCourseListViewQueryable(eocExp, efcExp);
  110. //var query1 = SelectCourseResultDAL.GetSelectCourseResultTeacher(eocExp, efcExp);
  111. if (schoolYearID.HasValue)
  112. {
  113. query = query.Where(x => x.SchoolyearID == schoolYearID);
  114. //query1 = query1.Where(x => x.SchoolyearID == schoolYearID);
  115. }
  116. if (collegeID.HasValue)
  117. {
  118. query = query.Where(x => x.CollegeID == collegeID);
  119. }
  120. if (courseID.HasValue)
  121. {
  122. query = query.Where(x => x.CoursematerialID == courseID);
  123. }
  124. if (courseTypeID.HasValue)
  125. {
  126. query = query.Where(x => x.CourseTypeID == courseTypeID);
  127. //query1 = query1.Where(x => x.CourseTypeID == courseTypeID);
  128. }
  129. if (selectCourseTypeID.HasValue)
  130. {
  131. query = query.Where(x => x.SelectCourseType == selectCourseTypeID);
  132. //query1 = query1.Where(x => x.SelectCourseType == selectCourseTypeID);
  133. }
  134. if (isCreated.HasValue)
  135. {
  136. query = query.Where(x => x.RecordStatus == isCreated);
  137. //if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes)
  138. // query = query.Where(x => x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
  139. //else if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsNo)
  140. // query = query.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
  141. }
  142. if (isOpened.HasValue)
  143. {
  144. query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
  145. //query1 = query1.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
  146. }
  147. //未提交状态不显示
  148. query = query.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
  149. //query1 = query1.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
  150. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  151. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  152. //var teacher = query1.ToList().OrderBy(x => x.SelectCourseType);
  153. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SelectCourseType).ToList();
  154. //result.ForEach(x => x.TeacherName = string.Join(",", teacher.Where(w => w.ID == x.ID).Select(w => w.TeacherName)));
  155. return result;
  156. }
  157. public bool SelectCourseListDelete(List<Guid?> IDs, List<int?> Types, List<Guid?> UserIDs)
  158. {
  159. try
  160. {
  161. if (IDs.Count > 0)
  162. {
  163. for (int i = 0; i < IDs.Count; i++)
  164. {
  165. if (Types[i] == 0)
  166. { //限选
  167. var id = IDs[i].Value;
  168. var UserID = UserIDs[i].Value;
  169. EM_ExecutableOptionalCourse ExecutableOptionalCourse = SelectCourseResultDAL.ExecutableOptionalCourseRepository.GetList(x => x.ExecutableOptionalCourseID == id, x => x.CF_Student).FirstOrDefault();
  170. ExecutableOptionalCourse.CF_Student.RemoveWhere(x => x.UserID == UserID);
  171. }
  172. else if (Types[i] == 1)
  173. { //任选
  174. var id = IDs[i].Value;
  175. var UserID = UserIDs[i].Value;
  176. EM_ExecutableFreeSelectionCouse ExecutableFreeSelectionCouse = SelectCourseResultDAL.ExecutableFreeSelectionCouseRepository.GetList(x => x.ExecutableFreeSelectionCouseID == id, x => x.CF_Student).FirstOrDefault();
  177. ExecutableFreeSelectionCouse.CF_Student.RemoveWhere(x => x.UserID == UserID);
  178. }
  179. }
  180. this.UnitOfWork.Commit();
  181. return true;
  182. }
  183. else
  184. throw new Exception("请选择要删除的学生信息");
  185. }
  186. catch (Exception ex)
  187. {
  188. throw new Exception(ex.Message);
  189. }
  190. }
  191. }
  192. }