123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.EvaluationManage;
- using EMIS.ViewModel;
- using EMIS.DataLogic.Common.EvaluationManage;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
- namespace EMIS.CommonLogic.EvaluationManage
- {
- public class EvaluationOpenControlServices : BaseServices,IEvaluationOpenControlServices
- {
- public EvaluationOpenControlDAL evaluationOpenControlDAL { get; set; }
- /// <summary>
- /// 查询评价控制信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="pageIndex">页码</param>
- /// <param name="pageSize">显示页数</param>
- /// <returns></returns>
- public IGridResultSet<EvaluationOpenControlView> GetEvaluationOpenControlViewGrid(ConfiguretView configuretView, Guid? SchoolYearID, Guid? CollegeID, int? Year, int? Standard, int? education, int? Learningform, string LearnSystem, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EvaluationGradeControl, bool>> exp = (x =>true);
- if (SchoolYearID.HasValue)
- exp=exp.And(x => x.SchoolyearID == SchoolYearID);
- if (CollegeID.HasValue)
- exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.CF_College.CollegeID == CollegeID);
- if(Year.HasValue)
- exp = exp.And(x => x.CF_Grademajor.GradeID == Year);
- if (Standard.HasValue)
- exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == Standard);
- if(education.HasValue)
- exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.EducationID == education);
- if(Learningform.HasValue)
- exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.LearningformID == Learningform);
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- exp = exp.And(x => x.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
- }
- var query = evaluationOpenControlDAL.GetEvaluationControlQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.SchoolyearID).ToGridResultSet<EvaluationOpenControlView>(pageIndex, pageSize);
- return query.OrderByDescending(x => x.SchoolyearID).ToGridResultSet<EvaluationOpenControlView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 通过ID查询开放控制
- /// </summary>
- /// <param name="evaluationGradeControlID"></param>
- /// <returns></returns>
- public EvaluationOpenControlView GetEvaluationOpenControlView(Guid? evaluationGradeControlID)
- {
- var query = evaluationOpenControlDAL.GetEvaluationControlQueryable(x => x.EvaluationGradeControlID == evaluationGradeControlID).FirstOrDefault();
- return query;
- }
- /// <summary>
- /// 查询开放控制信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="pageIndex">页码</param>
- /// <param name="pageSize">显示页数</param>
- /// <returns></returns>
- public IGridResultSet<GrademajorView> GrademajorViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? standardID, int? educationID, int? learningformID, int? schoolyear, string LearnSystem,Guid? SchoolYearID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Grademajor, bool>> exp = (x => true);
- Expression<Func<EM_EvaluationGradeControl, bool>> exps=(x=>true);
- if (campusID.HasValue)
- exp = exp.And(x => x.CF_Facultymajor.CF_College.CampusID == campusID);
- if (collegeID.HasValue)
- exp = exp.And(x => x.CF_Facultymajor.CF_College.CollegeID == collegeID);
- if(standardID.HasValue)
- exp = exp.And(x => x.CF_Facultymajor.StandardID == standardID);
- if(educationID.HasValue)
- exp = exp.And(x => x.CF_Facultymajor.EducationID == educationID);
- if (learningformID.HasValue)
- exp = exp.And(x => x.CF_Facultymajor.LearningformID == learningformID);
- if (schoolyear.HasValue)
- exp = exp.And(x => x.GradeID == schoolyear);
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- exp = exp.And(x => x.CF_Facultymajor.LearnSystem == LearnSystems);
- }
- if (SchoolYearID.HasValue)
- exps= exps.And(x => x.SchoolyearID == SchoolYearID);
- var query = evaluationOpenControlDAL.GrademajorViewGridQueryable(exp, exps);
- return query.OrderByDescending(x => x.CollegeID).OrderBy(x => x.FacultymajorID).ToGridResultSet<GrademajorView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 新增修改开放控制
- /// </summary>
- /// <param name="evaluationOpenControlView"></param>
- /// <returns></returns>
- public bool EvaluationOpenControlEdit(EvaluationOpenControlView evaluationOpenControlView, List<GrademajorView> GrademajorList)
- {
- if (evaluationOpenControlView.EvaluationGradeControlID == null || evaluationOpenControlView.EvaluationGradeControlID==Guid.Empty)
- {
- EvaluationOpenControlAdd(evaluationOpenControlView, GrademajorList);
- }
- else
- {
- EvaluationOpenControlUpdate(evaluationOpenControlView);
- }
- UnitOfWork.Commit();
- return true;
- }
- public void EvaluationOpenControlAdd(EvaluationOpenControlView evaluationOpenControlView, List<GrademajorView> GrademajorList)
- {
- List<EM_EvaluationGradeControl> EM_EvaluationGradeControlList = new List<EM_EvaluationGradeControl>();
- foreach (var g in GrademajorList){
- EM_EvaluationGradeControl EvaluationGradeControl = new EM_EvaluationGradeControl();
- EvaluationGradeControl.EvaluationGradeControlID = Guid.NewGuid();
- EvaluationGradeControl.GrademajorID = g.GrademajorID;
- EvaluationGradeControl.SchoolyearID = evaluationOpenControlView.SchoolyearID;
- EvaluationGradeControl.StartTime = evaluationOpenControlView.StartTime;
- var endTime = evaluationOpenControlView.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59);
- EvaluationGradeControl.EndTime = endTime;
- EvaluationGradeControl.Number = evaluationOpenControlView.EvaluationCount;
- SetNewStatus(EvaluationGradeControl);
- EM_EvaluationGradeControlList.Add(EvaluationGradeControl);
- }
- UnitOfWork.BulkInsert(EM_EvaluationGradeControlList);
- UnitOfWork.Commit();
- }
- public void EvaluationOpenControlUpdate(EvaluationOpenControlView evaluationOpenControlView)
- {
- EM_EvaluationGradeControl EvaluationGradeControl = new EM_EvaluationGradeControl();
- EvaluationGradeControl = evaluationOpenControlDAL.EvaluationGradeControlRepository.Entities.Where(x => x.EvaluationGradeControlID == evaluationOpenControlView.EvaluationGradeControlID).FirstOrDefault();
- EvaluationGradeControl.GrademajorID = evaluationOpenControlView.GrademajorID;
- EvaluationGradeControl.SchoolyearID = evaluationOpenControlView.SchoolyearID;
- EvaluationGradeControl.StartTime = evaluationOpenControlView.StartTime;
- EvaluationGradeControl.EndTime = evaluationOpenControlView.EndTime;
- EvaluationGradeControl.Number = evaluationOpenControlView.EvaluationCount;
- SetModifyStatus(EvaluationGradeControl);
- }
- public string Verification(Guid? SchoolYearID, List<Guid?> list, string StartTime, string EndTime)
- {
- //获取所有的开放控制
- var EvaluationGradeControlList = evaluationOpenControlDAL.EvaluationGradeControlRepository.GetList(x => true).ToList();
- //获取存在的开放控制
- var existList = EvaluationGradeControlList.Where(x => x.SchoolyearID == SchoolYearID && list.Contains(x.GrademajorID)).Select(x => x.GrademajorID).ToList();
- //获取存在的开放控制的年级专业
- var GrademajorList = evaluationOpenControlDAL.GrademajorRepository.GetList(x => existList.Contains(x.GrademajorID));
- //获取参评类型
- var EvaluationType = evaluationOpenControlDAL.EvaluationTypeRepository.GetList(x => x.IsStudent == true).FirstOrDefault();
-
- StringBuilder sb = new StringBuilder();
- if (EvaluationType != null)
- {
- if (EvaluationType.StartTime.Value.Date.CompareTo(Convert.ToDateTime(StartTime)) > 0)
- {
- sb.Append("开始时间早于参评类型设置的开始时间、");
- }
- if (EvaluationType.EndTime.Value.Date.CompareTo(Convert.ToDateTime(StartTime)) < 0)
- {
- sb.Append("开始时间晚于参评类型设置的结束时间、");
- }
- if (EvaluationType.StartTime.Value.Date.CompareTo(Convert.ToDateTime(EndTime)) > 0)
- {
- sb.Append("结束时间早于参评类型设置的开始时间、");
- }
- if (EvaluationType.EndTime.Value.Date.CompareTo(Convert.ToDateTime(EndTime)) < 0)
- {
- sb.Append("结束时间晚于参评类型设置的结束时间、");
- }
- if (Convert.ToDateTime(EndTime).CompareTo(Convert.ToDateTime(StartTime)) < 0)
- {
- sb.Append("结束时间早于开始时间、");
- }
- if (existList.Count > 0)
- {
- if (sb.ToString() == "")
- {
- foreach (var g in GrademajorList)
- {
- sb.Append(g.Name + "、");
- }
- sb.Remove(sb.ToString().LastIndexOf('、'), 1);
- sb.Append("等专业已存在,请检查!");
- return sb.ToString();
- }
- else
- {
- sb.Remove(sb.ToString().LastIndexOf('、'), 1);
- return sb.ToString();
- }
- }
- else
- {
- if (sb.ToString() != "")
- {
- sb.Remove(sb.ToString().LastIndexOf('、'), 1);
- return sb.ToString();
- }
- return "成功";
- }
- }
- else
- {
- sb.Append("请设置适用于学生参评类型。");
- return sb.ToString();
- }
-
- }
- public void Delete(List<Guid?> list)
- {
- UnitOfWork.Remove<EM_EvaluationGradeControl>(x => list.Contains(x.EvaluationGradeControlID));
- UnitOfWork.Commit();
- }
- }
- }
|