123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- 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.TeacherManage;
- using EMIS.DataLogic.ExaminationManage;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.UniversityManage.TeacherManage;
- using EMIS.CommonLogic.EducationSchedule;
- namespace EMIS.CommonLogic.ExaminationManage
- {
- public class ExaminationTeacherServices : BaseServices, IExaminationTeacherServices
- {
- public StaffDAL StaffDAL { get; set; }
- public ExaminationTeacherDAL ExaminationTeacherDAL { get; set; }
- public ExaminationPlanDAL ExaminationPlanDAL { get; set; }
- public Lazy<IScheduleServices> ScheduleServices { get; set; }
- public IGridResultSet<StaffView> GetStaffViewList(ConfiguretView teacherView,
- Guid? campusID, Guid? collegeID, Guid? departmentID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EX_ExaminationTeacher.Count() > 0);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.DepartmentID == departmentID);
- }
- var q = StaffDAL.GetStaffViewQueryable(exp);
- if (!string.IsNullOrEmpty(teacherView.ConditionValue) && !string.IsNullOrEmpty(teacherView.Attribute))
- q = q.DynamicWhere(teacherView.Attribute, teacherView.Condition, teacherView.ConditionValue);
- return GetQueryByDataRangeByCollege(q).OrderByDescending(x => x.CollegeName).ThenByDescending(x => x.IncumbencyState).ThenByDescending(x => x.Name)
- .ToGridResultSet<StaffView>(pageIndex, pageSize);
- }
- public IList<StaffView> GetStaffViewList(ConfiguretView teacherView, Guid? campusID, Guid? collegeID, Guid? departmentID)
- {
- Expression<Func<CF_Staff, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EX_ExaminationTeacher.Count() > 0);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.DepartmentID == departmentID);
- }
- var q = StaffDAL.GetStaffViewQueryable(exp);
- if (!string.IsNullOrEmpty(teacherView.ConditionValue) && !string.IsNullOrEmpty(teacherView.Attribute))
- q = q.DynamicWhere(teacherView.Attribute, teacherView.Condition, teacherView.ConditionValue);
- return GetQueryByDataRangeByCollege(q).OrderByDescending(x => x.CollegeName).ThenByDescending(x => x.IncumbencyState).ThenByDescending(x => x.Name)
- .ToList();
- }
- public void Add(IList<Guid?> userIDList)
- {
- foreach (var userID in userIDList)
- {
- var examinationTeacherEntity = ExaminationTeacherDAL.ExaminationTeacherRepository.GetSingle(x => x.UserID == userID);
- if (examinationTeacherEntity == null)
- {
- examinationTeacherEntity = new EX_ExaminationTeacher();
- examinationTeacherEntity.ExaminationTeacherID = Guid.NewGuid();
- examinationTeacherEntity.UserID = userID;
- this.SetNewStatus(examinationTeacherEntity);
- UnitOfWork.Add(examinationTeacherEntity);
- }
- }
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> userIDList)
- {
- if (userIDList.Count > 0)
- {
- UnitOfWork.Delete<EX_ExaminationTeacher>(x => userIDList.Contains(x.UserID));
- }
- }
- public IGridResultSet<StaffView> GetAvailableStaffViewList(ConfiguretView teacherView, Guid examinationPlanID, Guid classroomID, Guid? campusID, Guid? collegeID,
- Guid? departmentID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EX_ExaminationTeacher.Count() > 0);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.DepartmentID == departmentID);
- }
- 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.GetEducationSchedulingWeekNumViewForExaminationTeacher(examinationPlan.SchoolyearID.Value,
- scheduleDateTimeList);
- var scheduledTeacherIDList = schedulingList.SelectMany(x => x.TeacherList).Select(x => x.UserID).Distinct().ToList();
- exp = exp.And(x => !scheduledTeacherIDList.Contains(x.UserID));
- var q = ExaminationTeacherDAL.GetAvailableStaffView((x => x.ExaminationPlanID == examinationPlanID), classroomID, exp);
- if (!string.IsNullOrEmpty(teacherView.ConditionValue) && !string.IsNullOrEmpty(teacherView.Attribute))
- q = q.DynamicWhere(teacherView.Attribute, teacherView.Condition, teacherView.ConditionValue);
- return GetQueryByDataRangeByCollege(q).OrderByDescending(x => x.CollegeName).ThenByDescending(x => x.IncumbencyState).ThenByDescending(x => x.Name)
- .ToGridResultSet<StaffView>(pageIndex, pageSize);
- }
- public IGridResultSet<StaffView> GetAddAvailableStaffViewList(ConfiguretView teacherView, Guid classroomID, Guid? campusID, Guid? collegeID,
- Guid? departmentID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EX_ExaminationTeacher.Count() > 0);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.DepartmentID == departmentID);
- }
- var q = ExaminationTeacherDAL.GetAvailableStaffView((x => true), classroomID, exp);
- if (!string.IsNullOrEmpty(teacherView.ConditionValue) && !string.IsNullOrEmpty(teacherView.Attribute))
- q = q.DynamicWhere(teacherView.Attribute, teacherView.Condition, teacherView.ConditionValue);
- return GetQueryByDataRangeByCollege(q).OrderByDescending(x => x.CollegeName).ThenByDescending(x => x.IncumbencyState).ThenByDescending(x => x.Name)
- .ToGridResultSet<StaffView>(pageIndex, pageSize);
- }
- public IGridResultSet<StaffView> GetAvailableStaffViewGdssList(ConfiguretView teacherView, Guid schoolyearID, DateTime examinationDate,
- TimeSpan startTime, TimeSpan endTime, Guid classroomID, Guid? campusID, Guid? collegeID, Guid? departmentID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.EX_ExaminationTeacher.Count() > 0);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.DepartmentID == departmentID);
- }
- var scheduleDateTimeList = new List<StartEndTimeView> {
- new StartEndTimeView { StartTime = examinationDate.Add(startTime)
- , EndTime = examinationDate.Add(endTime) }
- };
- var schedulingList = this.ScheduleServices.Value.GetEducationSchedulingWeekNumViewForExaminationTeacher(schoolyearID,
- scheduleDateTimeList);
- var scheduledTeacherIDList = schedulingList.SelectMany(x => x.TeacherList).Select(x => x.UserID).Distinct().ToList();
- exp = exp.And(x => !scheduledTeacherIDList.Contains(x.UserID));
- var q = ExaminationTeacherDAL.GetAvailableStaffViewGdss((x => x.SchoolyearID == schoolyearID && x.ExaminationDate == examinationDate
- && x.StartTime <= endTime && x.EndTime >= startTime), classroomID, exp);
- if (!string.IsNullOrEmpty(teacherView.ConditionValue) && !string.IsNullOrEmpty(teacherView.Attribute))
- q = q.DynamicWhere(teacherView.Attribute, teacherView.Condition, teacherView.ConditionValue);
- return GetQueryByDataRangeByCollege(q).OrderByDescending(x => x.CollegeName).ThenByDescending(x => x.IncumbencyState).ThenByDescending(x => x.Name)
- .ToGridResultSet<StaffView>(pageIndex, pageSize);
- }
- }
- }
|