using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; 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.StudentManage.StudentStatistics; namespace EMIS.CommonLogic.EvaluationManage.StudentEvaluation { public class EvaluationStudentSettingDetailServices : BaseServices, IEvaluationStudentSettingDetailServices { public EvaluationStudentSettingDAL EvaluationStudentSettingDAL { get; set; } public Lazy InSchoolSettingServices { get; set; } /// /// 查询对应的学评名单信息View /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetEvaluationStudentSettingDetailViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID, Guid? coursematerialID, int? courseTypeID, int? teachingModeID, Guid? staffID, Guid? evaluationTableID, int? inSchoolStatus, int? openState, int? isEvaluation, int pageIndex, int pageSize) { Expression> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (staffID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == staffID); } 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); } } Expression> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (coursematerialID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID); } if (courseTypeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CourseTypeID == courseTypeID); } if (teachingModeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.TeachingModeID == teachingModeID); } Expression> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { 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> 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 (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } 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 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).ThenBy(x => x.StudentNo).ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的学评名单信息List /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetEvaluationStudentSettingDetailViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID, Guid? coursematerialID, int? courseTypeID, int? teachingModeID, Guid? staffID, Guid? evaluationTableID, int? inSchoolStatus, int? openState, int? isEvaluation) { Expression> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (staffID.HasValue) { expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.UserID == staffID); } 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); } } Expression> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (coursematerialID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID); } if (courseTypeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.CourseTypeID == courseTypeID); } if (teachingModeID.HasValue) { expEducationMissionClass = expEducationMissionClass.And(x => x.TeachingModeID == teachingModeID); } Expression> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { 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> 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 (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } 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 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).ThenBy(x => x.StudentNo).ToList(); } } }