123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.UniversityManage.ClassroomManage;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.UniversityManage.ClassroomManage;
- using EMIS.DataLogic.ExaminationManage;
- using EMIS.ViewModel.ExaminationApply;
- using EMIS.CommonLogic.EducationSchedule;
- namespace EMIS.CommonLogic.ExaminationManage
- {
- public class RoomSettingServices : BaseServices, IRoomSettingServices
- {
- public ClassroomDAL ClassroomDAL { get; set; }
- public RoomSettingDAL RoomSettingDAL { get; set; }
- public ExaminationPlanDAL ExaminationPlanDAL { get; set; }
- public Lazy<IScheduleServices> ScheduleServices { get; set; }
- public Lazy<IClassroomExcessiveUseServices> ClassroomExcessiveUseServices { get; set; }
- public IGridResultSet<ClassroomView> GetClassroomViewList(ViewModel.ConfiguretView roomSettingView, Guid? campusID, Guid? buildingsInfoID,
- bool? isAvailable, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Classroom, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EX_ExaminationRoomSetting.Count() > 0);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_BuildingsInfo.CampusID == campusID);
- }
- if (buildingsInfoID.HasValue)
- {
- exp = exp.And(x => x.BuildingsInfoID == buildingsInfoID);
- }
- if (isAvailable.HasValue)
- {
- exp = exp.And(x => x.IsAvailable == isAvailable);
- }
- var q = ClassroomDAL.GetClassroomViewQueryable(exp);
- if (!string.IsNullOrEmpty(roomSettingView.ConditionValue) && !string.IsNullOrEmpty(roomSettingView.Attribute))
- q = q.DynamicWhere(roomSettingView.Attribute, roomSettingView.Condition, roomSettingView.ConditionValue);
- return GetQueryByDataRangeByCampus(q).OrderByDescending(x => x.IsAvailable).ThenByDescending(x => x.BuildingsInfoName)
- .ThenByDescending(x => x.Name)
- .ToGridResultSet<ClassroomView>(pageIndex, pageSize);
- }
- public Bowin.Common.Linq.Entity.IGridResultSet<ExaminationClassroomView> GetAvailableClassroomViewList(ViewModel.ConfiguretView roomSettingView,
- Guid examinationPlanID, Guid? examinationRoomLayoutID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Classroom, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var examinationPlan = ExaminationPlanDAL.ExaminationPlanRepository.GetSingle(x => x.ExaminationPlanID == examinationPlanID);
- var scheduleDateTimeList = new List<StartEndTimeView> {
- new StartEndTimeView { StartTime = examinationPlan.ExaminationDate.Value.Add(examinationPlan.StartTime.Value)
- , EndTime = examinationPlan.ExaminationDate.Value.Add(examinationPlan.EndTime.Value) }
- };
- var schedulingList = this.ScheduleServices.Value.GetEducationSchedulingWeekNumViewByDateTimeList(examinationPlan.SchoolyearID.Value,
- scheduleDateTimeList);
- var scheduledClassroomIDList = schedulingList.Select(x => x.ClassroomID).Distinct().ToList();
- exp = exp.And(x => !scheduledClassroomIDList.Contains(x.ClassroomID));
- var q = RoomSettingDAL.GetAvailableClassroomView((x => x.ExaminationPlanID == examinationPlanID),
- (x => x.ExaminationRoomLayoutID == examinationRoomLayoutID), exp);
- if (!string.IsNullOrEmpty(roomSettingView.ConditionValue) && !string.IsNullOrEmpty(roomSettingView.Attribute))
- q = q.DynamicWhere(roomSettingView.Attribute, roomSettingView.Condition, roomSettingView.ConditionValue);
- q = q.Where(x => x.IsAvailable == true);
- return GetQueryByDataRangeByCampus(q).OrderByDescending(x => x.IsAvailable)
- .ThenByDescending(x => x.BuildingsInfoName).ThenByDescending(x => x.Name)
- .ToGridResultSet(pageIndex, pageSize);
- }
- public IGridResultSet<ExaminationClassroomView> GetAddAvailableClassroomViewList(ConfiguretView roomSettingView, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Classroom, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var q = RoomSettingDAL.GetAvailableClassroomView((x => true), (x => true), exp);
- if (!string.IsNullOrEmpty(roomSettingView.ConditionValue) && !string.IsNullOrEmpty(roomSettingView.Attribute))
- q = q.DynamicWhere(roomSettingView.Attribute, roomSettingView.Condition, roomSettingView.ConditionValue);
- q = q.Where(x => x.IsAvailable == true);
- return GetQueryByDataRangeByCampus(q).OrderByDescending(x => x.IsAvailable).OrderByDescending(x => x.BuildingsInfoName).OrderByDescending(x => x.Name)
- .ToGridResultSet(pageIndex, pageSize);
- }
- public IList<ClassroomView> GetClassroomViewList(ViewModel.ConfiguretView roomSettingView, Guid? campusID, Guid? buildingsInfoID, bool? isAvailable)
- {
- Expression<Func<CF_Classroom, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EX_ExaminationRoomSetting.Count() > 0);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_BuildingsInfo.CampusID == campusID);
- }
- if (buildingsInfoID.HasValue)
- {
- exp = exp.And(x => x.BuildingsInfoID == buildingsInfoID);
- }
- if (isAvailable.HasValue)
- {
- exp = exp.And(x => x.IsAvailable == isAvailable);
- }
- var q = ClassroomDAL.GetClassroomViewQueryable(exp);
- if (!string.IsNullOrEmpty(roomSettingView.ConditionValue) && !string.IsNullOrEmpty(roomSettingView.Attribute))
- q = q.DynamicWhere(roomSettingView.Attribute, roomSettingView.Condition, roomSettingView.ConditionValue);
- return GetQueryByDataRangeByCampus(q).OrderByDescending(x => x.IsAvailable)
- .ThenByDescending(x => x.BuildingsInfoName)
- .ThenByDescending(x => x.Name)
- .ToList();
- }
- public void Add(IList<Guid?> classroomIDList)
- {
- foreach (var classroomID in classroomIDList)
- {
- var roomSettingEntity = RoomSettingDAL.ExaminationRoomSettingRepository.GetSingle(x => x.ClassroomID == classroomID);
- if (roomSettingEntity == null)
- {
- roomSettingEntity = new EX_ExaminationRoomSetting();
- roomSettingEntity.ExaminationRoomSettingID = Guid.NewGuid();
- roomSettingEntity.ClassroomID = classroomID;
- this.SetNewStatus(roomSettingEntity);
- UnitOfWork.Add(roomSettingEntity);
- }
- }
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> classroomIDList)
- {
- if (classroomIDList.Count > 0)
- {
- UnitOfWork.Delete<EX_ExaminationRoomSetting>(x => classroomIDList.Contains(x.ClassroomID));
- }
- }
- public IGridResultSet<ExaminationClassroomView> GetAvailableClassroomViewGdssList(ConfiguretView roomSettingView, Guid examinationPlanID,
- Guid? buildingsInfoID, DateTime examinationDate, TimeSpan startTime, TimeSpan endTime, int studentCount, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationPlan, bool>> otherExaminationPlanExp = (x => x.ExaminationPlanID != examinationPlanID
- && x.ExaminationDate == examinationDate && x.EndTime >= startTime && x.StartTime <= endTime);
- Expression<Func<CF_Classroom, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var examinationPlan = ExaminationPlanDAL.ExaminationPlanRepository.GetSingle(x => x.ExaminationPlanID == examinationPlanID);
- var scheduleDateTimeList = new List<StartEndTimeView> {
- new StartEndTimeView { StartTime = examinationDate.Add(startTime)
- , EndTime = examinationDate.Add(endTime) }
- };
- var schedulingList = this.ScheduleServices.Value.GetEducationSchedulingWeekNumViewByDateTimeList(examinationPlan.SchoolyearID.Value,
- scheduleDateTimeList);
- var excessiveUseList = this.ClassroomExcessiveUseServices.Value.GetClassroomExcessiveUseWeekNumViewByDateTimeList(
- examinationPlan.SchoolyearID.Value,
- scheduleDateTimeList);
- var scheduledClassroomIDList = schedulingList.Select(x => x.ClassroomID)
- .Concat(excessiveUseList.Select(x => x.ClassroomID)).Distinct().ToList();
- exp = exp.And(x => !scheduledClassroomIDList.Contains(x.ClassroomID));
- if (buildingsInfoID.HasValue)
- {
- exp = exp.And(x => x.BuildingsInfoID == buildingsInfoID);
- }
- var q = RoomSettingDAL.GetAvailableClassroomViewGdss(otherExaminationPlanExp, exp, studentCount);
- if (!string.IsNullOrEmpty(roomSettingView.ConditionValue) && !string.IsNullOrEmpty(roomSettingView.Attribute))
- q = q.DynamicWhere(roomSettingView.Attribute, roomSettingView.Condition, roomSettingView.ConditionValue);
- q = q.Where(x => x.IsAvailable == true);
- return GetQueryByDataRangeByCampus(q).OrderByDescending(x => x.IsAvailable)
- .ThenByDescending(x => x.BuildingsInfoName).ThenByDescending(x => x.Name)
- .ToGridResultSet(pageIndex, pageSize);
- }
- }
- }
|