Esempio n. 1
0
        public List <UserLiteDto> GetGroupUsersByLoginUserID(int userId)
        {
            List <UserLiteDto> lstResult = null;

            try
            {
                SoaDataPage <UserSearchModel> filter = new SoaDataPage <UserSearchModel>();;
                CommonFunction.InitializeSoaDataPage(filter);
                filter.Where.UserId = userId;
                filter.PageIndex    = 1;
                filter.PageSize     = 100000000;
                var result = new Esmart.Permission.Application.DeparentManager.DepartmentManager().GetUsersByDepartList(filter);
                if (result != null && !CommonAction.IsSysAdmin(userId))
                {
                    List <UsersView> lstDepart = DepartmentUserDbAction.GetGroupsByUserId(userId);
                    lstResult = result.Body.Where(w => lstDepart.Find(f => f.UserID == w.UserID) != null).ToList().ConvertAll(c => new UserLiteDto {
                        UserID = c.UserID, TrueName = c.TrueName, WorkNo = c.WorkNo, Email = c.Email, Ename = c.Ename, Sex = c.Sex
                    });
                }
                else
                {
                    lstResult = result.Body.ToList().ConvertAll(c => new UserLiteDto {
                        UserID = c.UserID, TrueName = c.TrueName, WorkNo = c.WorkNo, Email = c.Email, Ename = c.Ename, Sex = c.Sex
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(lstResult);
        }
Esempio n. 2
0
        /// <summary>
        /// 分页数据
        /// </summary>
        /// <param name="queryModel"></param>
        /// <returns></returns>
        public SoaDataPageResponse <FunctionModel> GetList(SoaDataPage <FunctionQueryModelRequest> queryModel)
        {
            SoaDataPageResponse <FunctionModel> response = new SoaDataPageResponse <FunctionModel>();

            SoaDataPageResponse <Esmart_Sys_Functions> soa = FunctionDbAction.GetList(queryModel);
            List <FunctionModel> listFunction = new List <FunctionModel>();

            if (soa.Body.Any())
            {
                foreach (var li in soa.Body)
                {
                    listFunction.Add(new FunctionModel()
                    {
                        AppId        = li.AppId,
                        CreateId     = li.CreateId,
                        CreateTime   = li.CreateTime,
                        FunctionId   = li.FunctionId,
                        FunctionKey  = li.FunctionKey,
                        FunctionName = li.FunctionName,
                        Remark       = li.Remark
                    });
                }
            }
            response.Body  = listFunction;
            response.Count = soa.Count;
            return(response);
        }
Esempio n. 3
0
        /// <summary>
        /// 部门用户列表
        /// </summary>
        public PartialViewResult UserListPart(int DeapartmentId, SoaDataPage <UserSearchModel> filter)
        {
            CommonFunction.InitializeSoaDataPage(filter);
            filter.Where.DeapartmentId = DeapartmentId;
            filter.Where.UserId        = User.Identity.GetUserId <int>();
            var result = _departmentService.GetUsersByDepartList(filter);

            return(PartialView(result));
        }
Esempio n. 4
0
        public PartialViewResult FunctionManagerDataTable(SoaDataPage <Function> filter)
        {
            CommonFunction.InitializeSoaDataPage(filter);

            var list = _functionService.GetFunctionsOfApp(filter);

            ViewBag.Count = list.Count;
            return(PartialView(list.Body));
        }
Esempio n. 5
0
        public PartialViewResult RoleGrid(SoaDataPage <RoleGridFilterViewModel> filter)
        {
            CommonFunction.InitializeSoaDataPage(filter);

            filter.Where.LogInUserId = CurrentUser.UserId;

            var rolesList = _service.GetDepartmentRoles(filter);

            return(PartialView(rolesList));
        }
Esempio n. 6
0
 public SoaDataPageResponse <UsersView> GetUsersByDepartList(SoaDataPage <UserSearchModel> filter)
 {
     try
     {
         return(_departmentManager.GetUsersByDepartList(filter));
     }
     catch (Exception ex)
     {
         throw new TpoBaseException(ex.Message);
     }
 }
Esempio n. 7
0
 public SoaDataPageResponse <RoleModel> GetDepartmentRoles(SoaDataPage <RoleGridFilterViewModel> fiter)
 {
     try
     {
         return(_roleService.GetRoleList(fiter));
     }
     catch (Exception ex)
     {
         throw new TpoBaseException(ex.Message);
     }
 }
Esempio n. 8
0
        public static List <Esmart_Sys_Roles> GetRolesByUserId(SoaDataPage <RoleGridFilterViewModel> fiter, out int count)
        {
            var data = PermissionDb.CreateEngine().Esmart_Sys_Roles.Where(a => a.CreateId == fiter.Where.LogInUserId);

            if (!string.IsNullOrEmpty(fiter.Where.Name))
            {
                data = data.Where(a => a.RoleName.Contains(fiter.Where.Name));
            }
            if (fiter.Where.CreateId != null)
            {
                data = data.Where(a => a.CreateId == fiter.Where.CreateId.Value);
            }
            count = data.Count();

            data = data.OrderByDescending(a => a.RoleId).Skip((fiter.PageIndex - 1) * fiter.PageSize).Take(fiter.PageSize);

            return(data.ToList());
        }
Esempio n. 9
0
        public SoaDataPageResponse <FunctionModel> GetFunctionsOfApp(SoaDataPage <Function> soa)
        {
            SoaDataPage <FunctionQueryModelRequest> queryModel = new SoaDataPage <FunctionQueryModelRequest>()
            {
                PageIndex = soa.PageIndex,
                PageSize  = soa.PageSize,
                Where     = new FunctionQueryModelRequest()
                {
                    AppId = soa.Where.AppId
                }
            };

            try
            {
                return(_functionManager.GetList(queryModel));
            }
            catch (Exception ex)
            {
                throw new TpoBaseException(ex.Message);
            }
        }
Esempio n. 10
0
        public SoaDataPageResponse <RoleModel> GetRoleList(SoaDataPage <RoleGridFilterViewModel> fiter)
        {
            SoaDataPageResponse <RoleModel> response = new SoaDataPageResponse <RoleModel>();

            List <Esmart_Sys_Roles> roles;

            if (CommonAction.IsSysAdmin(fiter.Where.LogInUserId))
            {
                roles = RoleDbAction.GetAllRols();

                response.Count = roles.Count;

                roles = roles.Skip((fiter.PageIndex - 1) * fiter.PageSize).Take(fiter.PageSize).ToList();
            }
            else
            {
                int count;
                roles          = UserRolesDbAction.GetRolesByUserId(fiter, out count);
                response.Count = count;
            }

            var body = roles.ConvertAll(a => new RoleModel()
            {
                CreateTime = a.CreateTime,
                CreatorId  = a.CreateId,
                EndDate    = a.EndTime,
                Id         = a.RoleId,
                Name       = a.RoleName,
                Remark     = a.Remark,
                StartDate  = a.StartTime,
                IsBuiltin  = a.IsBuiltin
            });

            response.Body = body;

            return(response);
        }
Esempio n. 11
0
        /// <summary>
        /// 分页数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static SoaDataPageResponse <Esmart_Sys_Functions> GetList(SoaDataPage <FunctionQueryModelRequest> model)
        {
            SoaDataPageResponse <Esmart_Sys_Functions> response = new SoaDataPageResponse <Esmart_Sys_Functions>();

            var engine = PermissionDb.CreateEngine();
            var list   = engine.Esmart_Sys_Functions.Where(m => m.IsDelete == 0);

            if (model.Where.AppId > 0)
            {
                list = list.Where(m => m.AppId == model.Where.AppId);
            }
            if (!string.IsNullOrEmpty(model.Where.Name))
            {
                list = list.Where(m => (m.FunctionKey.Contains(model.Where.Name) || m.FunctionName.Contains(model.Where.Name)));
            }
            response.Count = list.Count();

            //分页
            var listFunctions = list.OrderByDescending(m => m.CreateTime).Skip((model.PageIndex - 1) * model.PageSize).Take(model.PageSize).ToList();

            response.Body = listFunctions;

            return(response);
        }
Esempio n. 12
0
        public List <UsersView> GetUsersByDepartList(int userId, string groupName, int departId = 0)
        {
            List <UsersView> lstResult = null;

            try
            {
                SoaDataPage <UserSearchModel> filter = new SoaDataPage <UserSearchModel>();;
                CommonFunction.InitializeSoaDataPage(filter);
                filter.Where.DeapartmentId = departId;
                filter.Where.UserId        = userId;
                filter.PageIndex           = 1;
                filter.PageSize            = 100000000;
                var result    = new Esmart.Permission.Application.DeparentManager.DepartmentManager().GetUsersByDepartList(filter);
                var resultEnd = result.Body.Where(f => f.RoleNames.Split(',').Contains(groupName));
                if (resultEnd != null)
                {
                    lstResult = resultEnd.ToList();
                }
            }catch (Exception ex)
            {
                throw ex;
            }
            return(lstResult);
        }
Esempio n. 13
0
        public static SoaDataPageResponse <UsersView> GetUsersByDepartList(SoaDataPage <UserSearchModel> filter)
        {
            var engine = PermissionDb.CreateEngine();

            var query = from t in engine.Esmart_Sys_Users
                        join d in engine.Esmart_Sys_Department_User on t.UserID equals d.UserId
                        join dep in engine.Esmart_Sys_Departments on d.DeparentId equals dep.DeparentId
                        where d.DeparentId == filter.Where.DeapartmentId
                        select new UsersView
            {
                UserID       = t.UserID,
                WorkNo       = t.WorkNo,
                UserName     = t.UserName,
                PassWord     = t.PassWord,
                Email        = t.Email,
                Ename        = t.Ename,
                TrueName     = t.TrueName,
                Sex          = t.Sex,
                Education    = t.Education,
                Graduate     = t.Graduate,
                Birthday     = t.Birthday,
                qq           = t.qq,
                Skype        = t.Skype,
                Mobile       = t.Mobile,
                HomeTel      = t.HomeTel,
                HomeAddr     = t.HomeAddr,
                OfficeAddr   = t.OfficeAddr,
                OfficeName   = t.OfficeName,
                Isleave      = t.Isleave,
                IsDelete     = t.IsDelete,
                Remark       = t.Remark,
                CreateId     = t.CreateId,
                CreateTime   = d.CreateTime,
                DeparentName = dep.Name
            };

            if (!string.IsNullOrWhiteSpace(filter.Where.TrueName))
            {
                query = query.Where(n => n.TrueName.Contains(filter.Where.TrueName));
            }

            if (!string.IsNullOrWhiteSpace(filter.Where.Ename))
            {
                query = query.Where(n => n.Ename.Contains(filter.Where.Ename));
            }

            if (!string.IsNullOrWhiteSpace(filter.Where.WorkNo))
            {
                query = query.Where(n => n.WorkNo.Contains(filter.Where.WorkNo));
            }

            var response = new SoaDataPageResponse <UsersView> {
                Count = query.Count()
            };

            query = !string.IsNullOrWhiteSpace(filter.OrderBy) ? query.SortBy(filter.OrderBy + " " + filter.SortCol) : query.OrderByDescending(n => n.CreateTime);

            response.Body = query.Skip((filter.PageIndex - 1) * filter.PageSize).Take(filter.PageSize).ToList();

            return(response);
        }
Esempio n. 14
0
        public SoaDataPageResponse <UsersView> GetUsersByDepartList(SoaDataPage <UserSearchModel> filter)
        {
            SoaDataPageResponse <UsersView> response;

            if (filter.Where.DeapartmentId != 0)
            {
                response = DepartmentDbAction.GetUsersByDepartList(filter);
            }
            else
            {
                IQueryable <UsersView> query;

                if (CommonAction.IsSysAdmin(filter.Where.UserId))
                {
                    query = DepartmentUserDbAction.GetAllUsers(true).AsQueryable();
                }
                else
                {
                    var userList = new List <UsersView>(100);

                    var departments = DepartmentDbAction.GetDepartments(filter.Where.UserId);

                    foreach (var department in departments)
                    {
                        var users = DepartmentUserDbAction.GetUsersInDepartment(department.DeparentId, true);
                        userList.AddRange(users);
                    }

                    query = userList.AsQueryable();
                }

                if (!string.IsNullOrWhiteSpace(filter.Where.TrueName))
                {
                    query = query.Where(n => n.TrueName != null && n.TrueName.Contains(filter.Where.TrueName));
                }

                if (!string.IsNullOrWhiteSpace(filter.Where.Ename))
                {
                    query = query.Where(n => n.Ename != null && n.Ename.Contains(filter.Where.Ename));
                }

                if (!string.IsNullOrWhiteSpace(filter.Where.WorkNo))
                {
                    query = query.Where(n => n.WorkNo != null && n.WorkNo.Contains(filter.Where.WorkNo));
                }

                response = new SoaDataPageResponse <UsersView> {
                    Count = query.Count()
                };

                query = !string.IsNullOrWhiteSpace(filter.OrderBy) ? query.SortBy(filter.OrderBy + " " + filter.SortCol) : query.OrderByDescending(n => n.CreateTime);

                response.Body = query.Skip((filter.PageIndex - 1) * filter.PageSize).Take(filter.PageSize).ToList();
            }

            foreach (var user in response.Body)
            {
                user.RoleNames = string.Join(",", UserRolesDbAction.GetUserRoleNames(user.UserID));
            }

            return(response);
        }
Esempio n. 15
0
        public static SoaDataPage <T> SetRequestPage <T>(T obj)
        {
            SoaDataPage <T> mr = new SoaDataPage <T>();

            return(mr);
        }