using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel.SchedulingManage.SchedulingSettings; using EMIS.ViewModel.UniversityManage.ClassroomManage; using EMIS.DataLogic.Repositories; namespace EMIS.DataLogic.SchedulingManage.SchedulingSettings { public class ClassroomReserveDAL { public ClassroomReserveRepository ClassroomReserveRepository { get; set; } public ClassroomRepository ClassroomRepository { get; set; } public CollegeClassroomRepository CollegeClassroomRepository { get; set; } public UserRepository UserRepository { get; set; } public DictionaryItemRepository DictionaryItemRepository { get; set; } /// /// 查询教室预留信息ClassroomReserveView(根据教室预留信息、统计排课分配院系个数) /// /// /// public IQueryable GetClassroomReserveViewQueryable(Expression> exp) { var query = from re in ClassroomReserveRepository.GetList(exp) join cr in ClassroomRepository.Entities on re.ClassroomID equals cr.ClassroomID join cc in ( from cc in CollegeClassroomRepository.Entities group cc by cc.ClassroomID into gcr select new { ClassroomID = gcr.Key, ScheduleCollegeCount = gcr.Count() } ) on re.ClassroomID equals cc.ClassroomID into tempcc from colcr in tempcc.DefaultIfEmpty() join cus in UserRepository.Entities on re.CreateUserID equals cus.UserID into tempcus from recus in tempcus.DefaultIfEmpty() select new ClassroomReserveView { ClassroomReserveID = re.ClassroomReserveID, ClassroomID = cr.ClassroomID, ClassroomCode = cr.Code, ClassroomName = cr.Name, BuildingsInfoID = cr.BuildingsInfoID, BuildingsInfoCode = cr.CF_BuildingsInfo.Code, BuildingsInfoName = cr.CF_BuildingsInfo.Name, CampusID = cr.CF_BuildingsInfo.CampusID, CampusNo = cr.CF_BuildingsInfo.CF_Campus.No, CampusName = cr.CF_BuildingsInfo.CF_Campus.Name, CollegeID = cr.CollegeID, CollegeCode = cr.CF_College.No, CollegeName = cr.CF_College.Name, UnitCategoryID = cr.CF_College.CF_CollegeProfile.UnitCategoryID, CollegeCampusID = cr.CF_College.CampusID, CollegeCampusCode = cr.CF_College.CF_Campus.No, CollegeCampusName = cr.CF_College.CF_Campus.Name, CF_ClassroomType = cr.CF_ClassroomType, ClassroomTypeIDList = cr.CF_ClassroomType.Select(x => x.ClassroomType).ToList(), RoomUseID = cr.RoomUseID, Totalseating = cr.Totalseating, Effectiveseating = cr.Effectiveseating, IsConcurrentUse = cr.IsConcurrentUse ?? false, IsReserve = re.IsReserved == true ? true : false, IsAvailable = cr.IsAvailable ?? false, ScheduleCollegeCount = colcr.ScheduleCollegeCount == null ? 0 : colcr.ScheduleCollegeCount, RecordStatus = re.RecordStatus, CreateUserID = re.CreateUserID, CreateUserName = recus.Name, CreateTime = re.CreateTime, ModifyUserID = re.ModifyUserID, ModifyTime = re.ModifyTime }; return query; } /// /// 查询未预留的教室信息ClassroomView /// /// /// public IQueryable GetClassroomViewNoReserveQueryable(Expression> exp) { var query = from cr in ClassroomRepository.GetList(exp) join re in ClassroomReserveRepository.Entities on cr.ClassroomID equals re.ClassroomID into tempre from crre in tempre.DefaultIfEmpty() where crre.ClassroomReserveID == null select new ClassroomView { ClassroomID = cr.ClassroomID, Code = cr.Code, Name = cr.Name, BuildingsInfoID = cr.BuildingsInfoID, BuildingsInfoCode = cr.CF_BuildingsInfo.Code, BuildingsInfoName = cr.CF_BuildingsInfo.Name, CampusID = cr.CF_BuildingsInfo.CampusID, CampusCode = cr.CF_BuildingsInfo.CF_Campus.No, CampusName = cr.CF_BuildingsInfo.CF_Campus.Name, CollegeID = cr.CollegeID, CollegeCode = cr.CF_College.No, CollegeName = cr.CF_College.Name, UnitCategoryID = cr.CF_College.CF_CollegeProfile.UnitCategoryID, CollegeCampusID = cr.CF_College.CampusID, CollegeCampusCode = cr.CF_College.CF_Campus.No, CollegeCampusName = cr.CF_College.CF_Campus.Name, CF_ClassroomType = cr.CF_ClassroomType, ClassroomTypeIDList = cr.CF_ClassroomType.Select(x => x.ClassroomType).ToList(), LayoutTypeID = cr.LayoutTypeID, RoomUseID = cr.RoomUseID, FloorLevel = cr.FloorLevel, Acreage = cr.Acreage, RowCout = cr.RowCout, ColumnCount = cr.ColumnCount, Totalseating = cr.Totalseating, Effectiveseating = cr.Effectiveseating, Examinationseating = cr.Examinationseating, IsWrittenExam = cr.IsWrittenExam ?? false, IsMachinetest = cr.IsMachinetest ?? false, IsConcurrentUse = cr.IsConcurrentUse ?? false, IsAvailable = cr.IsAvailable ?? false, Remark = cr.Remark, RecordStatus = cr.RecordStatus, CreateUserID = cr.CreateUserID, CreateTime = cr.CreateTime, ModifyUserID = cr.ModifyUserID, ModifyTime = cr.ModifyTime }; return query; } /// /// 查询教室类型信息ClassroomTypeView /// /// public IQueryable GetClassroomTypeViewQueryable() { var query = from cr in ClassroomRepository.Entities from crct in cr.CF_ClassroomType join dicct in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_ClassroomType).Name) on crct.ClassroomType equals dicct.Value select new ClassroomTypeView { ClassroomTypeID = crct.ClassroomTypeID, ClassroomID = cr.ClassroomID, ClassroomType = crct.ClassroomType, ClassroomTypeName = dicct.Name }; return query; } /// /// 查询教室类型信息ClassroomTypeView(根据教室信息) /// /// /// public IQueryable GetClassroomTypeViewQueryable(Expression> exp) { var query = from cr in ClassroomRepository.GetList(exp) from crct in cr.CF_ClassroomType join dicct in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_ClassroomType).Name) on crct.ClassroomType equals dicct.Value select new ClassroomTypeView { ClassroomTypeID = crct.ClassroomTypeID, ClassroomID = cr.ClassroomID, ClassroomType = crct.ClassroomType, ClassroomTypeName = dicct.Name }; return query; } } }