Пример #1
0
        public void AddLogin(string groupName, string login)
        {
            if (string.IsNullOrEmpty(login) || groupADSet == null)
            {
                return;
            }

            GroupAD groupAD = groupADSet.FirstOrDefault(_ => _.Name == groupName);

            if (groupAD == null)
            {
                groupAD = new GroupAD()
                {
                    Name = groupName, UserSet = new List <UserAD>()
                    {
                    }
                };
                groupAD.UserSet.Add(new UserAD()
                {
                    Login = login
                });
                groupADSet.Add(groupAD);
            }
            else
            {
                if (!string.IsNullOrEmpty(GetGroupNameByLogin(login)))
                {
                    groupAD.UserSet.Add(new UserAD()
                    {
                        Login = login
                    });
                }
            }
        }
Пример #2
0
        public GroupADSet GetUsersByGroupAd(List <string> GroupSet)
        {
            if (GroupSet == null || GroupSet.Count == 0)
            {
                return(null);
            }

            string cacheKey = string.Format("GetUsersByGroupAd_{0}", string.Join(",", GroupSet));

            return(_cacheManager.Resolve(cacheKey, () =>
            {
                GroupADSet _groupAD = new GroupADSet();
                _groupAD.groupADSet = new List <GroupAD>();
                foreach (var currentGroupAd in GroupSet)
                {
                    var users = GetUsersByGroupAd(currentGroupAd);
                    GroupAD groupAd = new GroupAD(currentGroupAd, users);
                    _groupAD.groupADSet.Add(groupAd);
                }
                return _groupAD;
            }));
        }