示例#1
0
 public void AddChild(UserGroupInfo child)
 {
     lock (Children)
     {
         Children.Add(child);
     }
 }
示例#2
0
 public void RemoveChild(UserGroupInfo child)
 {
     lock (Children)
     {
         Children.Remove(child);
     }
 }
示例#3
0
文件: UserInfo.cs 项目: RBSystems/LoT
 public void RemoveChild(UserGroupInfo child)
 {
     lock (Children)
     {
         Children.Remove(child);
     }
 }
示例#4
0
文件: UserInfo.cs 项目: RBSystems/LoT
 public void AddChild(UserGroupInfo child)
 {
     lock (Children)
     {
         Children.Add(child);
     }
 }
示例#5
0
        /// <summary>
        /// Is the other group an ancestor of this one?
        /// </summary>
        public bool IsAncestor(UserGroupInfo other)
        {
            if ((Parent != null) &&
                 (Parent.Equals(other) || Parent.IsAncestor(other)))
                return true;

            return false;
        }
示例#6
0
文件: UserInfo.cs 项目: RBSystems/LoT
        /// <summary>
        /// Is the other group an ancestor of this one?
        /// </summary>
        public bool IsAncestor(UserGroupInfo other)
        {
            if ((Parent != null) &&
                 (Parent.Equals(other) || Parent.IsAncestor(other)))
                return true;

            return false;

        }
示例#7
0
        /// <summary>
        /// Is the other group an ancestor of this one?
        /// </summary>
        public bool IsAncestor(UserGroupInfo other)
        {
            if ((Parent != null) &&
                (Parent.Equals(other) || Parent.IsAncestor(other)))
            {
                return(true);
            }

            return(false);
        }
示例#8
0
文件: UserInfo.cs 项目: RBSystems/LoT
        /// <summary>
        /// Is the other group descendant of this one?
        /// </summary>
        public bool IsDescendant(UserGroupInfo other)
        {
            lock (Children)
            {
                foreach (UserGroupInfo child in Children)
                {
                    if (child.Equals(other) || child.IsDescendant(other))
                        return true;
                }
            }

            return false;
        }
示例#9
0
        /// <summary>
        /// Is the other group descendant of this one?
        /// </summary>
        public bool IsDescendant(UserGroupInfo other)
        {
            lock (Children)
            {
                foreach (UserGroupInfo child in Children)
                {
                    if (child.Equals(other) || child.IsDescendant(other))
                        return true;
                }
            }

            return false;
        }
示例#10
0
 public void SetParent(UserGroupInfo parent)
 {
     this.Parent = parent;
 }
示例#11
0
        private void ReadUserSubTree(XmlElement xmlParent, UserGroupInfo parent)
        {
            foreach (XmlElement xmlChild in xmlParent.ChildNodes)
            {

                UserGroupInfo child;

                //names are case insensitive
                string name = xmlChild.GetAttribute("Name").ToLower();

                if (allGroups.ContainsKey(name))
                    throw new Exception("duplicate usergroup name " + name);

                switch (xmlChild.Name)
                {
                    case "Group":
                        {
                            child = new UserGroupInfo(nextUserOrGroupId, name);
                        }
                        break;
                    case "User":
                        {
                            string password = xmlChild.GetAttribute("Password");
                            string liveId = xmlChild.GetAttribute("LiveId");
                            string LiveIdUniqueUserToken = xmlChild.GetAttribute("LiveIdUniqueUserToken");
                            DateTime activeFrom = DateTime.Parse(xmlChild.GetAttribute("ActiveFrom"));
                            DateTime activeUntil = DateTime.Parse(xmlChild.GetAttribute("ActiveUntil"));

                            child = new UserInfo(nextUserOrGroupId, name, password, activeFrom, activeUntil, liveId, LiveIdUniqueUserToken);

                            if (xmlChild.ChildNodes.Count != 0)
                                throw new Exception("User " + name + " has children");
                        }
                        break;
                    default:
                        throw new Exception("bad node name in users file " + xmlChild.Name);
                }

                AddUserGroup(child, parent, false);
                nextUserOrGroupId++;

                ReadUserSubTree(xmlChild, child);

            }
        }
示例#12
0
文件: UserInfo.cs 项目: RBSystems/LoT
 public void SetParent(UserGroupInfo parent)
 {
     this.Parent = parent;
 }
示例#13
0
        private void WriteUserSubTree(XmlElement xmlParent, UserGroupInfo parent, XmlDocument xmlDoc)
        {
            foreach (UserGroupInfo userGroup in parent.Children)
            {
                XmlElement xmlChild;

                if (userGroup is UserInfo)
                {
                    xmlChild = xmlDoc.CreateElement("User");

                    UserInfo userInfo = (UserInfo)userGroup;
                    xmlChild.SetAttribute("Password", userInfo.Password);
                    xmlChild.SetAttribute("ActiveFrom", userInfo.ActiveFrom.ToString());
                    xmlChild.SetAttribute("ActiveUntil", userInfo.ActiveUntil.ToString());
                    xmlChild.SetAttribute("LiveId", userInfo.LiveId);
                    xmlChild.SetAttribute("LiveIdUniqueUserToken", userInfo.LiveIdUniqueUserToken);
                }
                else
                {
                    xmlChild = xmlDoc.CreateElement("Group");
                }

                xmlChild.SetAttribute("Name", userGroup.Name);

                xmlParent.AppendChild(xmlChild);

                WriteUserSubTree(xmlChild, userGroup, xmlDoc);
            }
        }
示例#14
0
        private void AddUserGroup(UserGroupInfo groupToAdd, UserGroupInfo parent, bool writeToDisk = true)
        {
            //we lock allGroups even when allUsers is being accessed
            lock (allGroups)
            {
                //add to all groups
                allGroups.Add(groupToAdd.Name, groupToAdd);

                //add to all users if this is a user
                if (groupToAdd is UserInfo)
                    allUsers.Add(groupToAdd.Name, (UserInfo)groupToAdd);

                //do the linking up and down
                groupToAdd.SetParent(parent);
                parent.AddChild(groupToAdd);

                if (writeToDisk)
                    WriteUserTree();
            }
        }
示例#15
0
 public bool Equals(UserGroupInfo other)
 {
     return this.Name.Equals(other.Name);
 }
示例#16
0
文件: UserInfo.cs 项目: RBSystems/LoT
 public bool Equals(UserGroupInfo other)
 {
     return this.Name.Equals(other.Name);
 }
示例#17
0
        private void ReadUserTree()
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlReader xmlReader = XmlReader.Create(this.UsersFile, xmlReaderSettings);

            xmlDoc.Load(xmlReader);

            XmlElement rootXml = xmlDoc.FirstChild as XmlElement;

            //names are case insensitive
            string name = rootXml.GetAttribute("Name").ToLower();

            rootGroup = new UserGroupInfo(nextUserOrGroupId, name); 
            
            allGroups.Add(name, rootGroup);

            nextUserOrGroupId++;

            ReadUserSubTree(rootXml, rootGroup);

            xmlReader.Close();
        }