using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using System.Transactions; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.CultureplanManage; using EMIS.ViewModel.CultureplanManage.PlanManagement; using EMIS.CommonLogic.SystemServices; using EMIS.DataLogic.CultureplanManage.PlanManagement; namespace EMIS.CommonLogic.CultureplanManage.PlanManagement { public class PlanApplicationServices : BaseWorkflowServices, IPlanApplicationServices { public PlanApplicationDAL PlanApplicationDAL { get; set; } /// /// 查询对应的计划申请信息PlanApplicationView /// 注:普教版本(年级专业) /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetPlanApplicationViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? coursematerialID, int? handleModeID, int? approvalStatus, int pageIndex, int pageSize) { //结束流程环节ID var endStatusID = this.GetCorrectEndStatus(); //审核流程状态IDList var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); var applyStatusList = this.GetStatusViewList(); var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID)) .Select(x => x.ID).ToList(); //计划申请 Expression> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expPlanApplication = expPlanApplication.And(x => applyStatusIDList.Contains(x.RecordStatus)); if (schoolyearID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.SchoolyearID == schoolyearID); } if (grademajorID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID); } if (coursematerialID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID); } if (handleModeID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.HandleModeID == handleModeID); } if (approvalStatus.HasValue) { expPlanApplication = expPlanApplication.And(x => x.RecordStatus == approvalStatus); } var query = PlanApplicationDAL.GetPlanApplicationViewQueryable(expPlanApplication); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (yearID.HasValue) { query = query.Where(x => x.GradeID == yearID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode) .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ThenByDescending(x => x.CreateTime).ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询对应的计划申请信息List /// 注:普教版本(年级专业) /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetPlanApplicationViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? coursematerialID, int? handleModeID, int? approvalStatus) { //结束流程环节ID var endStatusID = this.GetCorrectEndStatus(); //审核流程状态IDList var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); var applyStatusList = this.GetStatusViewList(); var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID)) .Select(x => x.ID).ToList(); //计划申请 Expression> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expPlanApplication = expPlanApplication.And(x => applyStatusIDList.Contains(x.RecordStatus)); if (schoolyearID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.SchoolyearID == schoolyearID); } if (grademajorID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID); } if (coursematerialID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID); } if (handleModeID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.HandleModeID == handleModeID); } if (approvalStatus.HasValue) { expPlanApplication = expPlanApplication.And(x => x.RecordStatus == approvalStatus); } var query = PlanApplicationDAL.GetPlanApplicationViewQueryable(expPlanApplication); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (yearID.HasValue) { query = query.Where(x => x.GradeID == yearID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode) .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ThenByDescending(x => x.CreateTime).ToList(); result.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 查询对应的计划申请信息PlanApplicationView(根据计划申请ID) /// /// /// public PlanApplicationView GetPlanApplicationView(Guid? planApplicationID) { try { var planApplicationView = PlanApplicationDAL.GetPlanApplicationViewQueryable(x => x.PlanApplicationID == planApplicationID).SingleOrDefault(); return planApplicationView; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID) /// /// public void PlanApplicationEdit(PlanApplicationView planApplicationView) { try { //查询对应的工作流程环节状态信息View var approveStatusList = this.GetStatusViewList(); if (approveStatusList == null || approveStatusList.Count() <= 0) { throw new Exception("工作流平台中,专业计划流程未配置,请核查。"); } //查询工作流程开始环节状态 var startStatusID = this.GetStartStatus(); if (startStatusID == null) { throw new Exception("工作流平台中,专业计划流程开始环节未配置,请核查。"); } //结束流程环节ID var endStatusID = this.GetCorrectEndStatus(); if (endStatusID == null) { throw new Exception("工作流平台中,专业计划流程结束环节未配置,请核查。"); } //审核流程状态IDList var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); var applyStatusIDList = approveStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID)) .Select(x => x.ID).ToList(); //查询数据库进行验证 var planApplicationVerify = PlanApplicationDAL.PlanApplicationRepository .GetList(x => x.PlanApplicationID != planApplicationView.PlanApplicationID && x.SchoolyearID == planApplicationView.SchoolyearID && x.GrademajorID == planApplicationView.GrademajorID && x.CoursematerialID == planApplicationView.CoursematerialID).SingleOrDefault(); if (planApplicationVerify == null) { //查询对应的年级专业信息 var grademajor = PlanApplicationDAL.GrademajorRepository .GetList(x => x.GrademajorID == planApplicationView.GrademajorID).SingleOrDefault(); if (grademajor == null) { throw new Exception("年级专业信息不存在,请检查。"); } //查询年级专业对应的入学学年学期信息 var startSchoolyear = PlanApplicationDAL.SchoolyearRepository.GetList(x => x.Years == grademajor.GradeID && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault(); if (startSchoolyear == null) { throw new Exception("年级专业对应的入学学年学期信息不存在,请检查。"); } //查询年级专业对应的毕业学年学期信息 var graduatingSemester = PlanApplicationDAL.SchoolyearRepository .GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault(); if (graduatingSemester == null) { throw new Exception("年级专业对应的毕业学年学期信息不存在,请检查。"); } //查询对应的学年学期信息 var schoolyear = PlanApplicationDAL.SchoolyearRepository .GetList(x => x.SchoolyearID == planApplicationView.SchoolyearID).SingleOrDefault(); if (schoolyear == null) { throw new Exception("学年学期信息不存在,请检查。"); } if (schoolyear.Value < startSchoolyear.Value) { throw new Exception("学年学期小于入学学年学期,请检查。"); } if (schoolyear.Value > graduatingSemester.Value) { throw new Exception("学年学期大于毕业学年学期,请检查。"); } List newPlanApplicationInList = new List(); List newPlanApplicationUpList = new List(); List newTeachingSettingInList = new List(); List newTeachingSettingUpList = new List(); List newTeachingModeTypeInList = new List(); List newTeachingPlaceInList = new List(); List planApplicationTMDelList = new List(); List planApplicationTPDelList = new List(); //数据有误验证 if (planApplicationView.PlanApplicationID != Guid.Empty) { var planApplication = PlanApplicationDAL.PlanApplicationRepository .GetList(x => x.PlanApplicationID == planApplicationView.PlanApplicationID, (x => x.EM_PlanApplicationTeachingSetting)).SingleOrDefault(); if (planApplication == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 if (applyStatusIDList.Any(x => x == planApplication.RecordStatus)) { planApplication.SchoolyearID = planApplicationView.SchoolyearID; planApplication.GrademajorID = planApplicationView.GrademajorID; planApplication.CoursematerialID = planApplicationView.CoursematerialID; planApplication.CourseStructureID = planApplicationView.CourseStructureID; planApplication.CourseCategoryID = planApplicationView.CourseCategoryID; planApplication.CourseTypeID = planApplicationView.CourseTypeID; planApplication.CourseQualityID = planApplicationView.CourseQualityID; planApplication.DepartmentID = planApplicationView.DepartmentID; planApplication.IsSpecialtycore = planApplicationView.IsSpecialtycore; planApplication.IsCooperation = planApplicationView.IsCooperation; planApplication.IsRequired = planApplicationView.IsRequired; planApplication.IsElective = planApplicationView.IsElective; planApplication.IsNetworkCourse = planApplicationView.IsNetworkCourse; planApplication.IsMainCourse = planApplicationView.IsMainCourse; planApplication.IsNeedMaterial = planApplicationView.IsNeedMaterial; planApplication.CourseFineID = planApplicationView.CourseFineID; planApplication.PracticeTypeID = planApplicationView.PracticeTypeID; planApplication.TeachinglanguageID = planApplicationView.TeachinglanguageID; planApplication.ExaminationModeID = planApplicationView.ExaminationModeID; planApplication.ResultTypeID = planApplicationView.ResultTypeID; planApplication.HandleModeID = planApplicationView.HandleModeID; planApplication.Remark = planApplicationView.Remark; SetModifyStatus(planApplication); newPlanApplicationUpList.Add(planApplication); if (planApplication.EM_PlanApplicationTeachingSetting == null) { var newTeachingSetting = new EM_PlanApplicationTeachingSetting(); newTeachingSetting.PlanApplicationID = planApplication.PlanApplicationID; newTeachingSetting.Credit = planApplicationView.Credit; newTeachingSetting.TheoryCourse = planApplicationView.TheoryCourse; newTeachingSetting.Practicehours = planApplicationView.Practicehours; newTeachingSetting.Trialhours = planApplicationView.Trialhours; newTeachingSetting.TheoryWeeklyNum = planApplicationView.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = planApplicationView.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = planApplicationView.TrialWeeklyNum; newTeachingSetting.WeeklyHours = planApplicationView.WeeklyHours; newTeachingSetting.WeeklyNum = planApplicationView.WeeklyNum; newTeachingSetting.StartWeeklyNum = planApplicationView.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = planApplicationView.EndWeeklyNum; newTeachingSettingInList.Add(newTeachingSetting); } else { planApplication.EM_PlanApplicationTeachingSetting.Credit = planApplicationView.Credit; planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse = planApplicationView.TheoryCourse; planApplication.EM_PlanApplicationTeachingSetting.Practicehours = planApplicationView.Practicehours; planApplication.EM_PlanApplicationTeachingSetting.Trialhours = planApplicationView.Trialhours; planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum = planApplicationView.TheoryWeeklyNum; planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum = planApplicationView.PracticeWeeklyNum; planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum = planApplicationView.TrialWeeklyNum; planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours = planApplicationView.WeeklyHours; planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum = planApplicationView.WeeklyNum; planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum = planApplicationView.StartWeeklyNum; planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum = planApplicationView.EndWeeklyNum; newTeachingSettingUpList.Add(planApplication.EM_PlanApplicationTeachingSetting); } if (planApplicationView.TeachingModeIDList != null && planApplicationView.TeachingModeIDList.Count() > 0) { planApplicationTMDelList.Add(planApplication.PlanApplicationID); foreach (var teachingModeID in planApplicationView.TeachingModeIDList) { var newTeachingMode = new EM_PlanApplicationTeachingModeType(); newTeachingMode.PlanApplicationTeachingModeTypeID = Guid.NewGuid(); newTeachingMode.PlanApplicationID = planApplication.PlanApplicationID; newTeachingMode.TeachingModeID = teachingModeID; SetNewStatus(newTeachingMode); newTeachingModeTypeInList.Add(newTeachingMode); } } else { planApplicationTMDelList.Add(planApplication.PlanApplicationID); } if (planApplicationView.TeachingPlaceIDList != null && planApplicationView.TeachingPlaceIDList.Count() > 0) { planApplicationTPDelList.Add(planApplication.PlanApplicationID); foreach (var teachingPlaceID in planApplicationView.TeachingPlaceIDList) { var newTeachingPlace = new EM_PlanApplicationTeachingPlace(); newTeachingPlace.PlanApplicationTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.PlanApplicationID = planApplication.PlanApplicationID; newTeachingPlace.TeachingPlace = teachingPlaceID; SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } else { planApplicationTPDelList.Add(planApplication.PlanApplicationID); } } else { throw new Exception("数据有误,请核查(只能修改未提交、已退回状态的信息)。"); } } } else { //表示新增 var newPlanApplication = new EM_PlanApplication(); newPlanApplication.PlanApplicationID = Guid.NewGuid(); newPlanApplication.SchoolyearID = planApplicationView.SchoolyearID; newPlanApplication.GrademajorID = planApplicationView.GrademajorID; newPlanApplication.CoursematerialID = planApplicationView.CoursematerialID; newPlanApplication.CourseStructureID = planApplicationView.CourseStructureID; newPlanApplication.CourseCategoryID = planApplicationView.CourseCategoryID; newPlanApplication.CourseTypeID = planApplicationView.CourseTypeID; newPlanApplication.CourseQualityID = planApplicationView.CourseQualityID; newPlanApplication.DepartmentID = planApplicationView.DepartmentID; newPlanApplication.IsSpecialtycore = planApplicationView.IsSpecialtycore; newPlanApplication.IsCooperation = planApplicationView.IsCooperation; newPlanApplication.IsRequired = planApplicationView.IsRequired; newPlanApplication.IsElective = planApplicationView.IsElective; newPlanApplication.IsNetworkCourse = planApplicationView.IsNetworkCourse; newPlanApplication.IsMainCourse = planApplicationView.IsMainCourse; newPlanApplication.IsNeedMaterial = planApplicationView.IsNeedMaterial; newPlanApplication.CourseFineID = planApplicationView.CourseFineID; newPlanApplication.PracticeTypeID = planApplicationView.PracticeTypeID; newPlanApplication.TeachinglanguageID = planApplicationView.TeachinglanguageID; newPlanApplication.ExaminationModeID = planApplicationView.ExaminationModeID; newPlanApplication.ResultTypeID = planApplicationView.ResultTypeID; newPlanApplication.HandleModeID = planApplicationView.HandleModeID; newPlanApplication.Remark = planApplicationView.Remark; SetNewStatus(newPlanApplication, startStatusID.Value); newPlanApplicationInList.Add(newPlanApplication); var newTeachingSetting = new EM_PlanApplicationTeachingSetting(); newTeachingSetting.PlanApplicationID = newPlanApplication.PlanApplicationID; newTeachingSetting.Credit = planApplicationView.Credit; newTeachingSetting.TheoryCourse = planApplicationView.TheoryCourse; newTeachingSetting.Practicehours = planApplicationView.Practicehours; newTeachingSetting.Trialhours = planApplicationView.Trialhours; newTeachingSetting.TheoryWeeklyNum = planApplicationView.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = planApplicationView.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = planApplicationView.TrialWeeklyNum; newTeachingSetting.WeeklyHours = planApplicationView.WeeklyHours; newTeachingSetting.WeeklyNum = planApplicationView.WeeklyNum; newTeachingSetting.StartWeeklyNum = planApplicationView.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = planApplicationView.EndWeeklyNum; newTeachingSettingInList.Add(newTeachingSetting); if (planApplicationView.TeachingModeIDList != null && planApplicationView.TeachingModeIDList.Count() > 0) { foreach (var teachingModeID in planApplicationView.TeachingModeIDList) { var newTeachingMode = new EM_PlanApplicationTeachingModeType(); newTeachingMode.PlanApplicationTeachingModeTypeID = Guid.NewGuid(); newTeachingMode.PlanApplicationID = newPlanApplication.PlanApplicationID; newTeachingMode.TeachingModeID = teachingModeID; SetNewStatus(newTeachingMode); newTeachingModeTypeInList.Add(newTeachingMode); } } if (planApplicationView.TeachingPlaceIDList != null && planApplicationView.TeachingPlaceIDList.Count() > 0) { foreach (var teachingPlaceID in planApplicationView.TeachingPlaceIDList) { var newTeachingPlace = new EM_PlanApplicationTeachingPlace(); newTeachingPlace.PlanApplicationTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.PlanApplicationID = newPlanApplication.PlanApplicationID; newTeachingPlace.TeachingPlace = teachingPlaceID; SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } } //事务提交 //UnitOfWork.Commit(); using (TransactionScope ts = new TransactionScope()) { //删除 UnitOfWork.Delete(x => planApplicationTPDelList.Contains(x.PlanApplicationID)); UnitOfWork.Delete(x => planApplicationTMDelList.Contains(x.PlanApplicationID)); //批量插入 UnitOfWork.BulkInsert(newPlanApplicationInList); UnitOfWork.BulkInsert(newTeachingSettingInList); UnitOfWork.BulkInsert(newTeachingModeTypeInList); UnitOfWork.BulkInsert(newTeachingPlaceInList); //批量统一提交更新 if (newPlanApplicationUpList != null && newPlanApplicationUpList.Count() > 0) { UnitOfWork.BatchUpdate(newPlanApplicationUpList); } //批量统一提交更新 if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(newTeachingSettingUpList); } ts.Complete(); } } else { throw new Exception("已存在相同的计划申请信息(学年学期、年级专业、课程信息唯一),请核查。"); } } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 专业课程模版批量新增 /// /// /// /// public string PlanApplicationBatchAdd(List specialtyCourseViewList, PlanApplicationView planApplicationView) { try { //查询对应的工作流程环节状态信息View var approveStatusList = this.GetStatusViewList(); if (approveStatusList == null || approveStatusList.Count() <= 0) { throw new Exception("工作流平台中,专业计划流程未配置,请核查。"); } //查询工作流程开始环节状态 var startStatusID = this.GetStartStatus(); if (startStatusID == null) { throw new Exception("工作流平台中,专业计划流程开始环节未配置,请核查。"); } //查询对应的年级专业信息 var grademajor = PlanApplicationDAL.GrademajorRepository.GetList(x => x.GrademajorID == planApplicationView.GrademajorID).SingleOrDefault(); if (grademajor == null) { throw new Exception("选择申请的年级专业不存在,请检查。"); } //查询学年学期信息schoolyearList var schoolyearList = PlanApplicationDAL.SchoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); //查询年级专业对应的入学学年学期信息 var startSchoolyear = schoolyearList.Where(x => x.Years == grademajor.GradeID && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault(); if (startSchoolyear == null) { throw new Exception("选择申请的年级专业对应的入学学年学期不存在,请检查。"); } //查询年级专业对应的毕业学年学期信息 var graduatingSemester = schoolyearList.Where(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault(); if (graduatingSemester == null) { throw new Exception("选择申请的年级专业对应的毕业学年学期信息不存在,请检查。"); } //查询计划申请信息planApplicationList var planApplicationList = PlanApplicationDAL.PlanApplicationRepository.GetList(x => x.GrademajorID == grademajor.GrademajorID, (x => x.EM_PlanApplicationTeachingSetting)).ToList(); int success = 0; //成功 int fail = 0; //失败 string tipMessage = null; //提示消息 List newPlanApplicationInList = new List(); List newTeachingSettingInList = new List(); List newTeachingModeTypeInList = new List(); List newTeachingPlaceInList = new List(); foreach (var specialtyCourseView in specialtyCourseViewList) { //判断对应的学年学期信息 var value = startSchoolyear.Value + specialtyCourseView.StarttermID - 1; if (value < startSchoolyear.Value) { //表示学年学期小于入学学年学期 fail++; } else { if (value > graduatingSemester.Value) { //表示学年学期大于毕业学年学期 fail++; } else { var schoolyear = schoolyearList.Where(x => x.Value == value).SingleOrDefault(); if (schoolyear == null) { //表示对应的学年学期信息不存在 fail++; } else { //查询对应的计划申请信息(根据业务主键:学年学期ID、年级专业ID、课程信息ID) var planApplication = planApplicationList.Where(x => x.SchoolyearID == schoolyear.SchoolyearID && x.GrademajorID == grademajor.GrademajorID && x.CoursematerialID == specialtyCourseView.CoursematerialID).SingleOrDefault(); if (planApplication == null) { //表示新增 var newPlanApplication = new EM_PlanApplication(); newPlanApplication.PlanApplicationID = Guid.NewGuid(); newPlanApplication.SchoolyearID = schoolyear.SchoolyearID; newPlanApplication.GrademajorID = grademajor.GrademajorID; newPlanApplication.CoursematerialID = specialtyCourseView.CoursematerialID; newPlanApplication.CourseStructureID = specialtyCourseView.CourseStructureID; newPlanApplication.CourseCategoryID = specialtyCourseView.CourseCategoryID; newPlanApplication.CourseTypeID = specialtyCourseView.CourseTypeID; newPlanApplication.CourseQualityID = specialtyCourseView.CourseQualityID; newPlanApplication.DepartmentID = specialtyCourseView.DepartmentID; newPlanApplication.IsSpecialtycore = specialtyCourseView.IsSpecialtycore; newPlanApplication.IsCooperation = specialtyCourseView.IsCooperation; newPlanApplication.IsRequired = specialtyCourseView.IsRequired; newPlanApplication.IsElective = specialtyCourseView.IsElective; newPlanApplication.IsNetworkCourse = specialtyCourseView.IsNetworkCourse; newPlanApplication.IsMainCourse = specialtyCourseView.IsMainCourse; newPlanApplication.IsNeedMaterial = specialtyCourseView.IsNeedMaterial; newPlanApplication.CourseFineID = specialtyCourseView.CourseFineID; newPlanApplication.PracticeTypeID = specialtyCourseView.PracticeTypeID; newPlanApplication.TeachinglanguageID = specialtyCourseView.TeachinglanguageID; newPlanApplication.ExaminationModeID = specialtyCourseView.ExaminationModeID; newPlanApplication.ResultTypeID = specialtyCourseView.ResultTypeID; newPlanApplication.HandleModeID = specialtyCourseView.HandleModeID; newPlanApplication.Remark = planApplicationView.Remark; SetNewStatus(newPlanApplication, startStatusID.Value); newPlanApplicationInList.Add(newPlanApplication); var newTeachingSetting = new EM_PlanApplicationTeachingSetting(); newTeachingSetting.PlanApplicationID = newPlanApplication.PlanApplicationID; newTeachingSetting.Credit = specialtyCourseView.Credit; newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse; newTeachingSetting.Practicehours = specialtyCourseView.Practicehours; newTeachingSetting.Trialhours = specialtyCourseView.Trialhours; newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum; newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours; newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum; newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum; newTeachingSettingInList.Add(newTeachingSetting); if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0) { foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList) { var newTeachingMode = new EM_PlanApplicationTeachingModeType(); newTeachingMode.PlanApplicationTeachingModeTypeID = Guid.NewGuid(); newTeachingMode.PlanApplicationID = newPlanApplication.PlanApplicationID; newTeachingMode.TeachingModeID = teachingModeID; SetNewStatus(newTeachingMode); newTeachingModeTypeInList.Add(newTeachingMode); } } if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0) { foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList) { var newTeachingPlace = new EM_PlanApplicationTeachingPlace(); newTeachingPlace.PlanApplicationTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.PlanApplicationID = newPlanApplication.PlanApplicationID; newTeachingPlace.TeachingPlace = teachingPlaceID; SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } success++; } else { //表示已存在相同的计划申请信息 fail++; } } } } } //事务提交 using (TransactionScope ts = new TransactionScope()) { //批量插入 UnitOfWork.BulkInsert(newPlanApplicationInList); UnitOfWork.BulkInsert(newTeachingSettingInList); UnitOfWork.BulkInsert(newTeachingModeTypeInList); UnitOfWork.BulkInsert(newTeachingPlaceInList); ts.Complete(); } if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条,失败" + fail + "条,原因:学年学期小于入学学年学期、学年学期大于毕业学年学期、对应的学年学期不存在或已存在相同的计划申请信息,请检查"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询对应的未申请专业课程信息SpecialtyCourseView /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetSpecialtyCourseViewNoApplyGrid(ConfiguretView configuretView, Guid? departmentID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? starttermID, int? handleModeID, int? yearID, Guid? grademajorID, int pageIndex, int pageSize) { //结束流程环节ID var endStatusID = this.GetCorrectEndStatus(); //专业课程 Expression> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true); if (departmentID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID); } if (coursematerialID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID); } if (starttermID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID); } if (handleModeID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID); } //年级专业 Expression> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (yearID.HasValue) { expGrademajor = expGrademajor.And(x => x.GradeID == yearID); } expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID); //计划申请 Expression> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //注:需排除审核通过状态的计划申请信息 expPlanApplication = expPlanApplication.And(x => x.RecordStatus != endStatusID); if (coursematerialID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID); } if (grademajorID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID); } //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (coursematerialID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID); } if (grademajorID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.GrademajorID == grademajorID); } var query = PlanApplicationDAL.GetSpecialtyCourseViewNoApplyQueryable(expSpecialtyCourse, expGrademajor, expPlanApplication, expSpecialtyPlan); if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID) .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem) .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的未申请专业课程信息List /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetSpecialtyCourseViewNoApplyList(ConfiguretView configuretView, Guid? departmentID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? starttermID, int? handleModeID, int? yearID, Guid? grademajorID) { //结束流程环节ID var endStatusID = this.GetCorrectEndStatus(); //专业课程 Expression> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true); if (departmentID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID); } if (coursematerialID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID); } if (starttermID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID); } if (handleModeID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID); } //年级专业 Expression> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (yearID.HasValue) { expGrademajor = expGrademajor.And(x => x.GradeID == yearID); } expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID); //计划申请 Expression> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //注:需排除审核通过状态的计划申请信息 expPlanApplication = expPlanApplication.And(x => x.RecordStatus != endStatusID); if (coursematerialID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID); } if (grademajorID.HasValue) { expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID); } //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (coursematerialID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID); } if (grademajorID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.GrademajorID == grademajorID); } var query = PlanApplicationDAL.GetSpecialtyCourseViewNoApplyQueryable(expSpecialtyCourse, expGrademajor, expPlanApplication, expSpecialtyPlan); if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID) .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem) .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ToList(); } /// /// 删除 /// /// /// public bool PlanApplicationDelete(List planApplicationIDs) { try { using (TransactionScope ts = new TransactionScope()) { UnitOfWork.Delete(x => planApplicationIDs.Contains(x.PlanApplicationID)); UnitOfWork.Delete(x => planApplicationIDs.Contains(x.PlanApplicationID)); UnitOfWork.Delete(x => planApplicationIDs.Contains(x.PlanApplicationID)); UnitOfWork.Delete(x => planApplicationIDs.Contains(x.PlanApplicationID)); ts.Complete(); return true; } } catch (Exception) { throw; } } /// /// 提交 /// /// /// /// /// public string PlanApplicationSubmit(List planApplicationIDs, Guid userID, string comment = "") { try { //查询对应的工作流程环节状态信息View var approveStatusList = this.GetStatusViewList(); if (approveStatusList == null || approveStatusList.Count() <= 0) { throw new Exception("工作流平台中,专业计划流程未配置,请核查。"); } //查询工作流程开始环节状态 var startStatusID = this.GetStartStatus(); if (startStatusID == null) { throw new Exception("工作流平台中,专业计划流程开始环节未配置,请核查。"); } //查询对应的计划申请信息List var planApplicationList = PlanApplicationDAL.PlanApplicationRepository .GetList(x => planApplicationIDs.Contains(x.PlanApplicationID), (x => x.EM_PlanApplicationTeachingSetting)).ToList(); //计划申请信息对应的grademajorIDList var grademajorIDList = planApplicationList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())) .Select(x => x.GrademajorID).ToList(); //查询对应的专业计划信息 var specialtyPlanList = PlanApplicationDAL.SpecialtyPlanRepository .GetList(x => grademajorIDList.Contains(x.GrademajorID), (x => x.EM_SpecialtyPlanTeachingSetting)).ToList(); int success = 0; //成功 int fail = 0; //失败 string tipMessage = null; //提示消息 var submitIDList = new List(); var approveIDList = new List(); foreach (var planApplication in planApplicationList) { //查询对应的专业计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID) var specialtyPlan = specialtyPlanList.Where(x => x.SchoolyearID == planApplication.SchoolyearID && x.GrademajorID == planApplication.GrademajorID && x.CoursematerialID == planApplication.CoursematerialID).SingleOrDefault(); if (specialtyPlan == null) { if (planApplication.RecordStatus == startStatusID) { submitIDList.Add(planApplication.PlanApplicationID); } else { approveIDList.Add(planApplication.PlanApplicationID); } success++; } else { fail++; } } if (submitIDList.Count > 0) { this.StartUp(submitIDList, userID, comment); } if (approveIDList.Count > 0) { this.Approve(approveIDList, userID, Guid.Empty, comment); } if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条," + fail + "条失败,原因:已存在相同的专业计划信息,请检查。"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询计划申请对应的授课方式List /// /// /// public List GetTeachingModeTypeList(Guid? planApplicationID) { //计划申请 Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.PlanApplicationID == planApplicationID); var query = PlanApplicationDAL.GetTeachingModeTypeQueryble(exp); return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList(); } /// /// 查询计划申请对应的授课地点List /// /// /// public List GetTeachingPlaceList(Guid? planApplicationID) { //计划申请 Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.PlanApplicationID == planApplicationID); var query = PlanApplicationDAL.GetTeachingPlaceQueryble(exp); return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList(); } /// /// 流程结束跳转函数(工作流平台中配置) /// 注:此为普教版本(年级专业) /// 注:根据不同的版本配置(区分普教、成教版本-工作流跳转函数) /// /// /// public void OnApproveEnd(List planApplicationIDList, Guid? userID) { try { //查询对应的工作流程环节状态信息View var approveStatusList = this.GetStatusViewList(); if (approveStatusList == null || approveStatusList.Count() <= 0) { throw new Exception("工作流平台中,专业计划流程未配置,请核查。"); } //查询工作流程结束环节状态 var endStatusID = this.GetCorrectEndStatus(); if (endStatusID == null) { throw new Exception("工作流平台中,专业计划流程结束环节未配置,请核查。"); } //查询对应的计划申请信息List var planApplicationList = PlanApplicationDAL.PlanApplicationRepository .GetList(x => planApplicationIDList.Contains(x.PlanApplicationID), (x => x.EM_PlanApplicationTeachingSetting), (x => x.EM_PlanApplicationTeachingModeType), (x => x.EM_PlanApplicationTeachingPlace)).ToList(); //计划申请信息对应的grademajorIDList var grademajorIDList = planApplicationList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList(); //查询对应的专业计划信息 var specialtyPlanList = PlanApplicationDAL.SpecialtyPlanRepository .GetList(x => grademajorIDList.Contains(x.GrademajorID), (x => x.EM_SpecialtyPlanTeachingSetting)).ToList(); List newSpecialtyPlanInList = new List(); List newSpecialtyPlanUpList = new List(); List newTeachingSettingInList = new List(); List newTeachingSettingUpList = new List(); List newTeachingModeTypeInList = new List(); List newTeachingPlaceInList = new List(); List specialtyPlanTMDelList = new List(); List specialtyPlanTPDelList = new List(); foreach (var planApplication in planApplicationList) { //查询对应的专业计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID) var specialtyPlan = specialtyPlanList.Where(x => x.SchoolyearID == planApplication.SchoolyearID && x.GrademajorID == planApplication.GrademajorID && x.CoursematerialID == planApplication.CoursematerialID).SingleOrDefault(); if (specialtyPlan == null) { //新增 var newSpecialtyPlan = new EM_SpecialtyPlan(); newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid(); newSpecialtyPlan.PlanApplicationID = planApplication.PlanApplicationID; newSpecialtyPlan.SchoolyearID = planApplication.SchoolyearID; newSpecialtyPlan.GrademajorID = planApplication.GrademajorID; newSpecialtyPlan.CoursematerialID = planApplication.CoursematerialID; newSpecialtyPlan.CourseStructureID = planApplication.CourseStructureID; newSpecialtyPlan.CourseCategoryID = planApplication.CourseCategoryID; newSpecialtyPlan.CourseTypeID = planApplication.CourseTypeID; newSpecialtyPlan.CourseQualityID = planApplication.CourseQualityID; newSpecialtyPlan.DepartmentID = planApplication.DepartmentID; newSpecialtyPlan.IsSpecialtycore = planApplication.IsSpecialtycore; newSpecialtyPlan.IsCooperation = planApplication.IsCooperation; newSpecialtyPlan.IsRequired = planApplication.IsRequired; newSpecialtyPlan.IsElective = planApplication.IsElective; newSpecialtyPlan.IsNetworkCourse = planApplication.IsNetworkCourse; newSpecialtyPlan.IsMainCourse = planApplication.IsMainCourse; newSpecialtyPlan.IsNeedMaterial = planApplication.IsNeedMaterial; newSpecialtyPlan.CourseFineID = planApplication.CourseFineID; newSpecialtyPlan.PracticeTypeID = planApplication.PracticeTypeID; newSpecialtyPlan.TeachinglanguageID = planApplication.TeachinglanguageID; newSpecialtyPlan.ExaminationModeID = planApplication.ExaminationModeID; newSpecialtyPlan.ResultTypeID = planApplication.ResultTypeID; newSpecialtyPlan.HandleModeID = planApplication.HandleModeID; newSpecialtyPlan.Remark = planApplication.Remark; SetNewStatus(newSpecialtyPlan); newSpecialtyPlanInList.Add(newSpecialtyPlan); var newTeachingSetting = new EM_SpecialtyPlanTeachingSetting(); newTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; if (planApplication.EM_PlanApplicationTeachingSetting != null) { newTeachingSetting.Credit = planApplication.EM_PlanApplicationTeachingSetting.Credit; newTeachingSetting.TheoryCourse = planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse; newTeachingSetting.Practicehours = planApplication.EM_PlanApplicationTeachingSetting.Practicehours; newTeachingSetting.Trialhours = planApplication.EM_PlanApplicationTeachingSetting.Trialhours; newTeachingSetting.TheoryWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum; newTeachingSetting.WeeklyHours = planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours; newTeachingSetting.WeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum; newTeachingSetting.StartWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum; } else { newTeachingSetting.Credit = 0; newTeachingSetting.TheoryCourse = 0; newTeachingSetting.Practicehours = 0; newTeachingSetting.Trialhours = 0; newTeachingSetting.TheoryWeeklyNum = 0; newTeachingSetting.PracticeWeeklyNum = 0; newTeachingSetting.TrialWeeklyNum = 0; newTeachingSetting.WeeklyHours = 0; newTeachingSetting.WeeklyNum = 0; newTeachingSetting.StartWeeklyNum = 1; newTeachingSetting.EndWeeklyNum = 16; } newTeachingSettingInList.Add(newTeachingSetting); if (planApplication.EM_PlanApplicationTeachingModeType != null && planApplication.EM_PlanApplicationTeachingModeType.Count() > 0) { foreach (var teachingMode in planApplication.EM_PlanApplicationTeachingModeType.ToList()) { var newTeachingMode = new EM_SpecialtyPlanTeachingModeType(); newTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid(); newTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newTeachingMode.TeachingModeID = teachingMode.TeachingModeID; SetNewStatus(newTeachingMode); newTeachingModeTypeInList.Add(newTeachingMode); } } else { var newTeachingMode = new EM_SpecialtyPlanTeachingModeType(); newTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid(); newTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newTeachingMode.TeachingModeID = (int)CF_TeachingMode.Theory; SetNewStatus(newTeachingMode); newTeachingModeTypeInList.Add(newTeachingMode); } if (planApplication.EM_PlanApplicationTeachingPlace != null && planApplication.EM_PlanApplicationTeachingPlace.Count() > 0) { foreach (var teachingPlace in planApplication.EM_PlanApplicationTeachingPlace.ToList()) { var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace(); newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newTeachingPlace.TeachingPlace = teachingPlace.TeachingPlace; SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } } else { //修改 specialtyPlan.CourseStructureID = planApplication.CourseStructureID; specialtyPlan.CourseCategoryID = planApplication.CourseCategoryID; specialtyPlan.CourseTypeID = planApplication.CourseTypeID; specialtyPlan.CourseQualityID = planApplication.CourseQualityID; specialtyPlan.DepartmentID = planApplication.DepartmentID; specialtyPlan.IsSpecialtycore = planApplication.IsSpecialtycore; specialtyPlan.IsCooperation = planApplication.IsCooperation; specialtyPlan.IsRequired = planApplication.IsRequired; specialtyPlan.IsElective = planApplication.IsElective; specialtyPlan.IsNetworkCourse = planApplication.IsNetworkCourse; specialtyPlan.IsMainCourse = planApplication.IsMainCourse; specialtyPlan.IsNeedMaterial = planApplication.IsNeedMaterial; specialtyPlan.CourseFineID = planApplication.CourseFineID; specialtyPlan.PracticeTypeID = planApplication.PracticeTypeID; specialtyPlan.TeachinglanguageID = planApplication.TeachinglanguageID; specialtyPlan.ExaminationModeID = planApplication.ExaminationModeID; specialtyPlan.ResultTypeID = planApplication.ResultTypeID; specialtyPlan.HandleModeID = planApplication.HandleModeID; specialtyPlan.Remark = planApplication.Remark; SetModifyStatus(specialtyPlan); newSpecialtyPlanUpList.Add(specialtyPlan); if (specialtyPlan.EM_SpecialtyPlanTeachingSetting == null) { var newTeachingSetting = new EM_SpecialtyPlanTeachingSetting(); newTeachingSetting.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; if (planApplication.EM_PlanApplicationTeachingSetting == null) { newTeachingSetting.Credit = 0; newTeachingSetting.TheoryCourse = 0; newTeachingSetting.Practicehours = 0; newTeachingSetting.Trialhours = 0; newTeachingSetting.TheoryWeeklyNum = 0; newTeachingSetting.PracticeWeeklyNum = 0; newTeachingSetting.TrialWeeklyNum = 0; newTeachingSetting.WeeklyHours = 0; newTeachingSetting.WeeklyNum = 0; newTeachingSetting.StartWeeklyNum = 1; newTeachingSetting.EndWeeklyNum = 16; } else { newTeachingSetting.Credit = planApplication.EM_PlanApplicationTeachingSetting.Credit; newTeachingSetting.TheoryCourse = planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse; newTeachingSetting.Practicehours = planApplication.EM_PlanApplicationTeachingSetting.Practicehours; newTeachingSetting.Trialhours = planApplication.EM_PlanApplicationTeachingSetting.Trialhours; newTeachingSetting.TheoryWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum; newTeachingSetting.WeeklyHours = planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours; newTeachingSetting.WeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum; newTeachingSetting.StartWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum; } newTeachingSettingInList.Add(newTeachingSetting); } else { if (planApplication.EM_PlanApplicationTeachingSetting != null) { specialtyPlan.EM_SpecialtyPlanTeachingSetting.Credit = planApplication.EM_PlanApplicationTeachingSetting.Credit; specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryCourse = planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse; specialtyPlan.EM_SpecialtyPlanTeachingSetting.Practicehours = planApplication.EM_PlanApplicationTeachingSetting.Practicehours; specialtyPlan.EM_SpecialtyPlanTeachingSetting.Trialhours = planApplication.EM_PlanApplicationTeachingSetting.Trialhours; specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.PracticeWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.TrialWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyHours = planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours; specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.StartWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.EndWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum; } newTeachingSettingUpList.Add(specialtyPlan.EM_SpecialtyPlanTeachingSetting); } if (planApplication.EM_PlanApplicationTeachingModeType != null && planApplication.EM_PlanApplicationTeachingModeType.Count() > 0) { specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID); foreach (var newModeType in planApplication.EM_PlanApplicationTeachingModeType.ToList()) { var newTeachingModeType = new EM_SpecialtyPlanTeachingModeType(); newTeachingModeType.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid(); newTeachingModeType.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; newTeachingModeType.TeachingModeID = newModeType.TeachingModeID; this.SetNewStatus(newTeachingModeType); newTeachingModeTypeInList.Add(newTeachingModeType); } } else { specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID); } if (planApplication.EM_PlanApplicationTeachingPlace != null && planApplication.EM_PlanApplicationTeachingPlace.Count() > 0) { specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID); foreach (var newPlace in planApplication.EM_PlanApplicationTeachingPlace.ToList()) { var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace(); newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; newTeachingPlace.TeachingPlace = newPlace.TeachingPlace; this.SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } else { specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID); } } } using (TransactionScope ts = new TransactionScope()) { //删除 UnitOfWork.Delete(x => specialtyPlanTPDelList.Contains(x.SpecialtyPlanID)); UnitOfWork.Delete(x => specialtyPlanTMDelList.Contains(x.SpecialtyPlanID)); //批量插入 UnitOfWork.BulkInsert(newSpecialtyPlanInList); UnitOfWork.BulkInsert(newTeachingSettingInList); UnitOfWork.BulkInsert(newTeachingModeTypeInList); UnitOfWork.BulkInsert(newTeachingPlaceInList); //批量统一提交更新 if (newSpecialtyPlanUpList != null && newSpecialtyPlanUpList.Count() > 0) { UnitOfWork.BatchUpdate(newSpecialtyPlanUpList); } //批量统一提交更新 if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(newTeachingSettingUpList); } ts.Complete(); } } catch (Exception) { throw; } } } }