CourseScheduleSettingServices.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.SchedulingManage.SchedulingSettings;
  6. using EMIS.CommonLogic.CalendarManage;
  7. using EMIS.Entities;
  8. using System.Linq.Expressions;
  9. using Bowin.Common.Linq.Entity;
  10. using Bowin.Common.Linq;
  11. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  12. using EMIS.ViewModel.CalendarManage;
  13. using EMIS.DataLogic.Repositories;
  14. namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings
  15. {
  16. public class CourseScheduleSettingServices : BaseServices, ICourseScheduleSettingServices
  17. {
  18. public CourseScheduleSettingDAL courseScheduleSettingDAL { get; set; }
  19. public IArrangementServices arrangementServices { get; set; }
  20. /// <summary>
  21. /// 查询课程排课时间设置
  22. /// </summary>
  23. /// <param name="coursematerialID"></param>
  24. /// <param name="courseLevelID"></param>
  25. /// <param name="courseScienceID"></param>
  26. /// <param name="pageIndex"></param>
  27. /// <param name="pageSize"></param>
  28. /// <returns></returns>
  29. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.SchedulingManage.SchedulingSettings.CourseScheduleSettingView> GetCourseScheduleSettingViewGrid(Guid? coursematerialID, int? courseLevelID, int? courseScienceID, int pageIndex, int pageSize)
  30. {
  31. Expression<Func<EM_Coursematerial, bool>> exp = (x => true);
  32. if (coursematerialID.HasValue)
  33. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  34. if (courseLevelID.HasValue)
  35. exp = exp.And(x => x.CourseLevelID == courseLevelID);
  36. if (courseScienceID.HasValue)
  37. exp = exp.And(x => x.CourseScienceID == courseScienceID);
  38. var query = courseScheduleSettingDAL.GetCourseScheduleSettingViewQueryable(exp);
  39. return query.OrderByDescending(x => x.CreateTime).ToGridResultSet<CourseScheduleSettingView>(pageIndex, pageSize);
  40. }
  41. /// <summary>
  42. /// 查询
  43. /// </summary>
  44. /// <param name="coursematerialID"></param>
  45. /// <returns></returns>
  46. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.CalendarManage.ArrangementView> GetArrangementViewGrid(Guid? coursematerialID)
  47. {
  48. var resultSet = courseScheduleSettingDAL.GetArrangementViewQueryable(coursematerialID).OrderBy(x => x.StartTimes).ToGridResultSet<ArrangementView>();
  49. if (resultSet.total > 0)
  50. {
  51. return resultSet;
  52. }
  53. return arrangementServices.GetArrangementViewGrid();
  54. }
  55. /// <summary>
  56. /// 新增
  57. /// </summary>
  58. /// <param name="listArrangement"></param>
  59. public void CourseScheduleSettingAdd(List<ViewModel.CalendarManage.ArrangementView> listArrangement, Guid? coursematerialID)
  60. {
  61. try
  62. {
  63. UnitOfWork.Delete<ES_CourseScheduleSetting>(x => x.CoursematerialID == coursematerialID);
  64. foreach (var arrangementView in listArrangement)
  65. {
  66. bool? IsOnWork = false;
  67. for (int i = 0; i < 7; i++)
  68. {
  69. if (i == (int)DayOfWeek.Monday)
  70. IsOnWork = arrangementView.MondayIsOnWork;
  71. if (i == (int)DayOfWeek.Tuesday)
  72. IsOnWork = arrangementView.TuesdayIsOnWork;
  73. if (i == (int)DayOfWeek.Wednesday)
  74. IsOnWork = arrangementView.WednesdayIsOnWork;
  75. if (i == (int)DayOfWeek.Thursday)
  76. IsOnWork = arrangementView.ThursdayIsOnWork;
  77. if (i == (int)DayOfWeek.Friday)
  78. IsOnWork = arrangementView.FridayIsOnWork;
  79. if (i == (int)DayOfWeek.Saturday)
  80. IsOnWork = arrangementView.SaturdayIsOnWork;
  81. if (i == (int)DayOfWeek.Sunday)
  82. IsOnWork = arrangementView.SundayIsOnWork;
  83. ES_CourseScheduleSetting courseScheduleSetting = new ES_CourseScheduleSetting();
  84. courseScheduleSetting.CourseScheduleSettingID = Guid.NewGuid();
  85. courseScheduleSetting.CoursematerialID = coursematerialID;
  86. courseScheduleSetting.CoursesTimeID = arrangementView.CoursesTimeID;
  87. courseScheduleSetting.Weekday = i;
  88. courseScheduleSetting.IsOnWork = IsOnWork;
  89. SetNewStatus(courseScheduleSetting);
  90. UnitOfWork.Add(courseScheduleSetting);
  91. }
  92. }
  93. UnitOfWork.Commit();
  94. }
  95. catch (Exception)
  96. {
  97. throw;
  98. }
  99. }
  100. /// <summary>
  101. /// 删除
  102. /// </summary>
  103. /// <param name="userIDs"></param>
  104. public void CourseScheduleSettingDelete(List<Guid?> coursematerialIDs)
  105. {
  106. try
  107. {
  108. UnitOfWork.Delete<ES_CourseScheduleSetting>(x => coursematerialIDs.Contains(x.CoursematerialID));
  109. }
  110. catch (Exception)
  111. {
  112. throw;
  113. }
  114. }
  115. }
  116. }