123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.MinorManage.MinorApply;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.MinorManage.MinorApply;
- using EMIS.DataLogic.MinorManage.MinorSetting;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.Utility;
- using EMIS.ViewModel.MinorManage.MinorSetting;
- using System.Transactions;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.MinorManage.MinorPlanManage;
- using EMIS.DataLogic.MinorManage.MinorPlanManage;
- namespace EMIS.CommonLogic.MinorManage.MinorApply
- {
- public class StudentMinorRegistApplyServices : BaseWorkflowServices<EM_StudentMinorRegist>, IStudentMinorRegistApplyServices
- {
- public StudentMinorRegistApplyDAL studentMinorRegistApplyDAL { get; set; }
- public MinorStandardSettingDAL minorStandardSettingDAL { get; set; }
- public MinorControlDAL minorControlDAL { get; set; }
- public ISchoolYearServices schoolYearServices { get; set; }
- public MinorConditionDAL minorConditionDAL { get; set; }
- public MinorPlanApplyDAL minorPlanApplyDAL { get; set; }
- public IGridResultSet<GrademinorView> GetGrademinorViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? yearID, int? minorStandardID, int pageIndex, int pageSize)
- {
- var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var applyStatusList = this.GetStatusViewList();
- var returnStatus = applyStatusList.Where(x => x.Description.Contains("BP")).FirstOrDefault().ID;
- var standardID = studentMinorRegistApplyDAL.GetStandardIDListByUserID(user.UserID);
- List<int?> minorStandardIDList = new List<int?>();
- if (standardID.HasValue)
- {
- var squery = minorStandardSettingDAL.GetMinorStandardSettingViewQueryable(x => x.StandardID == standardID);
- if (squery.Count() > 0)
- {
- minorStandardIDList = squery.Select(x => x.MinorStandardID).ToList();
- }
- }
- Expression<Func<CF_Grademinor, bool>> exp = x => true;
- //只显示已开放状态的辅修专业对应的信息
- //exp = exp.And(x => x.RecordStatus == (int)CF_GrademinorStatus.Opened);
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- exp = exp.And(x => x.YearID == yearID);
- }
- if (minorStandardID.HasValue)
- {
- exp = exp.And(x => x.StandardID == minorStandardID);
- }
- if (minorStandardIDList.Count <= 0)
- {
- exp = exp.And(x => x.StandardID == null);
- }
- else
- {
- exp = exp.And(x => minorStandardIDList.Contains(x.StandardID));
- }
- var query = studentMinorRegistApplyDAL.GetMinorClassViewQueryable(exp, user.UserID, returnStatus);
- //学生报名界面显示已报名的辅修信息,还有已开放的辅修信息
- query = query.Where(x => x.OpenStatus == (int)CF_GrademinorStatus.Opened || x.RecordStatus != null);
- //列表查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var schoolYear = schoolYearServices.GetSchoolYearIsCurrent(true);
- var control = studentMinorRegistApplyDAL.GetMinorControlViewByUserIDAndSchoolyear(user.UserID, schoolYear.SchoolyearID);
- var canSelect = true;
- var result = query.OrderByDescending(x => x.SchoolyearCode).ToGridResultSet(pageIndex, pageSize);
-
- if (control != null)
- {
- if (DateTime.Now < control.FirstOrDefault().StartDate || DateTime.Now > control.FirstOrDefault().EndDate)
- {
- result.rows.ForEach(x => x.CanSelect = false);
- }
- result.rows.ForEach(x => x.MinorControlID = control.FirstOrDefault().MinorControlID);
- result.rows.ForEach(x => x.StartDate = control.FirstOrDefault().StartDate);
- result.rows.ForEach(x => x.EndDate = control.FirstOrDefault().EndDate);
-
- }
- else{
- result.rows.ForEach(x => x.CanSelect = false);
- }
- if (query.Any(x => x.CanSelect == false))
- {
- result.rows.ForEach(x => x.CanSelect = false);
- }
- result.rows.ForEach(x => x.RecordStatusStr = x.RecordStatus != null ? applyStatusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name : "");
- result.rows.ForEach(x => x.CanSelect = x.OpenStatus != (int)CF_GrademinorStatus.Opened ? false : x.CanSelect);
- result.rows.ForEach(x => x.CanSelect = (x.OperateText == "已报满" || x.OperateText == "已报名") ? false : x.CanSelect);
- return result;
- }
- public void Apply(Guid GrademinorID)
- {
- try
- {
- //using (TransactionScope ts = new TransactionScope())
- //{
- Expression<Func<ER_MinorControl, bool>> exp = x => true;
- var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var schoolYear = schoolYearServices.GetSchoolYearIsCurrent(true);
- //开放控制验证
- var control = studentMinorRegistApplyDAL.GetMinorControlViewByUserIDAndSchoolyear(user.UserID, schoolYear.SchoolyearID);
- if (control != null)
- {
- var con = control.FirstOrDefault();
- if (DateTime.Now < con.StartDate || DateTime.Now > con.EndDate)
- {
- throw new Exception("不在辅修报名开放时间内");
- }
- }
- //辅修专业验证
- var grademinor = studentMinorRegistApplyDAL.grademinorRepository.GetSingle(x => x.GrademinorID == GrademinorID);
- if (grademinor != null)
- {
- if (grademinor.RecordStatus != (int)CF_GrademinorStatus.Opened)
- {
- throw new Exception("该辅修专业不处于已开放状态,不能进行报名");
- }
- }
- //辅修条件验证
- Expression<Func<ER_MinorCondition, bool>> mcdexp = x => x.RecordStatus >= (int)SYS_STATUS.USABLE;
- var query = minorConditionDAL.GetMinorConditionViewQueryable(mcdexp);
- bool isPass = true;
- foreach (var minorCondition in query)
- {
- var retValue = ReflectorHelper.RunMethod(minorCondition.MethodFullName, user.UserID);
- if (!(bool)retValue)
- {
- //表示条件不通过
- isPass = false;
- //终止循环
- break;
- }
- }
- if (!isPass)
- {
- throw new Exception("辅修条件不通过");
- }
- //查询对应的工作流程环节状态信息View
- var approveStatusList = this.GetStatusViewList();
- if (approveStatusList == null || approveStatusList.Count() <= 0)
- {
- throw new Exception("工作流平台中,辅修报名流程未配置,请核查");
- }
- //查询工作流程开始环节状态
- var approveStartStatus = this.GetStartStatus();
- if (approveStartStatus == null)
- {
- throw new Exception("工作流平台中,辅修报名流程开始环节未配置,请核查");
- }
- var action = this.GetActionView();
- var actionID = action.Where(x => x.Pid == approveStartStatus).FirstOrDefault().ActionID;
- EM_StudentMinorRegist studentMinorRegist = new EM_StudentMinorRegist();
- studentMinorRegist.StudentMinorRegistID = Guid.NewGuid();
- studentMinorRegist.SchoolyearID = schoolYear.SchoolyearID;
- studentMinorRegist.GrademinorID = GrademinorID;
- studentMinorRegist.UserID = user.UserID;
- studentMinorRegist.RecordStatus = approveStartStatus;
- studentMinorRegist.CreateTime = DateTime.Now;
- studentMinorRegist.CreateUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
- studentMinorRegist.ModifyTime = DateTime.Now;
- studentMinorRegist.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
- UnitOfWork.Add(studentMinorRegist);
- UnitOfWork.Commit();
- List<Guid> idList = new List<Guid>();
- idList.Add(studentMinorRegist.StudentMinorRegistID);
- this.StartUp(idList, user.UserID,"");
- // ts.Complete();
- //}
- }
- catch (Exception)
- {
- throw;
- }
- }
- public IGridResultSet<MinorPlanApplyView> existStandardAndMinorSpecialtyCourseViewGrid(Guid? grademinorID, int pageIndex, int pageSize)
- {
- var gradeMinorApplicationID = minorPlanApplyDAL.GrademinorRepository.GetSingle(x => x.GrademinorID == grademinorID).GrademinorApplicationID;
- Expression<Func<CF_GrademinorApplication, bool>> exp = (x => x.GradeMinorApplicationID == gradeMinorApplicationID);
- var query = minorPlanApplyDAL.existStandardAndMinorSpecialtyCourseView(exp);
- return this.GetQueryByDataRangeByCollege(query)
- .OrderBy(x => x.StarttermID).ThenBy(x => x.CourseCode)
- .ToGridResultSet<MinorPlanApplyView>(pageIndex, pageSize);
- }
- public string GetMinorApplyDateTime(Guid? schoolyearID)
- {
- var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var minorcontrolquery = studentMinorRegistApplyDAL.GetMinorControlViewByUserIDAndSchoolyear(user.UserID, schoolyearID.Value);
- if (minorcontrolquery == null)
- {
- return "未开放";
- }
- else
- {
- var minorcontrol = studentMinorRegistApplyDAL.GetMinorControlViewByUserIDAndSchoolyear(user.UserID, schoolyearID.Value).FirstOrDefault();
- if (minorcontrol.StartDate > DateTime.Now)
- {
- return Convert.ToDateTime(minorcontrol.StartDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " 至 " + Convert.ToDateTime(minorcontrol.EndDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " (即将开始)";
- }
- else if (minorcontrol.EndDate < DateTime.Now)
- {
- return Convert.ToDateTime(minorcontrol.StartDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " 至 " + Convert.ToDateTime(minorcontrol.EndDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " (报名结束)";
- }
- else
- {
- return Convert.ToDateTime(minorcontrol.StartDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " 至 " + Convert.ToDateTime(minorcontrol.EndDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " (开始报名)";
- }
- }
- }
- }
- }
|