123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- 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.CommonLogic.CalendarManage;
- using EMIS.ViewModel.CalendarManage;
- using EMIS.ViewModel.UniversityManage.ClassroomManage;
- namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings
- {
- public class ClassroomScheduleSettingServices : BaseServices, IClassroomScheduleSettingServices
- {
- public ClassroomScheduleSettingDAL classroomScheduleSettingDAL { get; set; }
- public IArrangementServices arrangementServices { get; set; }
- public ClassroomReserveDAL classroomReserveDAL { get; set; }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="classroomID"></param>
- /// <param name="collegeID"></param>
- /// <param name="titleID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.SchedulingManage.SchedulingSettings.ClassroomScheduleSettingView> GetClassroomScheduleSettingViewGrid(Guid? classroomID, Guid? collegeID, int? classroomTypeID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Classroom, bool>> exp = (x => true);
- if (classroomID.HasValue)
- exp = exp.And(x => x.ClassroomID == classroomID);
- if (collegeID.HasValue)
- exp = exp.And(x => x.CollegeID == collegeID);
- if (classroomTypeID.HasValue)
- exp = exp.And(x => x.CF_ClassroomType.Select(y => y.ClassroomType).Contains(classroomTypeID));
- var query = classroomScheduleSettingDAL.GetClassroomScheduleSettingViewQueryable(exp);
- var resultSet = query.OrderByDescending(x => x.CreateTime).ToGridResultSet<ClassroomScheduleSettingView>(pageIndex, pageSize);
- var classroomIDList = resultSet.rows.Select(x => x.ClassroomID).ToList();
- var queryClassroomTyoeView = classroomReserveDAL.GetClassroomTypeViewQueryable().Where(x => classroomIDList.Contains(x.ClassroomID)).ToList();
- resultSet.rows.ForEach(x => x.ClassroomTypes = new HashSet<ClassroomTypeView>(queryClassroomTyoeView.Where(y => y.ClassroomID == x.ClassroomID)));
- return resultSet;
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.CalendarManage.ArrangementView> GetArrangementViewGrid(Guid? classroomID)
- {
- var resultSet = classroomScheduleSettingDAL.GetArrangementViewQueryable(classroomID).OrderBy(x => x.StartTimes).ToGridResultSet<ArrangementView>();
- if (resultSet.total > 0)
- {
- return resultSet;
- }
- return arrangementServices.GetArrangementViewGrid();
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <param name="listArrangement"></param>
- public void ClassroomScheduleSettingAdd(List<ViewModel.CalendarManage.ArrangementView> listArrangement, Guid? classroomID)
- {
- try
- {
- UnitOfWork.Delete<ES_ClassroomScheduleSetting>(x => x.ClassroomID == classroomID);
- 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_ClassroomScheduleSetting classroomScheduleSetting = new ES_ClassroomScheduleSetting();
- classroomScheduleSetting.ClassroomScheduleSettingID = Guid.NewGuid();
- classroomScheduleSetting.ClassroomID = classroomID;
- classroomScheduleSetting.CoursesTimeID = arrangementView.CoursesTimeID;
- classroomScheduleSetting.Weekday = i;
- classroomScheduleSetting.IsOnWork = IsOnWork;
- SetNewStatus(classroomScheduleSetting);
- UnitOfWork.Add(classroomScheduleSetting);
- }
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="userIDs"></param>
- public void ClassroomScheduleSettingDelete(List<Guid?> classroomIDs)
- {
- try
- {
- UnitOfWork.Delete<ES_ClassroomScheduleSetting>(x => classroomIDs.Contains(x.ClassroomID));
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|