123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- 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<IControlItemServices> ControlItemServices { get; set; }
- /// <summary>
- /// 查询评价控制信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="pageIndex">页码</param>
- /// <param name="pageSize">显示页数</param>
- /// <returns></returns>
- public IGridResultSet<EvaluationControlView> 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<EvaluationControlView>(pageIndex, pageSize);
- return query.OrderByDescending(x => x.CreateTime).ToGridResultSet<EvaluationControlView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询评价控制信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <returns></returns>
- public List<EvaluationControlView> 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();
- }
- /// <summary>
- /// 获取评价控制信息
- /// </summary>
- /// <param name="controlID">主键ID</param>
- /// <returns></returns>
- public EM_EvaluationControl GetEvaluationControl(Guid? controlID)
- {
- //查询条件
- Expression<Func<EM_EvaluationControl, bool>> expression = (x => x.EvaluationControlID == controlID.Value);
- return evaluationControlDAL.evaluationControlRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取评价控制信息
- /// </summary>
- /// <param name="schoolyearID">学年学期ID</param>
- /// <returns></returns>
- public EM_EvaluationControl GetEvaluationControl(Guid schoolyearID)
- {
- //查询条件
- Expression<Func<EM_EvaluationControl, bool>> expression = (x => x.SchoolyearID == schoolyearID);
- return evaluationControlDAL.evaluationControlRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取评价控制信息
- /// </summary>
- /// <param name="controlID">主键ID</param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="evaluationControl">实体</param>
- /// <returns></returns>
- public bool EvaluationControlSave(EvaluationControlView evaluationControlView)
- {
- try
- {
- UnitOfWork.Delete<EM_EvaluationControl>(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;
- }
- }
- }
|