Esempio n. 1
0
        public static object GetUsers(System.Collections.Specialized.NameValueCollection nvl, out int recordCount)
        {
            var result         = UserInfoService.CurrentRepository.QueryEntity.Where(o => o.CompanyId == CommonService.CompanyId);
            var organizationId = nvl["organizationId"].IsNullOrEmpty() ? -1 : int.Parse(nvl["organizationId"]);
            var departmentId   = nvl["departmentId"].IsNullOrEmpty() ? -1 : int.Parse(nvl["departmentId"]);
            var roleGroupsId   = nvl["roleGroupsId"];
            var searchText     = nvl["searchText"];
            var express        = DynamicallyLinqHelper.True <SysUserInfo>().And(o => o.BranchId == organizationId, organizationId == -1).And(o => o.BumenId == departmentId, departmentId == -1)
                                 .And(o => o.RoleIds != null && o.RoleIds.Contains(roleGroupsId), roleGroupsId.IsNullOrEmpty()).And(o => (o.FullName.Contains(searchText) || o.LoginName.Contains(searchText)), searchText.IsNullOrEmpty());

            result      = result.Where(express);
            recordCount = result.Count();
            var list    = result.ToPageList();
            var orgIds  = list.Select(o => o.BranchId).Distinct().ToList();
            var deptIds = list.Select(o => o.BumenId).Distinct().ToList();
            var roleIds = list.Where(o => o.RoleIds != null).SelectMany(o => o.RoleIds.Split(',')).Select(o => int.Parse(o)).Distinct().ToList();
            var orgs    = DepartmentInfoService.FindList(o => orgIds.Contains(o.Id));
            var depts   = DepartmentInfoService.FindList(o => deptIds.Contains(o.Id));
            var roles   = RoleInfoService.FindList(o => roleIds.Contains(o.Id));

            return(list.Select(o => new
            {
                o.Id,
                o.FullName,
                o.LoginName,
                o.BranchId,
                o.BumenId,
                o.RoleIds,
                o.PositionId,
                Sex = o.Sex ? "男" : "女",
                PositionName = o.PositionId,
                OrganizationName = OrganizationName(o.BranchId, orgs),
                DepartmentName = DepartmentName(o.BumenId, orgs),
                RolesName = RolesName(o.RoleIds, roles),
            }));
        }
Esempio n. 2
0
 public static IList<SysDepartments> GetOrganizations()
 {
     return DepartmentInfoService.FindList(o => o.Type==1);
 }
Esempio n. 3
0
 public static SysDepartments GetDepartment(int id)
 {
     return DepartmentInfoService.Find(o => o.Id == id);
 }
Esempio n. 4
0
 public static IList<SysDepartments> GetChildDepartments(int pid)
 {
     return DepartmentInfoService.FindList(o => o.PDepId == pid);
 }