using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.ViewModel.ScoreManage;
using EMIS.ViewModel;
namespace EMIS.ExtensionLogic.DataLogic.ScoreManage
{
public class FinalExaminationDAL : EMIS.DataLogic.ScoreManage.FinalExaminationDAL
{
///
/// 补考设定,加上学时
///
///
///
public override IQueryable GetNotPassStudent(Guid? schoolyearID)
{
List resitStatus = ExamsStateSettingDAL.Value.GetResitIDList();
var query = from fs in FinallyScoreRepository.GetList(x => (x.TotalScore == null || x.TotalScore < 60) && x.SchoolyearID == schoolyearID && x.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam && resitStatus.Contains(x.ExamsStateID))
from s in studentRepository.Entities.Where(x => fs.UserID == x.UserID)
join iss in InSchoolSettingRepository.GetList(x => x.IsSelected == true)
on s.InSchoolStatusID equals iss.InSchoolStatusID
join exam in ExamsStateSettingRepository.Entities
on fs.ExamsStateID equals exam.ExamsStateID
from fe in finalExaminationRepository.Entities.Where(x => x.SchoolyearID == schoolyearID && x.CoursematerialID == fs.CoursematerialID
&& x.ExamsCategoryID == fs.ExamsCategoryID)
from fesr in FinalExaminationStudentRepository.Entities.Where(x => x.FinalExaminationID == fe.FinalExaminationID
&& x.UserID == fs.UserID && x.StarttermID == fs.StarttermID)
//join final in finalExaminationRepository.GetList(x => x.SchoolyearID == schoolyearID)
// on fesr.FinalExaminationID equals final.FinalExaminationID
// into dfianl
//from final in dfianl.DefaultIfEmpty()
from erfes in (
from student in FinalExaminationStudentRepository.Entities
from final in finalExaminationRepository.Entities.Where(x => x.FinalExaminationID == student.FinalExaminationID)
where final.CoursematerialID == fs.CoursematerialID && student.UserID == fs.UserID && student.StarttermID == fs.StarttermID
&& final.ExamsCategoryID == exam.ResitCategory && student.CreateTime > fs.CreateTime
select student
).DefaultIfEmpty()
where erfes.FinalExaminationStudentID == null
select new ResitStudentView
{
UserID = fs.CF_Student.UserID,
FinalExaminationID = fesr.FinalExaminationID,
Year = fs.CF_Student.CF_Classmajor.CF_Grademajor.GradeID,
CourseCollegeID = fs.CF_Department.CollegeID,
CollegeID = fs.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
StandardID = fs.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
GrademajorID = fs.CF_Student.CF_Classmajor.GrademajorID,
GrademajorName = fs.CF_Student.CF_Classmajor.CF_Grademajor.Name,
CoursematerialID = fs.CoursematerialID,
DepartmentID = fs.DepartmentID,
CourseName = fs.EM_Coursematerial.CourseName,
CourseTypeID = fs.CourseTypeID,
ExaminationModeID = fs.ExaminationModeID,
SchoolyearNumID = fs.SchoolyearNumID,
StartTermID = fs.StarttermID,
Credit = fs.Credit,
//加上学时
TotalHours = fs.TotalHours,
ResultTypeID = fs.ResultTypeID,
ClassmajorID = fs.CF_Student.CF_Classmajor.ClassmajorID,
ExamsCategoryID = exam.ResitCategory,
CreatorUserID = fs.CreatorUserID,
};
return query;
}
}
}