ExaminationTeacherDAL.cs 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.UniversityManage.TeacherManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel.ExaminationManage;
  10. using EMIS.DataLogic.UniversityManage.TeacherManage;
  11. namespace EMIS.DataLogic.ExaminationManage
  12. {
  13. public class ExaminationTeacherDAL
  14. {
  15. public ExaminationTeacherRepository ExaminationTeacherRepository { get; set; }
  16. public ExaminationRoomLayoutRepository ExaminationRoomLayoutRepository { get; set; }
  17. public ExaminationPlanRepository ExaminationPlanRepository { get; set; }
  18. public StaffDAL StaffDAL { get; set; }
  19. public IQueryable<StaffView> GetAvailableStaffView(Expression<Func<EX_ExaminationPlan, bool>> examinationPlanExp,
  20. Guid classroomID,
  21. Expression<Func<CF_Staff, bool>> staffExp)
  22. {
  23. var q = (
  24. from et in ExaminationTeacherRepository.Entities
  25. join s in StaffDAL.GetStaffViewQueryable(staffExp) on et.UserID equals s.UserID
  26. join nas in (
  27. from ep in ExaminationPlanRepository.GetList(examinationPlanExp)
  28. join erl in ExaminationRoomLayoutRepository.Entities on true equals true
  29. where erl.EX_ExaminationPlan.ExaminationDate == ep.ExaminationDate
  30. && erl.ClassroomID != classroomID
  31. && erl.EX_ExaminationPlan.EndTime >= ep.StartTime && erl.EX_ExaminationPlan.StartTime <= ep.EndTime
  32. from s in erl.CF_Staff
  33. select s
  34. ) on et.UserID equals nas.UserID into dnas
  35. from enas in dnas.DefaultIfEmpty()
  36. where enas.UserID == null
  37. select s
  38. );
  39. return q;
  40. }
  41. public IQueryable<StaffView> GetAvailableStaffViewGdss(Expression<Func<EX_ExaminationPlan, bool>> otherExaminationPlanExp,
  42. Guid classroomID, Expression<Func<CF_Staff, bool>> staffExp)
  43. {
  44. var q = (
  45. from et in ExaminationTeacherRepository.Entities
  46. join s in StaffDAL.GetStaffViewQueryable(staffExp) on et.UserID equals s.UserID
  47. join nas in
  48. (
  49. from other in ExaminationPlanRepository.GetList(otherExaminationPlanExp)
  50. join otherLayout in ExaminationRoomLayoutRepository.Entities on other.ExaminationPlanID equals otherLayout.ExaminationPlanID
  51. where otherLayout.ClassroomID != classroomID
  52. from s in otherLayout.CF_Staff
  53. select s
  54. ) on et.UserID equals nas.UserID into dnas
  55. from enas in dnas.DefaultIfEmpty()
  56. where enas.UserID == null
  57. select s
  58. );
  59. return q;
  60. }
  61. public IQueryable<TeacherConflictView> GetConflictStaffView(Expression<Func<EX_ExaminationPlan, bool>> examinationPlanExp,
  62. DateTime? date, TimeSpan? startTime, TimeSpan? endTime)
  63. {
  64. var q = (
  65. from ep in ExaminationPlanRepository.GetList(examinationPlanExp)
  66. from erl in ep.EX_ExaminationRoomLayout
  67. from erls in erl.CF_Staff
  68. join erlt in
  69. (
  70. from erlt1 in ExaminationRoomLayoutRepository.Entities
  71. from erlst1 in erlt1.CF_Staff
  72. select new { UserID = erlst1.UserID, ExaminationPlanID = erlt1.EX_ExaminationPlan.ExaminationPlanID,
  73. ExaminationPlanName = erlt1.EX_ExaminationPlan.ClassName,
  74. erlt1.EX_ExaminationPlan.ExaminationDate, erlt1.EX_ExaminationPlan.StartTime, erlt1.EX_ExaminationPlan.EndTime }
  75. ) on erls.UserID equals erlt.UserID
  76. where ep.ExaminationPlanID != erlt.ExaminationPlanID && erlt.ExaminationDate == date
  77. && erlt.EndTime >= startTime && erlt.StartTime <= endTime
  78. select new TeacherConflictView
  79. {
  80. UserID = erls.Sys_User.UserID,
  81. Name = erls.Sys_User.Name,
  82. ExaminationPlanID = erlt.ExaminationPlanID,
  83. ExaminationPlanName = erlt.ExaminationPlanName,
  84. StartTime = erlt.StartTime,
  85. EndTime = erlt.EndTime
  86. }
  87. );
  88. return q;
  89. }
  90. }
  91. }