using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Common.EvaluationManage; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.ViewModel; using System.Linq.Expressions; using EMIS.ViewModel.EvaluationManage; using EMIS.CommonLogic.SystemServices; namespace EMIS.CommonLogic.EvaluationManage { public class EvaluationControlServices : BaseServices, IEvaluationControlServices { public EvaluationControlDAL evaluationControlDAL { get; set; } public Lazy ControlItemServices { get; set; } /// /// 查询评价控制信息 /// /// 查询条件实体 /// 页码 /// 显示页数 /// public IGridResultSet GetEvaluationControlViewGrid(ConfiguretView configuretView, int? isResult, int? isCourse, int pageIndex, int pageSize) { var query = evaluationControlDAL.GetEvaluationControlQueryable(x => true); if (isResult.HasValue && isResult > -1) { bool result = isResult == 1 ? true : false; query = query.Where(x => x.IsResult == result); } if (isCourse.HasValue && isCourse > -1) { bool course = isCourse == 1 ? true : false; query = query.Where(x => x.IsCourse == course); } if (!string.IsNullOrEmpty(configuretView.ConditionValue)) return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.CreateTime).ToGridResultSet(pageIndex, pageSize); return query.OrderByDescending(x => x.CreateTime).ToGridResultSet(pageIndex, pageSize); } /// /// 查询评价控制信息 /// /// 查询条件实体 /// public List GetEvaluationControlViewList(ConfiguretView configuretView, int? isResult, int? isCourse) { var query = evaluationControlDAL.GetEvaluationControlQueryable(x => true); if (isResult.HasValue && isResult > -1) { bool result = isResult == 1 ? true : false; query = query.Where(x => x.IsResult == result); } if (isCourse.HasValue && isCourse > -1) { bool course = isCourse == 1 ? true : false; query = query.Where(x => x.IsCourse == course); } if (!string.IsNullOrEmpty(configuretView.ConditionValue)) return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.CreateTime).ToList(); return query.OrderByDescending(x => x.CreateTime).ToList(); } /// /// 获取评价控制信息 /// /// 主键ID /// public EM_EvaluationControl GetEvaluationControl(Guid? controlID) { //查询条件 Expression> expression = (x => x.EvaluationControlID == controlID.Value); return evaluationControlDAL.evaluationControlRepository.GetSingle(expression); } /// /// 获取评价控制信息 /// /// 学年学期ID /// public EM_EvaluationControl GetEvaluationControl(Guid schoolyearID) { //查询条件 Expression> expression = (x => x.SchoolyearID == schoolyearID); return evaluationControlDAL.evaluationControlRepository.GetSingle(expression); } /// /// 获取评价控制信息 /// /// 主键ID /// public EvaluationControlView GetEvaluationControlView() { var evaluationControlView = new EvaluationControlView(); //数据字典配置控制类型(费用控制-1,注册控制-2,评价控制-3) var type = SYS_ControlItemType.Evaluation; var controlItemList = ControlItemServices.Value.GetControlItemList(type); evaluationControlView = evaluationControlDAL.GetEvaluationControlQueryable(x => true).FirstOrDefault(); if (evaluationControlView==null) { evaluationControlView = new EvaluationControlView(); evaluationControlView.IsCourse = false; evaluationControlView.IsResult = false; evaluationControlView.IsStudentExaminationApply = false; evaluationControlView.IsStudentLevelScore = false; evaluationControlView.IsCourseDisplay = "none"; evaluationControlView.IsResultDisplay = "none"; evaluationControlView.IsStudentExaminationApplyDisplay = "none"; evaluationControlView.IsStudentLevelScoreDisplay = "none"; return evaluationControlView; } if (controlItemList == null || controlItemList.Count <= 0) { evaluationControlView.IsCourse = false; evaluationControlView.IsResult = false; evaluationControlView.IsStudentExaminationApply = false; evaluationControlView.IsStudentLevelScore = false; evaluationControlView.IsCourseDisplay = "none"; evaluationControlView.IsResultDisplay = "none"; evaluationControlView.IsStudentExaminationApplyDisplay = "none"; evaluationControlView.IsStudentLevelScoreDisplay = "none"; } else { var CourseLock = controlItemList.FirstOrDefault(x => x.ControlItemCode == "EvaluationSelectCourse"); var ResultLock = controlItemList.FirstOrDefault(x => x.ControlItemCode == "EvaluationScore"); var StudentExaminationApplyLock = controlItemList.FirstOrDefault(x => x.ControlItemCode == "EvaluationExaminationApply"); var StudentLevelScoreLock = controlItemList.FirstOrDefault(x => x.ControlItemCode == "EvaluationLevelScore"); if (CourseLock != null) { evaluationControlView.IsCourse = CourseLock.IsEnable ?? false; evaluationControlView.Course = CourseLock.Message; evaluationControlView.IsCourseDisplay = "table-row"; } else { evaluationControlView.IsCourse = false; evaluationControlView.Course = ""; evaluationControlView.IsCourseDisplay = "none"; } if (ResultLock != null) { evaluationControlView.IsResult = ResultLock.IsEnable ?? false; evaluationControlView.Result = ResultLock.Message; evaluationControlView.IsResultDisplay = "table-row"; } else { evaluationControlView.IsResult = false; evaluationControlView.Result = ""; evaluationControlView.IsResultDisplay = "none"; } if (StudentExaminationApplyLock != null) { evaluationControlView.IsStudentExaminationApply = StudentExaminationApplyLock.IsEnable ?? false; evaluationControlView.StudentExaminationApply = StudentExaminationApplyLock.Message; evaluationControlView.IsStudentExaminationApplyDisplay = "table-row"; } else { evaluationControlView.IsStudentExaminationApply = false; evaluationControlView.StudentExaminationApply = ""; evaluationControlView.IsStudentExaminationApplyDisplay = "none"; } if (StudentLevelScoreLock != null) { evaluationControlView.IsStudentLevelScore = StudentLevelScoreLock.IsEnable ?? false; evaluationControlView.StudentLevelScore = StudentLevelScoreLock.Message; evaluationControlView.IsStudentLevelScoreDisplay = "table-row"; } else { evaluationControlView.IsStudentLevelScore = false; evaluationControlView.StudentLevelScore = ""; evaluationControlView.IsStudentLevelScoreDisplay = "none"; } } return evaluationControlView; } /// /// 保存 /// /// 实体 /// public bool EvaluationControlSave(EvaluationControlView evaluationControlView) { try { UnitOfWork.Delete(x => true); var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; var controlItemList = ControlItemServices.Value.GetControlItemList(SYS_ControlItemType.Evaluation); var CourseLock = controlItemList.FirstOrDefault(x => x.ControlItemCode == "EvaluationSelectCourse"); var StudentExaminationApplyLock = controlItemList.FirstOrDefault(x => x.ControlItemCode == "EvaluationExaminationApply"); var ResultLock = controlItemList.FirstOrDefault(x => x.ControlItemCode == "EvaluationScore"); var StudentLevelScoreLock = controlItemList.FirstOrDefault(x => x.ControlItemCode == "EvaluationStudentLevelScore"); if (CourseLock != null) { CourseLock.IsEnable = evaluationControlView.IsCourse; //CourseLock.Message = evaluationControlView.Course; } if (ResultLock != null) { ResultLock.IsEnable = evaluationControlView.IsResult; //ResultLock.Message = evaluationControlView.Result; } if (StudentExaminationApplyLock != null) { StudentExaminationApplyLock.IsEnable = evaluationControlView.IsStudentExaminationApply; //StudentExaminationApplyLock.Message = evaluationControlView.StudentExaminationApply; } if (StudentLevelScoreLock != null) { StudentLevelScoreLock.IsEnable = evaluationControlView.IsStudentLevelScore; //StudentLevelScoreLock.Message = evaluationControlView.StudentLevelScore; } EM_EvaluationControl evaluationControl = new EM_EvaluationControl(); evaluationControl.EvaluationControlID = Guid.NewGuid(); evaluationControl.SchoolyearID = evaluationControlView.SchoolyearID.Value; evaluationControl.IsCourseScoreLock = evaluationControlView.IsResult; evaluationControl.IsSelectCourseLock = evaluationControlView.IsCourse; evaluationControl.IsExaminationApplyLock = evaluationControlView.IsStudentExaminationApply; evaluationControl.IsLevelScoreLock = evaluationControlView.IsStudentLevelScore; evaluationControl.NoNumber = evaluationControlView.AllowNotEvaluationCount; evaluationControl.CreateTime = DateTime.Now; evaluationControl.CreateUserID = curUser.UserID; evaluationControl.ModifyUserID = curUser.UserID; evaluationControl.ModifyTime = DateTime.Now; UnitOfWork.Add(evaluationControl); UnitOfWork.Commit(); ControlItemServices.Value.RefreshCache(); return true; } catch (Exception) { throw new Exception("控制项目表中评价控制数据为空,请配置。"); } } public bool CanViewScore(Guid userID) { var evaluationControl = this.GetEvaluationControlView(); var notEvaluationCount = evaluationControlDAL.GetStudentNotEvaluationList(x => x.UserID == userID, x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.OpenStatus == (int)CF_GeneralPurpose.IsYes && x.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == evaluationControl.SchoolyearID).Count(); if (notEvaluationCount > evaluationControl.AllowNotEvaluationCount && evaluationControl.IsResult) { return false; } return true; } public bool CanSelectCourse(Guid userID) { var evaluationControl = this.GetEvaluationControlView(); var notEvaluationCount = evaluationControlDAL.GetStudentNotEvaluationList(x => x.UserID == userID, x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == evaluationControl.SchoolyearID).Count(); if (notEvaluationCount > evaluationControl.AllowNotEvaluationCount && evaluationControl.IsCourse) { return false; } return true; } public bool CanExaminationApply(Guid userID) { var evaluationControl = this.GetEvaluationControlView(); var notEvaluationCount = evaluationControlDAL.GetStudentNotEvaluationList(x => x.UserID == userID, x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == evaluationControl.SchoolyearID).Count(); if (notEvaluationCount > evaluationControl.AllowNotEvaluationCount && evaluationControl.IsStudentExaminationApply) { return false; } return true; } public bool CanViewLevelScore(Guid userID) { var evaluationControl = this.GetEvaluationControlView(); var notEvaluationCount = evaluationControlDAL.GetStudentNotEvaluationList(x => x.UserID == userID, x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == evaluationControl.SchoolyearID).Count(); if (notEvaluationCount > evaluationControl.AllowNotEvaluationCount && evaluationControl.IsStudentLevelScore) { return false; } return true; } } }