using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.DataLogic.SystemDAL; using System.Linq.Expressions; using EMIS.ViewModel.SelectCourse.SelectCourseResult; using EMIS.Entities; using EMIS.DataLogic.Common.CalendarManage; namespace EMIS.DataLogic.SelectCourse.SelectCourseResult { public class SelectCourseListDAL { public FinallyScoreRepository FinallyScoreRepository { get; set; } public StudentRepository StudentRepository { get; set; } public ClassmajorRepository ClassmajorRepository { get; set; } public GrademajorRepository GrademajorRepository { get; set; } public FacultymajorRepository FacultymajorRepository { get; set; } public SpecialtyRepository SpecialtyRepository { get; set; } public DictionaryItemRepository DictionaryItemRepository { get; set; } public SchoolyearRepository schoolyearRepository { get; set; } public SelectCourseTypeSettingRepository SelectCourseTypeSettingRepository { get; set; } public SelectCourseOpenControlSettingRepository SelectCourseOpenControlSettingRepository { get; set; } public Lazy ParamterDAL { get; set; } public Lazy SchoolYearDAL { get; set; } public CampusRepository campusRepository { get; set; } public CollegeRepository collegeRepository { get; set; } public DepartmentRepository departmentRepository { get; set; } public CoursematerialRepository CoursematerialRepository { get; set; } public ExecutableOptionalCourseRepository ExecutableOptionalCourseRepository { get; set; }//限选设定 public ExecutableFreeSelectionCouseRepository ExecutableFreeSelectionCouseRepository { get; set; }//任选设定 public OptionalCoursePlanRepository OptionalCoursePlanRepository { get; set; } //限修计划 public FreeSelectionCourseGradeYearSettingRepository FreeSelectionCourseGradeYearSettingRepository { get; set; } //任选控制表 public ExecutableOptionalCourseTeacherRepository ExecutableOptionalCourseTeacherRepository { get; set; } //限选设定任课老师表 public ExecutableOptionalCourseTeachingModeRepository ExecutableOptionalCourseTeachingModeRepository { get; set; } //限选设定授课方式表 public ExecutableOptionalCourseTeachingSettingRepository ExecutableOptionalCourseTeachingSettingRepository { get; set; } //限选设定教学设置表 public ExecutableFreeSelectionCouseTeacherRepository ExecutableFreeSelectionCouseTeacherRepository { get; set; } //任选课程教师表 public ExecutableFreeSelectionCouseTeachingModeRepository ExecutableFreeSelectionCouseTeachingModeRepository { get; set; } //任选设定授课方式表 public ExecutableFreeSelectionCouseTeachingSettingRepository ExecutableFreeSelectionCouseTeachingSettingRepository { get; set; } //任选设定教学设置表 public ExecutableFreeSelectionCouseSpecialtyRepository ExecutableFreeSelectionCouseSpecialtyRepository { get; set; } public ExecutableFreeSelectionCouseGradeYearRepository ExecutableFreeSelectionCouseGradeYearRepository { get; set; } public ExecutableFreeSelectionCouseSchedulingRepository ExecutableFreeSelectionCouseSchedulingRepository { get; set; } public CoursesTimeRepository coursesTimeRepository { get; set; } public ClassroomRepository ClassroomRepository { get; set; } public UserRepository UserRepository { get; set; } /// /// 查询选课结果名单,0为限选,1为任选 /// /// /// /// public IQueryable GetSelectCourseListViewQueryable(Expression> eocExp, Expression> efsExp) { //1.0 获取限选设定的所有学生数据 var executableOptionalCourseResult = (from eoc in ExecutableOptionalCourseRepository.GetList(eocExp) from stu in eoc.CF_Student join user in UserRepository.Entities on stu.UserID equals user.UserID join cla in ClassmajorRepository.Entities on stu.ClassmajorID equals cla.ClassmajorID select new SelectCourseListView { UserID = user.UserID, LoginID = user.LoginID, UserName = user.Name, ClassMajorID = cla.ClassmajorID, ClassMajorName = cla.Name, ClassroomName = "", ID = eoc.ExecutableOptionalCourseID, StudentTotalNum = eoc.CF_Student.Count(), PeopleNumlower = eoc.PeopleNumlower, PeopleNumlimit = eoc.PeopleNumlimit, SchoolyearID = eoc.SchoolyearID, SchoolYearCode = null, CollegeID = eoc.CF_Grademajor.CF_Facultymajor.CollegeID, DepartmentID = eoc.DepartmentID, DepartmentName = eoc.EM_OptionalCoursePlan.CF_Department.Name, DefaultClassName = eoc.DefaultClassName, CoursematerialID = eoc.EM_OptionalCoursePlan.CoursematerialID, CourseCode = eoc.EM_OptionalCoursePlan.EM_Coursematerial.CourseCode, CourseName = eoc.EM_OptionalCoursePlan.EM_Coursematerial.CourseName, CourseTypeID = eoc.CourseTypeID, CourseQualityID = eoc.CourseQualityID, SelectCourseType = 0, TheoryCourse = eoc.EM_ExecutableOptionalCourseTeachingSetting.TheoryCourse ?? 0, Practicehours = eoc.EM_ExecutableOptionalCourseTeachingSetting.Practicehours ?? 0, Trialhours = eoc.EM_ExecutableOptionalCourseTeachingSetting.Trialhours ?? 0, Credit = eoc.EM_ExecutableOptionalCourseTeachingSetting.Credit ?? 0, StartWeeklyNum = eoc.EM_ExecutableOptionalCourseTeachingSetting.StartWeeklyNum ?? 0, EndWeeklyNum = eoc.EM_ExecutableOptionalCourseTeachingSetting.EndWeeklyNum ?? 0, SchoolcodeID = eoc.EM_OptionalCoursePlan.SchoolcodeID, TeacherUserID = null, TeacherName = "", RecordStatus = eoc.RecordStatus, IsOpened = eoc.IsOpened.Value, }); //2.0 获取任选设定的所有学生数据 var executableFreeSelectionCouseResult = (from efs in ExecutableFreeSelectionCouseRepository.GetList(efsExp) from stu in efs.CF_Student join user in UserRepository.Entities on stu.UserID equals user.UserID join cla in ClassmajorRepository.Entities on stu.ClassmajorID equals cla.ClassmajorID join Scheduling in (from sc in ExecutableFreeSelectionCouseSchedulingRepository.Entities join d in ClassroomRepository.Entities on sc.ClassroomID equals d.ClassroomID group d by new { sc.ExecutableFreeSelectionCouseID } into g select new { ExecutableFreeSelectionCouseID = g.Key.ExecutableFreeSelectionCouseID, ClassroomName = g.Select(x => x.Name).FirstOrDefault(), }) on efs.ExecutableFreeSelectionCouseID equals Scheduling.ExecutableFreeSelectionCouseID into lj from Scheduling in lj.DefaultIfEmpty() select new SelectCourseListView { UserID = user.UserID, LoginID = user.LoginID, UserName = user.Name, ClassMajorID = cla.ClassmajorID, ClassMajorName = cla.Name, ClassroomName = Scheduling.ClassroomName, ID = efs.ExecutableFreeSelectionCouseID, StudentTotalNum = efs.CF_Student.Count(), PeopleNumlower = efs.PeopleNumlower, PeopleNumlimit = efs.PeopleNumlimit, SchoolyearID = efs.SchoolyearID, SchoolYearCode = null, CollegeID = efs.CF_Department.CollegeID, DepartmentID = efs.DepartmentID, DepartmentName = efs.EM_FreeSelectionCouse.CF_Department.Name, DefaultClassName = efs.DefaultClassName, CoursematerialID = efs.EM_FreeSelectionCouse.CoursematerialID, CourseCode = efs.EM_FreeSelectionCouse.EM_Coursematerial.CourseCode, CourseName = efs.EM_FreeSelectionCouse.EM_Coursematerial.CourseName, CourseTypeID = efs.CourseTypeID, CourseQualityID = efs.CourseQualityID, SelectCourseType = 1, TheoryCourse = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.TheoryCourse ?? 0, Practicehours = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.Practicehours ?? 0, Trialhours = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.Trialhours ?? 0, Credit = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.Credit ?? 0, StartWeeklyNum = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.StartWeeklyNum ?? 0, EndWeeklyNum = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.EndWeeklyNum ?? 0, SchoolcodeID = efs.EM_FreeSelectionCouse.SchoolcodeID, TeacherUserID = null, TeacherName = "", RecordStatus = efs.RecordStatus, IsOpened = true, }); //3.0 合并限选/任选 var result = from a in executableOptionalCourseResult.Concat(executableFreeSelectionCouseResult) join s in schoolyearRepository.Entities on a.SchoolyearID equals s.SchoolyearID select new SelectCourseListView { UserID = a.UserID, LoginID = a.LoginID, UserName = a.UserName, ClassMajorID = a.ClassMajorID, ClassMajorName = a.ClassMajorName, ClassroomName = a.ClassroomName, ID = a.ID, StudentTotalNum = a.StudentTotalNum, PeopleNumlower = a.PeopleNumlower, PeopleNumlimit = a.PeopleNumlimit, SchoolyearID = a.SchoolyearID, SchoolYearCode = s.Code, CollegeID = a.CollegeID, DepartmentID = a.DepartmentID, DepartmentName = a.DepartmentName, DefaultClassName = a.DefaultClassName, CoursematerialID = a.CoursematerialID, CourseCode = a.CourseCode, CourseName = a.CourseName, CourseTypeID = a.CourseTypeID, CourseQualityID = a.CourseQualityID, SelectCourseType = a.SelectCourseType, TheoryCourse = a.TheoryCourse ?? 0, Practicehours = a.Practicehours ?? 0, Trialhours = a.Trialhours ?? 0, Credit = a.Credit ?? 0, StartWeeklyNum = a.StartWeeklyNum ?? 0, EndWeeklyNum = a.EndWeeklyNum ?? 0, SchoolcodeID = a.SchoolcodeID, TeacherUserID = null, TeacherName = a.TeacherName, RecordStatus = a.RecordStatus, IsOpened = a.IsOpened, }; return result; } } }