using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.ViewModel; using EMIS.ViewModel.ScoreManage; using EMIS.DataLogic.ScoreManage; using EMIS.Entities; namespace EMIS.CommonLogic.ScoreManage { public class ResitServices : BaseServices, IResitServices { public ResitDAL ResitDAL { get; set; } public IGridResultSet GetResitViewGrid(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, int? examinationSubjectID, int? schoolAreaID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, int? pageIndex, int? pageSize) { Expression> batchExp = (x => true); Expression> projectExp = (x => true); Expression> scoreExp = (x => true); Expression> facutyExp = (x => true); Expression> gradeExp = (x => true); Expression> studentExp = (x => true); if (schoolyearID.HasValue) { batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID); } if (examinationBatchID.HasValue) { batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID); } if (examinationTypeID.HasValue) { projectExp = projectExp.And(x => x.ExaminationTypeID == examinationTypeID); } if (examinationProjectID.HasValue) { projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID); } if (examinationSubjectID.HasValue) { scoreExp = scoreExp.And(x => x.ExaminationSubjectID == examinationSubjectID); } if (schoolAreaID.HasValue) { gradeExp = gradeExp.And(x => x.SchoolAreaID == schoolAreaID); } if (collegeID.HasValue) { facutyExp = facutyExp.And(x => x.CollegeID == collegeID); } if (yearID.HasValue) { gradeExp = gradeExp.And(x => x.SchoolyearID == yearID); } if (standardID.HasValue) { facutyExp = facutyExp.And(x => x.StandardID == standardID); } if (classmajorID.HasValue) { studentExp = studentExp.And(x => x.ClassmajorID == classmajorID); } var query = ResitDAL.GetResitViewQueryable(batchExp, projectExp, scoreExp, facutyExp, gradeExp, studentExp); if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute)) { query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue); } var result = GetQueryByDataRangeByCollege(query); return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(result)).OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.ExaminationBatchName) .ThenBy(x => x.ExaminationTypeName) .ThenBy(x => x.ExaminationProjectName) .ThenBy(x => x.ClassmajorName) .ThenBy(x => x.ExaminationSubjectID) .ThenBy(x => x.UserName) .ToGridResultSet(pageIndex, pageSize); } public List GetResitViewList(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, int? examinationSubjectID, int? schoolAreaID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID) { Expression> batchExp = (x => true); Expression> projectExp = (x => true); Expression> scoreExp = (x => true); Expression> facutyExp = (x => true); Expression> gradeExp = (x => true); Expression> studentExp = (x => true); if (schoolyearID.HasValue) { batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID); } if (examinationBatchID.HasValue) { batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID); } if (examinationTypeID.HasValue) { projectExp = projectExp.And(x => x.ExaminationTypeID == examinationTypeID); } if (examinationProjectID.HasValue) { projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID); } if (examinationSubjectID.HasValue) { scoreExp = scoreExp.And(x => x.ExaminationSubjectID == examinationSubjectID); } if (schoolAreaID.HasValue) { gradeExp = gradeExp.And(x => x.SchoolAreaID == schoolAreaID); } if (collegeID.HasValue) { facutyExp = facutyExp.And(x => x.CollegeID == collegeID); } if (yearID.HasValue) { gradeExp = gradeExp.And(x => x.SchoolyearID == yearID); } if (standardID.HasValue) { facutyExp = facutyExp.And(x => x.StandardID == standardID); } if (classmajorID.HasValue) { studentExp = studentExp.And(x => x.ClassmajorID == classmajorID); } var query = ResitDAL.GetResitViewQueryable(batchExp, projectExp, scoreExp, facutyExp, gradeExp, studentExp); if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute)) { query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue); } var result = GetQueryByDataRangeByCollege(query); return result.OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.ExaminationBatchName) .ThenBy(x => x.ExaminationTypeName) .ThenBy(x => x.ExaminationProjectName) .ThenBy(x => x.ClassmajorName) .ThenBy(x => x.ExaminationSubjectID) .ThenBy(x => x.UserName) .ToList(); } } }