using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.DataLogic.Repositories;
using EMIS.ViewModel.EvaluationManage;
using System.Linq.Expressions;
using EMIS.Entities;
using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
using EMIS.ViewModel;
namespace EMIS.DataLogic.Common.EvaluationManage
{
public class EvaluationOpenControlDAL
{
public EvaluationGradeControlRepository EvaluationGradeControlRepository { get; set; }
public SchoolyearRepository schoolyearRepository { get; set; }
public GrademajorRepository GrademajorRepository { get; set; }
public DictionaryItemRepository dictionaryItemRepository { get; set; }
public ClassmajorRepository classmajorRepository { get; set; }
public EvaluationTypeRepository EvaluationTypeRepository { get; set; }
///
/// 读取评价控制信息
///
///
///
public IQueryable GetEvaluationControlQueryable(Expression> exp)
{
var query = from egc in EvaluationGradeControlRepository.GetList(exp)
join sy in schoolyearRepository.Entities on egc.SchoolyearID equals sy.SchoolyearID into schoolyear
from year in schoolyear.DefaultIfEmpty()
join grad in GrademajorRepository.Entities on egc.GrademajorID equals grad.GrademajorID into grademajor
from g in grademajor.DefaultIfEmpty()
select new EvaluationOpenControlView
{
EvaluationGradeControlID=egc.EvaluationGradeControlID,
SchoolyearID = year.SchoolyearID,
SchoolyearCode = year.Code,
GrademajorID=g.GrademajorID,
GrademajorCode=g.Code,
GrademajorName=g.Name,
CollegeID=g.CF_Facultymajor.CF_College.CollegeID,
CollegeName=g.CF_Facultymajor.CF_College.Name,
StartTime=egc.StartTime,
EndTime=egc.EndTime,
EvaluationCount=egc.Number
};
return query;
}
///
/// 读取未控制的评价控制信息
///
///
///
public IQueryable GrademajorViewGridQueryable(Expression> exp, Expression> exps)
{
var query = from a in GrademajorRepository.GetList(exp)
join c in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name) on a.CF_Facultymajor.StandardID equals c.Value
join sc in
(from sc in classmajorRepository.Entities
group sc by sc.GrademajorID into g
select new
{
GrademajorID = g.Key,
StudentCount = g.Sum(x => x.CF_Student.Count())
}) on a.GrademajorID equals sc.GrademajorID into dsc
from esc in dsc.DefaultIfEmpty()
join egc in EvaluationGradeControlRepository.GetList(exps) on a.GrademajorID equals egc.GrademajorID into e
from eg in e.DefaultIfEmpty()
where eg.EvaluationGradeControlID == null
select new GrademajorView
{
GrademajorID = a.GrademajorID,
Code = a.Code,
Name = a.Name,
Abbreviation = a.Abbreviation,
GradeID = a.GradeID,
Professional = a.Professional,
SemesterID = a.SemesterID,
FacultymajorID = a.CF_Facultymajor.FacultymajorID,
FacultymajorCode = a.CF_Facultymajor.Code,
FacultymajorName = a.CF_Facultymajor.Name,
EducationID = a.CF_Facultymajor.EducationID,
LearningformID = a.CF_Facultymajor.LearningformID,
LearnSystem = a.CF_Facultymajor.LearnSystem,
StandardID = a.CF_Facultymajor.StandardID,
CollegeID = a.CF_Facultymajor.CollegeID,
CollegeName = a.CF_Facultymajor.CF_College.Name,
CollegeCode = a.CF_Facultymajor.CF_College.No,
CampusID = a.CF_Facultymajor.CF_College.CampusID,
GraduateSchoolyearID = a.GraduateSchoolyearID,
GraduateValue = a.CF_Schoolyear.Value,
GraduateSchoolyearCode = a.CF_Schoolyear.Code,
StudentCount = esc.StudentCount == null ? 0 : esc.StudentCount,
CreateUserID = a.CreateUserID,
CreateTime = a.CreateTime,
Remark = a.Remark
};
return query;
}
}
}