Beispiel #1
0
 public void RemoveDescendant(GroupInfo group)
 {
     if (group != null && Childs.Remove(group))
     {
         group.Parent = null;
     }
 }
Beispiel #2
0
 public void AddDescendant(GroupInfo group)
 {
     if (group != null && !Childs.Contains(group))
     {
         group.Parent = this;
         group.CategoryID = CategoryID;
         Childs.Add(group);
     }
 }
 ///<summary>
 ///</summary>
 ///<param name="group"></param>
 ///<param name="includeMembers"></param>
 public GroupWrapperFull(GroupInfo group, bool includeMembers)
 {
     Id = group.ID;
     Category = group.CategoryID;
     Parent = group.Parent!=null?group.Parent.ID:Guid.Empty;
     Name = group.Name;
     Manager = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(Core.CoreContext.UserManager.GetDepartmentManager(group.ID)));
     if (includeMembers)
     {
         Members = new List<EmployeeWraper>(Core.CoreContext.UserManager.GetUsersByGroup(group.ID).Select(x=>EmployeeWraper.Get(x)));
     }
 }
        private TreeNode AddNode(GroupInfo group)
        {
            TreeNode node = new TreeNode(group.Name.HtmlEncode());

            node.ToolTip = group.Description.HtmlEncode();
            node.Expanded = true;
            node.NavigateUrl = GetLinkByGuid(group.ID);
            foreach (var _group in group.Descendants.OrderBy(g => g.Name))
            {
                node.ChildNodes.Add(AddNode(_group));
            }

            return node;
        }
Beispiel #5
0
 public MyGroup(GroupInfo group)
 {
     Id = group.ID;
     Title = HttpUtility.HtmlEncode(group.Name);
 }
 public CorporateBlogSecObject(GroupInfo groupInfo)
     : base(groupInfo.ID, typeof(CorporateBlogSecObject))
 {
     this.groupInfo = groupInfo;
 }
        private void FillChildGroups(GroupInfo groupInfo)
        {
            var users = new List<UserInfo>(CoreContext.UserManager.GetUsersByGroup(groupInfo.ID));
            users.RemoveAll(ui => (DisabledUsers.Find(dui => dui.Equals(ui.ID)) != Guid.Empty));
            users = users.SortByUserName();

            if (users.Count > 0)
            {
                var userGroup = new UserGroup { Group = groupInfo };
                _userGroups.Add(userGroup);
                foreach (var u in users)
                {
                    userGroup.Users.Add(u);
                }
            }
        }
 public GroupWrapperSummary(GroupInfo group)
 {
     Id = group.ID;
     Name = group.Name;
     Manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(group.ID)).UserName;
 }
 protected string GetContainGroupUrl(GroupInfo group)
 {
     return GetLinkByGuid(group.ID);
 }
Beispiel #10
0
 private static void TransferUserToDepartment(Guid userId, GroupInfo group, bool setAsManager)
 {
     if (CoreContext.UserManager.UserExists(userId) || userId == Guid.Empty)
     {
         if (setAsManager)
         {
             CoreContext.UserManager.SetDepartmentManager(group.ID, userId);
         }
         CoreContext.UserManager.AddUserIntoGroup(userId, group.ID);
     }
 }
 private void AppendGroupsWithChild(List<GroupInfo> groups, GroupInfo group)
 {
     groups.Add(group);
     foreach (var g in group.Descendants)
         AppendGroupsWithChild(groups, g);
 }
 protected string GetMasterRenderLink(GroupInfo group)
 {
     var pid = CommonLinkUtility.GetProductID();
     var dephead = CoreContext.UserManager.GetUsers((CoreContext.UserManager.GetDepartmentManager(group.ID)));
     return dephead == null || dephead == Constants.LostUser ? "" : dephead.RenderProfileLink(pid);
 }
