123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using EMIS.DataLogic.DQPSystem;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.DQPSystem;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.ScoreManage;
- using EMIS.DataLogic.ScoreManage;
- namespace EMIS.CommonLogic.DQPSystem
- {
- public class SOCScoreServices : BaseServices, ISOCScoreServices
- {
- public SOCScoreDAL SOCScoreDAL { get; set; }
- public Lazy<IRoleServices> RoleServices { get; set; }
- public FinalExaminationDAL FinalExaminationDAL { get; set; }
- public IGridResultSet<SOCCourseScoreView> GetSOCCourseScoreViewList(ConfiguretView courseScoreConditionView, Guid? schoolyearID, Guid? collegeID,
- int? year, int? standardID, Guid? classmajorID, Guid? coursematerialID, int? pageIndex, int? pageSize)
- {
- Expression<Func<DQP_SOC, bool>> socExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classExp = (x => true);
- Expression<Func<DQP_SOCDetail, bool>> detailExp = (x => true);
- if (schoolyearID.HasValue)
- {
- socExp = socExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- facultyExp = facultyExp.And(x => x.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- gradeExp = gradeExp.And(x => x.GradeID == year);
- }
- if (standardID.HasValue)
- {
- facultyExp = facultyExp.And(x => x.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- classExp = classExp.And(x => x.ClassmajorID == classmajorID);
- }
- if (coursematerialID.HasValue)
- {
- socExp = socExp.And(x => x.CoursematerialID == coursematerialID);
- }
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var role = RoleServices.Value.GetEnabledTeacherRoleViewList();
- var teacherRole = role.Where(x => x.RoleName == "教师");
- if (curUser.RoleID == teacherRole.FirstOrDefault().RoleID)
- {
- detailExp = detailExp.And(x => x.CreateUserID == curUser.UserID);
- }
- var query = SOCScoreDAL.GetSOCCourseScoreViewQueryable(socExp, detailExp, facultyExp, gradeExp, classExp);
- if (!string.IsNullOrEmpty(courseScoreConditionView.ConditionValue) && !string.IsNullOrEmpty(courseScoreConditionView.Attribute))
- query = query.DynamicWhere(courseScoreConditionView.Attribute, courseScoreConditionView.Condition, courseScoreConditionView.ConditionValue);
- query = this.GetQueryByDataRangeByCollege(query);
- query = query.OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CourseCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.LoginID)
- .ThenBy(x => x.CourseCode);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- public List<SOCCourseScoreView> GetSOCCourseScoreViewList(ConfiguretView courseScoreConditionView, Guid? schoolyearID, Guid? collegeID,
- int? year, int? standardID, Guid? classmajorID, Guid? coursematerialID)
- {
- Expression<Func<DQP_SOC, bool>> socExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classExp = (x => true);
- Expression<Func<DQP_SOCDetail, bool>> detailExp = (x => true);
- if (schoolyearID.HasValue)
- {
- socExp = socExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- facultyExp = facultyExp.And(x => x.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- gradeExp = gradeExp.And(x => x.GradeID == year);
- }
- if (standardID.HasValue)
- {
- facultyExp = facultyExp.And(x => x.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- classExp = classExp.And(x => x.ClassmajorID == classmajorID);
- }
- if (coursematerialID.HasValue)
- {
- socExp = socExp.And(x => x.CoursematerialID == coursematerialID);
- }
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var role = RoleServices.Value.GetEnabledTeacherRoleViewList();
- var teacherRole = role.Where(x => x.RoleName == "教师");
- if (curUser.RoleID == teacherRole.FirstOrDefault().RoleID)
- {
- detailExp = detailExp.And(x => x.CreateUserID == curUser.UserID);
- }
- var query = SOCScoreDAL.GetSOCCourseScoreViewQueryable(socExp, detailExp, facultyExp, gradeExp, classExp);
- if (!string.IsNullOrEmpty(courseScoreConditionView.ConditionValue) && !string.IsNullOrEmpty(courseScoreConditionView.Attribute))
- query = query.DynamicWhere(courseScoreConditionView.Attribute, courseScoreConditionView.Condition, courseScoreConditionView.ConditionValue);
- query = this.GetQueryByDataRangeByCollege(query);
- query = query.OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CourseCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.LoginID)
- .ThenBy(x => x.CourseCode);
- return query.ToList();
- }
- public List<SOCCourseScoreView> GetScoreBySOCScore(Guid? finalExaminationID)
- {
- Expression<Func<DQP_SOC, bool>> socExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classExp = (x => true);
- Expression<Func<DQP_SOCDetail, bool>> detailExp = (x => true);
- var final = FinalExaminationDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationID, (x => x.ER_FinalExaminationStudent));
- if (final != null)
- {
- socExp = socExp.And(x => x.SchoolyearID == final.SchoolyearID);
- socExp = socExp.And(x => x.CoursematerialID == final.CoursematerialID);
- socExp = socExp.And(x => x.DepartmentID == final.DepartmentID);
- if (final.HandleModeID.HasValue)
- {
- socExp = socExp.And(x => x.HandleModeID == final.HandleModeID);
- }
- //socExp = socExp.And(x => x.OptionalCourseTypeID == final);
- var query = SOCScoreDAL.GetSOCCourseScoreViewQueryable(socExp, detailExp, facultyExp, gradeExp, classExp);
- var studentIDList = final.ER_FinalExaminationStudent.Select(x => x.UserID).ToList();
- query = query.Where(x => studentIDList.Contains(x.UserID) && x.TotalScore != null);
- return query.ToList();
- }
- else
- {
- return new List<SOCCourseScoreView>();
- }
- }
- }
- }
|