ClassmajorScheduleSettingDAL.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  7. using EMIS.Entities;
  8. using System.Linq.Expressions;
  9. using EMIS.ViewModel.CalendarManage;
  10. using EMIS.ViewModel;
  11. namespace EMIS.DataLogic.SchedulingManage.SchedulingSettings
  12. {
  13. public class ClassmajorScheduleSettingDAL
  14. {
  15. public ClassmajorScheduleSettingRepository classmajorScheduleSettingRepository { get; set; }
  16. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  17. public CoursesTimeRepository coursesTimeRepository { get; set; }
  18. public ClassmajorRepository classmajorRepository { get; set; }
  19. /// <summary>
  20. ///
  21. /// </summary>
  22. /// <returns></returns>
  23. public IQueryable<ClassmajorScheduleSettingView> GetClassmajorScheduleSettingViewQueryable(Expression<Func<CF_Classmajor, bool>> exp)
  24. {
  25. var query = from a in classmajorRepository.GetList(exp)
  26. join b in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_Education).Name)
  27. on a.CF_Grademajor.CF_Facultymajor.EducationID equals b.Value
  28. into ge
  29. from gEducation in ge.DefaultIfEmpty()
  30. join c in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_Learningform).Name)
  31. on a.CF_Grademajor.CF_Facultymajor.LearningformID equals c.Value
  32. into glf
  33. from gLearningform in glf.DefaultIfEmpty()
  34. select new ClassmajorScheduleSettingView
  35. {
  36. ClassmajorID = a.ClassmajorID,
  37. ClassmajorNo = a.No,
  38. ClassmajorName = a.Name,
  39. yearsID = a.CF_Grademajor.GradeID,
  40. GrademajorName = a.CF_Grademajor.Name,
  41. EducationName = gEducation.Name,
  42. LearningformName = gLearningform.Name,
  43. LearnSystem = a.CF_Grademajor.CF_Facultymajor.LearnSystem,
  44. CollegeName = a.CF_Grademajor.CF_Facultymajor.CF_College.Name,
  45. CreateUserID = a.CreateUserID,
  46. CreateTime = a.CreateTime,
  47. };
  48. return query;
  49. }
  50. /// <summary>
  51. /// 教室可排时间设置
  52. /// </summary>
  53. /// <param name="classroomID">教室ID</param>
  54. /// <returns></returns>
  55. public IQueryable<ArrangementView> GetArrangementViewQueryable(Guid? classmajorID)
  56. {
  57. var query = from a in coursesTimeRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  58. join b in
  59. classmajorScheduleSettingRepository.GetList(x => x.ClassmajorID == classmajorID)
  60. on a.CoursesTimeID equals b.CoursesTimeID
  61. group a by new
  62. {
  63. CoursesTimeID = a.CoursesTimeID,
  64. StartTimes = a.StartTimes,
  65. EndTimes = a.EndTimes,
  66. TimesSegment = a.TimesSegment,
  67. StartHour = a.StartHour,
  68. StartMinutes = a.StartMinutes,
  69. EndHour = a.EndHour,
  70. EndMinutes = a.EndMinutes,
  71. CreateTime = a.CreateTime,
  72. CreateUserID = a.CreateUserID,
  73. MondayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Monday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
  74. TuesdayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Tuesday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
  75. WednesdayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Wednesday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
  76. ThursdayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Thursday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
  77. FridayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Friday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
  78. SaturdayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Saturday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
  79. SundayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Sunday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork
  80. } into g
  81. select new ArrangementView
  82. {
  83. CoursesTimeID = g.Key.CoursesTimeID,
  84. StartTimes = g.Key.StartTimes,
  85. EndTimes = g.Key.EndTimes,
  86. TimesSegment = g.Key.TimesSegment,
  87. StartHour = g.Key.StartHour,
  88. StartMinutes = g.Key.StartMinutes,
  89. EndHour = g.Key.EndHour,
  90. EndMinutes = g.Key.EndMinutes,
  91. CreateTime = g.Key.CreateTime,
  92. CreateUserID = g.Key.CreateUserID,
  93. MondayIsOnWork = g.Key.MondayIsOnWork,
  94. TuesdayIsOnWork = g.Key.TuesdayIsOnWork,
  95. WednesdayIsOnWork = g.Key.WednesdayIsOnWork,
  96. ThursdayIsOnWork = g.Key.ThursdayIsOnWork,
  97. FridayIsOnWork = g.Key.FridayIsOnWork,
  98. SaturdayIsOnWork = g.Key.SaturdayIsOnWork,
  99. SundayIsOnWork = g.Key.SundayIsOnWork,
  100. };
  101. return query;
  102. }
  103. }
  104. }