using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel.EvaluationManage; using EMIS.DataLogic.SystemDAL; using EMIS.ViewModel; using EMIS.ViewModel.EducationManage; using EMIS.ViewModel.EvaluationManage.EvaluationEnter; namespace EMIS.DataLogic.Common.EvaluationManage { public class EvaluationRecordDAL { #region --0.0定义-- public EvaluationSettingRepository EvaluationSettingRepository { get; set; } public EducationMissionRepository EducationMissionRepository { get; set; } public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; } public EvaluationTableRepository EvaluationTableRepository { get; set; } public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; } public DictionaryDAL DictionaryDAL { get; set; } public UserRepository UserRepository { get; set; } public StaffRepository StaffRepository { get; set; } public StudentRepository StudentRepository { get; set; } public EducationMissionClassRepository EducationMissionClassRepository { get; set; } public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; } public EvaluationTypeRepository evaluationTypeRepository { get; set; } public EvaluationControlRepository EvaluationControlRepository { get; set; } public EvaluationEnterRepository EvaluationEnterRepository { get; set; } public EvaluationProjectRepository EvaluationProjectRepository { get; set; } public EvaluationTargetRepository EvaluationTargetRepository { get; set; } public EvaluationNormRepository EvaluationNormRepository { get; set; } public EvaluationNormDetailRepository EvaluationNormDetailRepository { get; set; } public EvaluationEnter_EM_EvaluationProjectRepository EvaluationEnter_EM_EvaluationProjectRepository { get; set; } public ClassmajorRepository ClassmajorRepository { get; set; } #endregion public IQueryable GetEvaluationRecordQuery() { //var linqStr = EvaluationEnterRepository.Entities.ToList(); var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; bool isStudent = curUser.IsStudent;//获取当前用户是否是学生 //Guid? typeID = isStudent == true ? evaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault().TypeID : evaluationTypeRepository.Entities.Where(w => w.IsStudent == false && w.IsDefault == true).FirstOrDefault().TypeID; var query = from c in EvaluationSettingRepository.GetList(x => x.OpenStatus == (int)CF_YesOrNoStatus.Yes) join f in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_TeachingMode).Name) on c.EM_EducationMissionClass.TeachingModeID equals f.Value join emc in EducationMissionClassRepository.Entities on c.EducationMissionClassID equals emc.EducationMissionClassID into temc from stemc in temc.DefaultIfEmpty() join cla in ClassmajorRepository.Entities on stemc.MainScheduleClassID equals cla.ClassmajorID into dcla from ecla in dcla.DefaultIfEmpty() from stcontrol in EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true && x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(c.EM_EducationMissionClass.TeachingModeID)).DefaultIfEmpty() join even in EvaluationEnterRepository.Entities on new { c.EducationMissionClassID, TableID = (Guid)stcontrol.EvaluationTableID } equals new { even.EducationMissionClassID, TableID = (Guid)even.EvaluationTableID } into teven from cteven in teven.DefaultIfEmpty() join sfuser in UserRepository.Entities on cteven.StaffUserID equals sfuser.UserID into bsfuser from tbsfuser in bsfuser.DefaultIfEmpty() join sduser in UserRepository.Entities on cteven.StudentUserID equals sduser.UserID into bsduser from tbsduser in bsduser.DefaultIfEmpty() select new EvaluationRecordView { //staffID=c.EM_EducationMissionClass.EM_MissionClassTeacher. CampusID =stemc.EM_EducationMission.CF_College.CampusID, Grade = ecla.CF_Grademajor.GradeID, StandardID = ecla.CF_Grademajor.CF_Facultymajor.StandardID, CollegeID = ecla.CF_Grademajor.CF_Facultymajor.CollegeID, EvaluationTableID = stcontrol.EvaluationTableID, EvaluationTableNo = stcontrol.Code, EvaluationEnterID = cteven.EvaluationEnterID, EvaluationIntTypeID = stcontrol.EvaluationIntTypeID, EvaluationTableTypeName = stcontrol.EM_EvaluationIntType.Name, //评价类型 EvaluationTypeName = stcontrol.EM_EvaluationType.Name, EvaluationTypeID = stcontrol.EvaluationTypeID, EducationMissionClassName = c.EM_EducationMissionClass.Name, EducationMissionClassID = c.EM_EducationMissionClass.EducationMissionClassID, EvaluationSettingCode = c.EvaluationSettingCode, EvaluationCount = cteven.EvaluationEnterID == null ? 0 : cteven.EM_EvaluationEnter_EM_EvaluationProject.GroupBy(x => x.ModifyTime).Select(y => y).Count(), LimitMore = (int)stcontrol.EM_EvaluationType.Number, SchoolyearID = stemc.EM_EducationMission.CF_Schoolyear.SchoolyearID, year=stemc.EM_EducationMission.CF_Schoolyear.Years, SchoolyearCode = stemc.EM_EducationMission.CF_Schoolyear.Code, Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User), EvaluationCode = tbsfuser.LoginID == null ? tbsduser.LoginID : tbsfuser.LoginID, EvaluationName = tbsfuser.Name == null ? tbsduser.Name : tbsfuser.Name, EvaluationTableName = stcontrol.Name, //EvaluationTableTypeID = stcontrol.EM_EvaluationType.TypeID, EvaluationTableTypeID = stcontrol.EvaluationIntTypeID, CourseName = stemc.EM_Coursematerial.CourseName, CourseCode = stemc.EM_Coursematerial.CourseCode, LearningformID = ecla.CF_Grademajor.CF_Facultymajor.LearningformID, LearnSystem = ecla.CF_Grademajor.CF_Facultymajor.LearnSystem, EducationID = ecla.CF_Grademajor.CF_Facultymajor.EducationID, }; return query.Where(x => x.EvaluationCode != null); } /// /// 读取参评类型信息 /// /// /// public IQueryable GetEvaluationTypeQueryable(Expression> exp) { var query = from c in EvaluationTableRepository.GetList(exp) join a in evaluationTypeRepository.Entities on c.EvaluationTypeID equals a.EvaluationTypeID select new EvaluationTypeView { TypeID = a.EvaluationTypeID, //Code = a.Code, Name = a.Name, IsStudent = a.IsStudent.Value, Student = (a.IsStudent.HasValue && a.IsStudent == true) ? "是" : "否", IsDefault = a.IsStudent.Value, Default = (a.IsStudent.HasValue && a.IsStudent == true) ? "是" : "否", StartTime = a.StartTime, EndTime = a.EndTime, Number = a.Number, Remark = a.Remark, CreateUserID = a.CreateUserID, CreateTime = a.CreateTime }; return query; } public IQueryable GetEvaluationRecordQuery(Expression> filter) { //var linqStr = EvaluationEnterRepository.Entities.ToList(); var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; bool isStudent = curUser.IsStudent;//获取当前用户是否是学生 //Guid? typeID = isStudent == true ? evaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault().TypeID : evaluationTypeRepository.Entities.Where(w => w.IsStudent == false && w.IsDefault == true).FirstOrDefault().TypeID; var query = from c in EvaluationSettingRepository.GetList(filter) join f in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_TeachingMode).Name) on c.EM_EducationMissionClass.TeachingModeID equals f.Value join emc in EducationMissionClassRepository.Entities on c.EducationMissionClassID equals emc.EducationMissionClassID into temc from stemc in temc.DefaultIfEmpty() join classmajor in ClassmajorRepository.Entities on stemc.MainScheduleClassID equals classmajor.ClassmajorID into dclassmajor from classmajor in dclassmajor.DefaultIfEmpty() from stcontrol in EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true && x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(c.EM_EducationMissionClass.TeachingModeID)).DefaultIfEmpty() join even in EvaluationEnterRepository.Entities on new { c.EducationMissionClassID, TableID = (Guid)stcontrol.EvaluationTableID } equals new { even.EducationMissionClassID, TableID = (Guid)even.EvaluationTableID } into teven from cteven in teven.DefaultIfEmpty() join sfuser in UserRepository.Entities on cteven.StaffUserID equals sfuser.UserID into bsfuser from tbsfuser in bsfuser.DefaultIfEmpty() join sduser in UserRepository.Entities on cteven.StudentUserID equals sduser.UserID into bsduser from tbsduser in bsduser.DefaultIfEmpty() select new EvaluationRecordView { //ClassID=stemc.EM_ExecutablePlan.CF_Grademajor.CF_Classmajor CampusID = classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CampusID, StandardID = classmajor.CF_Grademajor.CF_Facultymajor.StandardID, CollegeID = classmajor.CF_Grademajor.CF_Facultymajor.CollegeID, EvaluationTableID = stcontrol.EvaluationTableID, EvaluationEnterID = cteven.EvaluationEnterID, EvaluationTableTypeName = stcontrol.EM_EvaluationIntType.Name, //评价类型 EvaluationTypeName = stcontrol.EM_EvaluationType.Name, EvaluationTypeID = stcontrol.EvaluationTypeID, EducationMissionClassName = c.EM_EducationMissionClass.Name, EducationMissionClassID = c.EM_EducationMissionClass.EducationMissionClassID, EvaluationSettingCode = c.EvaluationSettingCode, EvaluationCount = cteven.EvaluationEnterID == null ? 0 : cteven.EM_EvaluationEnter_EM_EvaluationProject.GroupBy(x => x.ModifyTime).Select(y => y).Count(), LimitMore = (int)stcontrol.EM_EvaluationType.Number, SchoolyearID = stemc.EM_EducationMission.CF_Schoolyear.SchoolyearID, SchoolyearCode = stemc.EM_EducationMission.CF_Schoolyear.Code, Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User), EvaluationCode = tbsfuser.LoginID == null ? tbsduser.LoginID : tbsfuser.LoginID, EvaluationName = tbsfuser.Name == null ? tbsduser.Name : tbsfuser.Name, EvaluationTableName = stcontrol.Name, EvaluationTableTypeID = stcontrol.EM_EvaluationType.EvaluationTypeID, CourseName = stemc.EM_Coursematerial.CourseName, CourseCode = stemc.EM_Coursematerial.CourseCode, }; return query.Where(x => x.EvaluationCode != null); } } }