123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- 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<IControlItemServices> ControlItemServices { get; set; }
- /// <summary>
- /// 查询评价控制类型相应的信息View(费用控制-1,注册控制-2,评价控制-3)
- /// </summary>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- /// 评价控制保存
- /// </summary>
- /// <param name="evaluationControlView"></param>
- public void EvaluationControlSave(EvaluationControlView evaluationControlView)
- {
- try
- {
- var newEvaluationControlInList = new List<EM_EvaluationControl>();
- 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<EM_EvaluationControl>(x => true);
- UnitOfWork.BulkInsert(newEvaluationControlInList);
- this.UnitOfWork.Commit();
- ts.Complete();
- }
- ControlItemServices.Value.RefreshCache();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|