Пример #1
0
        public static UserPattern CreateUserPattern(string userpatternid, Role role, string comments, string defaultFormPattern, List <string> users)
        {
            UserPattern obj = new UserPattern();

            obj.Userpatternid      = userpatternid;
            obj.Role               = role;
            obj.Comments           = comments;
            obj.Users              = users;
            obj.CompanyId          = UserAdminConstants.CompanyName;
            obj.defaultFormPattern = defaultFormPattern;
            return(obj);
        }
Пример #2
0
        public XmlNode Searialize(XmlDocument document)
        {
            UserPattern obj  = this;
            XmlDocument doc  = document;
            XmlNode     node = null;

            node = doc.CreateNode(XmlNodeType.Element, "UserPattern", null);

            XmlAttribute userpatternidatt = doc.CreateAttribute("userpatternid");

            userpatternidatt.Value = obj.Userpatternid;
            node.Attributes.Append(userpatternidatt);

            XmlAttribute companyIdAtt = doc.CreateAttribute("CompanyId");

            companyIdAtt.Value = this.CompanyId;
            node.Attributes.Append(companyIdAtt);

            XmlAttribute defaultformpatternAtt = doc.CreateAttribute("defaultformpattern");

            defaultformpatternAtt.Value = this.DefaultFormPattern;
            node.Attributes.Append(defaultformpatternAtt);

            XmlNode commentsnode = doc.CreateNode(XmlNodeType.Text, "Comments", null);

            commentsnode.Value = obj.Comments;
            node.AppendChild(commentsnode);

            node.AppendChild(role.SearializeRole(doc, true));

            XmlNode usersnode = doc.CreateNode(XmlNodeType.Element, "Users", null);

            foreach (string user in obj.Users)
            {
                XmlNode      usernode  = doc.CreateNode(XmlNodeType.Element, "User", null);
                XmlAttribute useridatt = doc.CreateAttribute("userid");
                useridatt.Value = user;
                usernode.Attributes.Append(useridatt);
                usersnode.AppendChild(usernode);
            }

            node.AppendChild(usersnode);

            return(node);
        }
Пример #3
0
        public static UserPattern Desearialize(XmlNode node)
        {
            string        userpatternid, companyId, comments = " ", defaultformpattern = "";
            List <string> users = null;
            Role          role  = null;

            try
            {
                if (node != null)
                {
                    userpatternid = node.Attributes["userpatternid"].Value;
                    if (node.Attributes["companyId"] != null)
                    {
                        companyId = node.Attributes["CompanyId"].Value;
                    }
                    else
                    {
                        companyId = UserAdminConstants.CompanyName;
                    }

                    if (node.Attributes["defaultformpattern"] != null)
                    {
                        defaultformpattern = node.Attributes["defaultformpattern"].Value;
                    }
                    else
                    {
                        defaultformpattern = "";
                    }

                    users = new List <string>();
                    foreach (XmlNode cnode in node.ChildNodes)
                    {
                        if (cnode.NodeType == XmlNodeType.Text)
                        {
                            comments = cnode.Value;
                        }
                        else if (cnode.NodeType == XmlNodeType.Element)
                        {
                            if (cnode.Name == "Role")
                            {
                                role = Role.DesearializeRole(cnode);
                            }
                            if (cnode.Name == "Users")
                            {
                                foreach (XmlNode cusernode in cnode.ChildNodes)
                                {
                                    users.Add(cusernode.Attributes["userid"].Value);
                                }
                            }
                        }
                    }
                    return(UserPattern.CreateUserPattern(userpatternid, role, comments, defaultformpattern, users));
                }
                return(null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(null);
            }
        }