using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using System.Transactions; using Bowin.Common.Linq; using Bowin.Common.Data; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.EvaluationManage.EvaluationSetting; using EMIS.DataLogic.EvaluationManage.EvaluationSetting; using EMIS.CommonLogic.SystemServices; namespace EMIS.CommonLogic.EvaluationManage.EvaluationSetting { public class EvaluationControlServices : BaseServices, IEvaluationControlServices { public EvaluationControlDAL EvaluationControlDAL { get; set; } public Lazy ControlItemServices { get; set; } /// /// 查询评价控制类型相应的信息View(费用控制-1,注册控制-2,评价控制-3) /// /// public EvaluationControlView GetEvaluationControlView() { var evaluationControlView = EvaluationControlDAL.GetEvaluationControlViewQueryable(x => true).SingleOrDefault(); if (evaluationControlView == null) { evaluationControlView = new EvaluationControlView(); evaluationControlView.IsLoginLock = false; evaluationControlView.LoginLockMessage = "未设置"; evaluationControlView.IsLoginLockDisplay = "none"; evaluationControlView.IsSelectCourseLock = false; evaluationControlView.SelectCourseLockMessage = "未设置"; evaluationControlView.IsSelectCourseLockDisplay = "none"; evaluationControlView.IsExaminationApplyLock = false; evaluationControlView.ExaminationApplyLockMessage = "未设置"; evaluationControlView.IsExaminationApplyLockDisplay = "none"; evaluationControlView.IsCourseScoreLock = false; evaluationControlView.CourseScoreLockMessage = "未设置"; evaluationControlView.IsCourseScoreLockDisplay = "none"; evaluationControlView.IsLevelScoreLock = false; evaluationControlView.LevelScoreLockMessage = "未设置"; evaluationControlView.IsLevelScoreLockDisplay = "none"; evaluationControlView.NoNumber = 0; return evaluationControlView; } else { var controlItemList = EvaluationControlDAL.ControlItemRepository.GetList(x => x.ControlItemTypeID == (int)SYS_ControlItemType.Evaluation).ToList(); if (controlItemList == null || controlItemList.Count <= 0) { evaluationControlView.IsLoginLock = false; evaluationControlView.LoginLockMessage = "未设置"; evaluationControlView.IsLoginLockDisplay = "none"; evaluationControlView.IsSelectCourseLock = false; evaluationControlView.SelectCourseLockMessage = "未设置"; evaluationControlView.IsSelectCourseLockDisplay = "none"; evaluationControlView.IsExaminationApplyLock = false; evaluationControlView.ExaminationApplyLockMessage = "未设置"; evaluationControlView.IsExaminationApplyLockDisplay = "none"; evaluationControlView.IsCourseScoreLock = false; evaluationControlView.CourseScoreLockMessage = "未设置"; evaluationControlView.IsCourseScoreLockDisplay = "none"; evaluationControlView.IsLevelScoreLock = false; evaluationControlView.LevelScoreLockMessage = "未设置"; evaluationControlView.IsLevelScoreLockDisplay = "none"; evaluationControlView.NoNumber = 0; } else { var loginLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationLogin").SingleOrDefault(); if (loginLock != null) { evaluationControlView.IsLoginLock = loginLock.IsEnable ?? false; evaluationControlView.LoginLockMessage = loginLock.Message; evaluationControlView.IsLoginLockDisplay = "table-row"; } else { evaluationControlView.IsLoginLock = false; evaluationControlView.LoginLockMessage = "未设置。"; evaluationControlView.IsLoginLockDisplay = "none"; } var selectCourseLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationSelectCourse").SingleOrDefault(); if (selectCourseLock != null) { evaluationControlView.IsSelectCourseLock = selectCourseLock.IsEnable ?? false; evaluationControlView.SelectCourseLockMessage = selectCourseLock.Message; evaluationControlView.IsSelectCourseLockDisplay = "table-row"; } else { evaluationControlView.IsSelectCourseLock = false; evaluationControlView.SelectCourseLockMessage = "未设置。"; evaluationControlView.IsSelectCourseLockDisplay = "none"; } var examinationApplyLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationExaminationApply").SingleOrDefault(); if (examinationApplyLock != null) { evaluationControlView.IsExaminationApplyLock = examinationApplyLock.IsEnable ?? false; evaluationControlView.ExaminationApplyLockMessage = examinationApplyLock.Message; evaluationControlView.IsExaminationApplyLockDisplay = "table-row"; } else { evaluationControlView.IsExaminationApplyLock = false; evaluationControlView.ExaminationApplyLockMessage = "未设置。"; evaluationControlView.IsExaminationApplyLockDisplay = "none"; } var courseScoreLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationCourseScore").SingleOrDefault(); if (courseScoreLock != null) { evaluationControlView.IsCourseScoreLock = courseScoreLock.IsEnable ?? false; evaluationControlView.CourseScoreLockMessage = courseScoreLock.Message; evaluationControlView.IsCourseScoreLockDisplay = "table-row"; } else { evaluationControlView.IsCourseScoreLock = false; evaluationControlView.CourseScoreLockMessage = "未设置。"; evaluationControlView.IsCourseScoreLockDisplay = "none"; } var levelScoreLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationLevelScore").SingleOrDefault(); if (levelScoreLock != null) { evaluationControlView.IsLevelScoreLock = levelScoreLock.IsEnable ?? false; evaluationControlView.LevelScoreLockMessage = levelScoreLock.Message; evaluationControlView.IsLevelScoreLockDisplay = "table-row"; } else { evaluationControlView.IsLevelScoreLock = false; evaluationControlView.LevelScoreLockMessage = "未设置。"; evaluationControlView.IsLevelScoreLockDisplay = "none"; } } return evaluationControlView; } } /// /// 评价控制保存 /// /// public void EvaluationControlSave(EvaluationControlView evaluationControlView) { try { var newEvaluationControlInList = new List(); var controlItemList = EvaluationControlDAL.ControlItemRepository.GetList(x => x.ControlItemTypeID == (int)SYS_ControlItemType.Evaluation).ToList(); if (controlItemList == null || controlItemList.Count <= 0) { throw new Exception("评价控制类型未配置,请配置。"); } else { var loginLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationLogin").SingleOrDefault(); if (loginLock != null) { loginLock.IsLoginControl = true; loginLock.IsEnable = evaluationControlView.IsLoginLock; loginLock.Message = evaluationControlView.LoginLockMessage; } var selectCourseLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationSelectCourse").SingleOrDefault(); if (selectCourseLock != null) { selectCourseLock.IsLoginControl = false; selectCourseLock.IsEnable = evaluationControlView.IsSelectCourseLock; selectCourseLock.Message = evaluationControlView.SelectCourseLockMessage; } var examinationApplyLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationExaminationApply").SingleOrDefault(); if (examinationApplyLock != null) { examinationApplyLock.IsLoginControl = false; examinationApplyLock.IsEnable = evaluationControlView.IsExaminationApplyLock; examinationApplyLock.Message = evaluationControlView.ExaminationApplyLockMessage; } var courseScoreLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationCourseScore").SingleOrDefault(); if (courseScoreLock != null) { courseScoreLock.IsLoginControl = false; courseScoreLock.IsEnable = evaluationControlView.IsCourseScoreLock; courseScoreLock.Message = evaluationControlView.CourseScoreLockMessage; } var levelScoreLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationLevelScore").SingleOrDefault(); if (levelScoreLock != null) { levelScoreLock.IsLoginControl = false; levelScoreLock.IsEnable = evaluationControlView.IsLevelScoreLock; levelScoreLock.Message = evaluationControlView.LevelScoreLockMessage; } var evaluationControl = new EM_EvaluationControl(); evaluationControl.EvaluationControlID = Guid.NewGuid(); evaluationControl.SchoolyearID = evaluationControlView.SchoolyearID; evaluationControl.IsSelectCourseLock = evaluationControlView.IsSelectCourseLock; evaluationControl.IsExaminationApplyLock = evaluationControlView.IsExaminationApplyLock; evaluationControl.IsCourseScoreLock = evaluationControlView.IsCourseScoreLock; evaluationControl.IsLevelScoreLock = evaluationControlView.IsLevelScoreLock; evaluationControl.NoNumber = evaluationControlView.NoNumber; this.SetNewStatus(evaluationControl); newEvaluationControlInList.Add(evaluationControl); } using (TransactionScope ts = new TransactionScope()) { UnitOfWork.Delete(x => true); UnitOfWork.BulkInsert(newEvaluationControlInList); this.UnitOfWork.Commit(); ts.Complete(); } ControlItemServices.Value.RefreshCache(); } catch (Exception ex) { throw new Exception(ex.Message); } } } }