using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel.EvaluationManage; using EMIS.DataLogic.SystemDAL; using EMIS.ViewModel; using Bowin.Common.Linq; using EMIS.Utility; using EMIS.DataLogic.Common.Students; namespace EMIS.DataLogic.Common.EvaluationManage { public class EvaluationAdviseDAL { public EducationMissionClassRepository EducationMissionClassRepository { get; set; } public ParameterRepository parameterRepository { get; set; } public MissionClassTeacherRepository missionClassTeacherRepository { get; set; } public CoursematerialRepository coursematerialRepository { get; set; } public EvaluationEnterRepository evaluationEnterRepository { get; set; } public EvaluationTypeRepository evaluationTypeRepository { get; set; } public EvaluationTableRepository evaluationTableRepository { get; set; } public EducationMissionRepository educationMissionRepository { get; set; } public SchoolyearRepository schoolyearRepository { get; set; } public IQueryable GetEvaluationAdviseQuery() { var query = from a in EducationMissionClassRepository.Entities from b in a.EM_EvaluationSetting from c in a.EM_EvaluationEnter select new EvaluationAdviseView { Sys_User = a.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User), CoursematerialID = a.EM_Coursematerial.CoursematerialID, CourseName = a.EM_Coursematerial.CourseName, CourseCode = a.EM_Coursematerial.CourseCode, EducationMissionClassName = a.Name, EvaluationTypeID = c.EM_EvaluationTable.EM_EvaluationType.EvaluationTypeID, EvaluationTypeName = c.EM_EvaluationTable.EM_EvaluationType.Name, SchoolyearCode = c.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.Code, SchoolyearID = c.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.SchoolyearID, EvaluationTableID = c.EvaluationTableID, EvaluationTableName = c.EM_EvaluationTable.Name, CollegeID = c.EM_EducationMissionClass.EM_EducationMission.CF_College.CollegeID, DepartmentID = c.EM_EducationMissionClass.EM_EducationMission.CF_Department.DepartmentID, Remark = c.Remark }; return query; } public IQueryable GetMyEvaluationQuery(Expression> emcexp, Expression> emexp, Expression> eeexp, Expression> etexp) { //int paramterTypeID = (int)CF_ParameterType.SensitiveWords; //var paraquery = from a in parameterRepository.GetList(x => x.ParameterTypeID == paramterTypeID) // select new // { // Value = a.Value, // }; ////List valueList = new List(); //List sArray = new List(); ////var values = paraquery.FirstOrDefault().Value; //if (paraquery != null) //{ // var values = paraquery.FirstOrDefault().Value; // sArray = values.Split('|').ToList(); //} //else //{ // sArray = null; //} var query = from emcr in EducationMissionClassRepository.GetList(emcexp) join emr in educationMissionRepository.GetList(emexp) on emcr.EducationMissionID equals emr.EducationMissionID join sr in schoolyearRepository.Entities on emr.SchoolyearID equals sr.SchoolyearID join cmr in coursematerialRepository.Entities on emcr.CoursematerialID equals cmr.CoursematerialID join eer in evaluationEnterRepository.GetList(eeexp) on emcr.EducationMissionClassID equals eer.EducationMissionClassID join table in evaluationTableRepository.GetList(etexp) on eer.EvaluationTableID equals table.EvaluationTableID join etr in evaluationTypeRepository.Entities on table.EvaluationTypeID equals etr.EvaluationTypeID select new EvaluationAdviseView { Sys_User = emcr.EM_MissionClassTeacher.Select(x => x.CF_Staff.Sys_User), CoursematerialID = cmr.CoursematerialID, CourseName = cmr.CourseName, CourseCode = cmr.CourseCode, EducationMissionClassName = emcr.Name, EvaluationTypeID = etr.EvaluationTypeID, EvaluationTypeName = etr.Name, SchoolyearCode = sr.Code, SchoolyearID = sr.SchoolyearID, EvaluationTableID = table.EvaluationTableID, EvaluationTableName = table.Name, Remark = eer.Remark, }; //var query = from a in EducationMissionClassRepository.Entities // from b in a.EM_EvaluationSetting // from c in a.EM_EvaluationEnter // select new EvaluationAdviseView // { // Sys_User = a.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User), // CoursematerialID = a.EM_Coursematerial.CoursematerialID, // CourseName = a.EM_Coursematerial.CourseName, // CourseCode = a.EM_Coursematerial.CourseCode, // EducationMissionClassName = a.Name, // EvaluationTypeID = c.EM_EvaluationTable.EM_EvaluationType.TypeID, // EvaluationTypeName = c.EM_EvaluationTable.EM_EvaluationType.Name, // SchoolyearCode = c.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.Code, // SchoolyearID = c.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.SchoolyearID, // EvaluationTableID = c.EvaluationTableID, // EvaluationTableName = c.EM_EvaluationTable.Name, // CollegeID = c.EM_EducationMissionClass.EM_EducationMission.CF_College.CollegeID, // DepartmentID = c.EM_EducationMissionClass.EM_EducationMission.CF_Department.DepartmentID, // Remark = valueList.Any(y => c.Remark.Contains(y.ToString())) ? "" : c.Remark, // }; return query; } } }