ExaminationPLanDAL.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel;
  6. using EMIS.ViewModel.ExaminationManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. namespace EMIS.ExtensionLogic.DataLogic.ExaminationManage
  10. {
  11. public class ExaminationPLanDAL : EMIS.DataLogic.ExaminationManage.ExaminationPlanDAL
  12. {
  13. public override IQueryable<ExaminationPlanView> GetExaminationPlanByEducationMission(
  14. Expression<Func<EM_EducationMission, bool>> educationMissionExpression,
  15. Expression<Func<EM_EducationMissionClass, bool>> emcExp)
  16. {
  17. var missionClassQuery = (
  18. from emc in EducationMissionClassRepository.GetList(emcExp)
  19. join cm in CoursematerialRepository.Entities on emc.CoursematerialID equals cm.CoursematerialID
  20. join ems in ExaminationModeSettingRepository.GetList(x => x.IsGeneratePlan == false)
  21. on emc.ExaminationModeID equals ems.ExaminationModeID into dems
  22. from eems in dems.DefaultIfEmpty()
  23. from esc in emc.EM_EducationSchedulingClass
  24. from s in esc.CF_Student
  25. where emc.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted
  26. && eems.ExaminationModeSettingID == null && emc.HandleModeID == (int)CF_HandleMode.RequiredCourse
  27. group emc by new
  28. {
  29. emc.EducationMissionID,
  30. emc.CoursematerialID,
  31. cm.CourseName,
  32. emc.ExaminationModeID,
  33. s.ClassmajorID,
  34. s.CF_Classmajor.Name
  35. } into g
  36. select g.Key
  37. );
  38. var q = (from em in EducationMissionRepository.GetList(educationMissionExpression)
  39. join c in missionClassQuery
  40. on em.EducationMissionID equals c.EducationMissionID
  41. from eep in ExaminationPlanRepository.Entities.Where(x => x.EducationMissionID == em.EducationMissionID
  42. && x.ClassmajorID == c.ClassmajorID).DefaultIfEmpty()
  43. where eep.ExaminationPlanID == null
  44. select new ExaminationPlanView
  45. {
  46. SchoolyearID = em.SchoolyearID,
  47. CollegeID = em.CollegeID,
  48. CoursematerialID = c.CoursematerialID,
  49. ExaminationModeID = c.ExaminationModeID,
  50. ExaminationStyleID = (int)EX_ExaminationStyle.CloseBook,
  51. EducationMissionID = em.EducationMissionID,
  52. ClassmajorID = c.ClassmajorID,
  53. ClassName = c.Name,
  54. ExaminationDate = null,
  55. StartTime = null,
  56. EndTime = null,
  57. Students = (from esc in educationSchedulingClassRepository.Entities
  58. from emc in EducationMissionClassRepository.Entities.Where(x => x.EducationMissionClassID == esc.EducationMissionClassID)
  59. from s in esc.CF_Student
  60. where emc.EducationMissionID == em.EducationMissionID && s.ClassmajorID == c.ClassmajorID
  61. group s by s.UserID into g
  62. select g.FirstOrDefault())
  63. });
  64. return q;
  65. }
  66. }
  67. }