using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using EMIS.DataLogic.DQPSystem; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.DQPSystem; using EMIS.ViewModel; using EMIS.Entities; using EMIS.CommonLogic.SystemServices; using EMIS.ViewModel.ScoreManage; using EMIS.DataLogic.ScoreManage; namespace EMIS.CommonLogic.DQPSystem { public class SOCScoreServices : BaseServices, ISOCScoreServices { public SOCScoreDAL SOCScoreDAL { get; set; } public Lazy RoleServices { get; set; } public FinalExaminationDAL FinalExaminationDAL { get; set; } public IGridResultSet GetSOCCourseScoreViewList(ConfiguretView courseScoreConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, Guid? coursematerialID, int? pageIndex, int? pageSize) { Expression> socExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> facultyExp = (x => true); Expression> gradeExp = (x => true); Expression> classExp = (x => true); Expression> detailExp = (x => true); if (schoolyearID.HasValue) { socExp = socExp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { facultyExp = facultyExp.And(x => x.CollegeID == collegeID); } if (year.HasValue) { gradeExp = gradeExp.And(x => x.GradeID == year); } if (standardID.HasValue) { facultyExp = facultyExp.And(x => x.StandardID == standardID); } if (classmajorID.HasValue) { classExp = classExp.And(x => x.ClassmajorID == classmajorID); } if (coursematerialID.HasValue) { socExp = socExp.And(x => x.CoursematerialID == coursematerialID); } var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; var role = RoleServices.Value.GetEnabledTeacherRoleViewList(); var teacherRole = role.Where(x => x.RoleName == "教师"); if (curUser.RoleID == teacherRole.FirstOrDefault().RoleID) { detailExp = detailExp.And(x => x.CreateUserID == curUser.UserID); } var query = SOCScoreDAL.GetSOCCourseScoreViewQueryable(socExp, detailExp, facultyExp, gradeExp, classExp); if (!string.IsNullOrEmpty(courseScoreConditionView.ConditionValue) && !string.IsNullOrEmpty(courseScoreConditionView.Attribute)) query = query.DynamicWhere(courseScoreConditionView.Attribute, courseScoreConditionView.Condition, courseScoreConditionView.ConditionValue); query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.CourseCode) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo) .ThenBy(x => x.LoginID) .ThenBy(x => x.CourseCode); return query.ToGridResultSet(pageIndex, pageSize); } public List GetSOCCourseScoreViewList(ConfiguretView courseScoreConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, Guid? coursematerialID) { Expression> socExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> facultyExp = (x => true); Expression> gradeExp = (x => true); Expression> classExp = (x => true); Expression> detailExp = (x => true); if (schoolyearID.HasValue) { socExp = socExp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { facultyExp = facultyExp.And(x => x.CollegeID == collegeID); } if (year.HasValue) { gradeExp = gradeExp.And(x => x.GradeID == year); } if (standardID.HasValue) { facultyExp = facultyExp.And(x => x.StandardID == standardID); } if (classmajorID.HasValue) { classExp = classExp.And(x => x.ClassmajorID == classmajorID); } if (coursematerialID.HasValue) { socExp = socExp.And(x => x.CoursematerialID == coursematerialID); } var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; var role = RoleServices.Value.GetEnabledTeacherRoleViewList(); var teacherRole = role.Where(x => x.RoleName == "教师"); if (curUser.RoleID == teacherRole.FirstOrDefault().RoleID) { detailExp = detailExp.And(x => x.CreateUserID == curUser.UserID); } var query = SOCScoreDAL.GetSOCCourseScoreViewQueryable(socExp, detailExp, facultyExp, gradeExp, classExp); if (!string.IsNullOrEmpty(courseScoreConditionView.ConditionValue) && !string.IsNullOrEmpty(courseScoreConditionView.Attribute)) query = query.DynamicWhere(courseScoreConditionView.Attribute, courseScoreConditionView.Condition, courseScoreConditionView.ConditionValue); query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.CourseCode) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo) .ThenBy(x => x.LoginID) .ThenBy(x => x.CourseCode); return query.ToList(); } public List GetScoreBySOCScore(Guid? finalExaminationID) { Expression> socExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> facultyExp = (x => true); Expression> gradeExp = (x => true); Expression> classExp = (x => true); Expression> detailExp = (x => true); var final = FinalExaminationDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationID, (x => x.ER_FinalExaminationStudent)); if (final != null) { socExp = socExp.And(x => x.SchoolyearID == final.SchoolyearID); socExp = socExp.And(x => x.CoursematerialID == final.CoursematerialID); socExp = socExp.And(x => x.DepartmentID == final.DepartmentID); if (final.HandleModeID.HasValue) { socExp = socExp.And(x => x.HandleModeID == final.HandleModeID); } //socExp = socExp.And(x => x.OptionalCourseTypeID == final); var query = SOCScoreDAL.GetSOCCourseScoreViewQueryable(socExp, detailExp, facultyExp, gradeExp, classExp); var studentIDList = final.ER_FinalExaminationStudent.Select(x => x.UserID).ToList(); query = query.Where(x => studentIDList.Contains(x.UserID) && x.TotalScore != null); return query.ToList(); } else { return new List(); } } } }