using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.SchedulingManage.SchedulingSettings; using EMIS.CommonLogic.CalendarManage; using EMIS.Entities; using System.Linq.Expressions; using Bowin.Common.Linq.Entity; using Bowin.Common.Linq; using EMIS.ViewModel.SchedulingManage.SchedulingSettings; using EMIS.ViewModel.CalendarManage; using EMIS.DataLogic.Repositories; namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings { public class CourseScheduleSettingServices : BaseServices, ICourseScheduleSettingServices { public CourseScheduleSettingDAL courseScheduleSettingDAL { get; set; } public IArrangementServices arrangementServices { get; set; } /// /// 查询课程排课时间设置 /// /// /// /// /// /// /// public Bowin.Common.Linq.Entity.IGridResultSet GetCourseScheduleSettingViewGrid(Guid? coursematerialID, int? courseLevelID, int? courseScienceID, int pageIndex, int pageSize) { Expression> exp = (x => true); if (coursematerialID.HasValue) exp = exp.And(x => x.CoursematerialID == coursematerialID); if (courseLevelID.HasValue) exp = exp.And(x => x.CourseLevelID == courseLevelID); if (courseScienceID.HasValue) exp = exp.And(x => x.CourseScienceID == courseScienceID); var query = courseScheduleSettingDAL.GetCourseScheduleSettingViewQueryable(exp); return query.OrderByDescending(x => x.CreateTime).ToGridResultSet(pageIndex, pageSize); } /// /// 查询 /// /// /// public Bowin.Common.Linq.Entity.IGridResultSet GetArrangementViewGrid(Guid? coursematerialID) { var resultSet = courseScheduleSettingDAL.GetArrangementViewQueryable(coursematerialID).OrderBy(x => x.StartTimes).ToGridResultSet(); if (resultSet.total > 0) { return resultSet; } return arrangementServices.GetArrangementViewGrid(); } /// /// 新增 /// /// public void CourseScheduleSettingAdd(List listArrangement, Guid? coursematerialID) { try { UnitOfWork.Delete(x => x.CoursematerialID == coursematerialID); foreach (var arrangementView in listArrangement) { bool? IsOnWork = false; for (int i = 0; i < 7; i++) { if (i == (int)DayOfWeek.Monday) IsOnWork = arrangementView.MondayIsOnWork; if (i == (int)DayOfWeek.Tuesday) IsOnWork = arrangementView.TuesdayIsOnWork; if (i == (int)DayOfWeek.Wednesday) IsOnWork = arrangementView.WednesdayIsOnWork; if (i == (int)DayOfWeek.Thursday) IsOnWork = arrangementView.ThursdayIsOnWork; if (i == (int)DayOfWeek.Friday) IsOnWork = arrangementView.FridayIsOnWork; if (i == (int)DayOfWeek.Saturday) IsOnWork = arrangementView.SaturdayIsOnWork; if (i == (int)DayOfWeek.Sunday) IsOnWork = arrangementView.SundayIsOnWork; ES_CourseScheduleSetting courseScheduleSetting = new ES_CourseScheduleSetting(); courseScheduleSetting.CourseScheduleSettingID = Guid.NewGuid(); courseScheduleSetting.CoursematerialID = coursematerialID; courseScheduleSetting.CoursesTimeID = arrangementView.CoursesTimeID; courseScheduleSetting.Weekday = i; courseScheduleSetting.IsOnWork = IsOnWork; SetNewStatus(courseScheduleSetting); UnitOfWork.Add(courseScheduleSetting); } } UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 删除 /// /// public void CourseScheduleSettingDelete(List coursematerialIDs) { try { UnitOfWork.Delete(x => coursematerialIDs.Contains(x.CoursematerialID)); } catch (Exception) { throw; } } } }