123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- 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.ViewModel;
- using EMIS.DataLogic.ScoreManage;
- using EMIS.ViewModel.Cultureplan;
- using EMIS.Utility;
- namespace EMIS.CommonLogic.ScoreManage
- {
- public class MisconductServices : BaseWorkflowServices<ER_Misconduct>, IMisconductServices
- {
- public ExaminationSuspensionDAL ExaminationSuspensionDAL { get; set; }
- public MisconductDAL MisconductDAL { get; set; }
- public FinalExaminationDAL FinalExaminationDAL { get; set; }
- public ExamsStateSettingDAL ExamsStateSettingDAL { get; set; }
- public Lazy<IScoreServices> ScoreServices { get; set; }
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ScoreManage.MisconductView> GetMisconductGridView(ViewModel.ConfiguretView conditions,
- Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, int? examsCatagoryID, int? examsStateID,
- int? recordStatus, int? learningformID, int? education, string LearnSystem, int? pageIndex = null, int? pageSize = null)
- {
- Expression<Func<ER_Misconduct, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var statusList = this.GetStatusViewList();
- 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 (examsStateID.HasValue)
- {
- exp = exp.And(x => x.ExamsStateID == examsStateID);
- }
- 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.MisconductDAL.GetMisconductViewQueryable(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 List<ViewModel.ScoreManage.MisconductView> GetMisconductViewList(ViewModel.ConfiguretView conditions, Guid? schoolyearID,
- Guid? collegeID, int? year, int? standardID, Guid? classmajorID, int? examsCatagoryID, int? examsStateID, int? recordStatus, int? learningformID, int? education, string LearnSystem)
- {
- Expression<Func<ER_Misconduct, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var statusList = this.GetStatusViewList();
- 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 (examsStateID.HasValue)
- {
- exp = exp.And(x => x.ExamsStateID == examsStateID);
- }
- 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.MisconductDAL.GetMisconductViewQueryable(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 void Save(ViewModel.ScoreManage.MisconductView misconductView)
- {
- var dupMisconduct = this.MisconductDAL.MisconductRepository
- .GetSingle(x => x.UserID == misconductView.UserID && x.SchoolyearID == misconductView.SchoolyearID
- && x.CoursematerialID == misconductView.CoursematerialID && x.ExamsCategoryID == misconductView.ExamsCategoryID);
- ER_Misconduct misconduct = this.MisconductDAL.MisconductRepository
- .GetSingle(x => x.MisconductID == misconductView.MisconductID);
- ER_ExaminationSuspension examinationSuspension = this.ExaminationSuspensionDAL.ExaminationSuspensionRepository
- .GetSingle(x => x.SchoolyearID == misconductView.SchoolyearID
- &&x.UserID==misconductView.UserID
- &&x.ExamsCategoryID==misconductView.ExamsCategoryID
- &&x.CoursematerialID==misconductView.CoursematerialID
- &&x.RecordStatus==3);
- if (examinationSuspension!=null)
- {
- throw new Exception("该学生有这门考试的缓考申请记录,如需添加违纪请先撤销缓考申请。");
- }
- if (misconduct == null)
- {
- if (dupMisconduct != null)
- {
- throw new Exception("已经有相同的违纪名单,请勿重复申请。");
- }
- misconduct = new ER_Misconduct();
- misconduct.MisconductID = Guid.NewGuid();
- this.SetNewStatus(misconduct);
- misconduct.RecordStatus = this.GetStartStatus();
- this.UnitOfWork.Add(misconduct);
- }
- else
- {
- if (dupMisconduct != null && dupMisconduct.MisconductID != misconduct.MisconductID)
- {
- throw new Exception("已经有相同的违纪名单,请勿重复申请。");
- }
- this.SetModifyStatus(misconduct);
- }
- misconduct.UserID = misconductView.UserID;
- misconduct.SchoolyearID = misconductView.SchoolyearID;
- misconduct.CoursematerialID = misconductView.CoursematerialID;
- misconduct.ExamsCategoryID = misconductView.ExamsCategoryID;
- misconduct.ExamsStateID = misconductView.ExamsStateID;
- misconduct.Reason = misconductView.Reason;
- this.UnitOfWork.Commit();
- }
- public void Delete(IList<Guid> misconductIDList)
- {
- this.UnitOfWork.Remove<ER_Misconduct>(x => misconductIDList.Contains(x.MisconductID));
- this.UnitOfWork.Commit();
- }
- public List<Sys_DictionaryItem> GetMisconductExamsStateList()
- {
- var misconductIDList = this.ExamsStateSettingDAL.GetMisconductIDList().ToList();
- return DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ExamsState).Where(x => misconductIDList.Contains(x.Value)).ToList();
- }
- public ViewModel.ScoreManage.MisconductView GetMisconductView(Guid misconductID)
- {
- var statusList = this.GetStatusViewList();
- var misconductView = this.MisconductDAL.GetMisconductViewQueryable(x => x.MisconductID == misconductID)
- .FirstOrDefault();
- if (misconductView != null)
- {
- var recordStatus = statusList.FirstOrDefault(x => x.ID == misconductView.RecordStatus);
- if (recordStatus != null)
- {
- misconductView.RecordStatusName = recordStatus.Name;
- }
- }
- return misconductView;
- }
- public IGridResultSet<CoursematerialView> GetMisconductCoursematerialGridView(
- ConfiguretView conditions, Guid? schoolyearID, Guid? userID, int? pageIndex = null, int? pageSize = null)
- {
- Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolyearExp = (x => x.SchoolyearID == schoolyearID);
- Expression<Func<EMIS.Entities.CF_Student, bool>> studentExp = (x => x.UserID == userID);
- var query = this.MisconductDAL.GetMisconductCoursematerialViewQueryable(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 void OnApproveEnd(IList<Guid> misconductIDList, Guid? userID)
- {
- ScoreServices.Value.RefreshMisconductState(misconductIDList);
- }
- public void OnApproveEnds(IList<Guid> misconductIDList, Guid? userID)
- {
- ScoreServices.Value.RefreshCancelMisconductState(misconductIDList);
- }
- public List<ViewModel.ScoreManage.MisconductView> GetMisconductViewListByFinalExamination(Guid? finalExaminationID)
- {
- var endStatus = this.GetCorrectEndStatus();
- var finalExaminationView = FinalExaminationDAL.GetFinalExaminationViewQueryable(x => x.FinalExaminationID == finalExaminationID).FirstOrDefault();
- if (finalExaminationView == null)
- {
- return new List<ViewModel.ScoreManage.MisconductView>();
- }
- Expression<Func<ER_Misconduct, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
- && x.SchoolyearID == finalExaminationView.SchoolyearID && x.CoursematerialID == finalExaminationView.CoursematerialID
- && x.ExamsCategoryID == finalExaminationView.ExamsCategoryID && x.RecordStatus == 3);
- var statusList = this.GetStatusViewList();
- var query = this.MisconductDAL.GetMisconductViewQueryable(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> misconductIDList, Guid userID, string comment)
- {
- var endStatusID = GetEndStatusID();
- var misconductList = MisconductDAL.MisconductRepository.GetList(x => misconductIDList.Contains(x.MisconductID)).ToList();
- if (misconductList.Any(x => x.RecordStatus != endStatusID))
- {
- throw new Exception("只能撤回已通过状态的记录。");
- }
- var actionViewList = this.GetActionView(misconductIDList[0], userID);
- var actionView = actionViewList.FirstOrDefault();
- this.Approve(misconductIDList, 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;
- }
- }
- }
- }
|