1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq;
- using EMISOnline.Entities;
- using EMISOnline.DataLogic.Repositories;
- using EMISOnline.ViewModel;
- using EMISOnline.ViewModel.SystemView;
- using System.Linq.Expressions;
- namespace EMISOnline.DataLogic.SystemDAL
- {
- public class UserDAL
- {
- public UserRepository UserRepository { get; set; }
- public User_Sys_RoleRepository User_Sys_RoleRepository { get; set; }
- public RoleRepository RoleRepository { get; set; }
- public CampusRepository CampusRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public DepartmentRepository DepartmentRepository { get; set; }
- public StaffRepository StaffRepository { get; set; }
- public StudentRepository StudentRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- public Sys_User GetSingleEnableUser(System.Linq.Expressions.Expression<Func<Sys_User, bool>> expression)
- {
- System.Linq.Expressions.Expression<Func<Sys_User, bool>> newExp = expression.And(u => u.RecordStatus == (int)SYS_STATUS.USABLE);
- return UserRepository.GetSingle(newExp);
- }
- public IQueryable<UserView> GetUserView(Expression<Func<Sys_User, bool>> userExpression, Expression<Func<Sys_Role, bool>> roleExpression)
- {
- var q = (from u in UserRepository.GetList(userExpression)
- join ur in User_Sys_RoleRepository.Entities on u.UserID equals ur.UserID into dur
- from ur in dur.DefaultIfEmpty()
- join r in RoleRepository.Entities on ur.RoleID equals r.RoleID into dr
- from er in dr.DefaultIfEmpty()
- join s in StaffRepository.Entities on u.UserID equals s.UserID into ds
- from es in ds.DefaultIfEmpty()
- join stu in StudentRepository.Entities on u.UserID equals stu.UserID into dstu
- from estu in dstu.DefaultIfEmpty()
- join d in DepartmentRepository.Entities on es.DepartmentID equals d.DepartmentID into dd
- from ed in dd.DefaultIfEmpty()
- join c in CollegeRepository.Entities on es.CollegeID equals c.CollegeID into dc
- from ec in dc.DefaultIfEmpty()
- join cp in CampusRepository.Entities on ec.CampusID equals cp.CampusID into dcp
- from ecp in dcp.DefaultIfEmpty()
- join cu in UserRepository.Entities on u.CreateUserID equals cu.UserID into dcu
- from ecu in dcu.DefaultIfEmpty()
- join mu in UserRepository.Entities on u.ModifyUserID equals mu.UserID into dmu
- from emu in dmu.DefaultIfEmpty()
- select new UserView
- {
- UserID = u.UserID,
- LoginID = u.LoginID,
- Name = u.Name,
- UniversityID = ecp.UniversityID,
- CampusID = ec.CampusID,
- CollegeID = ec.CollegeID,
- CollegeName = ec.Name,
- DepartmentID = es.DepartmentID,
- DepartmentName = ed.Name,
- HierarchyID = ed.HierarchyID,
- StaffID = es.UserID,
- StudentID = estu.UserID,
- BirthDate = es.BirthDate,
- Sex = es.Sex,
- RoleID = er.RoleID,
- RoleName = er.RoleName,
- DataRange = er.DefaultDataRange,
- Remarks = es.Remarks,
- RecordStatus = u.RecordStatus,
- CreateUserID = u.CreateUserID,
- CreateUserName = ecu.Name,
- CreateTime = u.CreateTime,
- ModifyUserID = u.ModifyUserID,
- ModifyUserName = emu.Name,
- ModifyTime = u.ModifyTime
- });
- return q;
- }
- public IQueryable<Sys_Role> GetUserRoles(Expression<Func<Sys_User, bool>> userExpression, Expression<Func<Sys_Role, bool>> roleExpression)
- {
- var q = (from u in UserRepository.GetList(userExpression)
- join ur in User_Sys_RoleRepository.Entities on u.UserID equals ur.UserID
- join r in RoleRepository.Entities on ur.RoleID equals r.RoleID
- select r);
- return q;
- }
- }
- }
|