123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
- using EMIS.Entities;
- using System.Linq.Expressions;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.CalendarManage;
- using EMIS.ViewModel;
- namespace EMIS.DataLogic.SchedulingManage.SchedulingSettings
- {
- public class CourseScheduleSettingDAL
- {
- public CoursematerialRepository coursematerialRepository { get; set; }
- public DictionaryItemRepository dictionaryItemRepository { get; set; }
- public CoursesTimeRepository coursesTimeRepository { get; set; }
- public CourseScheduleSettingRepository courseScheduleSettingRepository { get; set; }
- /// <summary>
- /// 查询课程可排时间设置
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<CourseScheduleSettingView> GetCourseScheduleSettingViewQueryable(Expression<Func<EM_Coursematerial, bool>> exp)
- {
- var query = from a in coursematerialRepository.GetList(exp)
- join b in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_CourseLevel).Name)
- on a.CourseLevelID equals b.Value
- into gcl
- from gCourseLevel in gcl.DefaultIfEmpty()
- join c in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_CourseScience).Name)
- on a.CourseScienceID equals c.Value
- into gcs
- from gCourseScience in gcs.DefaultIfEmpty()
- select new CourseScheduleSettingView
- {
- CoursematerialID = a.CoursematerialID,
- CourseCode = a.CourseCode,
- CourseName = a.CourseName,
- CourseScienceName = gCourseScience.Name,
- CourseLevelName = gCourseLevel.Name,
- IsEnableName = a.IsEnable == false ? "否" : "是",
- CreateUserID = a.CreateUserID,
- CreateTime = a.CreateTime
- };
- return query;
- }
- /// <summary>
- /// 获取教师可排时间设置
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public IQueryable<ArrangementView> GetArrangementViewQueryable(Guid? coursematerialID)
- {
- var query = from a in coursesTimeRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
- join b in
- courseScheduleSettingRepository.GetList(x => x.CoursematerialID == coursematerialID)
- on a.CoursesTimeID equals b.CoursesTimeID
- group a by new
- {
- CoursesTimeID = a.CoursesTimeID,
- StartTimes = a.StartTimes,
- EndTimes = a.EndTimes,
- TimesSegment = a.TimesSegment,
- StartHour = a.StartHour,
- StartMinutes = a.StartMinutes,
- EndHour = a.EndHour,
- EndMinutes = a.EndMinutes,
- CreateTime = a.CreateTime,
- CreateUserID = a.CreateUserID,
- MondayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Monday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
- TuesdayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Tuesday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
- WednesdayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Wednesday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
- ThursdayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Thursday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
- FridayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Friday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
- SaturdayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Saturday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork,
- SundayIsOnWork = a.ES_CourseScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Sunday && x.CoursematerialID == b.CoursematerialID).FirstOrDefault().IsOnWork
- } into g
- select new ArrangementView
- {
- CoursesTimeID = g.Key.CoursesTimeID,
- StartTimes = g.Key.StartTimes,
- EndTimes = g.Key.EndTimes,
- TimesSegment = g.Key.TimesSegment,
- StartHour = g.Key.StartHour,
- StartMinutes = g.Key.StartMinutes,
- EndHour = g.Key.EndHour,
- EndMinutes = g.Key.EndMinutes,
- CreateTime = g.Key.CreateTime,
- CreateUserID = g.Key.CreateUserID,
- MondayIsOnWork = g.Key.MondayIsOnWork,
- TuesdayIsOnWork = g.Key.TuesdayIsOnWork,
- WednesdayIsOnWork = g.Key.WednesdayIsOnWork,
- ThursdayIsOnWork = g.Key.ThursdayIsOnWork,
- FridayIsOnWork = g.Key.FridayIsOnWork,
- SaturdayIsOnWork = g.Key.SaturdayIsOnWork,
- SundayIsOnWork = g.Key.SundayIsOnWork,
- };
- return query;
- }
- }
- }
|