123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.Entities;
- using EMIS.DataLogic.ScoreManage;
- using EMIS.ViewModel;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.Utility.FormValidate;
- namespace EMIS.CommonLogic.ScoreManage
- {
- public class ExaminationSuspensionServices : BaseWorkflowServices<ER_ExaminationSuspension>, IExaminationSuspensionServices
- {
- public ExaminationSuspensionDAL ExaminationSuspensionDAL { get; set; }
- public FinalExaminationDAL FinalExaminationDAL { get; set; }
- public Lazy<IScoreServices> ScoreServices { get; set; }
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ScoreManage.ExaminationSuspensionView> GetExaminationSuspensionGridView(
- ViewModel.ConfiguretView conditions, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID,
- int? examsCatagoryID, int? recordStatus, int? learningformID, int? education, string LearnSystem, int? pageIndex = null, int? pageSize = null)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<ER_ExaminationSuspension, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var startStatus = this.GetStartStatus();
- var userID = CustomPrincipal.Current.UserID;
- exp = exp.And(x => x.RecordStatus != startStatus||(x.RecordStatus==startStatus&&x.CreateUserID==userID));
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.ClassmajorID == classmajorID);
- }
- if (examsCatagoryID.HasValue)
- {
- exp = exp.And(x => x.ExamsCategoryID == examsCatagoryID);
- }
- if (recordStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == recordStatus);
- }
- if (learningformID.HasValue)
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
- }
- if (education.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
- }
- var query = this.ExaminationSuspensionDAL.GetExaminationSuspensionViewQueryable(exp);
- if (!string.IsNullOrEmpty(conditions.ConditionValue))
- {
- query = query.DynamicWhere(conditions.Attribute, conditions.Condition, conditions.ConditionValue);
- }
- query = this.GetQueryByDataRangeByCollege(query);
- var result = query.OrderByDescending(x => x.CreateTime).ThenBy(x => x.Year).ThenBy(x => x.StandardID).ToGridResultSet(pageIndex, pageSize);
- result.rows.ForEach(x => {
- var currentStatus = statusList.FirstOrDefault(w => w.ID == x.RecordStatus);
- if (currentStatus != null)
- {
- x.RecordStatusName = currentStatus.Name;
- }
- else
- {
- x.RecordStatusName = "";
- }
- });
- return result;
- }
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ScoreManage.ExaminationSuspensionView> GetExaminationSuspensionStudentGridView(
- ViewModel.ConfiguretView conditions, Guid? userID = null, int? pageIndex = null, int? pageSize = null)
- {
- Expression<Func<ER_ExaminationSuspension, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var statusList = this.GetStatusViewList();
- if (userID.HasValue)
- {
- exp = exp.And(x => x.UserID == userID);
- }
- var query = this.ExaminationSuspensionDAL.GetExaminationSuspensionViewQueryable(exp);
- if (!string.IsNullOrEmpty(conditions.ConditionValue))
- {
- query = query.DynamicWhere(conditions.Attribute, conditions.Condition, conditions.ConditionValue);
- }
- var result = query.OrderByDescending(x => x.CreateTime).ThenBy(x => x.Year).ThenBy(x => x.StandardID).ToGridResultSet(pageIndex, pageSize);
- result.rows.ForEach(x =>
- {
- var currentStatus = statusList.FirstOrDefault(w => w.ID == x.RecordStatus);
- if (currentStatus != null)
- {
- x.RecordStatusName = currentStatus.Name;
- }
- else
- {
- x.RecordStatusName = "";
- }
- });
- return result;
- }
- public List<ViewModel.ScoreManage.ExaminationSuspensionView> GetExaminationSuspensionViewList(ViewModel.ConfiguretView conditions,
- Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, int? examsCatagoryID, int? recordStatus,
- int? learningformID, int? education,string LearnSystem)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<ER_ExaminationSuspension, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var startStatus = this.GetStartStatus();
- exp = exp.And(x => x.RecordStatus != startStatus);
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.ClassmajorID == classmajorID);
- }
- if (examsCatagoryID.HasValue)
- {
- exp = exp.And(x => x.ExamsCategoryID == examsCatagoryID);
- }
- if (recordStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == recordStatus);
- }
- if (learningformID.HasValue)
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
- }
- if (education.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
- }
- var query = this.ExaminationSuspensionDAL.GetExaminationSuspensionViewQueryable(exp);
- if (!string.IsNullOrEmpty(conditions.ConditionValue))
- {
- query = query.DynamicWhere(conditions.Attribute, conditions.Condition, conditions.ConditionValue);
- }
- query = this.GetQueryByDataRangeByCollege(query);
- var result = query.OrderByDescending(x => x.CreateTime).ThenBy(x => x.Year).ThenBy(x => x.StandardID).ToList();
- result.ForEach(x =>
- {
- var currentStatus = statusList.FirstOrDefault(w => w.ID == x.RecordStatus);
- if (currentStatus != null)
- {
- x.RecordStatusName = currentStatus.Name;
- }
- else
- {
- x.RecordStatusName = "";
- }
- });
- return result;
- }
- public List<ViewModel.ScoreManage.ExaminationSuspensionView> GetExaminationSuspensionViewStudentList(ViewModel.ConfiguretView conditions,
- Guid? userID)
- {
- Expression<Func<ER_ExaminationSuspension, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var statusList = this.GetStatusViewList();
- if (userID.HasValue)
- {
- exp = exp.And(x => x.UserID == userID);
- }
- var query = this.ExaminationSuspensionDAL.GetExaminationSuspensionViewQueryable(exp);
- if (!string.IsNullOrEmpty(conditions.ConditionValue))
- {
- query = query.DynamicWhere(conditions.Attribute, conditions.Condition, conditions.ConditionValue);
- }
- var result = query.OrderByDescending(x => x.CreateTime).ThenBy(x => x.Year).ThenBy(x => x.StandardID).ToList();
- result.ForEach(x =>
- {
- var currentStatus = statusList.FirstOrDefault(w => w.ID == x.RecordStatus);
- if (currentStatus != null)
- {
- x.RecordStatusName = currentStatus.Name;
- }
- else
- {
- x.RecordStatusName = "";
- }
- });
- return result;
- }
- public EMIS.ViewModel.ScoreManage.ExaminationSuspensionView GetExaminationSuspensionView(Guid examinationSuspensionID)
- {
- var statusList = this.GetStatusViewList();
- var examinationSuspensionView = this.ExaminationSuspensionDAL.GetExaminationSuspensionViewQueryable(x => x.ExaminationSuspensionID == examinationSuspensionID)
- .FirstOrDefault();
- if (examinationSuspensionView != null)
- {
- var recordStatus = statusList.FirstOrDefault(x => x.ID == examinationSuspensionView.RecordStatus);
- if (recordStatus != null)
- {
- examinationSuspensionView.RecordStatusName = recordStatus.Name;
- }
- }
- return examinationSuspensionView;
- }
- public void Save(ViewModel.ScoreManage.ExaminationSuspensionView examinationSuspensionView)
- {
- int? endStatus = this.GetCorrectEndStatus();
- var dupSuspension = this.ExaminationSuspensionDAL.ExaminationSuspensionRepository
- .GetSingle(x => x.UserID == examinationSuspensionView.UserID && x.SchoolyearID == examinationSuspensionView.SchoolyearID
- && x.CoursematerialID == examinationSuspensionView.CoursematerialID && x.ExamsCategoryID == examinationSuspensionView.ExamsCategoryID && x.RecordStatus != endStatus);
-
- ER_ExaminationSuspension examinationSuspension = this.ExaminationSuspensionDAL.ExaminationSuspensionRepository
- .GetSingle(x => x.ExaminationSuspensionID == examinationSuspensionView.ExaminationSuspensionID);
- if (examinationSuspension == null)
- {
- if (dupSuspension != null)
- {
- throw new Exception("该科目在这个学期已经申请过缓考,请勿重复申请。");
- }
- examinationSuspension = new ER_ExaminationSuspension();
- examinationSuspension.ExaminationSuspensionID = Guid.NewGuid();
- this.SetNewStatus(examinationSuspension);
- examinationSuspension.RecordStatus = this.GetStartStatus();
- this.UnitOfWork.Add(examinationSuspension);
- }
- else
- {
- if (dupSuspension != null && dupSuspension.ExaminationSuspensionID != examinationSuspension.ExaminationSuspensionID && dupSuspension.RecordStatus != endStatus)
- {
- throw new Exception("该科目在这个学期已经申请过缓考,请勿重复申请。");
- }
- this.SetModifyStatus(examinationSuspension);
- }
- examinationSuspension.UserID = examinationSuspensionView.UserID;
- examinationSuspension.SchoolyearID = examinationSuspensionView.SchoolyearID;
- examinationSuspension.CoursematerialID = examinationSuspensionView.CoursematerialID;
- examinationSuspension.ExamsCategoryID = examinationSuspensionView.ExamsCategoryID;
- examinationSuspension.Reason = examinationSuspensionView.Reason;
- this.UnitOfWork.Commit();
- }
- public void Delete(IList<Guid> examinationSuspensionIDList)
- {
- this.UnitOfWork.Remove<ER_ExaminationSuspension>(x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID));
- this.UnitOfWork.Commit();
- }
- public IGridResultSet<ViewModel.ScoreManage.ExaminationSuspensionCoursematerialView> GetExaminationSuspensionCoursematerialGridView(
- ConfiguretView conditions, int? pageIndex = null, int? pageSize = null)
- {
- var userID = CustomPrincipal.Current.UserID;
- Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolyearExp = (x => x.IsCurrent == true);
- Expression<Func<EMIS.Entities.CF_Student, bool>> studentExp = (x => x.UserID == userID);
- var query = this.ExaminationSuspensionDAL.GetExaminationSuspensionCoursematerialViewQueryable(schoolyearExp, studentExp);
- if (!string.IsNullOrEmpty(conditions.ConditionValue))
- {
- query = query.DynamicWhere(conditions.Attribute, conditions.Condition, conditions.ConditionValue);
- }
- var result = query.OrderBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseName).ToGridResultSet(pageIndex, pageSize);
- return result;
- }
- public IGridResultSet<ViewModel.ScoreManage.ExaminationSuspensionCoursematerialView> GetExaminationSuspensionCoursematerialGridViewForTeacher(
- ConfiguretView conditions, Guid? UserID, int? pageIndex = null, int? pageSize = null)
- {
-
- Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolyearExp = (x => x.IsCurrent == true);
- Expression<Func<EMIS.Entities.CF_Student, bool>> studentExp = (x => true);
- if (UserID.HasValue)
- {
- studentExp=(x=>x.UserID== UserID);
- }
- var query = this.ExaminationSuspensionDAL.GetExaminationSuspensionCoursematerialViewQueryable(schoolyearExp, studentExp);
- if (!string.IsNullOrEmpty(conditions.ConditionValue))
- {
- query = query.DynamicWhere(conditions.Attribute, conditions.Condition, conditions.ConditionValue);
- }
- query = query.Distinct();
- var result = query.OrderBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseName).ToGridResultSet(pageIndex, pageSize);
- return result;
- }
- public void OnApproveEnd(List<Guid> examinationSuspensionIDList, Guid? userID)
- {
- ScoreServices.Value.RefreshExaminationSuspensionState(examinationSuspensionIDList);
- }
- public void OnApproveEnds(List<Guid> examinationSuspensionIDList, Guid? userID)
- {
- ScoreServices.Value.RefreshCancelExaminationSuspensionState(examinationSuspensionIDList);
- }
- public List<ViewModel.ScoreManage.ExaminationSuspensionView> GetExaminationSuspensionViewListByFinalExamination(Guid? finalExaminationID)
- {
- var endStatus = this.GetStatusViewList().FirstOrDefault(x => x.Description == "[End]");
- int? endStatusID = null;
- if (endStatus != null)
- {
- endStatusID = endStatus.ID;
- }
- var finalExaminationView = FinalExaminationDAL.GetFinalExaminationViewQueryable(x => x.FinalExaminationID == finalExaminationID).FirstOrDefault();
- if (finalExaminationView == null)
- {
- return new List<ViewModel.ScoreManage.ExaminationSuspensionView>();
- }
- Expression<Func<ER_ExaminationSuspension, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
- && x.SchoolyearID == finalExaminationView.SchoolyearID && x.CoursematerialID == finalExaminationView.CoursematerialID
- && x.ExamsCategoryID == finalExaminationView.ExamsCategoryID && x.RecordStatus == endStatusID);
- var statusList = this.GetStatusViewList();
- var query = this.ExaminationSuspensionDAL.GetExaminationSuspensionViewQueryable(exp);
- var result = query.OrderByDescending(x => x.CreateTime).ThenBy(x => x.Year).ThenBy(x => x.StandardID).ToList();
- result.ForEach(x =>
- {
- var currentStatus = statusList.FirstOrDefault(w => w.ID == x.RecordStatus);
- if (currentStatus != null)
- {
- x.RecordStatusName = currentStatus.Name;
- }
- else
- {
- x.RecordStatusName = "";
- }
- });
- return result;
- }
- public void Cancel(List<Guid> examinationSuspensionIDList, Guid userID, string comment)
- {
- var endStatusID = GetEndStatusID();
- var examinationSuspensionList = ExaminationSuspensionDAL.ExaminationSuspensionRepository
- .GetList(x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID)).ToList();
- if (examinationSuspensionList.Any(x => x.RecordStatus != endStatusID))
- {
- throw new Exception("只能撤回已通过状态的记录。");
- }
- var actionViewList = this.GetActionView(examinationSuspensionIDList[0], userID);
- var actionView = actionViewList.FirstOrDefault();
- this.Approve(examinationSuspensionIDList, userID, actionView.ActionID, comment);
- }
- public int? GetEndStatusID()
- {
- var endStatus = this.GetStatusViewList().FirstOrDefault(x => x.Description.Contains("[End]"));
- if (endStatus != null)
- {
- return endStatus.ID;
- }
- else
- {
- return null;
- }
- }
- }
- }
|