123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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; }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="userID"></param>
- /// <param name="teacherTypeID"></param>
- /// <param name="incumbencyStateID"></param>
- /// <param name="titleID"></param>
- /// <param name="collegeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.SchedulingManage.SchedulingSettings.TeacherScheduleSettingView> GetTeacherScheduleSettingViewGrid(Guid? userID, int? teacherTypeID, int? incumbencyStateID, int? titleID, Guid? collegeID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> 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<TeacherScheduleSettingView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.CalendarManage.ArrangementView> GetArrangementViewGrid(Guid? userID)
- {
- var resultSet = teacherScheduleSettingDAL.GetArrangementViewQueryable(userID).OrderBy(x => x.StartTimes).ToGridResultSet<ArrangementView>();
- if (resultSet.total > 0)
- {
- return resultSet;
- }
- return arrangementServices.GetArrangementViewGrid();
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <param name="listArrangement"></param>
- public void TeacherScheduleSettingAdd(List<ArrangementView> listArrangement, Guid? userID)
- {
- try
- {
- UnitOfWork.Delete<ES_TeacherScheduleSetting>(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;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="userIDs"></param>
- public void TeacherScheduleSettingDelete(List<Guid?> userIDs)
- {
- try
- {
- UnitOfWork.Delete<ES_TeacherScheduleSetting>(x => userIDs.Contains(x.UserID));
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- }
- }
|