123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.ViewModel.DQPSystem;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.Students;
- namespace EMIS.DataLogic.DQPSystem
- {
- public class SOCDetailGroupDAL
- {
- public SOCRepository SOCRepository { get; set; }
- public SOCDetailRepository SOCDetailRepository { get; set; }
- public SOCDetailAttachmentRepository SOCDetailAttachmentRepository { get; set; }
- public SOCDetailGroupRepository SOCDetailGroupRepository { get; set; }
- public StudentRepository studentRepository { get; set; }
- public EducationMissionRepository educationMissionRepository { get; set; }
- public IQueryable<SOCDetailGroupView> GetSOCDetailGroupViewQueryable(Expression<Func<DQP_SOCDetailGroup, bool>> exp)
- {
- var query = from fgro in SOCDetailGroupRepository.GetList(exp)
- join edu in educationMissionRepository.Entities
- on fgro.DQP_SOCDetail.DQP_SOC.EducationMissionID equals edu.EducationMissionID
- into gedu
- from edu in gedu.DefaultIfEmpty()
- //join att in SOCDetailAttachmentRepository.Entities
- //on detail.SOCDetailID equals att.SOCDetailID
- //into gatt
- //from fatt in gatt.DefaultIfEmpty()
- select new SOCDetailGroupView
- {
- SOCDetailGroupID = fgro.SOCDetailGroupID,
- EducationMissionID = fgro.DQP_SOCDetail.DQP_SOC.EducationMissionID,
- EducationMissionName = edu.ClassName,
- SOCDetailID = fgro.DQP_SOCDetail.SOCDetailID,
- Name = fgro.DQP_SOCDetail.Name,
- CoursematerialID = fgro.DQP_SOCDetail.DQP_SOC.CoursematerialID,
- CourseCode = fgro.DQP_SOCDetail.DQP_SOC.EM_Coursematerial.CourseCode,
- CourseName = fgro.DQP_SOCDetail.DQP_SOC.EM_Coursematerial.CourseName,
- No = fgro.No,
- Score = fgro.Score,
- StudentCount = fgro.CF_Student.Select(x => x.Sys_User).Distinct().Count(),
- StudentList = fgro.CF_Student.Select(x => x.Sys_User).Distinct()
- };
- return query;
- }
- /// <summary>
- /// 获取学生信息
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <returns></returns>
- public IQueryable<BaseStudentView> GetStudentListForGroup(Guid? SOCDetailID)
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var query = from a in SOCRepository.GetList(x => x.DQP_SOCDetail.Any(y => y.SOCDetailID == SOCDetailID))
- from c in a.DQP_SOCStaff.FirstOrDefault(x => x.UserID == curUser.UserID).CF_Student
- select new BaseStudentView
- {
- UserID = c.UserID,
- LoginID = c.Sys_User.LoginID,
- UserName = c.Sys_User.Name,
- SexID = c.SexID,
- IDNumber = c.IDNumber,
- InSchoolStatusID = c.InSchoolStatusID,
- StudentStatus = c.StudentStatus,
- ClassmajorCode = c.CF_Classmajor.No,
- ClassmajorName = c.CF_Classmajor.Name,
- };
- return query;
- }
- public IQueryable<GroupSOCDetailView> GetGroupSOCDetailViewQueryable(Expression<Func<DQP_SOCDetail, bool>> exp)
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var query = from detail in SOCDetailRepository.GetList(exp)
- select new GroupSOCDetailView
- {
- SOCDetailID = detail.SOCDetailID,
- StudentTotalNum = detail.DQP_SOC.DQP_SOCStaff.FirstOrDefault(x => x.UserID == curUser.UserID).CF_Student.Distinct().Count(),
- };
- return query;
- }
- //public List<DQP_SOC> GetStudentsForGroup(Expression<Func<DQP_SOC, bool>> exp)
- //{
- // var query = SOCRepository.GetList(exp, x => x.CF_Student).ToList();
- // return query;
- //}
- /// <summary>
- /// 获取学生信息
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <returns></returns>
- public IQueryable<BaseStudentView> GetSOCDetailGroupViewStudentList(Guid? SOCDetailGroupID)
- {
- var query = from a in SOCDetailGroupRepository.GetList(x => x.SOCDetailGroupID == SOCDetailGroupID)
- from c in a.CF_Student
- select new BaseStudentView
- {
- UserID = c.UserID,
- LoginID = c.Sys_User.LoginID,
- UserName = c.Sys_User.Name,
- SexID = c.SexID,
- IDNumber = c.IDNumber,
- InSchoolStatusID = c.InSchoolStatusID,
- StudentStatus = c.StudentStatus,
- ClassmajorCode = c.CF_Classmajor.No,
- ClassmajorName = c.CF_Classmajor.Name,
- };
- return query;
- }
- /// <summary>
- /// 获取学生信息(未分组)
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <returns></returns>
- public IQueryable<BaseStudentView> GetNotGroupStudentList(Guid? SOCDetailGroupID)
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var groupStu = from a in SOCDetailRepository.GetList(x => x.DQP_SOCDetailGroup.Any(y => y.SOCDetailGroupID == SOCDetailGroupID))
- from gro in a.DQP_SOCDetailGroup
- from stu in gro.CF_Student
- select new
- {
- UserID = stu.UserID,
- };
- var gStuID = groupStu.Select(x => x.UserID).Distinct().ToList();
- var query = from a in SOCDetailGroupRepository.GetList(x => x.SOCDetailGroupID == SOCDetailGroupID)
- from stu in a.DQP_SOCDetail.DQP_SOC.DQP_SOCStaff.FirstOrDefault(y => y.UserID == curUser.UserID).CF_Student
- join gstu in studentRepository.Entities
- on stu.UserID equals gstu.UserID
- where !gStuID.Contains(stu.UserID)
- select new BaseStudentView
- {
- UserID = stu.UserID,
- LoginID = gstu.Sys_User.LoginID,
- UserName = gstu.Sys_User.Name,
- SexID = stu.SexID,
- IDNumber = stu.IDNumber,
- InSchoolStatusID = stu.InSchoolStatusID,
- StudentStatus = stu.StudentStatus,
- ClassmajorCode = gstu.CF_Classmajor.No,
- ClassmajorName = gstu.CF_Classmajor.Name,
- };
- return query;
- }
- }
- }
|