using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.UniversityManage.ClassroomManage; using EMIS.DataLogic.Repositories; namespace EMIS.DataLogic.UniversityManage.ClassroomManage { public class ClassroomDAL { public ClassroomRepository ClassroomRepository { get; set; } public ClassroomTypeRepository ClassroomTypeRepository { get; set; } public BuildingsInfoRepository BuildingsInfoRepository { get; set; } public CollegeRepository CollegeRepository { get; set; } public ClassroomReserveRepository ClassroomReserveRepository { get; set; } public CollegeClassroomRepository CollegeClassroomRepository { get; set; } public DictionaryItemRepository DictionaryItemRepository { get; set; } public ClassroomTypeRepository classroomTypeRepository { get; set; } /// /// 查询教室信息View(关联排课中教室预留信息、统计排课分配的院系个数) /// /// /// public IQueryable GetClassroomViewQueryable(Expression> expClassroom) { var query = from cr in ClassroomRepository.GetList(expClassroom) join re in ClassroomReserveRepository.Entities on cr.ClassroomID equals re.ClassroomID into tempre from crre in tempre.DefaultIfEmpty() join cc in ( from cc in CollegeClassroomRepository.Entities group cc by cc.ClassroomID into gcr select new { ClassroomID = gcr.Key, ScheduleCollegeCount = gcr.Count() } ) on cr.ClassroomID equals cc.ClassroomID into tempcc from colcr in tempcc.DefaultIfEmpty() 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, IsReserve = crre.IsReserved == true ? true : false, IsAvailable = cr.IsAvailable ?? false, ScheduleCollegeCount = colcr.ScheduleCollegeCount == null ? 0 : colcr.ScheduleCollegeCount, Remark = cr.Remark, RecordStatus = cr.RecordStatus, CreateUserID = cr.CreateUserID, CreateTime = cr.CreateTime, ModifyUserID = cr.ModifyUserID, ModifyTime = cr.ModifyTime }; return query; } /// /// 查询教室信息对应的排课分配院系所信息(根据教室信息) /// /// /// public IQueryable GetClassroomCollegeViewQueryable(Expression> expClassroom) { var query = from cr in ClassroomRepository.GetList(expClassroom) join re in ClassroomReserveRepository.Entities on cr.ClassroomID equals re.ClassroomID into tempre from crre in tempre.DefaultIfEmpty() join colcr in CollegeClassroomRepository.Entities on cr.ClassroomID equals colcr.ClassroomID join col in CollegeRepository.Entities on colcr.CollegeID equals col.CollegeID 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 = colcr.CollegeID, CollegeCode = col.No, CollegeName = col.Name, UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID, CollegeCampusID = col.CampusID, CollegeCampusCode = col.CF_Campus.No, CollegeCampusName = col.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, IsReserve = crre.IsReserved == true ? true : 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; } /// /// 查询对应的教室类型信息(根据教室信息ID) /// /// /// public List GetClassroomModeTypeQueryble(Guid? classroomID) { var query = from a in ClassroomTypeRepository.Entities.Where(x => x.ClassroomID == classroomID) join b in DictionaryItemRepository.Entities on new { ClassroomType = a.ClassroomType, DictionaryCode = DictionaryItem.CF_ClassroomType.ToString() } equals new { ClassroomType = b.Value, DictionaryCode = b.DictionaryCode } select b.Value.Value; return query.ToList(); } } }