using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using EMIS.Entities;
using EMIS.ViewModel.EvaluationManage.EvaluationTable;
using EMIS.DataLogic.Repositories;
namespace EMIS.DataLogic.EvaluationManage.EvaluationTable
{
public class EvaluationTableDAL
{
public EvaluationTableRepository EvaluationTableRepository { get; set; }
public EvaluationParticipateTypeRepository EvaluationParticipateTypeRepository { get; set; }
public EvaluationIntTypeRepository EvaluationIntTypeRepository { get; set; }
public EvaluationTargetRepository EvaluationTargetRepository { get; set; }
public EvaluationProjectRepository EvaluationProjectRepository { get; set; }
public UserRepository UserRepository { get; set; }
///
/// 查询对应的评价表信息EvaluationTableView
///
///
///
public IQueryable GetEvaluationTableViewQueryable(Expression> expEvaluationTable)
{
var query = from evtb in EvaluationTableRepository.GetList(expEvaluationTable)
join evpt in EvaluationParticipateTypeRepository.Entities
on evtb.EvaluationParticipateTypeID equals evpt.EvaluationParticipateTypeID
join evit in EvaluationIntTypeRepository.Entities
on evtb.EvaluationIntTypeID equals evit.EvaluationIntTypeID
join tg in
(
from tg in EvaluationTargetRepository.Entities
group tg by tg.EvaluationTableID into gtg
select new
{
EvaluationTableID = gtg.Key,
TargetCount = gtg.Count()
}
)
on evtb.EvaluationTableID equals tg.EvaluationTableID into temptg
from evtg in temptg.DefaultIfEmpty()
join pj in
(
from pj in EvaluationProjectRepository.Entities
group pj by pj.EM_EvaluationTarget.EM_EvaluationTable.EvaluationTableID into gpj
select new
{
EvaluationTableID = gpj.Key,
ProjectCount = gpj.Count()
}
)
on evtb.EvaluationTableID equals pj.EvaluationTableID into temppj
from evpj in temppj.DefaultIfEmpty()
join usc in UserRepository.Entities
on evtb.CreateUserID equals usc.UserID into tempusc
from uscu in tempusc.DefaultIfEmpty()
join usm in UserRepository.Entities
on evtb.ModifyUserID equals usm.UserID into tempusm
from usmu in tempusm.DefaultIfEmpty()
select new EvaluationTableView
{
EvaluationTableID = evtb.EvaluationTableID,
Code = evtb.Code,
Name = evtb.Name,
EvaluationParticipateTypeID = evtb.EvaluationParticipateTypeID,
ParticipateTypeID = evpt.ParticipateTypeID,
IsStudent = evpt.IsStudent.Value,
EvaluationTypeID = evtb.EvaluationIntTypeID,
EvaluationTypeCode = evit.Code,
EvaluationTypeName = evit.Name,
TeachingModeIDList = evit.EM_EvaluationTeachingMode.OrderBy(x => x.TeachingModeID).Select(x => x.TeachingModeID).ToList(),
Weight = evtb.Weight,
TargetCount = evtg.TargetCount == null ? 0 : evtg.TargetCount,
ProjectCount = evpj.ProjectCount == null ? 0 : evpj.ProjectCount,
IsEnabled = evtb.IsEnabled.Value,
Remark = evtb.Remark,
RecordStatus = evtb.RecordStatus,
CreateUserID = evtb.CreateUserID,
CreateUserName = uscu.Name,
CreateTime = evtb.CreateTime,
ModifyUserID = evtb.ModifyUserID,
ModifyUserName = usmu.Name,
ModifyTime = evtb.ModifyTime
};
return query;
}
///
/// 查询对应的评价指标信息EvaluationTargetView(统计对应的评价项目个数)
///
///
///
public IQueryable GetEvaluationTargetViewQueryable(Expression> expEvaluationTable)
{
//var query = from col in CollegeRepository.GetList(expCollege)
// join dep in DepartmentRepository.Entities
// on col.CollegeID equals dep.CollegeID
// join c in UserRepository.Entities
// on dep.CF_DepartmentProfile.DirectorID equals c.UserID into gu
// from guic in gu.DefaultIfEmpty()
// join d in UserRepository.Entities
// on dep.CF_DepartmentProfile.DeputyDirectorID equals d.UserID into gude
// from gudeic in gude.DefaultIfEmpty()
// join sta in
// (
// from sta in StaffRepository.Entities
// group sta by sta.DepartmentID into stagr
// select new
// {
// DepartmentID = stagr.Key,
// StaffCount = stagr.Count()
// }
// )
// on dep.DepartmentID equals sta.DepartmentID into tempsta
// from stadep in tempsta.DefaultIfEmpty()
// select new DepartmentView
// {
// DepartmentID = dep.DepartmentID,
// No = dep.No,
// Name = dep.Name,
// SimpleName = dep.SimpleName,
// EnglishName = dep.EnglishName,
// CampusID = col.CampusID,
// CampusNo = col.CF_Campus.No,
// CampusName = col.CF_Campus.Name,
// CollegeID = dep.CollegeID,
// CollegeCode = col.No,
// CollegeName = col.Name,
// HierarchyID = dep.HierarchyID,
// DirectorID = dep.CF_DepartmentProfile.DirectorID,
// DirectorName = guic.Name,
// DeputyDirectorID = dep.CF_DepartmentProfile.DeputyDirectorID,
// DeputyDirectorName = gudeic.Name,
// FoundDate = dep.CF_DepartmentProfile.FoundDate,
// StaffCount = stadep.StaffCount == null ? 0 : stadep.StaffCount,
// Remark = dep.Remark,
// RecordStatus = dep.RecordStatus,
// CreateUserID = dep.CreateUserID,
// CreateTime = dep.CreateTime,
// ModifyUserID = dep.ModifyUserID,
// ModifyTime = dep.ModifyTime
// };
return null; ;
}
///
/// 查询对应的评价项目信息EvaluationProjectView
///
///
///
public IQueryable GetEvaluationProjectViewQueryable(Expression> expEvaluationTable)
{
//var query = from col in CollegeRepository.GetList(expCollege)
// join sf in StaffRepository.Entities
// on col.CollegeID equals sf.CollegeID
// join pr in StaffProfileRepository.Entities
// on sf.UserID equals pr.UserID into temppr
// from sfpr in temppr.DefaultIfEmpty()
// join dep in DepartmentRepository.Entities
// on sf.DepartmentID equals dep.DepartmentID into tempdep
// from sfdep in tempdep.DefaultIfEmpty()
// join us in UserRepository.Entities
// on sf.UserID equals us.UserID
// select new StaffView
// {
// UserID = sf.UserID,
// StaffCode = us.LoginID,
// Name = us.Name,
// UsedName = sfpr.UsedName,
// CampusID = col.CampusID,
// CampusCode = col.CF_Campus.No,
// CampusName = col.CF_Campus.Name,
// CollegeID = sf.CollegeID,
// CollegeNo = col.No,
// CollegeName = col.Name,
// DepartmentID = sf.DepartmentID,
// DepartmentCode = sfdep.No,
// DepartmentName = sfdep.Name,
// Nationality = sfpr.Nationality,
// Place = sfpr.Place,
// SexID = sf.SexID,
// BirthDate = sf.BirthDate,
// NationID = sf.NationID,
// PoliticsID = sf.PoliticsID,
// CertificatesType = sf.CertificatesType,
// CertificatesNum = sf.CertificatesNum,
// TeacherTypeID = sf.TeacherTypeID,
// IncumbencyState = sf.IncumbencyState,
// SituationID = sf.SituationID,
// TitleID = sf.TitleID,
// LiteracyLevelID = sf.LiteracyLevelID,
// LearnPositionID = sf.LearnPositionID,
// IsDualTeacher = sf.IsDualTeacher ?? false,
// PaymentLevelID = sf.PaymentLevelID,
// WorkDate = sf.WorkDate,
// ComeSchoolDate = sf.ComeSchoolDate,
// Email = sfpr.Email,
// ZIPCode = sfpr.ZIPCode,
// WeChatNum = sfpr.WeChatNum,
// QQ = sfpr.QQ,
// Telephone = sfpr.Telephone,
// OfficeTelephone = sfpr.OfficeTelephone,
// HousePhone = sfpr.HousePhone,
// Mobile = sfpr.Mobile,
// Speciality = sfpr.Speciality,
// HealthStateID = sfpr.HealthStateID,
// ReligionID = sfpr.ReligionID,
// Account = sfpr.Account,
// Residence = sfpr.Residence,
// HomeAddress = sfpr.HomeAddress,
// Address = sfpr.Address,
// NowAddress = sfpr.NowAddress,
// PhotoUrl = sf.PhotoUrl,
// PhotoHasValue = (sf.PhotoUrl == null || sf.PhotoUrl == "") ? false : true,
// Profile = sf.Profile,
// Remark = sf.Remark,
// RecordStatus = sf.RecordStatus,
// CreateUserID = sf.CreateUserID,
// CreateTime = sf.CreateTime,
// ModifyUserID = sf.ModifyUserID,
// ModifyTime = sf.ModifyTime
// };
return null;
}
}
}