CourseScheduleSettingDAL.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  6. using EMIS.Entities;
  7. using System.Linq.Expressions;
  8. using EMIS.DataLogic.Repositories;
  9. using EMIS.ViewModel.CalendarManage;
  10. using EMIS.ViewModel;
  11. namespace EMIS.DataLogic.SchedulingManage.SchedulingSettings
  12. {
  13. public class CourseScheduleSettingDAL
  14. {
  15. public CoursematerialRepository coursematerialRepository { get; set; }
  16. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  17. public CoursesTimeRepository coursesTimeRepository { get; set; }
  18. public CourseScheduleSettingRepository courseScheduleSettingRepository { get; set; }
  19. /// <summary>
  20. /// 查询课程可排时间设置
  21. /// </summary>
  22. /// <param name="exp"></param>
  23. /// <returns></returns>
  24. public IQueryable<CourseScheduleSettingView> GetCourseScheduleSettingViewQueryable(Expression<Func<EM_Coursematerial, bool>> exp)
  25. {
  26. var query = from a in coursematerialRepository.GetList(exp)
  27. join b in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_CourseLevel).Name)
  28. on a.CourseLevelID equals b.Value
  29. into gcl
  30. from gCourseLevel in gcl.DefaultIfEmpty()
  31. join c in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_CourseScience).Name)
  32. on a.CourseScienceID equals c.Value
  33. into gcs
  34. from gCourseScience in gcs.DefaultIfEmpty()
  35. select new CourseScheduleSettingView
  36. {
  37. CoursematerialID = a.CoursematerialID,
  38. CourseCode = a.CourseCode,
  39. CourseName = a.CourseName,
  40. CourseScienceName = gCourseScience.Name,
  41. CourseLevelName = gCourseLevel.Name,
  42. IsEnableName = a.IsEnable == false ? "否" : "是",
  43. CreateUserID = a.CreateUserID,
  44. CreateTime = a.CreateTime
  45. };
  46. return query;
  47. }
  48. /// <summary>
  49. /// 获取教师可排时间设置
  50. /// </summary>
  51. /// <param name="userID"></param>
  52. /// <returns></returns>
  53. public IQueryable<ArrangementView> GetArrangementViewQueryable(Guid? coursematerialID)
  54. {
  55. var query = from a in coursesTimeRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  56. join b in
  57. courseScheduleSettingRepository.GetList(x => x.CoursematerialID == coursematerialID)
  58. on a.CoursesTimeID equals b.CoursesTimeID
  59. group a by new
  60. {
  61. CoursesTimeID = a.CoursesTimeID,
  62. StartTimes = a.StartTimes,
  63. EndTimes = a.EndTimes,
  64. TimesSegment = a.TimesSegment,
  65. StartHour = a.StartHour,
  66. StartMinutes = a.StartMinutes,
  67. EndHour = a.EndHour,
  68. EndMinutes = a.EndMinutes,
  69. CreateTime = a.CreateTime,
  70. CreateUserID = a.CreateUserID,
  71. MondayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Monday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
  72. TuesdayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Tuesday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
  73. WednesdayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Wednesday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
  74. ThursdayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Thursday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
  75. FridayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Friday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
  76. SaturdayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Saturday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
  77. SundayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Sunday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork
  78. } into g
  79. select new ArrangementView
  80. {
  81. CoursesTimeID = g.Key.CoursesTimeID,
  82. StartTimes = g.Key.StartTimes,
  83. EndTimes = g.Key.EndTimes,
  84. TimesSegment = g.Key.TimesSegment,
  85. StartHour = g.Key.StartHour,
  86. StartMinutes = g.Key.StartMinutes,
  87. EndHour = g.Key.EndHour,
  88. EndMinutes = g.Key.EndMinutes,
  89. CreateTime = g.Key.CreateTime,
  90. CreateUserID = g.Key.CreateUserID,
  91. MondayIsOnWork = g.Key.MondayIsOnWork,
  92. TuesdayIsOnWork = g.Key.TuesdayIsOnWork,
  93. WednesdayIsOnWork = g.Key.WednesdayIsOnWork,
  94. ThursdayIsOnWork = g.Key.ThursdayIsOnWork,
  95. FridayIsOnWork = g.Key.FridayIsOnWork,
  96. SaturdayIsOnWork = g.Key.SaturdayIsOnWork,
  97. SundayIsOnWork = g.Key.SundayIsOnWork,
  98. };
  99. return query;
  100. }
  101. }
  102. }