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.DataLogic.EvaluationManage.StudentEvaluation; using EMIS.CommonLogic.EvaluationManage.EvaluationManage; using EMIS.CommonLogic.SystemServices; namespace EMIS.CommonLogic.EvaluationManage.StudentEvaluation { public class EvaluationStudentSettingScoreServices : BaseServices, IEvaluationStudentSettingScoreServices { public EvaluationStudentSettingScoreDAL EvaluationStudentSettingScoreDAL { get; set; } public EvaluationStudentSettingDAL EvaluationStudentSettingDAL { get; set; } public Lazy EvaluationStudentScoreServices { get; set; } public Lazy ParameterServices { get; set; } /// /// 查询对应的学评评分信息View /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetEvaluationStudentSettingScoreViewGrid(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> expEvaluationStudentSettingScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (staffID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == staffID); } if (teachingMethodID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.TeachingMethodID == teachingMethodID); } if (evaluationTableID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.EvaluationTableID == evaluationTableID); } if (openState.HasValue) { if (openState.Value == (int)CF_GeneralPurpose.IsYes) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.OpenState == true); } if (openState.Value == (int)CF_GeneralPurpose.IsNo) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.OpenState != true); } } var query = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(expEvaluationStudentSettingScore, expEvaluationStudentSetting); 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 GetEvaluationStudentSettingScoreViewList(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> expEvaluationStudentSettingScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (staffID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == staffID); } if (teachingMethodID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.TeachingMethodID == teachingMethodID); } if (evaluationTableID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.EvaluationTableID == evaluationTableID); } if (openState.HasValue) { if (openState.Value == (int)CF_GeneralPurpose.IsYes) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.OpenState == true); } if (openState.Value == (int)CF_GeneralPurpose.IsNo) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.OpenState != true); } } var query = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(expEvaluationStudentSettingScore, expEvaluationStudentSetting); 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(); } /// /// 查询对应的学评评分信息EvaluationStudentSettingScoreView /// /// /// public EvaluationStudentSettingScoreView GetEvaluationStudentSettingScoreView(Guid? evaluationStudentSettingScoreID) { try { Expression> exp = (x => x.EvaluationStudentSettingScoreID == evaluationStudentSettingScoreID); var query = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(exp).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 评分生成 /// /// /// /// /// /// /// /// /// /// /// /// /// /// public string EvaluationStudentSettingScoreCreate(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 = EvaluationStudentSettingScoreDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == schoolyearID).SingleOrDefault(); if (schoolyear == null) { throw new Exception("选择的学年学期有误,请核查。"); } var setParticipateCountScope = ParameterServices.Value.GetParameterValue(CF_ParameterType.ParticipateCountScope); if (setParticipateCountScope == null) { throw new Exception("未设置参评人数范围,请设置。"); } var participateCountScope = Convert.ToInt32(setParticipateCountScope); decimal? evStudentSettingScore = 0; Expression> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (staffID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == staffID); } if (teachingMethodID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.TeachingMethodID == teachingMethodID); } Expression> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); 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); } Expression> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) { expEducationMission = expEducationMission.And(x => x.CollegeID == collegeID); } if (departmentID.HasValue) { expEducationMission = expEducationMission.And(x => x.DepartmentID == departmentID); } if (schoolyearID.HasValue) { expEducationMission = expEducationMission.And(x => x.SchoolyearID == schoolyearID); } var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(expEvaluationStudentSetting, expEducationMissionClass, expEducationMission); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } var evaluationStudentSettingViewList = this.GetQueryByDataRangeByDepartment(query).ToList(); var evaluationStudentSettingIDList = evaluationStudentSettingViewList.Select(x => x.EvaluationStudentSettingID).ToList(); Expression> expEvaluationStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEvaluationStudent = expEvaluationStudent.And(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID.Value)); expEvaluationStudent = expEvaluationStudent.And(x => x.IsValidity == true); var evaluationStudentList = EvaluationStudentSettingScoreDAL.EvaluationStudentRepository.GetList(expEvaluationStudent).ToList(); var evaluationStudentSettingScoreList = EvaluationStudentSettingScoreDAL.EvaluationStudentSettingScoreRepository.GetList(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID.Value)).ToList(); int inSuccess = 0; int upSuccess = 0; string tipMessage = null; var evaluationStudentSettingScoreInList = new List(); var evaluationStudentSettingScoreUpList = new List(); foreach (var evaluationStudentSettingView in evaluationStudentSettingViewList) { var evaluationStudentVerifyList = evaluationStudentList.Where(x => x.EvaluationStudentSettingID == evaluationStudentSettingView.EvaluationStudentSettingID).OrderBy(x => x.TotalScore ?? 0).ToList(); if (evaluationStudentVerifyList == null || evaluationStudentVerifyList.Count() <= 0) { evStudentSettingScore = 0; } else { if (evaluationStudentVerifyList.Count() < participateCountScope) { evStudentSettingScore = evaluationStudentVerifyList.Average(x => x.TotalScore ?? 0); } else { var differenceNumber = Convert.ToInt32(Math.Round(((decimal)evaluationStudentVerifyList.Count() * (decimal)0.05), 0, MidpointRounding.AwayFromZero)); evaluationStudentVerifyList.RemoveRange(evaluationStudentVerifyList.Count() - differenceNumber, differenceNumber); evaluationStudentVerifyList.RemoveRange(0, differenceNumber); evStudentSettingScore = evaluationStudentVerifyList.Average(x => x.TotalScore ?? 0); } } var evaluationStudentSettingScoreVerify = evaluationStudentSettingScoreList.Where(x => x.EvaluationStudentSettingID == evaluationStudentSettingView.EvaluationStudentSettingID).SingleOrDefault(); if (evaluationStudentSettingScoreVerify == null) { var newEvaluationStudentSettingScore = new EM_EvaluationStudentSettingScore(); newEvaluationStudentSettingScore.EvaluationStudentSettingScoreID = Guid.NewGuid(); newEvaluationStudentSettingScore.EvaluationStudentSettingID = evaluationStudentSettingView.EvaluationStudentSettingID; newEvaluationStudentSettingScore.TotalScore = evStudentSettingScore; newEvaluationStudentSettingScore.Remark = null; SetNewStatus(newEvaluationStudentSettingScore); evaluationStudentSettingScoreInList.Add(newEvaluationStudentSettingScore); inSuccess++; } else { evaluationStudentSettingScoreVerify.TotalScore = evStudentSettingScore; SetModifyStatus(evaluationStudentSettingScoreVerify); evaluationStudentSettingScoreUpList.Add(evaluationStudentSettingScoreVerify); upSuccess++; } } using (TransactionScope ts = new TransactionScope()) { UnitOfWork.BulkInsert(evaluationStudentSettingScoreInList); if (evaluationStudentSettingScoreUpList != null && evaluationStudentSettingScoreUpList.Count() > 0) { UnitOfWork.BatchUpdate(evaluationStudentSettingScoreUpList); } ts.Complete(); } if (inSuccess > 0 && upSuccess <= 0) { tipMessage = inSuccess + "条"; } else { tipMessage = inSuccess + "条,更新成功" + upSuccess + "条"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 编辑 /// /// public void EvaluationStudentSettingScoreEdit(EvaluationStudentSettingScoreView evaluationStudentSettingScoreView) { try { if (!evaluationStudentSettingScoreView.EvaluationStudentSettingID.HasValue || evaluationStudentSettingScoreView.EvaluationStudentSettingID == Guid.Empty) { throw new Exception("对应的学评设定数据有误,请核查。"); } var evaluationStudentSettingScoreVerify = EvaluationStudentSettingScoreDAL.EvaluationStudentSettingScoreRepository.GetList(x => x.EvaluationStudentSettingScoreID != evaluationStudentSettingScoreView.EvaluationStudentSettingScoreID && x.EvaluationStudentSettingID == evaluationStudentSettingScoreView.EvaluationStudentSettingID).SingleOrDefault(); if (evaluationStudentSettingScoreVerify == null) { var setPassParticipateRate = ParameterServices.Value.GetParameterValue(CF_ParameterType.PassParticipateRate); if (setPassParticipateRate == null) { throw new Exception("未设置达标参评率,请设置。"); } var startStatusID = EvaluationStudentScoreServices.Value.GetStartStatus(); if (startStatusID == null) { throw new Exception("工作流平台中,学生评分流程开始环节未配置,请核查。"); } var passParticipateRate = Convert.ToDecimal(setPassParticipateRate); decimal? evStudentTotalScore = 0; Expression> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == evaluationStudentSettingScoreView.UserID); Expression> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEducationMission = expEducationMission.And(x => x.SchoolyearID == evaluationStudentSettingScoreView.SchoolyearID); expEducationMission = expEducationMission.And(x => x.DepartmentID == evaluationStudentSettingScoreView.DepartmentID); Expression> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == evaluationStudentSettingScoreView.CoursematerialID); var evaluationStudentSettingViewList = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(expEvaluationStudentSetting).ToList(); var evaluationStudentSettingView = evaluationStudentSettingViewList.Where(x => x.EvaluationStudentSettingID == evaluationStudentSettingScoreView.EvaluationStudentSettingID).SingleOrDefault(); if (evaluationStudentSettingView == null) { throw new Exception("对应的学评设定数据有误,请核查。"); } else { var evaluationStudentSettingScoreViewList = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(expEvaluationStudentSetting, expEducationMission, expEducationMissionClass).ToList(); if (evaluationStudentSettingScoreViewList != null && evaluationStudentSettingScoreViewList.Count() > 0) { var evaStuSettingScoreView = evaluationStudentSettingScoreViewList.Where(x => x.EvaluationStudentSettingID == evaluationStudentSettingScoreView.EvaluationStudentSettingID).SingleOrDefault(); if (evaStuSettingScoreView == null) { var passEvaStuSettingScoreViewList = evaluationStudentSettingScoreViewList.Where(x => x.ValidityParticipateRate >= passParticipateRate).ToList(); if (evaluationStudentSettingView.ValidityParticipateRate >= passParticipateRate) { evStudentTotalScore = Math.Round((decimal)((decimal?)((passEvaStuSettingScoreViewList.Sum(x => x.TotalScore) ?? 0) + (evaluationStudentSettingScoreView.TotalScore ?? 0)) * (decimal?)1.00 / (decimal?)(evaluationStudentSettingScoreViewList.Count() + 1)), 1); } else { evStudentTotalScore = Math.Round((decimal)((decimal?)(passEvaStuSettingScoreViewList.Sum(x => x.TotalScore) ?? 0) * (decimal?)1.00 / (decimal?)(evaluationStudentSettingScoreViewList.Count() + 1)), 1); } } else { var passEvaStuSettingScoreViewList = evaluationStudentSettingScoreViewList.Where(x => x.EvaluationStudentSettingID != evaluationStudentSettingScoreView.EvaluationStudentSettingID && x.ValidityParticipateRate >= passParticipateRate).ToList(); if (evaStuSettingScoreView.ValidityParticipateRate >= passParticipateRate) { evStudentTotalScore = Math.Round((decimal)((decimal?)((passEvaStuSettingScoreViewList.Sum(x => x.TotalScore) ?? 0) + (evaluationStudentSettingScoreView.TotalScore ?? 0)) * (decimal?)1.00 / (decimal?)evaluationStudentSettingScoreViewList.Count()), 1); } else { evStudentTotalScore = Math.Round((decimal)((decimal?)(passEvaStuSettingScoreViewList.Sum(x => x.TotalScore) ?? 0) * (decimal?)1.00 / (decimal?)evaluationStudentSettingScoreViewList.Count()), 1); } } } else { if (evaluationStudentSettingView.ValidityParticipateRate >= passParticipateRate) { evStudentTotalScore = evaluationStudentSettingScoreView.TotalScore; } else { evStudentTotalScore = 0; } } } var evaluationStudentScoreInList = new List(); var evaluationStudentScoreUpList = new List(); Expression> expEvaluationStudentScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expEvaluationStudentScore = expEvaluationStudentScore.And(x => x.SchoolyearID == evaluationStudentSettingScoreView.SchoolyearID); expEvaluationStudentScore = expEvaluationStudentScore.And(x => x.UserID == evaluationStudentSettingScoreView.UserID); expEvaluationStudentScore = expEvaluationStudentScore.And(x => x.CoursematerialID == evaluationStudentSettingScoreView.CoursematerialID); expEvaluationStudentScore = expEvaluationStudentScore.And(x => x.DepartmentID == evaluationStudentSettingScoreView.DepartmentID); var evaluationStudentScore = EvaluationStudentSettingScoreDAL.EvaluationStudentScoreRepository.GetList(expEvaluationStudentScore).SingleOrDefault(); if (evaluationStudentScore == null) { var newEvaluationStudentScore = new EM_EvaluationStudentScore(); newEvaluationStudentScore.EvaluationStudentScoreID = Guid.NewGuid(); newEvaluationStudentScore.SchoolyearID = evaluationStudentSettingScoreView.SchoolyearID; newEvaluationStudentScore.UserID = evaluationStudentSettingScoreView.UserID; newEvaluationStudentScore.CoursematerialID = evaluationStudentSettingScoreView.CoursematerialID; newEvaluationStudentScore.DepartmentID = evaluationStudentSettingScoreView.DepartmentID; newEvaluationStudentScore.TotalScore = evStudentTotalScore; newEvaluationStudentScore.ApprovalStatus = startStatusID; SetNewStatus(newEvaluationStudentScore); evaluationStudentScoreInList.Add(newEvaluationStudentScore); } else { if (evaluationStudentScore.ApprovalStatus == startStatusID) { evaluationStudentScore.TotalScore = evStudentTotalScore; SetModifyStatus(evaluationStudentScore); evaluationStudentScoreUpList.Add(evaluationStudentScore); } else { throw new Exception("对应的学生评分信息已在工作流程中,请核查。"); } } var evaluationStudentSettingScoreInList = new List(); var evaluationStudentSettingScoreUpList = new List(); if (evaluationStudentSettingScoreView.EvaluationStudentSettingScoreID != Guid.Empty) { var evaluationStudentSettingScore = EvaluationStudentSettingScoreDAL.EvaluationStudentSettingScoreRepository.GetList(x => x.EvaluationStudentSettingScoreID == evaluationStudentSettingScoreView.EvaluationStudentSettingScoreID).SingleOrDefault(); if (evaluationStudentSettingScore == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 evaluationStudentSettingScore.TotalScore = evaluationStudentSettingScoreView.TotalScore; evaluationStudentSettingScore.Remark = evaluationStudentSettingScoreView.Remark; SetModifyStatus(evaluationStudentSettingScore); evaluationStudentSettingScoreUpList.Add(evaluationStudentSettingScore); } } else { //表示新增 var newEvaluationStudentSettingScore = new EM_EvaluationStudentSettingScore(); newEvaluationStudentSettingScore.EvaluationStudentSettingScoreID = Guid.NewGuid(); newEvaluationStudentSettingScore.EvaluationStudentSettingID = evaluationStudentSettingScoreView.EvaluationStudentSettingID; newEvaluationStudentSettingScore.TotalScore = evaluationStudentSettingScoreView.TotalScore; newEvaluationStudentSettingScore.Remark = evaluationStudentSettingScoreView.Remark; SetNewStatus(newEvaluationStudentSettingScore); evaluationStudentSettingScoreInList.Add(newEvaluationStudentSettingScore); } using (TransactionScope ts = new TransactionScope()) { UnitOfWork.BulkInsert(evaluationStudentScoreInList); if (evaluationStudentScoreUpList != null && evaluationStudentScoreUpList.Count() > 0) { UnitOfWork.BatchUpdate(evaluationStudentScoreUpList); } UnitOfWork.BulkInsert(evaluationStudentSettingScoreInList); if (evaluationStudentSettingScoreUpList != null && evaluationStudentSettingScoreUpList.Count() > 0) { UnitOfWork.BatchUpdate(evaluationStudentSettingScoreUpList); } ts.Complete(); } } else { throw new Exception("已存在相同的学评评分信息(学评设定信息唯一),请核查。"); } } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除 /// /// /// public bool EvaluationStudentSettingScoreDelete(List evaluationStudentSettingScoreIDs) { try { Expression> expEvaluationStudentSetting = (x => evaluationStudentSettingScoreIDs.Contains(x.EvaluationStudentSettingScoreID)); var evaluationStudentSettingScoreViewList = EvaluationStudentSettingScoreDAL.GetEvaluationStudentSettingScoreViewQueryable(expEvaluationStudentSetting).ToList(); var userIDList = evaluationStudentSettingScoreViewList.Select(x => x.UserID).Distinct().ToList(); var evaluationStudentScoreList = EvaluationStudentSettingScoreDAL.EvaluationStudentScoreRepository.GetList(x => userIDList.Contains(x.UserID)).ToList(); var evaluationStudentSettingIDList = evaluationStudentSettingScoreViewList.Select(x => x.EvaluationStudentSettingID).ToList(); var evaluationStudentList = EvaluationStudentSettingScoreDAL.EvaluationStudentRepository.GetList(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID)).ToList(); var evaluationStudentIDList = evaluationStudentList.Select(x => x.EvaluationStudentID).ToList(); foreach (var evaluationStudentSettingScoreView in evaluationStudentSettingScoreViewList) { var evaluationStudentScore = evaluationStudentScoreList.Where(x => x.SchoolyearID == evaluationStudentSettingScoreView.SchoolyearID && x.UserID == evaluationStudentSettingScoreView.UserID && x.CoursematerialID == evaluationStudentSettingScoreView.CoursematerialID && x.DepartmentID == evaluationStudentSettingScoreView.DepartmentID).SingleOrDefault(); if (evaluationStudentScore != null) { throw new Exception("选择删除的信息中存在对应的学生评分信息,无法删除,请核查。"); } } using (TransactionScope ts = new TransactionScope()) { UnitOfWork.Delete(x => evaluationStudentSettingScoreIDs.Contains(x.EvaluationStudentSettingScoreID)); UnitOfWork.Delete(x => evaluationStudentIDList.Contains(x.EvaluationStudentID.Value)); UnitOfWork.Delete(x => evaluationStudentIDList.Contains(x.EvaluationStudentID)); ts.Complete(); } return true; } catch (Exception) { throw; } } } }