using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.EducationManage; using EMIS.DataLogic.Repositories; using EMIS.DataLogic.SelectCourse.SelectCourseResult; using EMIS.DataLogic.SelectCourse; using EMIS.DataLogic.UniversityManage.SpecialtyClassManage; using System.Linq.Expressions; using EMIS.Entities; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.SelectCourse.SelectCourseResult; using Bowin.Common.Linq; namespace EMIS.CommonLogic.SelectCourse.SelectCourseResult { public class SelectCourseListServices : BaseServices, ISelectCourseListServices { public EducationMissionClassDAL educationMissionClassDAL { get; set; } public MissionClassTeacherRepository missionClassTeacherRepository { get; set; } public SelectCourseResultDAL SelectCourseResultDAL { get; set; } public SelectCourseListDAL SelectCourseListDAL { get; set; } public OptionalCourseSettingDAL optionalCourseSettingDAL { get; set; } public ClassmajorDAL classmajorDAL { get; set; } public ExecutablePlanDAL ExecutablePlanDAL { get; set; } public OptionalCourseSettingDAL OptionalCourseSettingDAL { get; set; } public OpenControlSettingDAL OpenControlSettingDAL { get; set; } public ExecutableFreeSelectionCouseDAL ExecutableFreeSelectionCouseDAL { get; set; } public IStudentSelectCourseServices IStudentSelectCourseServices { get; set; } public IGridResultSet GetSelectCourseViewList (ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID, Guid? courseID, int? courseTypeID, int? selectCourseTypeID, int? isCreated, int? isOpened, int pageIndex, int pageSize) { Expression> eocExp = (x => true); Expression> efcExp = (x => true); var query = SelectCourseListDAL.GetSelectCourseListViewQueryable(eocExp, efcExp); //var query1 = SelectCourseResultDAL.GetSelectCourseResultTeacher(eocExp, efcExp); //var query2 = SelectCourseResultDAL.GetSelectCourseResultTeachingMode(eocExp, efcExp); if (schoolYearID.HasValue) { query = query.Where(x => x.SchoolyearID == schoolYearID); //query1 = query1.Where(x => x.SchoolyearID == schoolYearID); efcExp.And(x => x.SchoolyearID == schoolYearID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); efcExp.And(x => x.CF_Department.CollegeID == collegeID); } if (courseID.HasValue) { query = query.Where(x => x.CoursematerialID == courseID); efcExp.And(x => x.EM_FreeSelectionCouse.CoursematerialID == courseID); } if (courseTypeID.HasValue) { query = query.Where(x => x.CourseTypeID == courseTypeID); //query1 = query1.Where(x => x.CourseTypeID == courseTypeID); efcExp.And(x => x.CourseTypeID == courseTypeID); } if (selectCourseTypeID.HasValue) { query = query.Where(x => x.SelectCourseType == selectCourseTypeID); //query1 = query1.Where(x => x.SelectCourseType == selectCourseTypeID); } if (isCreated.HasValue) { query = query.Where(x => x.RecordStatus == isCreated); efcExp.And(x => x.RecordStatus == isCreated); //if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes) // query = query.Where(x => x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created); //else if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsNo) // query = query.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created); } if (isOpened.HasValue) { query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false)); //query1 = query1.Where(x => x.IsOpened == (isOpened == 1 ? true : false)); } //未提交状态不显示 query = query.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen); //query1 = query1.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen); //query2 = query2.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen); //任选具体上课时间 //var queryScheduling = SelectCourseListDAL.GetScheduling(efcExp).ToList(); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SelectCourseType).ToGridResultSet(pageIndex, pageSize); //var teacher = query1.ToList().OrderBy(x => x.SelectCourseType); //var teachingMode = query2.ToList().OrderBy(x => x.SelectCourseType); //result.rows.ForEach(x => x.TeacherName = string.Join(",", teacher.Where(w => w.ID == x.ID).Select(w => w.TeacherName))); //if (queryScheduling.Count > 0) //{ // var schedulingList = IStudentSelectCourseServices.GetWeekdayTimesSegmentName(queryScheduling); // result.rows.ForEach(x => // { // var list = schedulingList.Where(w => w.ID == x.ID); // x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName)); // }); //} return result; } public List GetSelectCourseList (ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID, Guid? courseID, int? courseTypeID, int? selectCourseTypeID, int? isCreated, int? isOpened) { Expression> eocExp = (x => true); Expression> efcExp = (x => true); var query = SelectCourseListDAL.GetSelectCourseListViewQueryable(eocExp, efcExp); //var query1 = SelectCourseResultDAL.GetSelectCourseResultTeacher(eocExp, efcExp); if (schoolYearID.HasValue) { query = query.Where(x => x.SchoolyearID == schoolYearID); //query1 = query1.Where(x => x.SchoolyearID == schoolYearID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (courseID.HasValue) { query = query.Where(x => x.CoursematerialID == courseID); } if (courseTypeID.HasValue) { query = query.Where(x => x.CourseTypeID == courseTypeID); //query1 = query1.Where(x => x.CourseTypeID == courseTypeID); } if (selectCourseTypeID.HasValue) { query = query.Where(x => x.SelectCourseType == selectCourseTypeID); //query1 = query1.Where(x => x.SelectCourseType == selectCourseTypeID); } if (isCreated.HasValue) { query = query.Where(x => x.RecordStatus == isCreated); //if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes) // query = query.Where(x => x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created); //else if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsNo) // query = query.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created); } if (isOpened.HasValue) { query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false)); //query1 = query1.Where(x => x.IsOpened == (isOpened == 1 ? true : false)); } //未提交状态不显示 query = query.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen); //query1 = query1.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); //var teacher = query1.ToList().OrderBy(x => x.SelectCourseType); var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SelectCourseType).ToList(); //result.ForEach(x => x.TeacherName = string.Join(",", teacher.Where(w => w.ID == x.ID).Select(w => w.TeacherName))); return result; } public bool SelectCourseListDelete(List IDs, List Types, List UserIDs) { try { if (IDs.Count > 0) { for (int i = 0; i < IDs.Count; i++) { if (Types[i] == 0) { //限选 var id = IDs[i].Value; var UserID = UserIDs[i].Value; EM_ExecutableOptionalCourse ExecutableOptionalCourse = SelectCourseResultDAL.ExecutableOptionalCourseRepository.GetList(x => x.ExecutableOptionalCourseID == id, x => x.CF_Student).FirstOrDefault(); ExecutableOptionalCourse.CF_Student.RemoveWhere(x => x.UserID == UserID); } else if (Types[i] == 1) { //任选 var id = IDs[i].Value; var UserID = UserIDs[i].Value; EM_ExecutableFreeSelectionCouse ExecutableFreeSelectionCouse = SelectCourseResultDAL.ExecutableFreeSelectionCouseRepository.GetList(x => x.ExecutableFreeSelectionCouseID == id, x => x.CF_Student).FirstOrDefault(); ExecutableFreeSelectionCouse.CF_Student.RemoveWhere(x => x.UserID == UserID); } } this.UnitOfWork.Commit(); return true; } else throw new Exception("请选择要删除的学生信息"); } catch (Exception ex) { throw new Exception(ex.Message); } } } }