using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.Entities; using System.Linq.Expressions; using Bowin.Common.Linq.Entity; using Bowin.Common.Linq; using EMIS.DataLogic.SchedulingManage.SchedulingSettings; using EMIS.ViewModel.SchedulingManage.SchedulingSettings; using EMIS.ViewModel.CalendarManage; using EMIS.CommonLogic.CalendarManage; namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings { public class TeacherScheduleSettingServices : BaseServices, ITeacherScheduleSettingServices { public TeacherScheduleSettingDAL teacherScheduleSettingDAL { get; set; } public IArrangementServices arrangementServices { get; set; } /// /// 查询 /// /// /// /// /// /// /// /// /// public Bowin.Common.Linq.Entity.IGridResultSet GetTeacherScheduleSettingViewGrid(Guid? userID, int? teacherTypeID, int? incumbencyStateID, int? titleID, Guid? collegeID, int pageIndex, int pageSize) { Expression> exp = (x => true); if (userID.HasValue) exp = exp.And(x => x.UserID == userID); if (teacherTypeID.HasValue) exp = exp.And(x => x.TeacherTypeID == teacherTypeID); if (incumbencyStateID.HasValue) exp = exp.And(x => x.IncumbencyState == incumbencyStateID); if (titleID.HasValue) exp = exp.And(x => x.TitleID == titleID); if (collegeID.HasValue) exp = exp.And(x => x.CollegeID == collegeID); var query = teacherScheduleSettingDAL.GetTeacherScheduleSettingViewQueryable(exp); return query.OrderByDescending(x => x.CreateTime).ToGridResultSet(pageIndex, pageSize); } /// /// 查询 /// /// /// public Bowin.Common.Linq.Entity.IGridResultSet GetArrangementViewGrid(Guid? userID) { var resultSet = teacherScheduleSettingDAL.GetArrangementViewQueryable(userID).OrderBy(x => x.StartTimes).ToGridResultSet(); if (resultSet.total > 0) { return resultSet; } return arrangementServices.GetArrangementViewGrid(); } /// /// 新增 /// /// public void TeacherScheduleSettingAdd(List listArrangement, Guid? userID) { try { UnitOfWork.Delete(x => x.UserID == userID); 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_TeacherScheduleSetting teacherScheduleSettin = new ES_TeacherScheduleSetting(); teacherScheduleSettin.TeacherScheduleSettingID = Guid.NewGuid(); teacherScheduleSettin.UserID = userID; teacherScheduleSettin.CoursesTimeID = arrangementView.CoursesTimeID; teacherScheduleSettin.Weekday = i; teacherScheduleSettin.IsOnWork = IsOnWork; SetNewStatus(teacherScheduleSettin); UnitOfWork.Add(teacherScheduleSettin); } } UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 删除 /// /// public void TeacherScheduleSettingDelete(List userIDs) { try { UnitOfWork.Delete(x => userIDs.Contains(x.UserID)); } catch (Exception) { throw; } } } }