ClassroomScheduleSettingServices.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.Entities;
  6. using System.Linq.Expressions;
  7. using Bowin.Common.Linq.Entity;
  8. using Bowin.Common.Linq;
  9. using EMIS.DataLogic.SchedulingManage.SchedulingSettings;
  10. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  11. using EMIS.CommonLogic.CalendarManage;
  12. using EMIS.ViewModel.CalendarManage;
  13. using EMIS.ViewModel.UniversityManage.ClassroomManage;
  14. namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings
  15. {
  16. public class ClassroomScheduleSettingServices : BaseServices, IClassroomScheduleSettingServices
  17. {
  18. public ClassroomScheduleSettingDAL classroomScheduleSettingDAL { get; set; }
  19. public IArrangementServices arrangementServices { get; set; }
  20. public ClassroomReserveDAL classroomReserveDAL { get; set; }
  21. /// <summary>
  22. /// 查询
  23. /// </summary>
  24. /// <param name="classroomID"></param>
  25. /// <param name="collegeID"></param>
  26. /// <param name="titleID"></param>
  27. /// <param name="pageIndex"></param>
  28. /// <param name="pageSize"></param>
  29. /// <returns></returns>
  30. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.SchedulingManage.SchedulingSettings.ClassroomScheduleSettingView> GetClassroomScheduleSettingViewGrid(Guid? classroomID, Guid? collegeID, int? classroomTypeID, int pageIndex, int pageSize)
  31. {
  32. Expression<Func<CF_Classroom, bool>> exp = (x => true);
  33. if (classroomID.HasValue)
  34. exp = exp.And(x => x.ClassroomID == classroomID);
  35. if (collegeID.HasValue)
  36. exp = exp.And(x => x.CollegeID == collegeID);
  37. if (classroomTypeID.HasValue)
  38. exp = exp.And(x => x.CF_ClassroomType.Select(y => y.ClassroomType).Contains(classroomTypeID));
  39. var query = classroomScheduleSettingDAL.GetClassroomScheduleSettingViewQueryable(exp);
  40. var resultSet = query.OrderByDescending(x => x.CreateTime).ToGridResultSet<ClassroomScheduleSettingView>(pageIndex, pageSize);
  41. var classroomIDList = resultSet.rows.Select(x => x.ClassroomID).ToList();
  42. var queryClassroomTyoeView = classroomReserveDAL.GetClassroomTypeViewQueryable().Where(x => classroomIDList.Contains(x.ClassroomID)).ToList();
  43. resultSet.rows.ForEach(x => x.ClassroomTypes = new HashSet<ClassroomTypeView>(queryClassroomTyoeView.Where(y => y.ClassroomID == x.ClassroomID)));
  44. return resultSet;
  45. }
  46. /// <summary>
  47. /// 查询
  48. /// </summary>
  49. /// <param name="userID"></param>
  50. /// <returns></returns>
  51. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.CalendarManage.ArrangementView> GetArrangementViewGrid(Guid? classroomID)
  52. {
  53. var resultSet = classroomScheduleSettingDAL.GetArrangementViewQueryable(classroomID).OrderBy(x => x.StartTimes).ToGridResultSet<ArrangementView>();
  54. if (resultSet.total > 0)
  55. {
  56. return resultSet;
  57. }
  58. return arrangementServices.GetArrangementViewGrid();
  59. }
  60. /// <summary>
  61. /// 新增
  62. /// </summary>
  63. /// <param name="listArrangement"></param>
  64. public void ClassroomScheduleSettingAdd(List<ViewModel.CalendarManage.ArrangementView> listArrangement, Guid? classroomID)
  65. {
  66. try
  67. {
  68. UnitOfWork.Delete<ES_ClassroomScheduleSetting>(x => x.ClassroomID == classroomID);
  69. foreach (var arrangementView in listArrangement)
  70. {
  71. bool? IsOnWork = false;
  72. for (int i = 0; i < 7; i++)
  73. {
  74. if (i == (int)DayOfWeek.Monday)
  75. IsOnWork = arrangementView.MondayIsOnWork;
  76. if (i == (int)DayOfWeek.Tuesday)
  77. IsOnWork = arrangementView.TuesdayIsOnWork;
  78. if (i == (int)DayOfWeek.Wednesday)
  79. IsOnWork = arrangementView.WednesdayIsOnWork;
  80. if (i == (int)DayOfWeek.Thursday)
  81. IsOnWork = arrangementView.ThursdayIsOnWork;
  82. if (i == (int)DayOfWeek.Friday)
  83. IsOnWork = arrangementView.FridayIsOnWork;
  84. if (i == (int)DayOfWeek.Saturday)
  85. IsOnWork = arrangementView.SaturdayIsOnWork;
  86. if (i == (int)DayOfWeek.Sunday)
  87. IsOnWork = arrangementView.SundayIsOnWork;
  88. ES_ClassroomScheduleSetting classroomScheduleSetting = new ES_ClassroomScheduleSetting();
  89. classroomScheduleSetting.ClassroomScheduleSettingID = Guid.NewGuid();
  90. classroomScheduleSetting.ClassroomID = classroomID;
  91. classroomScheduleSetting.CoursesTimeID = arrangementView.CoursesTimeID;
  92. classroomScheduleSetting.Weekday = i;
  93. classroomScheduleSetting.IsOnWork = IsOnWork;
  94. SetNewStatus(classroomScheduleSetting);
  95. UnitOfWork.Add(classroomScheduleSetting);
  96. }
  97. }
  98. UnitOfWork.Commit();
  99. }
  100. catch (Exception)
  101. {
  102. throw;
  103. }
  104. }
  105. /// <summary>
  106. /// 删除
  107. /// </summary>
  108. /// <param name="userIDs"></param>
  109. public void ClassroomScheduleSettingDelete(List<Guid?> classroomIDs)
  110. {
  111. try
  112. {
  113. UnitOfWork.Delete<ES_ClassroomScheduleSetting>(x => classroomIDs.Contains(x.ClassroomID));
  114. }
  115. catch (Exception)
  116. {
  117. throw;
  118. }
  119. }
  120. }
  121. }