12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using EMIS.DataLogic.EducationManage;
- using EMIS.DataLogic.EducationSchedule;
- using EMIS.DataLogic.SchedulingManage.SchedulingSettings;
- using EMIS.ViewModel.EducationManagement;
- using Bowin.Common.Utility;
- using EMIS.Utility;
- using Bowin.Common.DataTime;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.CacheManage;
- using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
- using EMIS.DataLogic.UniversityManage.TeacherManage;
- using EMIS.DataLogic;
- using EMIS.ViewModel.EducationManage;
- using System.Data.Entity;
- namespace EMIS.CommonLogic.EducationSchedule
- {
- public class EducationMissionClassScheduleAdultServices : BaseServices, IEducationMissionClassScheduleAdultServices
- {
- public AdultEducationMissionClassDAL educationMissionClassDAL { get; set; }
- public EducationSchedulingClassRepository educationSchedulingClassRepository { get; set; }
- public EducationMissionClassScheduleDAL educationMissionClassScheduleDAL { get; set; }
- public EducationMissionClassSchedulingASdultDAL EducationMissionClassSchedulingASdultDAL { get; set; }
- public CollegePriorityDAL collegePriorityDAL { get; set; }
- public CoursematerialRepository coursematerialRepository { get; set; }
- public ClassmajorRepository classmajorRepository { get; set; }
- public ClassroomRepository classroomRepository { get; set; }
- public SchoolyearRepository SchoolyearRepository { get; set; }
- public CoursesTimeRepository coursesTimeRepository { get; set; }
- public CourseTimeHoursDAL CourseTimeHoursDAL { get; set; }
- public EducationMissionClassRepository educationMissionClassRepository { get; set; }
- public EducationMissionRepository educationMissionRepository { get; set; }
- public StaffDAL staffDAL { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public AdultEducationScheduleRepository adultEducationScheduleRepository { get; set; }
- public AdultEducationScheduleTeacherRepository AdultEducationScheduleTeacherRepository { get; set; }
- public EducationSchedulingClassDAL EducationSchedulingClassDAL { get; set; }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="departmentID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="approvalStatus"></param>
- /// <param name="teachingModeID"></param>
- /// <param name="grademajorID"></param>
- /// <param name="gradeYearID"></param>
- /// <param name="StandardID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<EducationMissionImportClassView> GetEducationMissionClassScheduleViewGrid(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, Guid? departmentID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? grademajorID, int? gradeYearID, int? StandardID, Guid? CoursesTimeID,int? learningformID, int? education, string LearnSystem, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
- Expression<Func<EM_ExecutablePlan, bool>> executablePlanExp = (x => true);
- Expression<Func<EM_ExecutableOptionalCourse, bool>> executableOptionalCourseExp = (x => true);
- Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> executableFreeSelectionCourseCourseExp = (x => true);
- //if(StandardID.HasValue)
- //{
- // executablePlanExp = executablePlanExp.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == StandardID);
- //}
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.DepartmentID == departmentID);
- }
- if (gradeYearID.HasValue)
- {
- //exp = exp.And(x => x.EM_ExecutablePlan.CF_Grademajor.SchoolyearID == gradeYearID);
- executablePlanExp = executablePlanExp.And(x => x.CF_Grademajor.GradeID == gradeYearID);
- executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.CF_Grademajor.GradeID == gradeYearID);
- }
- //if (grademajorID.HasValue)
- //{
- // //exp = exp.And(x => x.EM_ExecutablePlan.GrademajorID == grademajorID);
- // executablePlanExp = executablePlanExp.And(x => x.GrademajorID == grademajorID);
- // executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.GrademajorID == grademajorID);
- //}
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- executablePlanExp = executablePlanExp.And(x => x.CoursematerialID == coursematerialID);
- executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.EM_OptionalCoursePlan.CoursematerialID == coursematerialID);
- executableFreeSelectionCourseCourseExp = executableFreeSelectionCourseCourseExp.And(x => x.EM_FreeSelectionCouse.CoursematerialID == coursematerialID);
- }
- if (approvalStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == approvalStatus);
- }
- if (teachingModeID.HasValue)
- {
- exp = exp.And(x => x.TeachingModeID == teachingModeID);
- }
- if (CoursesTimeID.HasValue)
- {
- exp = exp.And(x => x.EM_CoursesTime.Any(c => c.CoursesTimeID == CoursesTimeID));
- }
- if (learningformID.HasValue)
- exp = exp.And(x => x.CF_Classmajor.Any(w => w.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID));
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- exp = exp.And(x => x.CF_Classmajor.Any(w => w.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems));
- }
- if (education.HasValue)
- {
- exp = exp.And(x => x.CF_Classmajor.Any(w => w.CF_Grademajor.CF_Facultymajor.EducationID == education.Value));
- }
- var query = EducationMissionClassSchedulingASdultDAL.GetEducationMissionClassViewQuery(exp, executablePlanExp,
- executableOptionalCourseExp, executableFreeSelectionCourseCourseExp);
- if (StandardID.HasValue)
- {
- query = query.Where(x => x.StandardID == StandardID);
- }
- if (grademajorID.HasValue)
- {
- query = query.Where(x => x.GrademajorID == grademajorID);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var resultQuery = query.OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID)
- .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name);
- var result = resultQuery.ToGridResultSet<EducationMissionImportClassView>(pageIndex, pageSize);
- var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
- var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
- result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- /// <summary>
- /// 导出查询
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="departmentID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="approvalStatus"></param>
- /// <param name="teachingModeID"></param>
- /// <param name="grademajorID"></param>
- /// <param name="gradeYearID"></param>
- /// <param name="StandardID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public List<EducationMissionImportClassView> GetEducationMissionClassScheduleViewGridExcel(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, Guid? departmentID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? grademajorID, int? gradeYearID, int? StandardID, List<Guid?> EducationMissionClassList, Guid? CoursesTimeID, int? learningformID, int? education, string LearnSystem)
- {
- Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
- Expression<Func<EM_ExecutablePlan, bool>> executablePlanExp = (x => true);
- Expression<Func<EM_ExecutableOptionalCourse, bool>> executableOptionalCourseExp = (x => true);
- Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> executableFreeSelectionCourseCourseExp = (x => true);
- if (EducationMissionClassList != null)
- {
- exp = exp.And(x => EducationMissionClassList.Contains(x.EducationMissionClassID));
- }
- else{
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.DepartmentID == departmentID);
- }
- if (gradeYearID.HasValue)
- {
- executablePlanExp = executablePlanExp.And(x => x.CF_Grademajor.GradeID == gradeYearID);
- executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.CF_Grademajor.GradeID == gradeYearID);
- }
- if (grademajorID.HasValue)
- {
- executablePlanExp = executablePlanExp.And(x => x.GrademajorID == grademajorID);
- executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.GrademajorID == grademajorID);
- }
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- executablePlanExp = executablePlanExp.And(x => x.CoursematerialID == coursematerialID);
- executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.EM_OptionalCoursePlan.CoursematerialID == coursematerialID);
- executableFreeSelectionCourseCourseExp = executableFreeSelectionCourseCourseExp.And(x => x.EM_FreeSelectionCouse.CoursematerialID == coursematerialID);
- }
- if (approvalStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == approvalStatus);
- }
- if (teachingModeID.HasValue)
- {
- exp = exp.And(x => x.TeachingModeID == teachingModeID);
- }
- if (CoursesTimeID.HasValue)
- {
- exp = exp.And(x => x.EM_CoursesTime.Any(c => c.CoursesTimeID == CoursesTimeID));
- }
- if (learningformID.HasValue)
- exp = exp.And(x => x.CF_Classmajor.Any(w => w.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID));
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- exp = exp.And(x => x.CF_Classmajor.Any(w => w.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems));
- }
- if (education.HasValue)
- {
- exp = exp.And(x => x.CF_Classmajor.Any(w => w.CF_Grademajor.CF_Facultymajor.EducationID == education.Value));
- }
- }
- var query = EducationMissionClassSchedulingASdultDAL.GetEducationMissionClassViewQueryblExcel(exp, executablePlanExp,
- executableOptionalCourseExp, executableFreeSelectionCourseCourseExp);
- //if (EducationMissionClassList != null)
- //{
- // query.Where(x => EducationMissionClassList.Contains(x.EducationMissionClassID));
- //}
- if (StandardID.HasValue)
- {
- query = query.Where(x => x.StandardID == StandardID);
- }
- var educationMissionClassID = query.Select(x => x.EducationMissionClassID).ToList();
- var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID)
- .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name)
- .ToList();
- result.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- public void EducationMissionClassScheduleDelete(List<Guid?> missionClassID)
- {
- var missionClassList = educationMissionClassDAL.educationMissionClassRepository.GetList(x => missionClassID.Contains(x.EducationMissionClassID),
- (x => x.CF_Classmajor),
- (x => x.EM_EducationMission),
- (x => x.EM_EducationMissionClassSettings),
- (x => x.EM_EducationMissionClassTeachingSetting),
- (x => x.EM_EducationSchedulingClass),
- (x => x.EM_EducationSchedulingClass.Select(w => w.CF_Student)),
- (x => x.EM_MissionClassTeacher),
- (x => x.EM_CourseProcess),
- (x => x.EM_CoursesTime),
- (x => x.EM_CourseProcess.Select(y => y.EM_CourseProcessTeacher))).ToList();
- var adultEducationScheduleIDList = adultEducationScheduleRepository.GetList(x=>missionClassID.Contains(x.EM_EducationSchedulingClass.EM_EducationMissionClass.EducationMissionClassID)).Select(w=>w.AdultEducationScheduleID).ToList();
- foreach (var mid in missionClassID)
- {
- UnitOfWork.Delete<EM_MissionClassTeacher>(x => x.MissionClassID==mid);
-
- }
- foreach(var missionClass in missionClassList)
- {
- missionClass.RecordStatus = (int)EMIS.ViewModel.EM_EducationMissionClassStatus.Submitted;
- this.SetModifyStatus(missionClass);
- UnitOfWork.Delete<EM_EducationMissionExamTime>(x => x.EducationMissionID == missionClass.EducationMissionID);
- UnitOfWork.Delete<EM_EducationMissionExamWeekNum>(x => x.EducationMissionID == missionClass.EducationMissionID);
- }
- foreach (var mid in adultEducationScheduleIDList)
- {
- UnitOfWork.Delete<ES_AdultEducationScheduleTeacher>(x => x.AdultEducationScheduleID == mid);
- UnitOfWork.Delete<ES_AdultEducationSchedule>(x =>x.AdultEducationScheduleID==mid);
- }
- UnitOfWork.Commit();
- }
- /// <summary>
- /// 教学任务导入
- /// </summary>
- /// <param name="dataList">导入的数据集合</param>
- /// <param name="errdataList">返回的操作失败集合</param>
- /// <param name="successCount">操作成功记录条数</param>
- /// <returns></returns>
- public void EducationMissionClassImport(out int OkCount, out List<EducationMissionImportClassView> errdataList, out int successCount, string sourcePhysicalPath, string sourceWebPath, out string errorWebPath, out string Errinfo, Guid schoolyear)
- {
- var excel = new NpoiExcelHelper();
- #region 1.0 单元格抬头
- Dictionary<string, string> cellheader = new Dictionary<string, string>
- {
-
- { "CollegeName", RSL.Get("College") }, { "Education", RSL.Get("CultureModel") },
- { "Learningform","学习形式" },{ "ClassNumStr", "班级人数" },
- { "Name", "任务班名称" },{ "CourseName", "课程名称" },
- { "TotalhoursStr", "总学时" },{ "ReferenceDays", "参考天数" },
- { "TeachingTime", "上课时间" },{ "ClassroomName", "课室" },
- { "TeacherNameString", "授课教师" },{"ExaminationModeStr","考试方式"},
- { "ExamWeek", "考试周次" },{ "ExamTime", "考试时间" },
- { "Assistant", "班主任" },{ "StandardName", "年级专业" },
- { "CourseCode", "课程代码" },{ "CourseTime", "课时类别" },
- { "TheoryCourseStr", "理论学时" },{ "PracticehoursStr", "实践学时" },
- { "TeachingDay", "执行天数" }, { "TeachingHours", "执行学时" },
- { "ErrorMessage", "错误信息" }
- };
- #endregion
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<EducationMissionImportClassView> errList = new List<EducationMissionImportClassView>();
- DataTimeHelper dth = new DataTimeHelper();
- #region 1.1解析文件,存放到一个List集合里
- // 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//去除异常列、导入操作不需要
- List<EducationMissionImportClassView> enlist =
- NpoiExcelHelper.ExcelToEntityList<EducationMissionImportClassView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "错误信息");//还原字典项
- #endregion
- #region 读取校验数据
- if (enlist.Count() <= 0)
- {
- throw new Exception("请填写Excel模板信息数据。");
- }
- //任务班
- var missionClassNameList = enlist.Select(x => x.Name).ToList();
- var missionClassList = educationMissionClassDAL.educationMissionClassRepository.GetList(x => missionClassNameList.Contains(x.Name),
- (x => x.CF_Classmajor),
- (x => x.EM_EducationMission),
- (x => x.EM_EducationMissionClassTeachingSetting),
- (x => x.EM_EducationMissionClassSettings),
- (x => x.EM_EducationSchedulingClass),
- (x => x.EM_EducationSchedulingClass.Select(w => w.CF_Student)),
- (x => x.EM_MissionClassTeacher),
- (x => x.EM_CourseProcess),
- (x => x.EM_CoursesTime),
- (x => x.EM_CourseProcess.Select(y => y.EM_CourseProcessTeacher))).ToList();
- var classmajorIDList = missionClassList.Select(w => w.MainScheduleClassID).ToList();
- var classmajorList = this.classmajorRepository.GetList(x => classmajorIDList.Contains(x.ClassmajorID), (x => x.CF_Grademajor)).ToList();
- //任务班年级
- var gradeyearList = classmajorList.Select(x => x.CF_Grademajor.GradeID).Distinct().ToList();
- //教师
- var teacherNameList = enlist.Where(x => !string.IsNullOrEmpty(x.TeacherNameString))
- .SelectMany(x => x.TeacherNameString.Split('\\').ToList()).Distinct().ToList();
- var teacherList = staffDAL.staffRepository.GetList(x => teacherNameList.Contains(x.Sys_User.Name));
- //教室
- var ClassroomNameList = enlist.Select(x => x.ClassroomName);
- var ClassroomName = classroomRepository.GetList(x => ClassroomNameList.Contains(x.Name),(x=>x.CF_ClassroomType)).ToList();
- //课时类别
- List<CourseTimeHoursView> CourseTimeHoursList = CourseTimeHoursDAL.GetCoursesTimeQueryable(x => x.RecordStatus > (int?)SYS_STATUS.UNUSABLE, w => w.RecordStatus > (int?)SYS_STATUS.UNUSABLE
- && (gradeyearList.Contains(w.Years))
- ).ToList();
- //任务班ID
- var missionClassIDList = missionClassList.Select(x=>x.EducationMissionClassID).ToList();
- //排课班
- var educationSchedulingClassIDList= educationSchedulingClassRepository.GetList(x=> missionClassIDList.Contains(x.EM_EducationMissionClass.EducationMissionClassID)).ToList();
- //已排的课
- var EducationScheduleList = adultEducationScheduleRepository.GetList(x => x.SchoolyearID == schoolyear, (x => x.EM_EducationSchedulingClass)).ToList();
- //学年学期
- var school= SchoolyearRepository.Entities.Where(x => x.SchoolyearID == schoolyear).FirstOrDefault();
- #endregion
- #region 1.2 将Excel数据写入数据库中
- #region 1.2.1 对List集合进行有效性校验
-
- #region 1.2.1.1检测必填项是否必填
- for (int i = 0; i < enlist.Count; i++)
- {
- EducationMissionImportClassView en = enlist[i];
- string errorMsgStr = "第" + (i + 2) + "行数据检测异常:";
- en.ErrorMessage = errorMsgStr;
- bool isHaveNoInputValue = false; // 是否含有未输入项
- en.IsExcelVaildateOK = true;
- if (string.IsNullOrEmpty(en.Name))
- {
- errorMsgStr += "任务班名称不能为空;";
- isHaveNoInputValue = true;
- }
- if (string.IsNullOrEmpty(en.ClassroomName))
- {
- errorMsgStr += "课室不能为空;";
- isHaveNoInputValue = true;
- }
- if (string.IsNullOrEmpty(en.TeacherNameString))
- {
- errorMsgStr += "授课教师不能为空;";
- isHaveNoInputValue = true;
- }
- if (string.IsNullOrEmpty(en.TeachingTime))
- {
- errorMsgStr += "上课时间不能为空;";
- isHaveNoInputValue = true;
- }
-
- #region 1.2.1.2 检测(数据唯一性、)
- var missionClass = missionClassList.Where(x => x.Name == en.Name).FirstOrDefault();
- var missionClassYear = missionClassList.Where(x => x.Name == en.Name && x.EM_EducationMission.SchoolyearID == schoolyear).FirstOrDefault();
- //var missionStates
-
- #region 任务班
- if (!string.IsNullOrEmpty(en.Name))
- {
-
- if (missionClass==null)
- {
- errorMsgStr += "任务班不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (missionClassYear == null)
- {
- errorMsgStr += "任务班的学年学期不是当前选中的学年学期;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- if (missionClassYear.EM_CoursesTime==null)
- {
- errorMsgStr += "请设置课时类别;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- }
- //if (missionClass.ApprovalStatus == (int)EM_EducationMissionClassStatus.Scheduled)
- //{
- // errorMsgStr += "任务班状态为以排课状态,不能导入;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- //}
- //if (missionClass.ApprovalStatus == (int)EM_EducationMissionClassStatus.NotSubmitted)
- //{
- // errorMsgStr += "任务班状态为未提交状态,不能导入;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- //}
- }
- #endregion
- #region 课时类别
- if (missionClassYear!=null)
- {
- if (missionClassYear.EM_CoursesTime.Count()!=0)
- {
- if (!string.IsNullOrEmpty(en.CourseTime))
- {
- var missionClassMainClassmajor = classmajorList.FirstOrDefault(x => x.ClassmajorID == missionClassYear.MainScheduleClassID);
- var gradeYear = missionClassMainClassmajor.CF_Grademajor.GradeID;
- if (CourseTimeHoursList.Count(x => x.Year == gradeYear) != 0)
- {
- var CourseTimeHours = CourseTimeHoursList.Where(x => x.time_starTime_endTime == en.CourseTime && x.Year == gradeYear).FirstOrDefault();
- if(CourseTimeHours!=null){
- en.CourseTimeID=CourseTimeHours.CoursesTimeID;
- }
- else
- {
- errorMsgStr += "请填写正确的课时类别;";
- isHaveNoInputValue = true;
- }
- }
- else
- {
- errorMsgStr += "该年级的课时类别找不到对应的学时转换设置,请检查学时转换设置;";
- isHaveNoInputValue = true;
- }
- }
- else
- {
- errorMsgStr += "课时类别不能为空;";
- isHaveNoInputValue = true;
- }
-
- }
- else
- {
- errorMsgStr += "任务班未设置课时类别,请去教学任务设置;";
- isHaveNoInputValue = true;
- }
- }
- #endregion
- #region 课室
- if (missionClassYear != null)
- {
- if (!string.IsNullOrEmpty(en.ClassroomName))
- {
- var ClassID = Guid.Empty;
- var Classroom = ClassroomName.Where(x => x.Name == en.ClassroomName.Trim()).FirstOrDefault();
- if (Classroom != null)
- {
- ClassID = ClassroomName.Where(x => x.CF_ClassroomType.Any(w => w.ClassroomID == Classroom.ClassroomID && w.ClassroomType == missionClassYear.ClassroomTypeID)).Select(t => t.ClassroomID).FirstOrDefault();
- }
- if (Classroom == null)
- {
- errorMsgStr += "课室不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- if (ClassID == Guid.Empty)
- {
- errorMsgStr += "课室类型与任务班设置的教室类型不一致;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.ClassroomID = Classroom.ClassroomID;
- }
- }
- }
- }
- #endregion
- #region 上课时间
- if (!string.IsNullOrEmpty(en.TeachingTime))
- {
- if (en.TeachingTime.Contains("日"))
- {
- en.TeachingTime.TrimEnd("日");
- }
- if (en.TeachingTime.Contains("月"))
- {
- List<string> TimesSegment = en.TeachingTime.Split(',').ToList();
- if (en.TeachingTime.Contains(",") && !en.TeachingTime.Contains(","))
- {
- TimesSegment = en.TeachingTime.Split(',').ToList();
- }
- List<string> teachtingTime = new List<string>();
- for (int t = 0; t < TimesSegment.Count(); t++)
- {
- List<string> month = TimesSegment[t].Split('月').ToList();
- for (int m = 1; m < month.Count(); m++)
- {
- List<string> day = month[m].Split('、').ToList();
- for (int d = 0; d < day.Count(); d++)
- {
- teachtingTime.Add(month[0] + "月");
- int index = teachtingTime.Count()-1;
- teachtingTime[index] += day[d];
- }
- }
- }
- DateTime Date;
- en.Time = new List<string>();
- foreach (var date in teachtingTime)
- {
-
- if (!DateTime.TryParse(date, out Date))
- {
- errorMsgStr += "上课时间格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- break;
- }
- else
- {
- en.Time.Add(date);
- if (dth.ToDateTimeValue(date) != string.Empty)
- {
- Date = Convert.ToDateTime(dth.ToDateTimeValue(date));
- }
- else
- {
- Date = Convert.ToDateTime(date);
- }
- if (missionClassYear != null && en.CourseTimeID != null)
- {
- var isok = EducationScheduleList.Where(x => x.ScheduleDate == Date && x.ClassroomID == en.ClassroomID && x.CoursesTimeID == en.CourseTimeID && x.EM_EducationSchedulingClass.EducationMissionClassID != missionClassYear.EducationMissionClassID).ToList();
- if (isok.Count() != 0)
- {
- errorMsgStr += "该教室在该时间段已被使用;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- break;
- }
- }
- }
- }
- }
- if (!en.TeachingTime.Contains("月"))
- {
- errorMsgStr += "上课时间格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (en.TeachingTime.Contains(",") && en.TeachingTime.Contains(","))
- {
- errorMsgStr += "上课时间分割月份的逗号只能选择中文或英文逗号的一种;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- }
- #endregion
- #region 授课教师
- if (!string.IsNullOrEmpty(en.TeacherNameString))
- {
-
- List<Guid> userID=new List<Guid>();
- string[] TName=null;
- if (en.TeacherNameString.Contains("\\"))
- {
- TName = en.TeacherNameString.Split('\\');
- }
- if(TName!=null){
- var teacher = teacherList.Where(x => TName.Contains(x.Sys_User.Name)).Select(x=>x.UserID).ToList();
- userID=teacher;
- if(teacher.Count()!=TName.Count())
- {
- errorMsgStr += "授课教师不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- en.UserID=userID.Distinct().ToList();
- }
- else
- {
- userID = teacherList.Where(x=>x.Sys_User.Name==en.TeacherNameString).Select(w => w.UserID).ToList();
- if(userID.Count==0){
- errorMsgStr += "授课教师不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- DateTime date;
- if(en.Time!=null){
- foreach(var datetime in en.Time){
- if (dth.ToDateTimeValue(datetime) != string.Empty){
- date=Convert.ToDateTime(dth.ToDateTimeValue(datetime));
- }
- else
- {
- date = Convert.ToDateTime(datetime);
- }
- if(userID.Count!=0){
- if (en.CourseTimeID != null && en.ClassroomID == Guid.Empty)
- {
- foreach(var staffid in userID){
- var staffOnWork = EducationMissionClassSchedulingASdultDAL.CheckTeacherIsOnWork(x => x.CoursesTimeID == en.CourseTimeID && x.ScheduleDate == date, w => w.UserID == staffid).Select(x => x.AdultUserId).FirstOrDefault();
- if(staffOnWork==null){
- errorMsgStr += "授课教师在"+date.Month+"月"+date.Day+"日已有排课安排;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- break;
- }
- }
- }
- }
- }
- }
- en.UserID = userID.Distinct().ToList();
- }
- }
- #endregion
- #region 考试周次
- if (!string.IsNullOrEmpty(en.ExamWeek))
- {
- int isok = 0;
- List<string> week = en.ExamWeek.Split('\\').ToList();
- List<int?> weeks = new List<int?>();
- if (week!=null)
- {
- for (int w = 0; w < week.Count(); w++)
- {
- if (int.TryParse(week[w], out isok))
- {
- int day = Convert.ToInt32(week[w]);
- var weeknum = school;
- if (day > weeknum.WeeksNum || day < 0)
- {
- errorMsgStr += "考试周次输入的格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- weeks.Add(day);
- }
- }
- else
- {
- errorMsgStr += "考试周次输入的格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- }
- en.ExaWeek = weeks;
- }
-
-
- }
- #endregion
- #region 考试时间
- if(!string.IsNullOrEmpty(en.ExamTime)){
- List<string> year = en.ExamTime.Split('日').ToList();
- if (year.Count == 2)
- {
- List<string> times = year[1].Trim().Split('-').ToList();
- if (times.Count == 2)
- {
- DateTime date;
- TimeSpan timespan;
- string years = year[0] + "日";
- if (DateTime.TryParse(years, out date))
- {
- en.ExamDate = Convert.ToDateTime(years);
- }
- else
- {
- errorMsgStr += "考试时间输入的格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- List<string> Star = times[0].Split(':').ToList();
- if (Star.Count() == 2)
- {
- int isok = 0;
- if (int.TryParse(Star[0], out isok) && int.TryParse(Star[1], out isok))
- {
- timespan = new TimeSpan(Convert.ToInt32(Star[0]), Convert.ToInt32(Star[1]), 0);
- en.StarTime = timespan;
- }
- else
- {
- errorMsgStr += "考试时间输入的格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- }
- else
- {
- errorMsgStr += "考试时间输入的格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- List<string> end=times[1].Split(':').ToList();
- if(end.Count()==2){
- int isok = 0;
- if (int.TryParse(end[0], out isok) && int.TryParse(end[1], out isok))
- {
- timespan = new TimeSpan(Convert.ToInt32(end[0]), Convert.ToInt32(end[1]), 0);
- en.EndTime = timespan;
- }
- else
- {
- errorMsgStr += "考试时间输入的格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- }
- else
- {
- errorMsgStr += "考试时间输入的格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
-
- }
- else
- {
- errorMsgStr += "考试时间输入的格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- }
- else
- {
- errorMsgStr += "考试时间输入的格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
-
- }
- for (int j = i + 1; j < enlist.Count; j++)
- {
- EducationMissionImportClassView enB = enlist[j];
- // 判断必填列是否全部重复
- if (
- !string.IsNullOrEmpty(en.Name) && !string.IsNullOrEmpty(enB.Name)&&
- !string.IsNullOrEmpty(en.TeachingTime) && !string.IsNullOrEmpty(enB.TeachingTime) &&
- !string.IsNullOrEmpty(en.ClassroomName) && !string.IsNullOrEmpty(enB.ClassroomName) &&
- !string.IsNullOrEmpty(en.CourseTime) && !string.IsNullOrEmpty(enB.CourseTime)
- )
- {
- if (
- en.Name == enB.Name&&
- en.TeachingTime==enB.TeachingTime&&
- en.ClassroomName == enB.ClassroomName
- )
- {
- isHaveNoInputValue = true;
- errorMsgStr += "第" + (i + 2) + "行与第" + (j + 2) + "行的必填列重复了";
- en.ErrorMessage = errorMsgStr;
- }
- if (
- en.Name == enB.Name &&
- en.CourseTime != enB.CourseTime
- )
- {
- isHaveNoInputValue = true;
- errorMsgStr += "第" + (i + 2) + "行与第" + (j + 2) + "行的课时类别不同";
- en.ErrorMessage = errorMsgStr;
- }
- }
- if (!string.IsNullOrEmpty(en.TeachingTime) && !string.IsNullOrEmpty(enB.TeachingTime) && !string.IsNullOrEmpty(en.ClassroomName) && !string.IsNullOrEmpty(enB.ClassroomName))
- {
- if (en.TeachingTime.Contains("月") && enB.TeachingTime.Contains("月"))
- {
- string[] TName = en.TeacherNameString.Split('\\');
- List<string> TimesSegment = en.TeachingTime.Split(',').ToList();
- List<string> TimesSegmentB = enB.TeachingTime.Split(',').ToList();
- List<string> teachtingTimeA = new List<string>();
- for (int t = 0; t < TimesSegment.Count(); t++)
- {
- List<string> month = TimesSegment[t].Split('月').ToList();
- for (int m = 1; m < month.Count(); m++)
- {
- List<string> day = month[m].Split('、').ToList();
- for (int d = 0; d < day.Count(); d++)
- {
- teachtingTimeA.Add(month[0] + "月");
- int index = teachtingTimeA.Count() - 1;
- teachtingTimeA[index] += day[d];
- }
- }
- }
- List<string> teachtingTimeB = new List<string>();
- for (int t = 0; t < TimesSegmentB.Count(); t++)
- {
- List<string> month = TimesSegmentB[t].Split('月').ToList();
- for (int m = 1; m < month.Count(); m++)
- {
- List<string> day = month[m].Split('、').ToList();
- for (int d = 0; d < day.Count(); d++)
- {
- teachtingTimeB.Add(month[0] + "月");
- int index = teachtingTimeB.Count() - 1;
- teachtingTimeB[index] += day[d];
- }
- }
- }
- for (int c = 0; c < TimesSegmentB.Count(); c++)
- {
- foreach (var n in TName)
- {
- if (enB.TeacherNameString.Contains(n) && teachtingTimeA.Contains(teachtingTimeB[c]) && en.CourseTime == enB.CourseTime)
- {
- isHaveNoInputValue = true;
- errorMsgStr += "第" + (i + 2) + "行与第" + (j + 2) + "行的同一个老师在同一天同一个时间段内有不同的安排";
- break;
- }
- }
- if (teachtingTimeA.Contains(teachtingTimeB[c]) && en.ClassroomName == enB.ClassroomName && en.CourseTime == enB.CourseTime)
- {
- isHaveNoInputValue = true;
- errorMsgStr += "第" + (i + 2) + "行与第" + (j + 2) + "行的同一个教室在同一天同一个时间段内有不同的安排";
- break;
- }
- }
- }
- }
- }
- #endregion
- #endregion
- if (isHaveNoInputValue) // 若必填项有值未填
- {
- en.IsExcelVaildateOK = false;
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- }
- }
- #endregion
- // TODO:其他检测
- #region 1.2.1.3 循环写入验证成功的数据
- List<EducationMissionImportClassView> className = new List<EducationMissionImportClassView>();
- for (int i = 0; i < enlist.Count; i++)
- {
-
- EducationMissionImportClassView enA = enlist[i];
- enA.OrderNo = i;
- if (enA.IsExcelVaildateOK == false) // 上面验证不通过,不进行此步验证
- {
- continue;
- }
-
- for (int j = i + 1; j < enlist.Count; j++)
- {
- EducationMissionImportClassView enB = enlist[j];
- // 判断必填列是否全部重复
- if (
- !string.IsNullOrEmpty(enA.Name) && !string.IsNullOrEmpty(enB.Name)
- )
- {
- if (
- enA.Name == enB.Name
- )
- {
- className.Add(enA);
- }
- }
- }
- try
- {
- var educationMissionClass = missionClassList.Where(x => x.Name == enA.Name).FirstOrDefault(); //educationMissionClassDAL.GetEducationMissionClassViewQueryble(x => x.Name == enA.Name && x.EM_EducationMission.SchoolyearID == schoolyear, w => true, c => true, a => true).FirstOrDefault();
- var classrommId = ClassroomName.Where(x => x.Name == enA.ClassroomName).FirstOrDefault();
- var educationMissionClassID = educationMissionClass.EducationMissionClassID;
- List<Guid> educationSchedulingClassID = educationSchedulingClassIDList.Where(x => x.EducationMissionClassID == educationMissionClassID).Select(w=>w.EducationSchedulingClassID).ToList();
- var e = className.OrderBy(w => w.OrderNo).Where(x => x.Name == enA.Name).FirstOrDefault();
- int errornums = 0;
- foreach(var edID in educationSchedulingClassID){
- if (errornums==0)
- {
- foreach(var datetime in enA.Time){
- DateTime t = Convert.ToDateTime(datetime);
- var studentQuery = this.EducationSchedulingClassDAL.GetStudentQueryable(x => x.EducationSchedulingClassID == edID);
- var studentIsBusy = (from es in adultEducationScheduleRepository.GetList(
- x => x.SchoolyearID == schoolyear && x.EducationSchedulingClassID != edID)
- from s in es.EM_EducationSchedulingClass.CF_Student
- .Join(studentQuery, (x => x.UserID), (x => x.UserID), (x, y) => x)
- where es.ScheduleDate == t && es.CoursesTimeID == enA.CourseTimeID
- select s).Include(x => x.Sys_User).ToList();
- if (studentIsBusy.Count > 0)
- {
- errornums = studentIsBusy.Count;
- enA.ErrorMessage += "部分学生在"+t.Month+"月"+t.Day+"日有课,不能上课;";
- errList.Add(enA);
- break;
- }
- }
- }
- List<Guid> adultEducationScheduleID = EducationScheduleList.Where(x => x.EducationSchedulingClassID == edID).Select(w => w.AdultEducationScheduleID).ToList();
- if (e==null)
- {
- if (adultEducationScheduleID.Count() != 0 && errornums == 0)
- {
- //先删除旧数据、重新创建新数据
- UnitOfWork.Delete<EM_EducationMissionExamTime>(x => x.EducationMissionID == educationMissionClass.EducationMissionID);
- UnitOfWork.Delete<EM_MissionClassTeacher>(x => x.MissionClassID == educationMissionClass.EducationMissionClassID);
- UnitOfWork.Delete<EM_EducationMissionExamWeekNum>(x => x.EducationMissionID == educationMissionClass.EducationMissionID);
- UnitOfWork.Delete<ES_AdultEducationScheduleTeacher>(x => adultEducationScheduleID.Contains((Guid)x.AdultEducationScheduleID));
- UnitOfWork.Delete<ES_AdultEducationSchedule>(x => educationSchedulingClassID.Contains((Guid)x.EducationSchedulingClassID));
- }
- if (educationMissionClass.EM_MissionClassTeacher.Count > 0)
- {
- UnitOfWork.Delete<EM_MissionClassTeacher>(x => x.MissionClassID == educationMissionClass.EducationMissionClassID);
- }
- }
- else
- {
- if(e.OrderNo==enA.OrderNo){
- if (adultEducationScheduleID.Count() != 0 && errornums == 0)
- {
- //先删除旧数据、重新创建新数据
- UnitOfWork.Delete<EM_EducationMissionExamTime>(x => x.EducationMissionID == educationMissionClass.EducationMissionID);
- UnitOfWork.Delete<EM_MissionClassTeacher>(x => x.MissionClassID == educationMissionClass.EducationMissionClassID);
- UnitOfWork.Delete<EM_EducationMissionExamWeekNum>(x => x.EducationMissionID == educationMissionClass.EducationMissionID);
- UnitOfWork.Delete<ES_AdultEducationScheduleTeacher>(x => adultEducationScheduleID.Contains((Guid)x.AdultEducationScheduleID));
- UnitOfWork.Delete<ES_AdultEducationSchedule>(x => educationSchedulingClassID.Contains((Guid)x.EducationSchedulingClassID));
- }
- if (educationMissionClass.EM_MissionClassTeacher.Count > 0)
- {
- UnitOfWork.Delete<EM_MissionClassTeacher>(x => x.MissionClassID == educationMissionClass.EducationMissionClassID);
- }
- }
- }
- }
-
- if (enA != null&&errornums==0) //有数据开始组装数据
- {
- if(enA.CourseTimeID!=null){
- EM_CoursesTime c =coursesTimeRepository.Entities.Where(x=>x.CoursesTimeID==(Guid)enA.CourseTimeID).FirstOrDefault();
- if(c!=null){
- EM_EducationMissionClass ec = new EM_EducationMissionClass();
- ec = educationMissionClass;
- ec.ClassroomID = enA.ClassroomID;
- ec.EM_CoursesTime = new HashSet<EM_CoursesTime>();
- ec.EM_CoursesTime.Add(c);
- this.SetNewStatus(ec);
- ec.RecordStatus = (int)EMIS.ViewModel.EM_EducationMissionClassStatus.Scheduled;
- UnitOfWork.Update(ec);
- }
- }
- if (enA.ExamDate!=null&&enA.EndTime!=null&&enA.StarTime != null)
- {
- if (e == null)
- {
- EM_EducationMissionExamTime Examtime = new EM_EducationMissionExamTime();
- Examtime.EducationMissionExamTimeID = Guid.NewGuid();
- Examtime.EducationMissionID = educationMissionClass.EducationMissionID;
- if (enA.ExamDate.ToLongDateString().ToString() == "0001年1月1日")
- {
- Examtime.ExamDate = null;
- Examtime.StartTime = null;
- Examtime.EndTime = null;
- }
- else
- {
- Examtime.ExamDate = enA.ExamDate;
- TimeSpan tt = new TimeSpan(enA.ExamDate.Hour, enA.ExamDate.Minute, enA.ExamDate.Second);
- Examtime.StartTime = enA.StarTime;
- Examtime.EndTime = enA.EndTime;
- }
- this.SetNewStatus(Examtime);
- UnitOfWork.Add(Examtime);
- }
- else
- {
- if (e.OrderNo == enA.OrderNo)
- {
- EM_EducationMissionExamTime Examtime = new EM_EducationMissionExamTime();
- Examtime.EducationMissionExamTimeID = Guid.NewGuid();
- Examtime.EducationMissionID = educationMissionClass.EducationMissionID;
- if (enA.ExamDate.ToLongDateString().ToString() == "0001年1月1日")
- {
- Examtime.ExamDate = null;
- Examtime.StartTime = null;
- Examtime.EndTime = null;
- }
- else
- {
- Examtime.ExamDate = enA.ExamDate;
- TimeSpan tt = new TimeSpan(enA.ExamDate.Hour, enA.ExamDate.Minute, enA.ExamDate.Second);
- Examtime.StartTime = enA.StarTime;
- Examtime.EndTime = enA.EndTime;
- }
- this.SetNewStatus(Examtime);
- UnitOfWork.Add(Examtime);
- }
- }
- }
- if(enA.ExaWeek!=null){
- if (e == null)
- {
- foreach (var week in enA.ExaWeek)
- {
- EM_EducationMissionExamWeekNum ExamWeekNum = new EM_EducationMissionExamWeekNum();
- ExamWeekNum.EducationMissionExamWeekNumID = Guid.NewGuid();
- ExamWeekNum.EducationMissionID = educationMissionClass.EducationMissionID;
- ExamWeekNum.WeeklyNum = week;
- this.SetNewStatus(ExamWeekNum);
- UnitOfWork.Add(ExamWeekNum);
- }
- }
- else
- {
- if (e.OrderNo == enA.OrderNo)
- {
- foreach (var week in enA.ExaWeek)
- {
- EM_EducationMissionExamWeekNum ExamWeekNum = new EM_EducationMissionExamWeekNum();
- ExamWeekNum.EducationMissionExamWeekNumID = Guid.NewGuid();
- ExamWeekNum.EducationMissionID = educationMissionClass.EducationMissionID;
- ExamWeekNum.WeeklyNum = week;
- this.SetNewStatus(ExamWeekNum);
- UnitOfWork.Add(ExamWeekNum);
- }
- }
- }
- }
- foreach(var staffID in enA.UserID){
- UnitOfWork.Delete<EM_MissionClassTeacher>(x => x.MissionClassID == educationMissionClass.EducationMissionClassID && x.UserID == staffID);
- EM_MissionClassTeacher teacher = new EM_MissionClassTeacher();
- teacher.MissionClassTeacherID = Guid.NewGuid();
- teacher.MissionClassID = educationMissionClass.EducationMissionClassID;
- teacher.UserID = staffID;
- teacher.TeachType = (int?)EM_TeachingMethod.Lecturer;
- this.SetNewStatus(teacher);
- UnitOfWork.Add(teacher);
- }
- foreach (var schedulingClass in educationSchedulingClassID)
- {
- foreach (var times in enA.Time)
- {
- ES_AdultEducationSchedule EducationScheduling = new ES_AdultEducationSchedule();
- EducationScheduling.AdultEducationScheduleID = Guid.NewGuid();
- EducationScheduling.EducationSchedulingClassID = schedulingClass;
- EducationScheduling.ClassroomID = enA.ClassroomID;
- EducationScheduling.SchoolyearID = schoolyear;
- EducationScheduling.CoursesTimeID = enA.CourseTimeID;
- if (dth.ToDateTimeValue(times) != string.Empty)
- EducationScheduling.ScheduleDate = Convert.ToDateTime(dth.ToDateTimeValue(times));
- else
- EducationScheduling.ScheduleDate = Convert.ToDateTime(times);
- SetNewStatus(EducationScheduling);
- UnitOfWork.Add(EducationScheduling);
- if (enA.UserID != null)
- {
- foreach (var user in enA.UserID)
- {
- ES_AdultEducationScheduleTeacher EducationSchedulingTeacher = new ES_AdultEducationScheduleTeacher();
- EducationSchedulingTeacher.AdultEducationScheduleTeacherID = Guid.NewGuid();
- EducationSchedulingTeacher.AdultEducationScheduleID = EducationScheduling.AdultEducationScheduleID;
- EducationSchedulingTeacher.UserID = user;
- EducationSchedulingTeacher.TeachingMethod = (int?)EM_TeachingMethod.Lecturer;
- SetNewStatus(EducationSchedulingTeacher);
- UnitOfWork.Add(EducationSchedulingTeacher);
- }
- }
- }
- }
- }
- UnitOfWork.Commit();
- }
-
- catch (Exception)
- {
- throw;
- }
- }
- #endregion
-
- #endregion
- #endregion
- #region 1.3 返回各项数据值
- errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "教学任务课程安排操作失败文件", sourceWebPath));
- successCount = enlist.Distinct().Count() - errList.Distinct().Count();//共条数减去失败条数
- errdataList = errList.Distinct().ToList();
- OkCount = errList.Distinct().Count();
- Errinfo = string.Format("提示:成功导入{0}条记录,失败{1}条,详情请点击错误数据下载查看。", successCount < 1 ? 0 : successCount, OkCount < 1 ? 0 : OkCount);
- #endregion
- }
- }
- }
|