using System; using System.Collections.Generic; using System.Linq; using System.Text; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.EducationManage; using EMIS.ViewModel; using System.Linq.Expressions; using EMIS.Entities; using Bowin.Common.Linq; using EMIS.DataLogic.EducationManage; using Bowin.Common.Exceptions; using EMIS.Utility; namespace EMIS.CommonLogic.EducationManage { public class ExecutableMinorPlanServices : BaseServices, IExecutableMinorPlanServices { public ExecutableMinorPlanDAL ExecutableMinorPlanDAL { get; set; } public IGridResultSet GetExecutableMinorPlanViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? yearID, int? standardID, Guid? coursematerialID, int? schoolyearNum, int? schoolcode, int? executableMinorPlanStatus, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); 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.EM_MinorPlan.CF_Grademinor.YearID == yearID); if (standardID.HasValue) exp = exp.And(x => x.StandardID == standardID); if (coursematerialID.HasValue) exp = exp.And(x => x.CoursematerialID == coursematerialID); if (executableMinorPlanStatus.HasValue) exp = exp.And(x => x.RecordStatus == executableMinorPlanStatus); var query = ExecutableMinorPlanDAL.GetExecutableMinorPlanView(exp); if (schoolyearNum.HasValue) query = query.Where(x => x.SchoolyearNumID == schoolyearNum); if (schoolcode.HasValue) query = query.Where(x => x.SchoolcodeID == schoolcode); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); var resultSet = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolcodeStr) .ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode).ThenByDescending(x => x.StandardID) .ToGridResultSet(pageIndex, pageSize); var executablePlanIDList = resultSet.rows.Select(x => x.ExecutableMinorPlanID).ToList(); return resultSet; } public ExecutableMinorPlanView GetExecutableMinorPlanView(Guid? ExecutableMinorPlanID) { Expression> exp = (x => x.ExecutableMinorPlanID == ExecutableMinorPlanID); var query = ExecutableMinorPlanDAL.GetExecutableMinorPlanView(exp); return query.FirstOrDefault(); } /// /// 获取辅修执行计划信息 /// /// 辅修执行计划ID /// public EM_ExecutableMinorPlan GetExecutableMinorPlan(Guid? ExecutableMinorPlanID) { //查询条件 Expression> exp = (x => x.ExecutableMinorPlanID == ExecutableMinorPlanID); return ExecutableMinorPlanDAL.ExecutableMinorPlanRepository.GetSingle(exp, (x => x.CF_Department), (x => x.EM_Coursematerial), (x => x.EM_ExecutableMinorPlanTeachingSetting)); } /// /// 根据专业课程获取授课方式 /// /// /// public List GetTeachingModeType(Guid? ExecutableMinorPlanID) { return ExecutableMinorPlanDAL.GetTeachingModeTypeQueryble(ExecutableMinorPlanID); } /// /// 根据专业课程获取授课地点 /// /// /// public List GetTeachingPlace(Guid? ExecutableMinorPlanID) { return ExecutableMinorPlanDAL.GetTeachingPlaceQueryble(ExecutableMinorPlanID); } /// /// 辅修执行计划设置表 /// /// 辅修执行计划ID /// public EM_ExecutableMinorPlanTeachingSetting GetExecutableMinorPlanTeachingSetting(Guid? ExecutableMinorPlanID) { //查询条件 Expression> exp = (x => x.ExecutableMinorPlanID == ExecutableMinorPlanID); return ExecutableMinorPlanDAL.ExecutableMinorPlanTeachingSettingRepository.GetSingle(exp); } public void isOKForexecutablePlan(ExecutableMinorPlanView executableMinorPlanView) { if (this.ExecutableMinorPlanDAL.ExecutableMinorPlanRepository .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.MinorPlanID == executableMinorPlanView.MinorPlanID && x.SchoolyearID == executableMinorPlanView.SchoolyearID && x.CoursematerialID == executableMinorPlanView.CoursematerialID).Count() > 0) { throw new Exception("指定的年级专业及课程在这学期已经开课或列表存在重复数据,请重新输入。"); } } public void GenerateExecutablePlan(int? StandardID, Guid? SchoolyearID, bool IsOverwrite, Guid? CampusID, Guid? CollegeID, int? YearID) { try { Expression> exp = (x => x.CF_Grademinor.RecordStatus == (int)CF_GrademinorStatus.Confirmed); if (StandardID.HasValue) { exp = exp.And(x => x.CF_Grademinor.StandardID == StandardID); } if (CollegeID.HasValue) { exp = exp.And(x => x.CF_Grademinor.CollegeID == CollegeID); } if (YearID.HasValue) { exp = exp.And(x => x.CF_Grademinor.YearID == YearID); } if (SchoolyearID.HasValue) { exp = exp.And(x => x.SchoolyearID == SchoolyearID); } //if (!isOverwrite) //{ // exp = exp.And(x => x.TeachingStatus == null); //} if (!IsOverwrite) { //TODO:调整执行计划生成查询逻辑 2016年10月26日15:56:18 exp = exp.And(x => x.EM_ExecutableMinorPlan.FirstOrDefault().ExecutableMinorPlanID == null); } var executablePlanIDs = this.GetQueryByDataRangeByCollege(ExecutableMinorPlanDAL.MinorPlanRepository.GetList(exp, (x => x.CF_Department.CF_College)).Select(x => new { x.MinorPlanID, x.CF_Department.CollegeID })).ToList().Select(x => (Guid?)x.MinorPlanID).ToList(); var listSpecialtyPlan = ExecutableMinorPlanDAL.MinorPlanRepository .GetList(exp, (x => x.EM_MinorPlanTeachingModeType), (x => x.EM_MinorPlanTeachingPlace), (x => x.EM_MinorPlanTeachingSetting), (x => x.EM_ExecutableMinorPlan), (x => x.CF_Grademinor) ).Where(x => executablePlanIDs.Contains(x.MinorPlanID)).ToList(); var relateMissionClass = ExecutableMinorPlanDAL.GetEducationMissionClassByExecutablePlanID(executablePlanIDs); if (listSpecialtyPlan.Count() == 0) throw new Exception("未能匹配到需要生成执行计划的数据,请查检辅修计划和辅修执行计划信息! (注:辅修计划信息未生成相关的辅修执行计划时,系统会以红字标识)"); if (!IsOverwrite) //当选择覆盖时,不判断重复。现在判断重复方法感觉没什么作用,因为当不选择覆盖时查询出来的数据是未生成执行计划,理论上不会有重复 { ExecutableMinorPlanView ex = new ExecutableMinorPlanView(); foreach (var e in listSpecialtyPlan) { ex.MinorPlanID = e.MinorPlanID; ex.SchoolyearID = e.SchoolyearID; ex.CoursematerialID = e.CoursematerialID; isOKForexecutablePlan(ex); } } //辅修执行计划 List executablePlanList = new List(); List executablePlanTeachingSettingList = new List(); List teachingModeTypeList = new List(); List teachingPlaceList = new List(); List executablePlanSubmitedList = new List(); foreach (var specialtyPlan in listSpecialtyPlan) { if (specialtyPlan.EM_ExecutableMinorPlan.Count > 0) { var existExecutablePlanList = specialtyPlan.EM_ExecutableMinorPlan.ToList(); var hasSubmitedExecutablePlan = false; foreach (var existExecutablePlan in existExecutablePlanList) { var ClassID=existExecutablePlan.EM_MinorPlan.CF_Grademinor.CF_Classminor.Select(s=>s.ClassminorID).FirstOrDefault(); var existMissionClass = relateMissionClass.Where(x => x.EM_EducationMission.SchoolyearID == existExecutablePlan.SchoolyearID && x.CoursematerialID == existExecutablePlan.CoursematerialID && x.CF_Classmajor.Any(w => w.ClassmajorID == ClassID)).ToList(); if (existExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.Submited || existMissionClass.Count > 0) { hasSubmitedExecutablePlan = true; break; } } if (hasSubmitedExecutablePlan) { executablePlanSubmitedList.Add(specialtyPlan); continue; } else { var existExecutablePlanIDList = existExecutablePlanList.Select(x => x.ExecutableMinorPlanID).ToList(); foreach (var e in existExecutablePlanIDList) { UnitOfWork.Delete(x =>x.ExecutableMinorPlanID==e); UnitOfWork.Delete(x =>x.ExecutableMinorPlanID==e); UnitOfWork.Delete(x => x.ExecutableMinorPlanID==e); UnitOfWork.Delete(x =>x.ExecutableMinorPlanID==e); } } } EM_ExecutableMinorPlan executablePlan = new EM_ExecutableMinorPlan(); executablePlan.ExecutableMinorPlanID = Guid.NewGuid(); executablePlan.MinorPlanID = specialtyPlan.MinorPlanID; executablePlan.SchoolyearID = specialtyPlan.SchoolyearID; executablePlan.CoursematerialID = specialtyPlan.CoursematerialID; executablePlan.DepartmentID = specialtyPlan.DepartmentID; executablePlan.CollegeID = specialtyPlan.CF_Grademinor.CollegeID; executablePlan.YearID = specialtyPlan.CF_Grademinor.YearID; executablePlan.StandardID = specialtyPlan.CF_Grademinor.StandardID; executablePlan.CourseStructureID = specialtyPlan.CourseStructureID; executablePlan.CourseCategoryID = specialtyPlan.CourseCategoryID; executablePlan.CourseTypeID = specialtyPlan.CourseTypeID; executablePlan.CourseQualityID = specialtyPlan.CourseQualityID; executablePlan.PracticeTypeID = specialtyPlan.PracticeTypeID; executablePlan.ExaminationModeID = specialtyPlan.ExaminationModeID; executablePlan.CourseFineID = specialtyPlan.CourseFineID; executablePlan.IsSpecialtycore = specialtyPlan.IsSpecialtycore; executablePlan.IsCooperation = specialtyPlan.IsCooperation; executablePlan.IsRequired = specialtyPlan.IsRequired; executablePlan.IsElective = specialtyPlan.IsElective; executablePlan.IsNetworkCourse = specialtyPlan.IsNetworkCourse; executablePlan.IsMainCourse = specialtyPlan.IsMainCourse; executablePlan.TeachinglanguageID = specialtyPlan.TeachinglanguageID; executablePlan.HandleModeID = specialtyPlan.HandleModeID; executablePlan.IsNeedMaterial = specialtyPlan.IsNeedMaterial; executablePlan.ResultTypeID = specialtyPlan.ResultTypeID; executablePlan.Remarks = specialtyPlan.Remarks; this.SetNewStatus(executablePlan); executablePlan.RecordStatus = (int)EM_ExecuteStatus.NotSubmited; executablePlanList.Add(executablePlan); if (specialtyPlan.EM_MinorPlanTeachingSetting == null) { throw new Exception("该专业计划教学设置信息不存在。"); } EM_ExecutableMinorPlanTeachingSetting executablePlanTeachingSetting = new EM_ExecutableMinorPlanTeachingSetting(); executablePlanTeachingSetting.ExecutableMinorPlanID = executablePlan.ExecutableMinorPlanID; executablePlanTeachingSetting.Credit = specialtyPlan.EM_MinorPlanTeachingSetting.Credit ?? 0; executablePlanTeachingSetting.TheoryCourse = specialtyPlan.EM_MinorPlanTeachingSetting.TheoryCourse ?? 0; executablePlanTeachingSetting.Practicehours = specialtyPlan.EM_MinorPlanTeachingSetting.Practicehours ?? 0; executablePlanTeachingSetting.Trialhours = specialtyPlan.EM_MinorPlanTeachingSetting.Trialhours ?? 0; executablePlanTeachingSetting.WeeklyNum = specialtyPlan.EM_MinorPlanTeachingSetting.WeeklyNum ?? 0; executablePlanTeachingSetting.TheoryWeeklyNum = specialtyPlan.EM_MinorPlanTeachingSetting.TheoryWeeklyNum ?? 0; executablePlanTeachingSetting.PracticeWeeklyNum = specialtyPlan.EM_MinorPlanTeachingSetting.PracticeWeeklyNum ?? 0; executablePlanTeachingSetting.TrialWeeklyNum = specialtyPlan.EM_MinorPlanTeachingSetting.TrialWeeklyNum ?? 0; executablePlanTeachingSetting.StartWeeklyNum = specialtyPlan.EM_MinorPlanTeachingSetting.StartWeeklyNum ?? 0; executablePlanTeachingSetting.EndWeeklyNum = specialtyPlan.EM_MinorPlanTeachingSetting.EndWeeklyNum ?? 0; executablePlanTeachingSetting.WeeklyHours = specialtyPlan.EM_MinorPlanTeachingSetting.WeeklyHours ?? 0; executablePlanTeachingSettingList.Add(executablePlanTeachingSetting); specialtyPlan.EM_MinorPlanTeachingModeType.ToList().ForEach(x => { EM_ExecutableMinorPlanTeachingModeType teachingModeType = new EM_ExecutableMinorPlanTeachingModeType(); teachingModeType.ExecutableMinorPlanTeachingModeTypeID = Guid.NewGuid(); teachingModeType.ExecutableMinorPlanID = executablePlan.ExecutableMinorPlanID; teachingModeType.TeachingModeID = x.TeachingModeID; this.SetNewStatus(teachingModeType); teachingModeTypeList.Add(teachingModeType); }); specialtyPlan.EM_MinorPlanTeachingPlace.ToList().ForEach(x => { EM_ExecutableMinorPlanTeachingPlace teachingPlace = new EM_ExecutableMinorPlanTeachingPlace(); teachingPlace.ExecutableMinorPlanTeachingPlaceID = Guid.NewGuid(); teachingPlace.ExecutableMinorPlanID = executablePlan.ExecutableMinorPlanID; teachingPlace.TeachingPlace = x.TeachingPlace; this.SetNewStatus(teachingPlace); teachingPlaceList.Add(teachingPlace); }); } UnitOfWork.AddRange(executablePlanList); UnitOfWork.AddRange(executablePlanTeachingSettingList); UnitOfWork.AddRange(teachingModeTypeList); UnitOfWork.AddRange(teachingPlaceList); UnitOfWork.Commit(); if (executablePlanSubmitedList.Count > 0) { var sucessCount = listSpecialtyPlan.Count - executablePlanSubmitedList.Count; if (sucessCount > 0) { throw new SuccessException(string.Format("执行完成,成功生成{0}条记录,{1}条记录由于对应的执行计划已经提交,无法覆盖。", sucessCount, executablePlanSubmitedList.Count)); } } } catch (SuccessException ex) { throw new SuccessException(ex.Message); } catch (Exception ex) { throw new Exception(ex.Message); } } public void ExecutableMinorPlanEdit(ExecutableMinorPlanView executableMinorPlanView) { EM_ExecutableMinorPlan ExecutableMinorPlan = null; EM_ExecutableMinorPlanTeachingSetting ExecutableMinorPlanTeachingSetting = null; ExecutableMinorPlan = GetExecutableMinorPlan(executableMinorPlanView.ExecutableMinorPlanID); ExecutableMinorPlanTeachingSetting = GetExecutableMinorPlanTeachingSetting(executableMinorPlanView.ExecutableMinorPlanID); ExecutableMinorPlan.ResultTypeID = executableMinorPlanView.ResultTypeID; ExecutableMinorPlan.Remarks = executableMinorPlanView.Remark; SetModifyStatus(ExecutableMinorPlan); ExecutableMinorPlanTeachingSetting.Credit = executableMinorPlanView.Credit; ExecutableMinorPlanTeachingSetting.TheoryCourse = executableMinorPlanView.TheoryCourse; ExecutableMinorPlanTeachingSetting.Practicehours = executableMinorPlanView.Practicehours; ExecutableMinorPlanTeachingSetting.Trialhours = executableMinorPlanView.Trialhours; ExecutableMinorPlanTeachingSetting.WeeklyNum = executableMinorPlanView.WeeklyNum; ExecutableMinorPlanTeachingSetting.TheoryWeeklyNum = executableMinorPlanView.TheoryWeeklyNum; ExecutableMinorPlanTeachingSetting.PracticeWeeklyNum = executableMinorPlanView.PracticeWeeklyNum; ExecutableMinorPlanTeachingSetting.TrialWeeklyNum = executableMinorPlanView.TrialWeeklyNum; ExecutableMinorPlanTeachingSetting.StartWeeklyNum = executableMinorPlanView.StartWeeklyNum; ExecutableMinorPlanTeachingSetting.EndWeeklyNum = executableMinorPlanView.EndWeeklyNum; ExecutableMinorPlanTeachingSetting.WeeklyHours = executableMinorPlanView.WeeklyHours; UnitOfWork.Update(ExecutableMinorPlanTeachingSetting); if (executableMinorPlanView.TeachingModeID != null) { UnitOfWork.Delete(x => x.ExecutableMinorPlanID == ExecutableMinorPlan.ExecutableMinorPlanID); foreach (var i in executableMinorPlanView.TeachingModeID) { EM_ExecutableMinorPlanTeachingModeType ExecutableMinorPlanTeachingModeType = new EM_ExecutableMinorPlanTeachingModeType(); ExecutableMinorPlanTeachingModeType.ExecutableMinorPlanTeachingModeTypeID = Guid.NewGuid(); ExecutableMinorPlanTeachingModeType.ExecutableMinorPlanID = ExecutableMinorPlan.ExecutableMinorPlanID; ExecutableMinorPlanTeachingModeType.TeachingModeID = i; SetNewStatus(ExecutableMinorPlanTeachingModeType); UnitOfWork.Add(ExecutableMinorPlanTeachingModeType); } } if (executableMinorPlanView.TeachingPlaceID != null) { UnitOfWork.Delete(x => x.ExecutableMinorPlanID == ExecutableMinorPlan.ExecutableMinorPlanID); foreach (var i in executableMinorPlanView.TeachingPlaceID) { EM_ExecutableMinorPlanTeachingPlace ExecutableMinorPlanTeachingPlace = new EM_ExecutableMinorPlanTeachingPlace(); ExecutableMinorPlanTeachingPlace.ExecutableMinorPlanTeachingPlaceID = Guid.NewGuid(); ExecutableMinorPlanTeachingPlace.ExecutableMinorPlanID = ExecutableMinorPlan.ExecutableMinorPlanID; ExecutableMinorPlanTeachingPlace.TeachingPlace = i; SetNewStatus(ExecutableMinorPlanTeachingPlace); UnitOfWork.Add(ExecutableMinorPlanTeachingPlace); } } UnitOfWork.Commit(); } public bool ExecutableMinorPlanDelete(List IDList) { try { if (IDList.Count > 0) { UnitOfWork.Delete(x => IDList.Contains(x.ExecutableMinorPlanID)); UnitOfWork.Delete(x => IDList.Contains(x.ExecutableMinorPlanID)); UnitOfWork.Delete(x => IDList.Contains(x.ExecutableMinorPlanID)); UnitOfWork.Delete(x => IDList.Contains(x.ExecutableMinorPlanID)); } return true; } catch (Exception) { throw; } } /// /// 生成限选教学任务班 /// /// /// public void GenerateEducationMissionClassOptionalCourse(List ExecutableMinorPlanIDs) { try { var executableMinorCourseList = ExecutableMinorPlanDAL.ExecutableMinorPlanRepository.GetList(x => ExecutableMinorPlanIDs.Contains(x.ExecutableMinorPlanID), (x => x.EM_MinorPlan.CF_Grademinor.CF_Classminor), (x => x.EM_MinorPlan.CF_Grademinor), (x => x.EM_ExecutableMinorPlanTeachingModeType), (x => x.EM_ExecutableMinorPlanTeachingSetting), (x => x.EM_MinorPlan.EM_Coursematerial), (x => x.EM_MinorPlan.EM_Coursematerial.EM_ClassGrouping.EM_ClassGroupingSettings), (x => x.EM_MinorPlan.CF_Department.CF_College.CF_Facultymajor), (x => x.EM_MinorPlan.CF_Department) ).ToList(); //判断是否有设置授课方式 var noTeachingModeTypeList = executableMinorCourseList.Where(x => x.EM_ExecutableMinorPlanTeachingModeType.Count == 0) .Concat(executableMinorCourseList.Where(x => !x.EM_ExecutableMinorPlanTeachingModeType.Any(w => w.TeachingModeID != null))).ToList(); if (noTeachingModeTypeList.Count > 0) { throw new Exception("没有设置授课方式的计划不能提交,请核查。"); } var resultMissionList = new List(); var resultMissionClassList = new List(); var resultMissionClassTeachingSettingList = new List(); var resultSchedulingClassList = new List(); var resultTeacherList = new List(); string coursematerialName = ""; var courseNames = executableMinorCourseList.Where(x =>x.EM_Coursematerial != null && x.EM_Coursematerial.EM_ClassGrouping == null).Select(x => x.EM_Coursematerial.CourseName).Distinct().ToArray(); coursematerialName = string.Join(",", courseNames); if (courseNames.Length > 0) { throw new Exception("以下执行计划所对应的课程并未设置上课类型,无法确定任务班的分班方式,请到课程资料菜单完成设置后再次进行提交:\r\n" + coursematerialName); } var query = ( from eop in ( //先找出上课类型没有设置的授课方式,然后单独成一个班 (from eop in executableMinorCourseList where eop.EM_ExecutableMinorPlanTeachingModeType .Any(x => !eop.EM_Coursematerial .EM_ClassGrouping .EM_ClassGroupingSettings.Select(w => w.TeachingModeID).Contains(x.TeachingModeID)) select new { ExecutableMinorCourse = eop, TeachingMode = eop.EM_ExecutableMinorPlanTeachingModeType .FirstOrDefault(x => !eop.EM_Coursematerial .EM_ClassGrouping .EM_ClassGroupingSettings.Select(w => w.TeachingModeID).Contains(x.TeachingModeID)) .TeachingModeID }) //接下来对除理论班之外的其他分班设置进行匹配,如果该专业课程有这个授课方式的话,就单独再分一个班 .Concat( from eop in executableMinorCourseList from tmt in eop.EM_ExecutableMinorPlanTeachingModeType from cgs in eop.EM_Coursematerial.EM_ClassGrouping.EM_ClassGroupingSettings where tmt.TeachingModeID == cgs.TeachingModeID select new { ExecutableMinorCourse = eop, TeachingMode = cgs.TeachingModeID })) join dtm in DictionaryHelper.GetDictionaryValue(ViewModel.DictionaryItem.CF_TeachingMode) on eop.TeachingMode equals dtm.Value group dtm by new { //Classmajor = sp.Classmajor, ExecutableMinorCourse = eop.ExecutableMinorCourse } into g select new { ExecutableMinorPlanID=g.Key.ExecutableMinorCourse.ExecutableMinorPlanID, ExecutableMinorCourse = g.Key.ExecutableMinorCourse, Classmajor = g.Key.ExecutableMinorCourse.EM_MinorPlan.CF_Grademinor.CF_Classminor, Student=g.Key.ExecutableMinorCourse.EM_MinorPlan.CF_Grademinor.CF_Classminor.Select(x=>x.CF_ClassminorStudent), TeachingMode = g.Select(x => x).ToList() } ); var missionDataList = query.ToList(); for (int i = 0; i < missionDataList.Count; i++) { var mission = missionDataList[i]; EM_EducationMission educationMission = new EM_EducationMission(); educationMission.EducationMissionID = Guid.NewGuid(); educationMission.ClassName = mission.ExecutableMinorCourse.EM_MinorPlan.CF_Grademinor.CF_Classminor.Select(x => x.Name).FirstOrDefault() +"-"+ mission.ExecutableMinorCourse.EM_Coursematerial.CourseName; educationMission.DepartmentID = mission.ExecutableMinorCourse.DepartmentID; educationMission.CollegeID = mission.ExecutableMinorCourse.CollegeID; educationMission.SchoolyearID = mission.ExecutableMinorCourse.SchoolyearID; SetNewStatus(educationMission); resultMissionList.Add(educationMission); foreach (var tm in mission.TeachingMode) { EM_EducationMissionClass educationMissionClass = new EM_EducationMissionClass(); educationMissionClass.EducationMissionClassID = Guid.NewGuid(); educationMissionClass.EducationMissionID = educationMission.EducationMissionID; educationMissionClass.MainScheduleClassID = mission.Classmajor.OrderBy(x => x.ClassNum).FirstOrDefault().ClassminorID; educationMissionClass.OrderNo = 0; educationMissionClass.Name = mission.ExecutableMinorCourse.EM_MinorPlan.CF_Grademinor.CF_Classminor.Select(x => x.Name).FirstOrDefault() + "-" + mission.ExecutableMinorCourse.EM_Coursematerial.CourseName; educationMissionClass.TeachingModeID = tm.Value; if (mission.TeachingMode.Count > 0) { educationMissionClass.Name += "【" + tm.Name + "】"; } educationMissionClass.OptionalCourseTypeID = (int)CF_CourseSelectType.OptionalCourse; educationMissionClass.CoursematerialID = mission.ExecutableMinorCourse.CoursematerialID; educationMissionClass.CourseStructureID = mission.ExecutableMinorCourse.CourseStructureID; educationMissionClass.CourseCategoryID = mission.ExecutableMinorCourse.CourseCategoryID; educationMissionClass.CourseTypeID = mission.ExecutableMinorCourse.CourseTypeID; educationMissionClass.CourseQualityID = mission.ExecutableMinorCourse.CourseQualityID; educationMissionClass.ExaminationModeID = mission.ExecutableMinorCourse.ExaminationModeID; educationMissionClass.TeachinglanguageID = mission.ExecutableMinorCourse.TeachinglanguageID; educationMissionClass.HandleModeID = (int)CF_HandleMode.MinorCourse; educationMissionClass.IsNeedMaterial = false; educationMissionClass.CF_Classmajor = null; educationMissionClass.ResultTypeID = mission.ExecutableMinorCourse.ResultTypeID; SetNewStatus(educationMissionClass); educationMissionClass.RecordStatus = (int)EMIS.ViewModel.CF_ApprovalStatus.NotSubmitted; //插入教学设置 EM_EducationMissionClassTeachingSetting educationMissionClassTeachingSetting = new EM_EducationMissionClassTeachingSetting(); educationMissionClassTeachingSetting.EducationMissionClassID = educationMissionClass.EducationMissionClassID; educationMissionClassTeachingSetting.Credit = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.Credit; educationMissionClassTeachingSetting.TheoryCourse = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.TheoryCourse; educationMissionClassTeachingSetting.Practicehours = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.Practicehours; educationMissionClassTeachingSetting.Trialhours = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.Trialhours; educationMissionClassTeachingSetting.WeeklyNum = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.WeeklyNum; educationMissionClassTeachingSetting.TheoryWeeklyNum = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.TheoryWeeklyNum; educationMissionClassTeachingSetting.PracticeWeeklyNum = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.PracticeWeeklyNum; educationMissionClassTeachingSetting.TrialWeeklyNum = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.TrialWeeklyNum; educationMissionClassTeachingSetting.StartWeeklyNum = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.StartWeeklyNum; educationMissionClassTeachingSetting.EndWeeklyNum = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.EndWeeklyNum; educationMissionClassTeachingSetting.WeeklyHours = mission.ExecutableMinorCourse.EM_ExecutableMinorPlanTeachingSetting.WeeklyHours; //插入排课班 EM_EducationSchedulingClass educationSchedulingClass = new EM_EducationSchedulingClass(); educationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid(); educationSchedulingClass.EducationMissionClassID = educationMissionClass.EducationMissionClassID; educationSchedulingClass.TaskGroupName = "1班"; SetNewStatus(educationSchedulingClass); var ClassminorIDList =mission.Classmajor.Select(x=>x.ClassminorID).ToList(); var studentIDList=ExecutableMinorPlanDAL.ClassminorStudentRepository.GetList(x=>ClassminorIDList.Contains(x.ClassminorID)).Select(w=>w.UserID).ToList(); var StudentList= ExecutableMinorPlanDAL.StudentRepository.GetList(x=>studentIDList.Contains(x.UserID)).ToList(); foreach(var s in StudentList) { CF_Student stu=s; educationSchedulingClass.CF_Student.Add(s); } EM_ExecutableMinorPlan ExecutableMinorPlan = ExecutableMinorPlanDAL.ExecutableMinorPlanRepository.GetList(x => x.ExecutableMinorPlanID == mission.ExecutableMinorPlanID).FirstOrDefault(); if (ExecutableMinorPlan!=null) { ExecutableMinorPlan.EM_EducationMissionClass.Add(educationMissionClass); } resultMissionClassList.Add(educationMissionClass); resultMissionClassTeachingSettingList.Add(educationMissionClassTeachingSetting); resultSchedulingClassList.Add(educationSchedulingClass); } mission.ExecutableMinorCourse.RecordStatus = (int)EMIS.ViewModel.EM_ExecuteStatus.Submited; } UnitOfWork.BulkInsert(resultMissionList); //UnitOfWork.BulkInsert(resultMissionClassList); UnitOfWork.BulkInsert(resultMissionClassTeachingSettingList); UnitOfWork.BulkInsert(resultSchedulingClassList); UnitOfWork.BulkInsert(resultSchedulingClassList, (x => x.CF_Student)); UnitOfWork.Commit(); } catch (Exception) { throw; } } } }