示例#1
0
        public int Update(string string_0, string title, string imgsrc, string linkUrl)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(this.GetPath());
            XmlNodeList childNodes = xmlDocument.SelectSingleNode("ads").ChildNodes;

            foreach (XmlNode xmlNode in childNodes)
            {
                XmlElement xmlElement = (XmlElement)xmlNode;
                if (xmlElement.GetAttribute("id") == string_0.Replace("'", ""))
                {
                    xmlElement.SetAttribute("title", title);
                    xmlElement.SetAttribute("imgsrc", imgsrc);
                    xmlElement.SetAttribute("href", linkUrl);
                    break;
                }
            }
            int result;

            try
            {
                xmlDocument.Save(this.GetPath());
                DefaultAdvertismentOperate.ResetDe();
                result = 1;
            }
            catch (Exception)
            {
                result = 0;
            }
            return(result);
        }
示例#2
0
        public int Delete(string guids)
        {
            string[] array = guids.Replace("'", "").Split(new char[]
            {
                ','
            });
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(this.GetPath());
            XmlNodeList childNodes = xmlDocument.SelectSingleNode("ads").ChildNodes;

            for (int i = 0; i < array.Length; i++)
            {
                foreach (XmlNode xmlNode in childNodes)
                {
                    XmlElement xmlElement = (XmlElement)xmlNode;
                    if (xmlElement.GetAttribute("id") == array[i])
                    {
                        xmlDocument.SelectSingleNode("ads").RemoveChild(xmlNode);
                        break;
                    }
                }
            }
            int result;

            try
            {
                xmlDocument.Save(this.GetPath());
                DefaultAdvertismentOperate.ResetDe();
                result = 1;
            }
            catch (Exception)
            {
                result = 0;
            }
            return(result);
        }