Beispiel #13
0
 private static void RemoveUserFromDepartment(Guid userId, GroupInfo @group)
 {
     if (!CoreContext.UserManager.UserExists(userId)) return;
     
     var user = CoreContext.UserManager.GetUsers(userId);
     CoreContext.UserManager.RemoveUserFromGroup(user.ID, @group.ID);
     CoreContext.UserManager.SaveUserInfo(user);
 }
 public List<GroupInfo> GetDiscoveredGroupsByAttributes(LDAPSupportSettings settings)
 {
     if (settings.GroupMembership)
     {
         if (DomainGroups == null)
         {
             DomainGroups = ADDomain.GetGroupsByParameter(settings);
         }
         if (DomainGroups != null)
         {
             var groups = new List<GroupInfo>(DomainGroups.Count);
             var removedGroups = new List<LDAPGroup>();
             foreach (var domainGroup in DomainGroups)
             {
                 var lastId = domainGroup.Sid.Value.Split(LAST_HYPHEN).Last();
                 if (lastId != PRIMARY_GROUP)
                 {
                     var members = ADDomain.GetGroupAttribute(domainGroup, settings.GroupAttribute);
                     if (members == null || members.Value == null)
                     {
                         removedGroups.Add(domainGroup);
                         continue;
                     }
                 }
                 var groupInfo = new GroupInfo
                 {
                     Name = domainGroup.Name,
                     Sid = domainGroup.Sid.Value
                 };
                 // Domain Users - primary group
                 if (domainGroup.Sid.Value.Split(LAST_HYPHEN).Last() == PRIMARY_GROUP)
                 {
                     _primaryGroup = groupInfo;
                 }
                 if (CoreContext.GroupManager.GetGroupInfoBySid(groupInfo.Sid).ID == Core.Users.Constants.LostGroupInfo.ID)
                 {
                     groups.Add(groupInfo);
                 }
             }
             foreach (var domainGroup in removedGroups)
             {
                 if (DomainGroups.Contains(domainGroup))
                 {
                     DomainGroups.Remove(domainGroup);
                 }
             }
             return groups;
         }
     }
     return null;
 }
 private static IEnumerable<GroupInfo> GetChildDepartments(GroupInfo dep)
 {
     return Enumerable.Empty<GroupInfo>();
 }
        private void FillChildGroups(GroupInfo groupInfo)
        {
            var users = new List<UserInfo>(CoreContext.UserManager.GetUsersByGroup(groupInfo.ID));
            users.RemoveAll(ui => (DisabledUsers.Find(dui => dui.Equals(ui.ID)) != Guid.Empty));
            users = users.SortByUserName();

            if (users.Count > 0)
            {
                var userGroup = new UserGroup {Group = groupInfo};
                _userGroups.Add(userGroup);


                foreach (var u in users)
                {
                    userGroup.Users.Add(new UserItem
                                            {
                                                UserInfo = u,
                                                Selected = (SelectedUsers.Find(sui => sui.Equals(u.ID)) != Guid.Empty)
                                            });
                }
            }

            foreach (var g in groupInfo.Descendants)
            {
                FillChildGroups(g);
            }
        }
Beispiel #17
0
        private static void TransferUserToDepartment(Guid userId, GroupInfo @group, bool setAsManager)
        {
            if (CoreContext.UserManager.UserExists(userId))
            {
                if (setAsManager)
                    CoreContext.UserManager.SetDepartmentManager(group.ID, userId);

                var manager = CoreContext.UserManager.GetUsers(userId);
                UserManagerWrapper.TransferUser2Department(manager.ID, group.ID);
            }
        }
Beispiel #18
0
 private static void TransferUserToDepartment(Guid userId, GroupInfo group, bool setAsManager)
 {
     if (!CoreContext.UserManager.UserExists(userId) && userId != Guid.Empty) return;
     
     if (setAsManager)
     {
         CoreContext.UserManager.SetDepartmentManager(@group.ID, userId);
     }
     CoreContext.UserManager.AddUserIntoGroup(userId, @group.ID);
 }
        public GroupInfo SaveGroupInfo(GroupInfo g)
        {
            if (Constants.LostGroupInfo.Equals(g)) return Constants.LostGroupInfo;
            if (Constants.BuildinGroups.Any(b => b.ID == g.ID)) return Constants.BuildinGroups.Single(b => b.ID == g.ID);
            SecurityContext.DemandPermissions(new[] { Constants.Action_EditGroups, Constants.Action_EditAz });

            var newGroup = userService.SaveGroup(CoreContext.TenantManager.GetCurrentTenant().TenantId, ToGroup(g));
            return GetGroupInfo(newGroup.Id);
        }
 protected string GetGroupName(GroupInfo group)
 {
     return group.Name.HtmlEncode();
 }
 private void RecursiveAddChildGroups(GroupInfo parent, List<GroupInfo> result)
 {
     if (parent == null || parent.Descendants == null) return;
     foreach (var group in parent.Descendants)
     {
         if (!result.Contains(group)) result.Add(group);
         RecursiveAddChildGroups(group, result);
     }
 }
 protected string GetContainGroupCaption(GroupInfo group)
 {
     return string.Format(Resources.Resource.DepartmentHeadCount, CoreContext.UserManager.GetUsersByGroup(group.ID).Length);
 }
 private IEnumerable<GroupInfo> GetGroupsInternal()
 {
     var groupsInfo = new Dictionary<Guid, GroupInfo>();
     var groups = userService.GetGroups(CoreContext.TenantManager.GetCurrentTenant().TenantId, default(DateTime));
     foreach (var g in groups.Values.Where(g => !g.Removed).OrderBy(g => g.ParentId))
     {
         var gi = new GroupInfo
         {
             ID = g.Id,
             Name = g.Name,
             CategoryID = g.CategoryId,
         };
         if (g.ParentId != Guid.Empty && groupsInfo.ContainsKey(g.ParentId))
         {
             groupsInfo[g.ParentId].AddDescendant(gi);
         }
         groupsInfo[gi.ID] = gi;
     }
     return groupsInfo.Values.Concat(Constants.BuildinGroups);
 }
 private Group ToGroup(GroupInfo g)
 {
     if (g == null) return null;
     return new Group
     {
         Id = g.ID,
         Name = g.Name,
         ParentId = g.Parent != null ? g.Parent.ID : Guid.Empty,
         CategoryId = g.CategoryID,
     };
 }
Beispiel #25
0
        private List<GroupInfo> GetChildDepartments(GroupInfo dep)
        {
            var deps = new List<GroupInfo>();
            foreach (var childDep in dep.Descendants)
            {
                deps.Add(childDep);
                deps.AddRange(GetChildDepartments(childDep));
            }

            return deps;
        }