using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using System.Transactions; using Bowin.Common.Linq; using Bowin.Common.Data; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.EvaluationManage.StudentEvaluation; using EMIS.ViewModel.EducationManage.EducationArrange; using EMIS.DataLogic.EvaluationManage.StudentEvaluation; using EMIS.DataLogic.EvaluationManage.EvaluationTable; using EMIS.CommonLogic.StudentManage.StudentStatistics; namespace EMIS.CommonLogic.EvaluationManage.StudentEvaluation { public class EvaluationStudentSettingServices : BaseServices, IEvaluationStudentSettingServices { public EvaluationStudentSettingDAL EvaluationStudentSettingDAL { get; set; } public EvaluationTableDAL EvaluationTableDAL { get; set; } public Lazy InSchoolSettingServices { get; set; } /// /// 查询对应的学评设定信息View /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetEvaluationStudentSettingViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID, Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? evaluationTableID, int? openState, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (staffID.HasValue) { exp = exp.And(x => x.UserID == staffID); } if (teachingMethodID.HasValue) { exp = exp.And(x => x.TeachingMethodID == teachingMethodID); } if (evaluationTableID.HasValue) { exp = exp.And(x => x.EvaluationTableID == evaluationTableID); } if (openState.HasValue) { if (openState.Value == (int)CF_GeneralPurpose.IsYes) { exp = exp.And(x => x.OpenState == true); } if (openState.Value == (int)CF_GeneralPurpose.IsNo) { exp = exp.And(x => x.OpenState != true); } } var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(exp); if (schoolyearID.HasValue) { query = query.Where(x => x.SchoolyearID == schoolyearID); } if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (departmentID.HasValue) { query = query.Where(x => x.DepartmentID == departmentID); } if (coursematerialID.HasValue) { query = query.Where(x => x.CoursematerialID == coursematerialID); } if (courseTypeID.HasValue) { query = query.Where(x => x.CourseTypeID == courseTypeID); } if (handleModeID.HasValue) { query = query.Where(x => x.HandleModeID == handleModeID); } if (teachingModeID.HasValue) { query = query.Where(x => x.TeachingModeID == teachingModeID); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length) .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的学评设定信息List /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetEvaluationStudentSettingViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID, Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? evaluationTableID, int? openState) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (staffID.HasValue) { exp = exp.And(x => x.UserID == staffID); } if (teachingMethodID.HasValue) { exp = exp.And(x => x.TeachingMethodID == teachingMethodID); } if (evaluationTableID.HasValue) { exp = exp.And(x => x.EvaluationTableID == evaluationTableID); } if (openState.HasValue) { if (openState.Value == (int)CF_GeneralPurpose.IsYes) { exp = exp.And(x => x.OpenState == true); } if (openState.Value == (int)CF_GeneralPurpose.IsNo) { exp = exp.And(x => x.OpenState != true); } } var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(exp); if (schoolyearID.HasValue) { query = query.Where(x => x.SchoolyearID == schoolyearID); } if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (departmentID.HasValue) { query = query.Where(x => x.DepartmentID == departmentID); } if (coursematerialID.HasValue) { query = query.Where(x => x.CoursematerialID == coursematerialID); } if (courseTypeID.HasValue) { query = query.Where(x => x.CourseTypeID == courseTypeID); } if (handleModeID.HasValue) { query = query.Where(x => x.HandleModeID == handleModeID); } if (teachingModeID.HasValue) { query = query.Where(x => x.TeachingModeID == teachingModeID); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length) .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToList(); } /// /// 查询对应的学评设定信息EvaluationStudentSettingView /// /// /// public EvaluationStudentSettingView GetEvaluationStudentSettingView(Guid? evaluationStudentSettingID) { try { Expression> exp = (x => x.EvaluationStudentSettingID == evaluationStudentSettingID); var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(exp).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 评价生成 /// /// /// /// /// /// /// /// /// /// /// /// /// /// public string EvaluationStudentSettingCreate(Guid? campusID, Guid? collegeID, Guid? departmentID, int? gradeID, int? standardID, Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? schoolyearID) { try { var schoolyear = EvaluationStudentSettingDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == schoolyearID).SingleOrDefault(); if (schoolyear == null) { throw new Exception("选择的学年学期有误,请核查。"); } var evaluationParticipateType = EvaluationStudentSettingDAL.EvaluationParticipateTypeRepository.GetList(x => x.ParticipateTypeID == (int)EM_ParticipateType.Student).SingleOrDefault(); if (evaluationParticipateType == null) { throw new Exception("对应的参评类型不存在,请核查。"); } Expression> expEvaluationTable = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEvaluationTable = expEvaluationTable.And(x => x.IsEnabled == true); expEvaluationTable = expEvaluationTable.And(x => x.EvaluationParticipateTypeID == evaluationParticipateType.EvaluationParticipateTypeID); var evaluationTableViewList = EvaluationTableDAL.GetEvaluationTableViewQueryable(expEvaluationTable).ToList(); Expression> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEducationMissionClass = expEducationMissionClass.And(x => x.RecordStatus == (int)EM_EducationMissionClassStatus.Submitted || x.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled); Expression> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); bool classmajorHasValue = false; if (gradeID.HasValue) { expClassmajor = expClassmajor.And(x => x.CF_Grademajor.GradeID == gradeID); classmajorHasValue = true; } if (standardID.HasValue) { expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID); classmajorHasValue = true; } if (classmajorHasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CF_Classmajor.AsQueryable().Any(expClassmajor)); } if (coursematerialID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID); } if (courseTypeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CourseTypeID == courseTypeID); } if (handleModeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.HandleModeID == handleModeID); } if (teachingModeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.TeachingModeID == teachingModeID); } var query = EvaluationStudentSettingDAL.GetEducationMissionClassViewQueryable(expEducationMissionClass); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (departmentID.HasValue) { query = query.Where(x => x.DepartmentID == departmentID); } if (staffID.HasValue) { query = query.Where(x => x.UserID == staffID); } if (teachingMethodID.HasValue) { query = query.Where(x => x.TeachingMethodID == teachingMethodID); } if (schoolyearID.HasValue) { query = query.Where(x => x.SchoolyearID == schoolyearID); } var educationMissionClassViewList = this.GetQueryByDataRangeByDepartment(query).ToList(); if (educationMissionClassViewList == null || educationMissionClassViewList.Count() <= 0) { throw new Exception("对应的教学任务班评价信息为空,请核查(如:任务状态为未提交)。"); } var educationMissionClassIDList = educationMissionClassViewList.Select(x => x.EducationMissionClassID).Distinct().ToList(); var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => educationMissionClassIDList.Contains(x.EducationMissionClassID.Value)).ToList(); int inSuccess = 0; int upSuccess = 0; int fail = 0; string tipMessage = null; var evaluationStudentSettingInList = new List(); var evaluationStudentSettingUpList = new List(); foreach (var educationMissionClassView in educationMissionClassViewList) { var evaluationTableList = evaluationTableViewList.Where(x => x.TeachingModeIDList.Contains(educationMissionClassView.TeachingModeID)).ToList(); if (evaluationTableList == null || evaluationTableList.Count() <= 0) { fail++; } else if (evaluationTableList != null && evaluationTableList.Count() > 1) { fail++; } else { var evaluationTable = evaluationTableList.Where(x => true).SingleOrDefault(); var educlStudentList = EvaluationStudentSettingDAL.GetEducationMissionClassStudentQueryable(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID).ToList(); var evaluationStudentSettingVerify = evaluationStudentSettingList.Where(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID && x.UserID == educationMissionClassView.UserID).SingleOrDefault(); if (evaluationStudentSettingVerify == null) { var newEvaluationStudentSetting = new EM_EvaluationStudentSetting(); newEvaluationStudentSetting.EvaluationStudentSettingID = Guid.NewGuid(); newEvaluationStudentSetting.EducationMissionClassID = educationMissionClassView.EducationMissionClassID; newEvaluationStudentSetting.EvaluationTableID = evaluationTable.EvaluationTableID; newEvaluationStudentSetting.UserID = educationMissionClassView.UserID; newEvaluationStudentSetting.TeachingMethodID = educationMissionClassView.TeachingMethodID; newEvaluationStudentSetting.OpenState = false; newEvaluationStudentSetting.Remark = educationMissionClassView.Remark; SetNewStatus(newEvaluationStudentSetting); evaluationStudentSettingInList.Add(newEvaluationStudentSetting); educlStudentList.ForEach(x => newEvaluationStudentSetting.CF_Student.Add(x)); inSuccess++; } else { if (evaluationStudentSettingVerify.OpenState != true) { evaluationStudentSettingVerify.EvaluationTableID = evaluationTable.EvaluationTableID; } evaluationStudentSettingVerify.TeachingMethodID = educationMissionClassView.TeachingMethodID; SetModifyStatus(evaluationStudentSettingVerify); evaluationStudentSettingUpList.Add(evaluationStudentSettingVerify); var evaluationStudentList = EvaluationStudentSettingDAL.GetEvaluationStudentSettingStudentQueryable(x => x.EvaluationStudentSettingID == evaluationStudentSettingVerify.EvaluationStudentSettingID).ToList(); foreach (var educlStudent in educlStudentList) { var student = evaluationStudentList.Where(x => x.UserID == educlStudent.UserID).SingleOrDefault(); if (student == null) { evaluationStudentSettingVerify.CF_Student.Add(educlStudent); } } upSuccess++; } } } using (TransactionScope ts = new TransactionScope()) { UnitOfWork.BulkInsert(evaluationStudentSettingInList); UnitOfWork.BulkInsert(evaluationStudentSettingInList, (x => x.CF_Student)); if (evaluationStudentSettingUpList != null && evaluationStudentSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(evaluationStudentSettingUpList); } UnitOfWork.BulkInsert(evaluationStudentSettingUpList, (x => x.CF_Student)); ts.Complete(); } if (upSuccess <= 0 && fail <= 0) { tipMessage = inSuccess + "条"; } else { if (upSuccess > 0 && fail <= 0) { tipMessage = inSuccess + "条,更新成功" + upSuccess + "条"; } else { tipMessage = inSuccess + "条,更新成功" + upSuccess + "条,失败" + fail + "条,原因:对应的评价表无法匹配,请检查"; } } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 编辑 /// /// public void EvaluationStudentSettingEdit(EvaluationStudentSettingView evaluationStudentSettingView) { try { if (!evaluationStudentSettingView.EducationMissionClassID.HasValue || evaluationStudentSettingView.EducationMissionClassID == Guid.Empty) { throw new Exception("对应的教学任务数据有误,请核查。"); } var evaluationStudentSettingVerify = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => x.EvaluationStudentSettingID != evaluationStudentSettingView.EvaluationStudentSettingID && x.EducationMissionClassID == evaluationStudentSettingView.EducationMissionClassID && x.UserID == evaluationStudentSettingView.UserID).SingleOrDefault(); if (evaluationStudentSettingVerify == null) { var evaluationStudentSettingInList = new List(); var evaluationStudentSettingUpList = new List(); var educlStudentList = EvaluationStudentSettingDAL.GetEducationMissionClassStudentQueryable(x => x.EducationMissionClassID == evaluationStudentSettingView.EducationMissionClassID).ToList(); if (evaluationStudentSettingView.EvaluationStudentSettingID != Guid.Empty) { var evaluationStudentSetting = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => x.EvaluationStudentSettingID == evaluationStudentSettingView.EvaluationStudentSettingID).SingleOrDefault(); if (evaluationStudentSetting == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 evaluationStudentSetting.EvaluationTableID = evaluationStudentSettingView.EvaluationTableID; evaluationStudentSetting.UserID = evaluationStudentSettingView.UserID; evaluationStudentSetting.TeachingMethodID = evaluationStudentSettingView.TeachingMethodID; evaluationStudentSetting.Remark = evaluationStudentSettingView.Remark; SetModifyStatus(evaluationStudentSetting); evaluationStudentSettingUpList.Add(evaluationStudentSetting); var evaluationStudentList = EvaluationStudentSettingDAL.GetEvaluationStudentSettingStudentQueryable(x => x.EvaluationStudentSettingID == evaluationStudentSetting.EvaluationStudentSettingID).ToList(); foreach (var educlStudent in educlStudentList) { var student = evaluationStudentList.Where(x => x.UserID == educlStudent.UserID).SingleOrDefault(); if (student == null) { evaluationStudentSetting.CF_Student.Add(educlStudent); } } } } else { //表示新增 var newEvaluationStudentSetting = new EM_EvaluationStudentSetting(); newEvaluationStudentSetting.EvaluationStudentSettingID = Guid.NewGuid(); newEvaluationStudentSetting.EducationMissionClassID = evaluationStudentSettingView.EducationMissionClassID; newEvaluationStudentSetting.EvaluationTableID = evaluationStudentSettingView.EvaluationTableID; newEvaluationStudentSetting.UserID = evaluationStudentSettingView.UserID; newEvaluationStudentSetting.TeachingMethodID = evaluationStudentSettingView.TeachingMethodID; newEvaluationStudentSetting.OpenState = false; newEvaluationStudentSetting.Remark = evaluationStudentSettingView.Remark; SetNewStatus(newEvaluationStudentSetting); evaluationStudentSettingInList.Add(newEvaluationStudentSetting); educlStudentList.ForEach(x => newEvaluationStudentSetting.CF_Student.Add(x)); } using (TransactionScope ts = new TransactionScope()) { UnitOfWork.BulkInsert(evaluationStudentSettingInList); UnitOfWork.BulkInsert(evaluationStudentSettingInList, (x => x.CF_Student)); if (evaluationStudentSettingUpList != null && evaluationStudentSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(evaluationStudentSettingUpList); } UnitOfWork.BulkInsert(evaluationStudentSettingUpList, (x => x.CF_Student)); ts.Complete(); } } else { throw new Exception("已存在相同的学生评价信息(教学任务班、任课教师唯一),请核查。"); } } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 批量新增 /// /// /// /// public string EvaluationStudentSettingBatchAdd(List educationMissionClassViewList, EvaluationStudentSettingView evaluationStudentSettingView) { try { var schoolyear = EvaluationStudentSettingDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == evaluationStudentSettingView.SchoolyearID).SingleOrDefault(); if (schoolyear == null) { throw new Exception("选择的学年学期有误,请核查。"); } var evaluationParticipateType = EvaluationStudentSettingDAL.EvaluationParticipateTypeRepository.GetList(x => x.ParticipateTypeID == (int)EM_ParticipateType.Student).SingleOrDefault(); if (evaluationParticipateType == null) { throw new Exception("对应的参评类型不存在,请核查。"); } Expression> expEvaluationTable = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEvaluationTable = expEvaluationTable.And(x => x.IsEnabled == true); expEvaluationTable = expEvaluationTable.And(x => x.EvaluationParticipateTypeID == evaluationParticipateType.EvaluationParticipateTypeID); var evaluationTableViewList = EvaluationTableDAL.GetEvaluationTableViewQueryable(expEvaluationTable).ToList(); var educationMissionClassIDList = educationMissionClassViewList.Select(x => x.EducationMissionClassID).Distinct().ToList(); var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => educationMissionClassIDList.Contains(x.EducationMissionClassID.Value)).ToList(); int success = 0; int fail = 0; string tipMessage = null; var evaluationStudentSettingInList = new List(); foreach (var educationMissionClassView in educationMissionClassViewList) { var evaluationTableList = evaluationTableViewList.Where(x => x.TeachingModeIDList.Contains(educationMissionClassView.TeachingModeID)).ToList(); if (evaluationTableList == null || evaluationTableList.Count() <= 0) { fail++; } else if (evaluationTableList != null && evaluationTableList.Count() > 1) { fail++; } else { var evaluationTable = evaluationTableList.Where(x => true).SingleOrDefault(); var educlStudentList = EvaluationStudentSettingDAL.GetEducationMissionClassStudentQueryable(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID).ToList(); var evaluationStudentSettingVerify = evaluationStudentSettingList.Where(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID && x.UserID == educationMissionClassView.UserID).SingleOrDefault(); if (evaluationStudentSettingVerify == null) { var newEvaluationStudentSetting = new EM_EvaluationStudentSetting(); newEvaluationStudentSetting.EvaluationStudentSettingID = Guid.NewGuid(); newEvaluationStudentSetting.EducationMissionClassID = educationMissionClassView.EducationMissionClassID; newEvaluationStudentSetting.EvaluationTableID = evaluationTable.EvaluationTableID; newEvaluationStudentSetting.UserID = educationMissionClassView.UserID; newEvaluationStudentSetting.TeachingMethodID = educationMissionClassView.TeachingMethodID; newEvaluationStudentSetting.OpenState = false; newEvaluationStudentSetting.Remark = educationMissionClassView.Remark; SetNewStatus(newEvaluationStudentSetting); evaluationStudentSettingInList.Add(newEvaluationStudentSetting); educlStudentList.ForEach(x => newEvaluationStudentSetting.CF_Student.Add(x)); success++; } else { fail++; } } } using (TransactionScope ts = new TransactionScope()) { UnitOfWork.BulkInsert(evaluationStudentSettingInList); UnitOfWork.BulkInsert(evaluationStudentSettingInList, (x => x.CF_Student)); ts.Complete(); } if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条,失败" + fail + "条,原因:对应的评价表无法匹配或已存在相同的学生评价信息(教学任务班、任课教师唯一),请核查"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询教学任务班中未新增学生评价信息View /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetEducationMissionClassViewNoAddGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? departmentID, int? gradeID, int? standardID, Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? schoolyearID, int pageIndex, int pageSize) { Expression> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEducationMission = expEducationMission.And(x => x.SchoolyearID == schoolyearID); if (collegeID.HasValue) { expEducationMission = expEducationMission.And(x => x.CollegeID == collegeID); } if (departmentID.HasValue) { expEducationMission = expEducationMission.And(x => x.DepartmentID == departmentID); } Expression> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEducationMissionClass = expEducationMissionClass.And(x => x.RecordStatus == (int)EM_EducationMissionClassStatus.Submitted || x.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled); Expression> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); bool classmajorHasValue = false; if (gradeID.HasValue) { expClassmajor = expClassmajor.And(x => x.CF_Grademajor.GradeID == gradeID); classmajorHasValue = true; } if (standardID.HasValue) { expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID); classmajorHasValue = true; } if (classmajorHasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CF_Classmajor.AsQueryable().Any(expClassmajor)); } if (coursematerialID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID); } if (courseTypeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CourseTypeID == courseTypeID); } if (handleModeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.HandleModeID == handleModeID); } if (teachingModeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.TeachingModeID == teachingModeID); } var query = EvaluationStudentSettingDAL.GetEducationMissionClassViewNoAddQueryable(expEducationMission, expEducationMissionClass); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (staffID.HasValue) { query = query.Where(x => x.UserID == staffID); } if (teachingMethodID.HasValue) { query = query.Where(x => x.TeachingMethodID == teachingMethodID); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length) .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToGridResultSet(pageIndex, pageSize); } /// /// 查询教学任务班中未新增学生评价信息List /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetEducationMissionClassViewNoAddList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? departmentID, int? gradeID, int? standardID, Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? schoolyearID) { Expression> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEducationMission = expEducationMission.And(x => x.SchoolyearID == schoolyearID); if (collegeID.HasValue) { expEducationMission = expEducationMission.And(x => x.CollegeID == collegeID); } if (departmentID.HasValue) { expEducationMission = expEducationMission.And(x => x.DepartmentID == departmentID); } Expression> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEducationMissionClass = expEducationMissionClass.And(x => x.RecordStatus == (int)EM_EducationMissionClassStatus.Submitted || x.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled); Expression> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); bool classmajorHasValue = false; if (gradeID.HasValue) { expClassmajor = expClassmajor.And(x => x.CF_Grademajor.GradeID == gradeID); classmajorHasValue = true; } if (standardID.HasValue) { expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID); classmajorHasValue = true; } if (classmajorHasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CF_Classmajor.AsQueryable().Any(expClassmajor)); } if (coursematerialID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID); } if (courseTypeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CourseTypeID == courseTypeID); } if (handleModeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.HandleModeID == handleModeID); } if (teachingModeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.TeachingModeID == teachingModeID); } var query = EvaluationStudentSettingDAL.GetEducationMissionClassViewNoAddQueryable(expEducationMission, expEducationMissionClass); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (staffID.HasValue) { query = query.Where(x => x.UserID == staffID); } if (teachingMethodID.HasValue) { query = query.Where(x => x.TeachingMethodID == teachingMethodID); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length) .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToList(); } /// /// 删除 /// /// /// public bool EvaluationStudentSettingDelete(List evaluationStudentSettingIDs) { try { var evaluationStudentList = EvaluationStudentSettingDAL.EvaluationStudentRepository.GetList(x => evaluationStudentSettingIDs.Contains(x.EvaluationStudentSettingID)).ToList(); if (evaluationStudentList == null || evaluationStudentList.Count() <= 0) { var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => evaluationStudentSettingIDs.Contains(x.EvaluationStudentSettingID), (x => x.CF_Student)).ToList(); using (TransactionScope ts = new TransactionScope()) { foreach (var evaluationStudentSetting in evaluationStudentSettingList) { //evaluationStudentSetting.CF_Student = new HashSet(); UnitOfWork.Delete(evaluationStudentSetting, (x => x.CF_Student)); UnitOfWork.Delete(x => x.EvaluationStudentSettingID == evaluationStudentSetting.EvaluationStudentSettingID); //evaluationStudentSetting.CF_Student.RemoveWhere(x => true); //UnitOfWork.RemoveRange(evaluationStudentSetting.CF_Student); //UnitOfWork.Remove(evaluationStudentSetting); } //this.UnitOfWork.Commit(); ts.Complete(); return true; } } else { throw new Exception("选择删除的信息中,存在已评价信息无法删除。"); } } catch (Exception) { throw; } } /// /// 查询学生评价中对应的学生名单信息View /// /// /// /// /// /// /// /// public IGridResultSet GetEvaluationStudentSettingDetailViewGrid(ConfiguretView configuretView, Guid? evaluationStudentSettingID, int? isEvaluation, int? inSchoolStatus, int pageIndex, int pageSize) { Expression> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.EvaluationStudentSettingID == evaluationStudentSettingID); Expression> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (inSchoolStatus != null && inSchoolStatus > -1) { var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); if (inSchoolStatus == 1) { expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingDetailViewQueryable(expEvaluationStudentSetting, expEducationMissionClass, expEducationMission, expStudent); if (isEvaluation.HasValue) { if (isEvaluation.Value == (int)CF_GeneralPurpose.IsYes) { query = query.Where(x => x.IsEvaluation == true); } if (isEvaluation.Value == (int)CF_GeneralPurpose.IsNo) { query = query.Where(x => x.IsEvaluation != true); } } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.StudentNo).ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ToGridResultSet(pageIndex, pageSize); } /// /// 查询学生评价中对应的学生名单信息List /// /// /// /// /// /// public IList GetEvaluationStudentSettingDetailViewList(ConfiguretView configuretView, Guid? evaluationStudentSettingID, int? isEvaluation, int? inSchoolStatus) { Expression> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.EvaluationStudentSettingID == evaluationStudentSettingID); Expression> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (inSchoolStatus != null && inSchoolStatus > -1) { var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); if (inSchoolStatus == 1) { expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingDetailViewQueryable(expEvaluationStudentSetting, expEducationMissionClass, expEducationMission, expStudent); if (isEvaluation.HasValue) { if (isEvaluation.Value == (int)CF_GeneralPurpose.IsYes) { query = query.Where(x => x.IsEvaluation == true); } if (isEvaluation.Value == (int)CF_GeneralPurpose.IsNo) { query = query.Where(x => x.IsEvaluation != true); } } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.StudentNo).ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ToList(); } /// /// 编辑学生 /// /// /// public void EvaluationStudentEdit(Guid? evaluationStudentSettingID, Guid? userID) { try { var evaluationStudentSetting = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => x.EvaluationStudentSettingID == evaluationStudentSettingID, (x => x.CF_Student)).SingleOrDefault(); if (evaluationStudentSetting == null) { throw new Exception("数据有误,请核查。"); } else { var evaluationStudentVerify = evaluationStudentSetting.CF_Student.Where(x => x.UserID == userID).SingleOrDefault(); var student = EvaluationStudentSettingDAL.StudentRepository.GetList(x => x.UserID == userID).SingleOrDefault(); if (evaluationStudentVerify == null) { evaluationStudentSetting.CF_Student.Add(student); } else { throw new Exception("已存在相同的学生名单信息,请核查。"); } } UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除学生 /// /// /// /// public bool EvaluationStudentDelete(Guid? evaluationStudentSettingID, List userIDs) { try { var evaluationStudentSetting = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => x.EvaluationStudentSettingID == evaluationStudentSettingID, (x => x.CF_Student), (x => x.EM_EvaluationStudent)).SingleOrDefault(); using (TransactionScope ts = new TransactionScope()) { var evaluationStudentList = evaluationStudentSetting.EM_EvaluationStudent.Where(x => userIDs.Contains(x.UserID)).ToList(); if (evaluationStudentList == null || evaluationStudentList.Count() <= 0) { evaluationStudentSetting.CF_Student.RemoveWhere(x => userIDs.Contains(x.UserID)); } else { throw new Exception("选择删除的学生中,存在已评价信息无法删除。"); } UnitOfWork.Commit(); ts.Complete(); return true; } } catch (Exception) { throw; } } /// /// 取消 /// /// /// public bool EvaluationStudentSettingCancel(List evaluationStudentSettingIDList) { try { var evaluationStudentSettingUpList = new List(); var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID)).ToList(); foreach (var evaluationStudentSetting in evaluationStudentSettingList) { evaluationStudentSetting.OpenState = false; this.SetModifyStatus(evaluationStudentSetting); evaluationStudentSettingUpList.Add(evaluationStudentSetting); } if (evaluationStudentSettingUpList != null && evaluationStudentSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(evaluationStudentSettingUpList); } return true; } catch (Exception) { throw; } } /// /// 开放 /// /// /// public bool EvaluationStudentSettingOpen(List evaluationStudentSettingIDList) { try { var evaluationStudentSettingUpList = new List(); var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID)).ToList(); foreach (var evaluationStudentSetting in evaluationStudentSettingList) { evaluationStudentSetting.OpenState = true; this.SetModifyStatus(evaluationStudentSetting); evaluationStudentSettingUpList.Add(evaluationStudentSetting); } if (evaluationStudentSettingUpList != null && evaluationStudentSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(evaluationStudentSettingUpList); } return true; } catch (Exception) { throw; } } } }