Ejemplo n.º 1
0
        /// <summary>
        /// 添加节点
        /// </summary>
        /// <param name="parentName">父节点名称</param>
        /// <param name="NodeName">子节点名称</param>
        /// <param name="lst">属性集合</param>
        public void AddNode(string parentName, string NodeName, List <NodeProp> lst)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(FilePath);                                           //加载xml文件,路径未指定时默认在当前项目环境下
            XmlNode parentNode = xmlDoc.SelectSingleNode("//" + parentName); //取得父亲节点

            if (parentNode == null)
            {
                //添加ParentNode节点
                XmlElement root = xmlDoc.DocumentElement;
                parentNode = xmlDoc.CreateElement(parentName);
                root.AppendChild(parentNode);
            }

            XmlElement childNode = xmlDoc.CreateElement(NodeName);

            parentNode.AppendChild(childNode);
            if (lst != null && lst.Count > 0)
            {
                for (int i = 0; i < lst.Count; i++)
                {
                    if (lst[i].IsEncrypt)
                    {
                        childNode.SetAttribute(lst[i].NodeName, StringSecurity.DESEncrypt(lst[i].NodeValue));
                    }
                    else
                    {
                        childNode.SetAttribute(lst[i].NodeName, lst[i].NodeValue);
                    }
                }
            }
            xmlDoc.Save(FilePath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新节点
        /// </summary>
        /// <param name="parentName">父节点名称</param>
        /// <param name="NodeName">子节点名称</param>
        public string UpdateNode(string parentName, string NodeName, List <NodeProp> lst)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(FilePath);                                           //加载xml文件,路径未指定时默认在当前项目环境下
            XmlNode parentNode = xmlDoc.SelectSingleNode("//" + parentName); //取得父亲节点

            if (parentNode == null)
            {
                return("未在该XML文件中找到父节点");
            }
            XmlElement childNode = (XmlElement)parentNode.SelectSingleNode("//" + NodeName);

            if (childNode == null)
            {
                return("未在该XML文件中找到子节点");
            }
            childNode.RemoveAllAttributes();
            if (lst != null && lst.Count > 0)
            {
                for (int i = 0; i < lst.Count; i++)
                {
                    if (lst[i].IsEncrypt)
                    {
                        childNode.SetAttribute(lst[i].NodeName, StringSecurity.DESEncrypt(lst[i].NodeValue));
                    }
                    else
                    {
                        childNode.SetAttribute(lst[i].NodeName, lst[i].NodeValue);
                    }
                }
            }
            xmlDoc.Save(FilePath);
            return("更新成功");
        }
Ejemplo n.º 3
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtcorpid.Text))
     {
         MessageBox.Show("请输入企业id");
         return;
     }
     txtactivte.Text = StringSecurity.MD5Encrypt(StringSecurity.DESEncrypt(txtcorpid.Text) + "EC" + StringSecurity.DESEncrypt("YLTC") + DateTime.Now.Year);
 }
Ejemplo n.º 4
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        try
        {
            if (!loginSuccessfully)
            {
                tbValidCode.Text = "";

                //在Cookie中放置一个随机数用作验证码。
                Response.Cookies["AreYouHuman"].Value = StringSecurity.DESEncrypt(CaptchaImage.GenerateRandomCode());
            }
        }
        catch (Exception ex)
        {
            log.Error(null, ex);
            throw;
        }
    }
Ejemplo n.º 5
0
 private void button2_Click(object sender, EventArgs e)
 {
     textBox4.Text = StringSecurity.DESEncrypt(textBox3.Text);
 }