CreateNode() public method

public CreateNode ( System.Xml.XmlNodeType type, string name, string namespaceURI ) : XmlNode
type System.Xml.XmlNodeType
name string
namespaceURI string
return XmlNode
Esempio n. 1
0
 private void SaveAsXML()
 {
     DataTable dt = (DataTable)bindingSource.DataSource;
     XmlDocument doc = new XmlDocument();
     XmlNode rootNode = doc.CreateNode(XmlNodeType.Element,"root", null);
     foreach (DataRow row in dt.Rows)
     {
         object[] values = row.ItemArray;
         XmlNode prop = doc.CreateNode(XmlNodeType.Element, "propertyset", null);
         XmlNode name = doc.CreateNode(XmlNodeType.Element, "name", null);
         XmlNode value = doc.CreateNode(XmlNodeType.Element, "value", null);
         name.InnerText = (string)values[0];
         value.InnerText = (string)values[1];
         prop.AppendChild(name);
         prop.AppendChild(value);
         rootNode.AppendChild(prop);
     }
     doc.AppendChild(rootNode);
     string file = Path.Combine(GetExecutingDir(), xmlPropertyFileName);
     if (File.Exists(file))
     {
         File.Delete(file);
     }
     doc.Save(file);
     doc.RemoveAll();
     doc = null;
 }
Esempio n. 2
0
        /// <summary>
        /// Stores the numeric option as an XML Node (calls base implementation)
        /// </summary>
        /// <param name="doc">The XML document to which the node will be added</param>
        /// <returns>The XML node containing the information of numeric option</returns>
        internal new XmlNode saveXML(System.Xml.XmlDocument doc)
        {
            XmlNode node = base.saveXML(doc);

            //Min_Value
            XmlNode minNode = doc.CreateNode(XmlNodeType.Element, "minValue", "");

            minNode.InnerText = this.min_value.ToString();
            node.AppendChild(minNode);

            //Max_Value
            XmlNode maxNode = doc.CreateNode(XmlNodeType.Element, "maxValue", "");

            maxNode.InnerText = this.max_value.ToString();
            node.AppendChild(maxNode);

            if (this.stepFunction != null)
            {
                //StepFunction
                XmlNode stepNode = doc.CreateNode(XmlNodeType.Element, "stepFunction", "");
                stepNode.InnerText = this.stepFunction.ToString();
                node.AppendChild(stepNode);
            }

            if (values != null)
            {
                //Values
                XmlNode valuesNode = doc.CreateNode(XmlNodeType.Element, "values", "");
                valuesNode.InnerText = values.ToString();
                node.AppendChild(valuesNode);
            }
            return(node);
        }
        public XmlElement ToXml(XmlDocument document)
        {
            if (string.IsNullOrEmpty(program)) throw new InvalidOperationException("There must be a program node.");

            XmlElement alertNode = document.CreateElement("idmef:OverflowAlert", "http://iana.org/idmef");

            XmlElement subNode = document.CreateElement("idmef:program", "http://iana.org/idmef");
            XmlNode subNodeText = document
                .CreateNode(XmlNodeType.Text, "idmef", "program", "http://iana.org/idmef");
            subNodeText.Value = program;
            subNode.AppendChild(subNodeText);
            alertNode.AppendChild(subNode);
            if (size != null)
            {
                subNode = document.CreateElement("idmef:size", "http://iana.org/idmef");
                subNodeText = document.CreateNode(XmlNodeType.Text, "idmef", "size", "http://iana.org/idmef");
                subNodeText.Value = size.ToString();
                subNode.AppendChild(subNodeText);
                alertNode.AppendChild(subNode);
            }
            if ((buffer != null) && (buffer.Length > 0))
            {
                subNode = document.CreateElement("idmef:buffer", "http://iana.org/idmef");
                subNodeText = document.CreateNode(XmlNodeType.Text, "idmef", "buffer", "http://iana.org/idmef");
                subNodeText.Value = Convert.ToBase64String(buffer);
                subNode.AppendChild(subNodeText);
                alertNode.AppendChild(subNode);
            }

            return alertNode;
        }
Esempio n. 4
0
        public XmlElement ToXml(XmlDocument document)
        {
            XmlElement addressNode = document.CreateElement("idmef:Address", "http://iana.org/idmef");

            addressNode.SetAttribute("ident", ident);
            addressNode.SetAttribute("category", EnumDescription.GetEnumDescription(category));
            if (!string.IsNullOrEmpty(vlanName)) addressNode.SetAttribute("vlan-name", vlanName);
            if (vlanNum != null) addressNode.SetAttribute("vlan-num", vlanNum.ToString());

            if (string.IsNullOrEmpty(address)) throw new InvalidOperationException("Address must have an address node.");
            XmlElement addressSubNode = document.CreateElement("idmef:address", "http://iana.org/idmef");
            XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "address", "http://iana.org/idmef");
            subNode.Value = address;
            addressSubNode.AppendChild(subNode);
            addressNode.AppendChild(addressSubNode);

            if (!string.IsNullOrEmpty(netmask))
            {
                addressSubNode = document.CreateElement("idmef:netmask", "http://iana.org/idmef");
                subNode = document.CreateNode(XmlNodeType.Text, "idmef", "netmask", "http://iana.org/idmef");
                subNode.Value = netmask;
                addressSubNode.AppendChild(subNode);
                addressNode.AppendChild(addressSubNode);
            }

            return addressNode;
        }
Esempio n. 5
0
 private XmlNode Yandex()
 {
     if (DateTime.Now >= _cTemplate.dtNext)
     {
         int nBuild;
         XmlNode cResult;
         XmlNode[] aItems;
         XmlDocument cXmlDocument = new XmlDocument();
         cXmlDocument.LoadXml((new System.Net.WebClient() { Encoding = Encoding.UTF8 }).DownloadString("http://news.yandex.ru/index.rss"));
         nBuild = cXmlDocument.NodeGet("rss/channel/lastBuildDate").InnerText.GetHashCode();
         if (_cTemplate.nBuild != nBuild)
         {
             aItems = cXmlDocument.NodesGet("rss/channel/item", false);
             if (null != aItems)
             {
                 _cTemplate.nBuild = nBuild;
                 cXmlDocument = new XmlDocument();
                 cResult = cXmlDocument.CreateNode(XmlNodeType.Element, "result", null);
                 XmlNode cXNItem;
                 foreach (string sItem in aItems.Select(o => o.NodeGet("title").InnerText).ToArray())
                 {
                     cXNItem = cXmlDocument.CreateNode(XmlNodeType.Element, "item", null);
                     cXNItem.InnerText = sItem.StripTags() + ".    ";
                     cResult.AppendChild(cXNItem);
                 }
                 _cTemplate.cValue = cResult;
                 _cTemplate.dt = DateTime.Now;
             }
             else
                 (new Logger()).WriteWarning("can't get any news from rss");
         }
     }
     return _cTemplate.cValue;
 }
Esempio n. 6
0
        public XmlElement ToXml(XmlDocument document)
        {
            XmlElement addressNode = document.CreateElement("idmef:UserId", "http://iana.org/idmef");

            addressNode.SetAttribute("ident", ident);
            addressNode.SetAttribute("type", EnumDescription.GetEnumDescription(type));
            if (!string.IsNullOrEmpty(tty)) addressNode.SetAttribute("tty", tty);

            if (!string.IsNullOrEmpty(name))
            {
                XmlElement addressSubNode = document.CreateElement("idmef:name", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "name", "http://iana.org/idmef");
                subNode.Value = name;
                addressSubNode.AppendChild(subNode);
                addressNode.AppendChild(addressSubNode);
            }
            if (number != null)
            {
                XmlElement addressSubNode = document.CreateElement("idmef:number", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "number", "http://iana.org/idmef");
                subNode.Value = number.ToString();
                addressSubNode.AppendChild(subNode);
                addressNode.AppendChild(addressSubNode);
            }

            return addressNode;
        }
Esempio n. 7
0
 public string AddNewElement(string filePathName, string parent)
 {
     //Here we load the XML file into the memory
     XmlDocument xmlDocument = new XmlDocument();
     xmlDocument.Load(filePathName);
     //Here we create employee node without any namespace
     XmlNode employeeNode = xmlDocument.CreateNode(XmlNodeType.Element, "employee", null);
     //Here we define an attribute and add it to the employee node
     XmlAttribute attribute = xmlDocument.CreateAttribute("id");
     attribute.Value = "e8000";
     employeeNode.Attributes.Append(attribute);
     //Here we create name node without any namespace
     XmlNode nameNode = xmlDocument.CreateNode(XmlNodeType.Element, "name", null);
     nameNode.InnerText = "Arash";
     employeeNode.AppendChild(nameNode);
     //Here we create job node without any namespace
     XmlNode jobNode = xmlDocument.CreateNode(XmlNodeType.Element, "job", null);
     jobNode.InnerText = "Software developer";
     employeeNode.AppendChild(jobNode);
     //Here we select the first element with the name specified by variable parent and
     //append the newly created child to it.
     xmlDocument.SelectSingleNode("//" + parent).AppendChild(employeeNode);
     //Here we save changes to the XML tree permanently.
     xmlDocument.Save(filePathName);
     //Here we retun some information about the file.
     return GetFileInfo(filePathName);
 }
Esempio n. 8
0
        /// <summary>
        /// Stores the binary options as an XML node (calling base implementation)
        /// </summary>
        /// <param name="doc">The XML document to which the node will be added</param>
        /// <returns>The XML node containing the options information</returns>
        internal XmlNode saveXML(System.Xml.XmlDocument doc)
        {
            XmlNode node = base.saveXML(doc);

            //Default value
            XmlNode defaultNode = doc.CreateNode(XmlNodeType.Element, "defaultValue", "");

            if (this.DefaultValue == BinaryValue.Selected)
            {
                defaultNode.InnerText = "Selected";
            }
            else
            {
                defaultNode.InnerText = "Deselected";
            }
            node.AppendChild(defaultNode);

            //Optional
            XmlNode optionalNode = doc.CreateNode(XmlNodeType.Element, "optional", "");

            if (this.Optional)
            {
                optionalNode.InnerText = "True";
            }
            else
            {
                optionalNode.InnerText = "False";
            }
            node.AppendChild(optionalNode);

            return(node);
        }
    //
    //  METHOD      : BuildDetail
    //  DESCRIPTION : Create bulk of error log, parameters fill in the specific details like error type, variable name, and explanation
    //  PARAMETERS  : string name                 - Variable name
    //                string type                 - Error type
    //                string explanation          - Explanation of error
    //  RETURNS     : XmlNode node                - XML containing constructed log.
    //
    public XmlNode BuildDetail(string name, string type, string explanation)
    {
        XmlDocument  doc  = new System.Xml.XmlDocument();
        XmlNode      node = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
        XmlNode      details;
        XmlAttribute nameAttr;
        XmlAttribute errorTypeAttr;
        XmlAttribute explanationAttr;

        details               = doc.CreateNode(XmlNodeType.Element, "ParameterError", "http://localhost/LoanService");
        nameAttr              = doc.CreateAttribute("s", "name", "http://localhost/LoanService");
        nameAttr.Value        = name;
        errorTypeAttr         = doc.CreateAttribute("s", "errorType", "http://localhost/LoanService");
        errorTypeAttr.Value   = type;
        explanationAttr       = doc.CreateAttribute("s", "explanation", "http://localhost/LoanService");
        explanationAttr.Value = explanation;

        details.Attributes.Append(nameAttr);
        details.Attributes.Append(errorTypeAttr);
        details.Attributes.Append(explanationAttr);

        node.AppendChild(details);

        return(node);
    }
        public static XmlDocument CreateXMLDocument()
        {
            XmlDocument doc = new XmlDocument();
            XmlNode docNode = doc.CreateXmlDeclaration("1.0", null, null);
            doc.AppendChild(docNode);

            XmlNode configurationNode = doc.CreateElement("Configuration");
            doc.AppendChild(configurationNode);

            XmlNode hostNode = doc.CreateNode(XmlNodeType.Element, "host", "");
            hostNode.InnerText = "https://testserver.datacash.com/Transaction";
            XmlNode timeoutNode = doc.CreateNode(XmlNodeType.Element, "timeout", "");
            timeoutNode.InnerText = "500";
            XmlNode proxyNode = doc.CreateNode(XmlNodeType.Element, "proxy", "");
            proxyNode.InnerText = "http://bloxx.dfguk.com:8080";
            XmlNode logfileNode = doc.CreateNode(XmlNodeType.Element, "logfile", "");
            logfileNode.InnerText = @"C:\Inetpub\wwwroot\WSDataCash\log.txt";
            XmlNode loggingNode = doc.CreateNode(XmlNodeType.Element, "logging", "");
            loggingNode.InnerText = "1";

            configurationNode.AppendChild(hostNode);
            configurationNode.AppendChild(timeoutNode);
            configurationNode.AppendChild(proxyNode);
            configurationNode.AppendChild(logfileNode);
            configurationNode.AppendChild(loggingNode);

            return doc;
        }
Esempio n. 11
0
		protected override void LoadStaticConfiguration()
		{
			base.LoadStaticConfiguration();

			Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            string filename = config.FilePath;

            database0 = database1 = "test";

            XmlDocument configDoc = new XmlDocument();
            configDoc.PreserveWhitespace = true;
            configDoc.Load(filename);
            XmlElement configNode = configDoc["configuration"];
            configNode.RemoveAll();

            XmlElement systemData = (XmlElement)configDoc.CreateNode(XmlNodeType.Element, "system.data", "");
            XmlElement dbFactories = (XmlElement)configDoc.CreateNode(XmlNodeType.Element, "DbProviderFactories", "");
            XmlElement provider = (XmlElement)configDoc.CreateNode(XmlNodeType.Element, "add", "");
            provider.SetAttribute("name", "MySQL Data Provider");
            provider.SetAttribute("description", ".Net Framework Data Provider for MySQL");
            provider.SetAttribute("invariant", "MySql.Data.MySqlClient");

            string fullname = String.Format("MySql.Data.MySqlClient.MySqlClientFactory, {0}",
                typeof(MySqlConnection).Assembly.FullName);
            provider.SetAttribute("type", fullname);

            dbFactories.AppendChild(provider);
            systemData.AppendChild(dbFactories);
            configNode.AppendChild(systemData);
            configDoc.Save(filename);

			ConfigurationManager.RefreshSection("system.data");
		}
Esempio n. 12
0
        public XmlSecurityRatings()
        {
            _document = new XmlDocument();

            /// _securityRatings = _document.CreateNode(XmlNodeType.Element, "SecurityRatings", XmlSecurityRatings._securityNs);
            _securityRatings = _document.CreateNode(XmlNodeType.Element, "SecurityRatings", null);
            _document.AppendChild(_securityRatings);

            _highSecurity = _document.CreateNode(XmlNodeType.Element, "High", null);
            _securityRatings.AppendChild(_highSecurity);
            appendAttribute(_highSecurity, @"title", @"HIGH RISK");
            appendAttribute(_highSecurity, @"comment", @"This document contains high risk elements");
            appendAttribute(_highSecurity, @"color", @"#B14343");
            appendAttribute(_highSecurity, @"include-in-summary", @"yes");
            appendAttribute(_highSecurity, @"hiddendata", @"This document contains high risk hidden data");
            appendAttribute(_highSecurity, @"contentpolicy", @"This document contains high risk content policy violations");

            _mediumSecurity = _document.CreateNode(XmlNodeType.Element, "Medium", null);
            _securityRatings.AppendChild(_mediumSecurity);
            appendAttribute(_mediumSecurity, @"title", @"MEDIUM RISK");
            appendAttribute(_mediumSecurity, @"comment", @"This document contains medium risk elements");
            appendAttribute(_mediumSecurity, @"color", @"#F0C060");
            appendAttribute(_mediumSecurity, @"include-in-summary", @"yes");
            appendAttribute(_mediumSecurity, @"hiddendata", @"This document contains medium risk hidden data");
            appendAttribute(_mediumSecurity, @"contentpolicy", @"This document contains medium risk content policy violations");

            _lowSecurity = _document.CreateNode(XmlNodeType.Element, "Low", null);
            _securityRatings.AppendChild(_lowSecurity);
            appendAttribute(_lowSecurity, @"title", @"LOW RISK");
            appendAttribute(_lowSecurity, @"comment", @"This document contains normal elements");
            appendAttribute(_lowSecurity, @"color", @"#4E7C49");
            appendAttribute(_lowSecurity, @"include-in-summary", @"no");
            appendAttribute(_lowSecurity, @"hiddendata", @"This document contains low risk hidden data");
            appendAttribute(_lowSecurity, @"contentpolicy", @"This document contains low risk content policy violations");
        }
Esempio n. 13
0
        public XmlElement ToXml(XmlDocument document)
        {
            XmlElement nodeNode = document.CreateElement("idmef:Node", "http://iana.org/idmef");

            nodeNode.SetAttribute("ident", ident);
            nodeNode.SetAttribute("category", EnumDescription.GetEnumDescription(category));

            if (!string.IsNullOrEmpty(location))
            {
                XmlElement nodeSubNode = document.CreateElement("idmef:location", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "location", "http://iana.org/idmef");
                subNode.Value = location;
                nodeSubNode.AppendChild(subNode);
                nodeNode.AppendChild(nodeSubNode);
            }
            if (!string.IsNullOrEmpty(name))
            {
                XmlElement nodeSubNode = document.CreateElement("idmef:name", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "name", "http://iana.org/idmef");
                subNode.Value = name;
                nodeSubNode.AppendChild(subNode);
                nodeNode.AppendChild(nodeSubNode);
            }
            if ((address != null) && (address.Length > 0))
                foreach (var a in address)
                    if (a != null) nodeNode.AppendChild(a.ToXml(document));

            return nodeNode;
        }
        internal static void Main()
        {
            StreamReader textReader = new StreamReader("../../Person.txt");
            XmlDocument xmlDocument = new XmlDocument();

            XmlNode persons = xmlDocument.CreateNode(XmlNodeType.Element, "persons", string.Empty);

            using (textReader)
            {
                while (!textReader.EndOfStream)
                {
                    XmlNode person = xmlDocument.CreateNode(XmlNodeType.Element, "person", string.Empty);
                    XmlNode personName = xmlDocument.CreateNode(XmlNodeType.Element, "name", string.Empty);
                    XmlNode personAddres = xmlDocument.CreateNode(XmlNodeType.Element, "address", string.Empty);
                    XmlNode personPhone = xmlDocument.CreateNode(XmlNodeType.Element, "phone", string.Empty);

                    personName.InnerText = textReader.ReadLine();
                    personPhone.InnerText = textReader.ReadLine();
                    personAddres.InnerText = textReader.ReadLine();

                    person.AppendChild(personName);
                    person.AppendChild(personAddres);
                    person.AppendChild(personPhone);

                    persons.AppendChild(person);
                }
            }

            xmlDocument.AppendChild(persons);
            xmlDocument.Save("../../saved.xml");
            Console.WriteLine("See results in saved.xml");
        }
Esempio n. 15
0
        public void LoadData()
        {
            lock (this)
            {
                doc = new XmlDocument();
                if (File.Exists(fileName))
                {
                    XmlTextReader reader = new XmlTextReader(fileName);
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    doc.Load(reader);
                    reader.Close();
                }
                else
                {
                    createdFile = true;
                    rootNode = doc.CreateNode(XmlNodeType.Element, "Root", String.Empty);
                    doc.AppendChild(rootNode);
                    configNode = doc.CreateNode(XmlNodeType.Element, "Config", String.Empty);
                    rootNode.AppendChild(configNode);
                }

                LoadDataToClass();

                if (createdFile)
                {
                    Commit();
                }
            }
        }
Esempio n. 16
0
        public void AddAttachmentPlaceHolder(string actualPath, string placeholderPath)
        {
            var placeholderDocument = new XmlDocument();

			placeholderDocument.CreateXmlDeclaration("1.0", "utf-16", "yes");

            XmlNode rootNode = placeholderDocument.CreateNode(XmlNodeType.Element, "ManagedAttachment", string.Empty);
            XmlNode actualPathNode = placeholderDocument.CreateNode(XmlNodeType.Element, "ActualPath", string.Empty);
            XmlNode placeholderNode = placeholderDocument.CreateNode(XmlNodeType.Element, "PlaceholderPath",
                                                                     string.Empty);

            actualPathNode.InnerText = actualPath;
            placeholderNode.InnerText = placeholderPath;

            rootNode.AppendChild(actualPathNode);
            rootNode.AppendChild(placeholderNode);

            placeholderDocument.AppendChild(rootNode);

            using (var ms = new MemoryStream())
            {
                ms.Position = 0;
                placeholderDocument.Save(ms);
                ms.Flush();

                ms.Position = 0;
                var sr = new StreamReader(ms);
                string xml = sr.ReadToEnd();

                string filecontents = LargeAttachmentHelper.FileTag + xml;
				File.WriteAllText(placeholderPath, filecontents, Encoding.Unicode);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Stores the numeric option as an XML Node (calls base implementation)
        /// </summary>
        /// <param name="doc">The XML document to which the node will be added</param>
        /// <returns>The XML node containing the information of numeric option</returns>
        internal XmlNode saveXML(System.Xml.XmlDocument doc)
        {
            XmlNode node = base.saveXML(doc);

            //Min_Value
            XmlNode minNode = doc.CreateNode(XmlNodeType.Element, "minValue", "");

            minNode.InnerText = this.min_value.ToString();
            node.AppendChild(minNode);

            //Max_Value
            XmlNode maxNode = doc.CreateNode(XmlNodeType.Element, "maxValue", "");

            maxNode.InnerText = this.max_value.ToString();
            node.AppendChild(maxNode);

            //StepFunction
            XmlNode stepNode = doc.CreateNode(XmlNodeType.Element, "stepFunction", "");

            stepNode.InnerText = this.stepFunction.ToString();
            node.AppendChild(stepNode);

            //DefaultValue
            XmlNode defNode = doc.CreateNode(XmlNodeType.Element, "defaultValue", "");

            defNode.InnerText = this.defaultValue.ToString();
            node.AppendChild(defNode);

            return(node);
        }
Esempio n. 18
0
        public string CreatingFile(XMLMovieProperties objMovie)
        {
            try
            {
                if (objMovie == null) return null;

                BlobStorageService _blobStorageService = new BlobStorageService();
                XmlDocument documnet = new XmlDocument();

                string fileName = "MovieList-" + objMovie.Month.Substring(0, 3) + "-" + objMovie.Year.ToString() + ".xml";
                string existFileContent = _blobStorageService.GetUploadeXMLFileContent(BlobStorageService.Blob_XMLFileContainer, fileName);

                if (!string.IsNullOrEmpty(existFileContent))
                {
                    documnet.LoadXml(existFileContent);

                    var oldMonth = documnet.SelectSingleNode("Movies/Month[@name='" + objMovie.Month + "']");

                    var oldMovie = oldMonth.SelectSingleNode("Movie[@name='" + objMovie.MovieName + "']");

                    if (oldMovie == null)
                        oldMonth.AppendChild(AddMovieNode(documnet, objMovie));
                    else
                    {
                        oldMonth.RemoveChild(oldMovie);
                        oldMonth.AppendChild(AddMovieNode(documnet, objMovie));
                    }
                }
                else
                {
                    XmlNode root = documnet.CreateNode(XmlNodeType.Element, "Movies", "");

                    XmlAttribute movieYear = documnet.CreateAttribute("year");
                    movieYear.Value = objMovie.Year.ToString();
                    root.Attributes.Append(movieYear);

                    XmlNode month = documnet.CreateNode(XmlNodeType.Element, "Month", "");

                    XmlAttribute monthName = documnet.CreateAttribute("name");
                    monthName.Value = objMovie.Month.ToString();
                    month.Attributes.Append(monthName);

                    month.AppendChild(AddMovieNode(documnet, objMovie));
                    root.AppendChild(month);
                    documnet.AppendChild(root);
                }

                _blobStorageService.UploadXMLFileOnBlob(BlobStorageService.Blob_XMLFileContainer, fileName, documnet.OuterXml);

                return documnet.OuterXml;
                //return fileName;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                return "";
            }
        }
Esempio n. 19
0
    public static void SetPluginSettingString(string strDiscCode, string strItem, string strValue)
    {
        if (!m_bLoaded)
        {
            return;
        }

        string strSel = "/Configuration/PluginSettings/" + strDiscCode + "/" + strItem + "/self::*";

        System.Xml.XmlNodeList ndList = m_xmlDoc.SelectNodes(strSel);

        if (ndList.Count == 1)
        {
            ndList[0].InnerText = strValue;
        }
        else
        {
            XmlNode nodePlugin, nodeDiscipline, nodeItem;
            strSel = "/Configuration/PluginSettings/" + strDiscCode + "/self::*";
            ndList = m_xmlDoc.SelectNodes(strSel);

            if (ndList.Count < 1)
            {
                strSel = "/Configuration/PluginSettings/self::*";
                ndList = m_xmlDoc.SelectNodes(strSel);

                if (ndList.Count < 1)
                {
                    strSel = "/Configuration/self::*";
                    ndList = m_xmlDoc.SelectNodes(strSel);

                    if (ndList.Count < 1)
                    {
                        return;
                    }

                    nodePlugin = m_xmlDoc.CreateNode(XmlNodeType.Element, "PluginSettings", null);
                    ndList[0].AppendChild(nodePlugin);
                }
                else
                {
                    nodePlugin = ndList[0];
                }

                nodeDiscipline = m_xmlDoc.CreateNode(XmlNodeType.Element, strDiscCode, null);
                nodePlugin.AppendChild(nodeDiscipline);
            }
            else
            {
                nodeDiscipline = ndList[0];
            }

            nodeItem = m_xmlDoc.CreateNode(XmlNodeType.Element, strItem, null);
            nodeDiscipline.AppendChild(nodeItem);
            nodeItem.InnerText = strValue;
        }
    }
Esempio n. 20
0
 public void ProcessInputKeyFile(string inputPath, string outputPath, string pass,X509Certificate2 xcert,bool flag,string oneTimePassword )
 {
     string strKey = string.Format("//{0}/{1}", CollectionIDTag, KeyTag);
     string strID = string.Format("//{0}/{1}", CollectionIDTag, iFolderIDTag);
     string decKey;
     byte[] decKeyByteArray;
     rsadec = xcert.PrivateKey as RSACryptoServiceProvider;
     try
     {
         string inKeyPath = Path.GetFullPath(inputPath);
         string outKeyPath = Path.GetFullPath(outputPath);
         XmlDocument encFile = new XmlDocument();
         encFile.Load(inKeyPath);
         XmlNodeList keyNodeList, idNodeList;
         XmlElement root = encFile.DocumentElement;
         keyNodeList = root.SelectNodes(strKey);
         idNodeList = root.SelectNodes(strID);
         System.Xml.XmlDocument document = new XmlDocument();
         XmlDeclaration xmlDeclaration = document.CreateXmlDeclaration("1.0", "utf-8", null);
         document.InsertBefore(xmlDeclaration, document.DocumentElement);
         XmlElement title = document.CreateElement(titleTag);
         document.AppendChild(title);
         int i = 0;
         foreach (XmlNode idNode in idNodeList)
         {
             if (idNode.InnerText == null || idNode.InnerText == String.Empty)
                 continue;
             Console.WriteLine(idNode.InnerText);
             XmlNode newNode = document.CreateNode("element", CollectionIDTag, "");
             newNode.InnerText = "";
             document.DocumentElement.AppendChild(newNode);
             XmlNode innerNode = document.CreateNode("element", iFolderIDTag, "");
             innerNode.InnerText = idNode.InnerText;
             newNode.AppendChild(innerNode);
             {
                 XmlNode keyNode = keyNodeList[i++];
                 Console.WriteLine(decKey = keyNode.InnerText);
                 decKeyByteArray = Convert.FromBase64String(decKey);
                 XmlNode newElem2 = document.CreateNode("element", KeyTag, "");
                 if (decKey == null || decKey == String.Empty)
                     continue;
                 if (flag == true)
                     newElem2.InnerText = DecodeMessage(decKeyByteArray, oneTimePassword);
                 else
                     newElem2.InnerText = DecodeMessage(decKeyByteArray);
                 newNode.AppendChild(newElem2);
             }
         }
         if (File.Exists(outKeyPath))
             File.Delete(outKeyPath);
         document.Save(outKeyPath);
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception while processing" + e.Message + e.StackTrace);
     }
 }
		public XmlNode BuildRuleItem(XmlDocument xmlDoc)
		{
			XmlNode nodeRuleItem = xmlDoc.CreateNode(XmlNodeType.Element, XMLNames._E_RuleItem, XMLNames._M_NameSpaceURI);
			Utility.XMLHelper.AddText(xmlDoc, nodeRuleItem, _keyValue);
			XmlNode nodeRuleItemDetails = xmlDoc.CreateNode(XmlNodeType.Element, XMLNames._E_RuleItemDetails, XMLNames._M_NameSpaceURI);
			nodeRuleItem.AppendChild(nodeRuleItemDetails);
			foreach (ExternalInterfaceSearchCriteriaDetail detail in _details)
				nodeRuleItemDetails.AppendChild(detail.BuildRuleItemDetail(xmlDoc));
			return nodeRuleItem;			
		}
Esempio n. 22
0
        public XmlElement ToXml(XmlDocument document)
        {
            XmlElement inodeNode = document.CreateElement("idmef:Inode", "http://iana.org/idmef");

            if (changeTime != null)
            {
                XmlElement inodeSubNode = document.CreateElement("idmef:change-time", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "change-time", "http://iana.org/idmef");
                subNode.Value = ((DateTime)changeTime).ToString("o");
                inodeSubNode.AppendChild(subNode);
                inodeNode.AppendChild(inodeSubNode);
            }
            if (number != null)
            {
                XmlElement inodeSubNode = document.CreateElement("idmef:number", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "number", "http://iana.org/idmef");
                subNode.Value = number.ToString();
                inodeSubNode.AppendChild(subNode);
                inodeNode.AppendChild(inodeSubNode);
            }
            if (majorDevice != null)
            {
                XmlElement inodeSubNode = document.CreateElement("idmef:major-device", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "major-device", "http://iana.org/idmef");
                subNode.Value = majorDevice.ToString();
                inodeSubNode.AppendChild(subNode);
                inodeNode.AppendChild(inodeSubNode);
            }
            if (minorDevice != null)
            {
                XmlElement inodeSubNode = document.CreateElement("idmef:minor-device", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "minor-device", "http://iana.org/idmef");
                subNode.Value = minorDevice.ToString();
                inodeSubNode.AppendChild(subNode);
                inodeNode.AppendChild(inodeSubNode);
            }
            if (cMajorDevice != null)
            {
                XmlElement inodeSubNode = document.CreateElement("idmef:c-major-device", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "c-major-device", "http://iana.org/idmef");
                subNode.Value = cMajorDevice.ToString();
                inodeSubNode.AppendChild(subNode);
                inodeNode.AppendChild(inodeSubNode);
            }
            if (cMinorDevice != null)
            {
                XmlElement inodeSubNode = document.CreateElement("idmef:c-minor-device", "http://iana.org/idmef");
                XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "c-minor-device", "http://iana.org/idmef");
                subNode.Value = cMinorDevice.ToString();
                inodeSubNode.AppendChild(subNode);
                inodeNode.AppendChild(inodeSubNode);
            }

            return inodeNode;
        }
Esempio n. 23
0
 public static SoapException RaiseException(string uri,
                             string webServiceNamespace,
                             string errorMessage,
                             string errorNumber,
                             string errorSource,
                             FaultCode code)
 {
     XmlQualifiedName faultCodeLocation = null;
     //Identify the location of the FaultCode
     switch (code)
     {
         case FaultCode.Client:
             faultCodeLocation = SoapException.ClientFaultCode;
             break;
         case FaultCode.Server:
             faultCodeLocation = SoapException.ServerFaultCode;
             break;
     }
     XmlDocument xmlDoc = new XmlDocument();
     //Create the Detail node
     XmlNode rootNode = xmlDoc.CreateNode(XmlNodeType.Element,
                        SoapException.DetailElementName.Name,
                        SoapException.DetailElementName.Namespace);
     //Build specific details for the SoapException
     //Add first child of detail XML element.
     XmlNode errorNode = xmlDoc.CreateNode(XmlNodeType.Element, "Error",
                                           webServiceNamespace);
     //Create and set the value for the ErrorNumber node
     XmlNode errorNumberNode =
       xmlDoc.CreateNode(XmlNodeType.Element, "ErrorNumber",
                         webServiceNamespace);
     errorNumberNode.InnerText = errorNumber;
     //Create and set the value for the ErrorMessage node
     XmlNode errorMessageNode = xmlDoc.CreateNode(XmlNodeType.Element,
                                                 "ErrorMessage",
                                                 webServiceNamespace);
     errorMessageNode.InnerText = errorMessage;
     //Create and set the value for the ErrorSource node
     XmlNode errorSourceNode =
       xmlDoc.CreateNode(XmlNodeType.Element, "ErrorSource",
                         webServiceNamespace);
     errorSourceNode.InnerText = errorSource;
     //Append the Error child element nodes to the root detail node.
     errorNode.AppendChild(errorNumberNode);
     errorNode.AppendChild(errorMessageNode);
     errorNode.AppendChild(errorSourceNode);
     //Append the Detail node to the root node
     rootNode.AppendChild(errorNode);
     //Construct the exception
     SoapException soapEx = new SoapException(errorMessage,
                                              faultCodeLocation, uri,
                                              rootNode);
     //Raise the exception  back to the caller
     return soapEx;
 }
Esempio n. 24
0
 private static XmlNode CreateDValueNodeWithValue(double value)
 {
     var doc = new XmlDocument();
     var node = doc.CreateNode(XmlNodeType.Element, AstConstants.Node, AstConstants.Nodes.Scalar_DNumber, "");
     var valueNode = doc.CreateNode(XmlNodeType.Element, AstConstants.Subnode, AstConstants.Subnodes.Value, "");
     var floatNode = doc.CreateNode(XmlNodeType.Element, AstConstants.Scalar, AstConstants.Scalars.Float, "");
     floatNode.InnerText = value.ToString(CultureInfo.InvariantCulture);
     valueNode.AppendChild(floatNode);
     node.AppendChild(valueNode);
     return node;
 }
Esempio n. 25
0
        public string Estadisticas()
        {
            try
            {
                IlogicaViajes FLogica = FabricaLogica.GetLogicaViajes();
                List <Viajes> lista   = FLogica.ListarViajesTodos();
                XmlDocument   xmldoc  = new XmlDocument();

                xmldoc.LoadXml("<lista></lista>");

                foreach (Viajes v in lista)
                {
                    XmlNode nodoViaje = xmldoc.CreateNode(XmlNodeType.Element, "Viaje", "");

                    XmlNode nodoNumero = xmldoc.CreateNode(XmlNodeType.Element, "Número", "");
                    nodoNumero.InnerXml = v.numero.ToString();
                    nodoViaje.AppendChild(nodoNumero);

                    XmlNode nodoCiudadDestino = xmldoc.CreateNode(XmlNodeType.Element, "CiudadDestino", "");
                    nodoCiudadDestino.InnerXml = v.t.ciudad;
                    nodoViaje.AppendChild(nodoCiudadDestino);

                    XmlNode nodoPaisDestino = xmldoc.CreateNode(XmlNodeType.Element, "PaisDestino", "");
                    nodoPaisDestino.InnerXml = v.t.pais;
                    nodoViaje.AppendChild(nodoPaisDestino);

                    XmlNode nodoCompania = xmldoc.CreateNode(XmlNodeType.Element, "Compania", "");
                    nodoCompania.InnerXml = v.c.nombre;
                    nodoViaje.AppendChild(nodoCompania);

                    XmlNode nodoFechaPartida = xmldoc.CreateNode(XmlNodeType.Element, "FechaPartida", "");
                    nodoFechaPartida.InnerXml = v.partida.ToString();
                    nodoViaje.AppendChild(nodoFechaPartida);

                    xmldoc.DocumentElement.AppendChild(nodoViaje);
                }
                return(xmldoc.OuterXml);
            }
            catch (Exception ex)
            {
                XmlDocument unDoc      = new System.Xml.XmlDocument();
                XmlNode     noddoError = unDoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);

                XmlNode nodeDetalle = unDoc.CreateNode(XmlNodeType.Element, "Error", "");
                nodeDetalle.InnerText = ex.Message;


                noddoError.AppendChild(nodeDetalle);

                SoapException miEx = new SoapException(ex.Message, SoapException.ClientFaultCode, Context.Request.Url.AbsolutePath, noddoError);

                throw miEx;
            }
        }
Esempio n. 26
0
        public string ViajesXML()
        {
            ILogicaViaje LViaje       = FabricaLogica.GetLogicaViajes();
            List <Viaje> ListarViajes = LViaje.Listar();

            XmlDocument DocumentoXML = new XmlDocument();
            XmlNode     NodoV        = DocumentoXML.CreateNode(XmlNodeType.Element, "Viaje", "");

            try
            {
                foreach (Viaje V in ListarViajes)
                {
                    XmlNode NodoViaje = DocumentoXML.CreateNode(XmlNodeType.Element, "Viaje", "");

                    XmlNode NodoNum = DocumentoXML.CreateNode(XmlNodeType.Element, "Numero", "");
                    NodoNum.InnerText = V._NumViaje.ToString();
                    NodoViaje.AppendChild(NodoNum);

                    XmlNode NodoCiudad = DocumentoXML.CreateNode(XmlNodeType.Element, "CiudadDestino", "");
                    NodoCiudad.InnerText = V._Ter._Ciudad;
                    NodoViaje.AppendChild(NodoCiudad);

                    XmlNode NodoPais = DocumentoXML.CreateNode(XmlNodeType.Element, "PaisDestino", "");
                    NodoPais.InnerText = V._Ter._Pais;
                    NodoViaje.AppendChild(NodoPais);

                    XmlNode NodoCompañia = DocumentoXML.CreateNode(XmlNodeType.Element, "Compañia", "");
                    NodoCompañia.InnerText = V._Com._Nombre;
                    NodoViaje.AppendChild(NodoCompañia);

                    XmlNode NodoFecha = DocumentoXML.CreateNode(XmlNodeType.Element, "FechaPartida", "");
                    NodoFecha.InnerText = V._FechaPartida.ToString();;
                    NodoViaje.AppendChild(NodoFecha);

                    NodoV.AppendChild(NodoViaje);
                }
            }
            catch (Exception ex)
            {
                XmlDocument _undoc       = new System.Xml.XmlDocument();
                XmlNode     _NodoError   = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
                XmlNode     _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ex.Message);

                _NodoDetalle.InnerText = ex.Message;
                _NodoError.AppendChild(_NodoDetalle);
                SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError);
                throw _MiEx;
            }
            DocumentoXML.AppendChild(NodoV);

            return(DocumentoXML.OuterXml);
        }
Esempio n. 27
0
        public XmlElement ToXml(XmlDocument document)
        {
            XmlElement processNode = document.CreateElement("idmef:Process", "http://iana.org/idmef");

            processNode.SetAttribute("ident", ident);

            if (string.IsNullOrEmpty(name)) throw new ArgumentException("Process must have a name node.");

            XmlElement processSubNode = document.CreateElement("idmef:name", "http://iana.org/idmef");
            XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "name", "http://iana.org/idmef");
            subNode.Value = name;
            processSubNode.AppendChild(subNode);
            processNode.AppendChild(processSubNode);
            if (pid != null)
            {
                processSubNode = document.CreateElement("idmef:pid", "http://iana.org/idmef");
                subNode = document.CreateNode(XmlNodeType.Text, "idmef", "pid", "http://iana.org/idmef");
                subNode.Value = pid.ToString();
                processSubNode.AppendChild(subNode);
                processNode.AppendChild(processSubNode);
            }
            if (!string.IsNullOrEmpty(path))
            {
                processSubNode = document.CreateElement("idmef:path", "http://iana.org/idmef");
                subNode = document.CreateNode(XmlNodeType.Text, "idmef", "path", "http://iana.org/idmef");
                subNode.Value = path;
                processSubNode.AppendChild(subNode);
                processNode.AppendChild(processSubNode);
            }
            if ((arg != null) && (arg.Length > 0))
                foreach (var a in arg)
                    if (!string.IsNullOrEmpty(a))
                    {
                        processSubNode = document.CreateElement("idmef:arg", "http://iana.org/idmef");
                        subNode = document.CreateNode(XmlNodeType.Text, "idmef", "arg", "http://iana.org/idmef");
                        subNode.Value = a;
                        processSubNode.AppendChild(subNode);
                        processNode.AppendChild(processSubNode);
                    }
            if ((env != null) && (env.Length > 0))
                foreach (var e in env)
                    if (!string.IsNullOrEmpty(e))
                    {
                        processSubNode = document.CreateElement("idmef:env", "http://iana.org/idmef");
                        subNode = document.CreateNode(XmlNodeType.Text, "idmef", "env", "http://iana.org/idmef");
                        subNode.Value = e;
                        processSubNode.AppendChild(subNode);
                        processNode.AppendChild(processSubNode);
                    }

            return processNode;
        }
Esempio n. 28
0
        private void Init(string rootName)
        {
            try
            {
                doc = new XmlDocument();

                var dec = doc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                doc.InsertAfter(dec, null);
                root = doc.CreateNode(XmlNodeType.Element, rootName, "");
                doc.InsertAfter(root, dec);
            }
            catch { }
        }
Esempio n. 29
0
 public static void SetValue(string AppKey, string AppValue, bool tt)
 {
     XmlDocument document = new XmlDocument();
     XmlNode node = document.CreateNode(XmlNodeType.Element, "configuration", "");
     document.AppendChild(node);
     XmlNode node2 = document.CreateNode(XmlNodeType.Element, "appSettings", "");
     node.AppendChild(node2);
     XmlElement newChild = document.CreateElement("add");
     newChild.SetAttribute("key", AppKey);
     newChild.SetAttribute("value", AppValue);
     node2.AppendChild(newChild);
     document.Save(System.AppDomain.CurrentDomain.BaseDirectory + "LrcSet.xml");
 }
Esempio n. 30
0
        public static XmlDocument GetErrorDocument(string errormessage)
        {
            XmlDocument errorDoc = new XmlDocument();

            errorDoc.AppendChild(errorDoc.CreateProcessingInstruction("xml-stylesheet", "type='text/xsl' href='xsl/errorPage.xsl'"));
            XmlNode root = errorDoc.AppendChild(errorDoc.CreateNode(XmlNodeType.Element, "root", null));
            XmlNode node = root.AppendChild(errorDoc.CreateNode(XmlNodeType.Element, "message", null));

            node.InnerText = errormessage;

            Timingutil.info("Compile Error ! , generate ErrorDom");
            return errorDoc;
        }
Esempio n. 31
0
        public XmlNode AddSubEntity(TreeNode treeNode, XmlDocument document)
        {
            Entity entity = EntityDictionary[treeNode.Text];

            XmlNode xmlNode = document.CreateNode(XmlNodeType.Element, "Item", null);
            XmlAttribute attribute = document.CreateAttribute("Name");
            attribute.Value = entity.Name;

            xmlNode.Attributes.Append(attribute);

            if (entity.Parameters.Count > 0)
            {
                XmlNode parameterContainerNode = document.CreateNode(XmlNodeType.Element, "Parameters", null);

                foreach (Entity.Parameter parameter in entity.Parameters)
                {
                    //Create Node for the parameter
                    XmlNode parameterNode = document.CreateNode(XmlNodeType.Element, "Parameter", null);

                    //Create an attribute containing the type
                    XmlAttribute parameterType = document.CreateAttribute("Type");
                    parameterType.Value = parameter.Type.ToString();

                    //Set the inner text to the name of the parameter
                    parameterNode.InnerText = parameter.Name;

                    //add the attribute to the node
                    parameterNode.Attributes.Append(parameterType);

                    //add the parameter node to the parameterContainer
                    parameterContainerNode.AppendChild(parameterNode);

                }

                xmlNode.AppendChild(parameterContainerNode);
            }

            if (treeNode.Nodes.Count > 0)
            {
                XmlNode subEntities = document.CreateNode(XmlNodeType.Element, "SubEntities", null);

                foreach (TreeNode subTreeNode in treeNode.Nodes)
                {
                    subEntities.AppendChild(AddSubEntity(subTreeNode, document));
                }

                xmlNode.AppendChild(subEntities);
            }

            return xmlNode;
        }
    private void GeneroSoapException(Exception ex)
    {
        XmlDocument _undoc     = new System.Xml.XmlDocument();
        XmlNode     _NodoError = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);

        XmlNode _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", "");

        _NodoDetalle.InnerText = ex.Message;
        _NodoError.AppendChild(_NodoDetalle);

        SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError);

        throw _MiEx;
    }
Esempio n. 33
0
 public RolesDataSource(string rolesFile, string application)
 {
     this._rolesFile = rolesFile;
     this.ApplicationName = application;
     this._agent = new FileAgent();
     if (!this._agent.HasKey(rolesFile))
     {
         XmlDocument doc = new XmlDocument();
         doc.AppendChild(doc.CreateNode(XmlNodeType.XmlDeclaration, "", ""));
         doc.AppendChild(doc.CreateNode(XmlNodeType.Element, "roles", ""));
         this._agent.Write(this._rolesFile, string.Empty);
         this.SaveRolesFile(doc);
     }
 }
        //save into package
        public void SaveToXML(System.Xml.XmlDocument doc, IDTSInfoEvents infoEvents)
        {
            XmlElement elementRoot;
            XmlNode    propertyNode;

            elementRoot = doc.CreateElement(string.Empty, "DtParameters", string.Empty);

            if (DtParameters != null)
            {
                if (DtParameters.Rows.Count > 0)
                {
                    //
                    foreach (DataRow row in DtParameters.Rows)
                    {
                        propertyNode           = doc.CreateNode(XmlNodeType.Element, "Parameter", string.Empty);
                        propertyNode.InnerText = row["ParameterValue"].ToString();

                        XmlAttribute attrParameterName = doc.CreateAttribute("ParameterName");
                        attrParameterName.Value = row["ParameterName"].ToString();
                        propertyNode.Attributes.Append(attrParameterName);

                        XmlAttribute attrRequired = doc.CreateAttribute("Required");
                        attrRequired.Value = row["Required"].ToString();
                        propertyNode.Attributes.Append(attrRequired);

                        elementRoot.AppendChild(propertyNode);
                    }
                }
            }


            propertyNode           = doc.CreateNode(XmlNodeType.Element, "Server", string.Empty);
            propertyNode.InnerText = Server;
            elementRoot.AppendChild(propertyNode);

            propertyNode           = doc.CreateNode(XmlNodeType.Element, "SelectedReport", string.Empty);
            propertyNode.InnerText = SelectedReport;
            elementRoot.AppendChild(propertyNode);

            propertyNode           = doc.CreateNode(XmlNodeType.Element, "FileName", string.Empty);
            propertyNode.InnerText = FileName;
            elementRoot.AppendChild(propertyNode);

            propertyNode           = doc.CreateNode(XmlNodeType.Element, "FileFormat", string.Empty);
            propertyNode.InnerText = FileFormat;
            elementRoot.AppendChild(propertyNode);

            doc.AppendChild(elementRoot);
        }
Esempio n. 35
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            String strAddinPath = Path.GetDirectoryName(FAddIn.Object.GetType().Assembly.Location) + "\\ServerPath.xml";
            if (!File.Exists(strAddinPath))
            {
                FileStream fs = File.Open(strAddinPath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine("<Infolight></Infolight>");
                sw.Close();
                fs.Close();
                XmlDocument x = new XmlDocument();
                x.Load(strAddinPath);
                XmlNode xn = x.CreateNode(XmlNodeType.Element, "ServerPath", "");
                XmlAttribute xa = x.CreateAttribute("Value");
                xa.Value = this.tbServerPath.Text;

                xn.Attributes.Append(xa);
                x.ChildNodes[0].AppendChild(xn);

                xn = x.CreateNode(XmlNodeType.Element, "WebClientPath", "");
                xa = x.CreateAttribute("Value");
                xa.Value = this.tbWebClientPath.Text;

                xn.Attributes.Append(xa);
                x.ChildNodes[0].AppendChild(xn);
                x.Save(strAddinPath);
            }
            else
            {
                XmlDocument x = new XmlDocument();
                x.Load(strAddinPath);
                x.FirstChild.ChildNodes[0].Attributes["Value"].Value = this.tbServerPath.Text;

                if (x.FirstChild.ChildNodes.Count < 2)
                {
                    XmlNode xn = x.CreateNode(XmlNodeType.Element, "WebClientPath", "");
                    XmlAttribute xa = x.CreateAttribute("Value");
                    xa.Value = this.tbWebClientPath.Text;
                    xn.Attributes.Append(xa);
                    x.ChildNodes[0].AppendChild(xn);
                }
                else
                {
                    x.FirstChild.ChildNodes[1].Attributes["Value"].Value = this.tbWebClientPath.Text;
                }
                x.Save(strAddinPath);
            }
            this.Hide();
        }
Esempio n. 36
0
        static void Main(string[] args)
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlNode xmlNode;
            xmlNode = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
            xmlDoc.AppendChild(xmlNode);

            XmlNode root = xmlDoc.CreateElement("urlset");
            xmlDoc.AppendChild(root);

            using (SqlConnection conn = new SqlConnection(connectionstring))
            {
                SqlCommand cmd = new SqlCommand("select idkey from feature", conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    XmlNode url = xmlDoc.CreateNode(XmlNodeType.Element, "url", null);
                    root.AppendChild(url);

                    xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "loc", null);
                    xmlNode.InnerText = string.Format("http://www.culture-visions.com/f/{0}.html", Base64.Encode(reader.GetInt32(0).ToString()));
                    url.AppendChild(xmlNode);

                    xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "lastmod", null);
                    xmlNode.InnerText = "2011-07-25";
                    url.AppendChild(xmlNode);

                    xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "priority", null);
                    xmlNode.InnerText = "0.5";
                    url.AppendChild(xmlNode);
                }

                reader.Close();

                cmd = new SqlCommand("select idkey,aired from webcast order by aired desc", conn);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    XmlNode url = xmlDoc.CreateNode(XmlNodeType.Element, "url", null);
                    root.AppendChild(url);

                    xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "loc", null);
                    xmlNode.InnerText = string.Format("http://www.culture-visions.com/w/{0}.html", Base64.Encode(reader.GetInt32(0).ToString()));
                    url.AppendChild(xmlNode);

                    xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "lastmod", null);
                    xmlNode.InnerText = reader.GetDateTime(1).ToString("yyyy-MM-dd");
                    url.AppendChild(xmlNode);

                    xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "priority", null);
                    xmlNode.InnerText = "0.8";
                    url.AppendChild(xmlNode);
                }
            }

            xmlDoc.Save(@"E:\sitemap.xml");
        }
        internal static XElement ToXml(this Property property, IDataTypeService dataTypeService)
        {
            var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "data" : property.Alias.ToSafeAlias();

            var xd = new XmlDocument();
            var xmlNode = xd.CreateNode(XmlNodeType.Element, nodeName, "");

            //Add the property alias to the legacy schema
            if (UmbracoSettings.UseLegacyXmlSchema)
            {
                var alias = xd.CreateAttribute("alias");
                alias.Value = property.Alias.ToSafeAlias();
                xmlNode.Attributes.Append(alias);
            }

            //This seems to fail during testing 
            //SD: With the new null checks below, this shouldn't fail anymore.
            var dt = property.PropertyType.DataType(property.Id, dataTypeService);
            if (dt != null && dt.Data != null)
            {
                //We've already got the value for the property so we're going to give it to the 
                // data type's data property so it doesn't go re-look up the value from the db again.
                var defaultData = dt.Data as IDataValueSetter;
                if (defaultData != null)
                {
                    defaultData.SetValue(property.Value, property.PropertyType.DataTypeDatabaseType.ToString());
                }

                xmlNode.AppendChild(dt.Data.ToXMl(xd));
            }

            var element = xmlNode.GetXElement();
            return element;
        }
        static XmlDocument AddOrModifyAppSettings(XmlDocument xmlDoc, string key, string value)
        {
            bool isNew = false;

            XmlNodeList list = xmlDoc.DocumentElement.SelectNodes(string.Format("appSettings/add[@key='{0}']", key));
            XmlNode node;
            isNew = list.Count == 0;
            if (isNew)
            {
                node = xmlDoc.CreateNode(XmlNodeType.Element, "add", null);
                XmlAttribute attribute = xmlDoc.CreateAttribute("key");
                attribute.Value = key;
                node.Attributes.Append(attribute);

                attribute = xmlDoc.CreateAttribute("value");
                attribute.Value = value;
                node.Attributes.Append(attribute);

                xmlDoc.DocumentElement.SelectNodes("appSettings")[0].AppendChild(node);
            }
            else
            {
                node = list[0];
                node.Attributes["value"].Value = value;
            }
            return xmlDoc;
        }
        protected void PrepareCSProjUser()
        {
            //load csproj user
            var proj = new System.Xml.XmlDocument();

            proj.Load(this.CSProjUserPath);

            //create XML NameSpace
            var    strNamespace = proj.DocumentElement.NamespaceURI;
            var    nsManager    = new XmlNamespaceManager(proj.NameTable);
            string prefix       = el.GetType().ToString() + "Project";

            nsManager.AddNamespace(prefix, strNamespace);

            //remove all reference paths
            XmlNode ReferencePathParent;

            if (proj.DocumentElement.SelectSingleNode("//" + prefix + ":ReferencePath", nsManager) == null)
            {
                ReferencePathParent = proj.DocumentElement.SelectSingleNode("//" + prefix + ":ReferencePath", nsManager).ParentNode;
                ReferencePathParent.RemoveAll();
                var referenceNode = proj.CreateNode(XmlNodeType.Element, "ReferencePath", strNamespace);
                referenceNode.InnerText = this.ProjectReferenceDirAssemblies + ";" + this.ProjectReferenceDirBin;
                ReferencePathParent.AppendChild(referenceNode);
            }
            //save .csproj.user
            proj.Save(this.CSProjUserPath);
        }
Esempio n. 40
0
        /// <summary>
        /// 创建Data基础xml
        /// </summary>
        /// <param name="path"></param>
        private void CreateDataXml(string path)
        {
            //创建XML文档对象
            System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
            //创建xml 声明节点
            System.Xml.XmlNode xmlnode = xmldoc.CreateNode(System.Xml.XmlNodeType.XmlDeclaration, "", "");
            //添加上述创建和 xml声明节点
            xmldoc.AppendChild(xmlnode);
            //创建xml dbGuest 元素(根节点)
            System.Xml.XmlElement xmlelem = xmldoc.CreateElement("", "Data", "");


            xmldoc.AppendChild(xmlelem);
            try
            {
                xmldoc.Save(path);
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("访问被拒绝") != -1)
                {
                    return;
                }
            }
        }
Esempio n. 41
0
    public XMLFile()
    {
        doc  = new System.Xml.XmlDocument();
        node = doc.CreateNode(System.Xml.XmlNodeType.Element, "root", null);

        doc.AppendChild(node);
    }
Esempio n. 42
0
        /// <summary>
        /// Adds expiration record to the SQLFileCache
        /// </summary>
        public static void AddFileExpiration(string Key, ref SQLOptions o)
        {
            string strXMLXPath = "/SQLHelper_FileExpirations/File";
            string strXMLForeignKeyAttribute = "Key";

            System.Xml.XmlDocument doc = GetFileExpirations(ref o);
            o.WriteToLog("updating expiration file for this value..." + Key);
            General.Debug.Trace("updating expiration file for this value..." + Key);
            System.Xml.XmlNode node = doc.SelectSingleNode(strXMLXPath + "[@" + strXMLForeignKeyAttribute + "='" + Key + "']");
            if (node == null)
            {
                o.WriteToLog("record not found... creating..." + Key);
                General.Debug.Trace("record not found... creating..." + Key);
                node = doc.CreateNode(System.Xml.XmlNodeType.Element, "File", "");
                node.Attributes.Append(doc.CreateAttribute("Key"));
                node.Attributes["Key"].Value = Key;
                node.Attributes.Append(doc.CreateAttribute("ExpirationDate"));
                node.Attributes["ExpirationDate"].Value = o.Expiration.ToString();
                doc.DocumentElement.AppendChild(node);
            }
            else
            {
                o.WriteToLog("record found... updating..." + Key);
                General.Debug.Trace("record found... updating..." + Key);
                node.Attributes["ExpirationDate"].Value = o.Expiration.ToString();
            }
            SaveFileExpirations(doc, ref o);
        }
Esempio n. 43
0
        private string GetXML()
        {
            XmlDocument document = new XmlDocument();

            XmlElement RazaoNode = document.CreateElement("Razao");
            RazaoNode.InnerText = Razao;

            XmlElement ValoresNode = document.CreateElement("Valores");
            XmlElement ValorNode = document.CreateElement("Valor");

            XmlAttribute moeda = document.CreateAttribute("moeda");
            moeda.Value = "BRL";

            ValorNode.Attributes.Append(moeda);
            ValorNode.InnerText = String.Format("{0:0.00}", Valor).Replace(',','.');

            ValoresNode.AppendChild(ValorNode);

            XmlNode EnviarInstrucao = document.CreateElement("EnviarInstrucao");
            XmlNode InstrucaoUnica = EnviarInstrucao.AppendChild(document.CreateNode(XmlNodeType.Element, "InstrucaoUnica", ""));

            InstrucaoUnica.AppendChild(RazaoNode);
            InstrucaoUnica.AppendChild(ValoresNode);

            return EnviarInstrucao.OuterXml;
        }
        protected void PrepareCSProj()
        {
            //load csproj
            var proj = new System.Xml.XmlDocument();

            proj.Load(this.CSProjPath);

            //create XML NameSpace
            var    strNamespace = proj.DocumentElement.NamespaceURI;
            var    nsManager    = new XmlNamespaceManager(proj.NameTable);
            string prefix       = el.GetType().ToString() + "Project";

            nsManager.AddNamespace(prefix, strNamespace);

            //get all references
            var ReferenceParent = proj.DocumentElement.SelectSingleNode("//" + prefix + ":Reference", nsManager).ParentNode;

            foreach (var reference in ReferenceParent.ChildNodes)
            {
                //update references path
                foreach (var referenceChildElement in (reference as XmlElement).ChildNodes)
                {
                    if ((referenceChildElement as XmlElement).Name.ToLower() == "hintpath")
                    {
                        var hintPath = (referenceChildElement as XmlElement).InnerText;
                        var dllName  = hintPath.Split('\\').LastOrDefault();
                        //Find reference in assembilies folder
                        if (true == System.IO.File.Exists(this.ProjectReferenceDirAssemblies + dllName))
                        {
                            (referenceChildElement as XmlElement).InnerText = this.ProjectReferenceDirAssemblies + dllName;
                        }
                        else if (true == System.IO.File.Exists(this.ProjectReferenceDirBin + dllName))
                        {
                            (referenceChildElement as XmlElement).InnerText = this.ProjectReferenceDirBin + dllName;
                        }
                    }
                }
            }

            //set up build to
            if (proj.DocumentElement.SelectSingleNode("//" + prefix + ":PostBuildEvent", nsManager) != null)
            {
                var PostBuildEventParent = proj.DocumentElement.SelectSingleNode("//" + prefix + ":PostBuildEvent", nsManager).ParentNode;
                PostBuildEventParent.RemoveAll();
                var referenceNode = proj.CreateNode(XmlNodeType.Element, "PostBuildEvent", strNamespace);
                referenceNode.InnerText = string.Empty;
                if (this.AutoDeploy == true)
                {
                    referenceNode.InnerText += this.DeployCMD + Environment.NewLine;
                }
                if (this.AutoIISRecycle == true)
                {
                    referenceNode.InnerText += this.IISRecycleCMD + Environment.NewLine;
                }
                PostBuildEventParent.AppendChild(referenceNode);
            }

            //save csproj
            proj.Save(this.CSProjPath);
        }
Esempio n. 45
0
        public string GetUsers(string UID)
        {
            XmlDocument xmlDocument = new XmlDocument();

            try
            {
                IncidentUserTicket ticket = IncidentUserTicket.Load(new Guid(UID));
                if (ticket == null)
                {
                    System.Xml.XmlDocument doc      = new System.Xml.XmlDocument();
                    System.Xml.XmlNode     node     = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
                    System.Xml.XmlNode     resource = doc.CreateNode(XmlNodeType.Element, "resource", string.Empty);
                    resource.InnerText = "strNotfound";
                    node.AppendChild(resource);
                    throw new SoapException(String.Format("The ticket '{0}' not found", UID), new XmlQualifiedName(typeof(ArgumentException).FullName), System.Web.HttpContext.Current.Request.Url.AbsoluteUri, node);
                }

                Security.UserLoginByTicket(ticket);

                xmlDocument.LoadXml("<Users></Users>");
                XmlNode xmlRootNode = xmlDocument.SelectSingleNode("Users");

                DataView dataView = Mediachase.IBN.Business.User.GetListActiveDataTable(string.Empty).DefaultView;

                foreach (DataRow row in dataView.Table.Rows)
                {
                    /// Row includes fields:
                    ///	PrincipalId, Login, Password, FirstName, LastName, Email, IMGroupId, OriginalId,
                    /// DisplayName, Department
                    XmlElement userNode = xmlDocument.CreateElement("User");
                    xmlRootNode.AppendChild(userNode);

                    userNode.SetAttribute("id", row["PrincipalId"].ToString());
                    userNode.SetAttribute("fn", row["FirstName"].ToString());
                    userNode.SetAttribute("ln", row["LastName"].ToString());
                    userNode.SetAttribute("email", row["Email"].ToString());
                    userNode.SetAttribute("department", row["Department"].ToString());
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }
            return(xmlDocument.InnerXml);
        }
Esempio n. 46
0
    //var node = file.doc.CreateNode(System.Xml.XmlNodeType.Element, "collider", null);
    public XmlNode CreateNode(String label)
    {
        if (doc != null)
        {
            return(doc.CreateNode(System.Xml.XmlNodeType.Element, label, null));
        }

        return(null);
    }
Esempio n. 47
0
    private SoapException devolverSoapException(Exception ex)
    {
        //generacion manual de excepcion SOAP - para poder obtener solo el mensaje enviado por alguna de las capas

        //1.- se debe crear un nodo xml (NodoError) el cual sera utilizado  para cargar el atributo Details de la exception SOAP
        XmlDocument _undoc     = new System.Xml.XmlDocument();
        XmlNode     _NodoError = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);

        //2.- Se crea un nodo xml (NodoDetalle) q contendra el texto del error
        XmlNode _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", "");

        _NodoDetalle.InnerText = ex.Message;
        _NodoError.AppendChild(_NodoDetalle);

        //4. Creacion manual y lanzamiento de la exception SOAP
        SoapException _MiEx = new SoapException(ex.Message, SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError);

        throw _MiEx;
    }
Esempio n. 48
0
        public Empleado Logueo(string cedula, string pass)
        {
            try
            {
                ILogicaEmpleado Lempleado = FabricaLogica.GetLogicaEmpleado();
                return(Lempleado.Logueo(cedula, pass));
            }
            catch (Exception ex)
            {
                XmlDocument _undoc       = new System.Xml.XmlDocument();
                XmlNode     _NodoError   = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
                XmlNode     _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ex.Message);

                _NodoDetalle.InnerText = ex.Message;
                _NodoError.AppendChild(_NodoDetalle);
                SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError);
                throw _MiEx;
            }
        }
Esempio n. 49
0
        public Terminal BuscarTerminal(string codigo)
        {
            try
            {
                ILogicaTerminal LTerminal = FabricaLogica.GetLogicaTerminales();
                return(LTerminal.Buscar(codigo));
            }
            catch (Exception ex)
            {
                XmlDocument _undoc       = new System.Xml.XmlDocument();
                XmlNode     _NodoError   = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
                XmlNode     _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ex.Message);

                _NodoDetalle.InnerText = ex.Message;
                _NodoError.AppendChild(_NodoDetalle);
                SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError);
                throw _MiEx;
            }
        }
Esempio n. 50
0
        public void EliminarCompania(Compania c)
        {
            try
            {
                ILogicaCompania Lcompania = FabricaLogica.GetLogicaCompania();
                Lcompania.Eliminar(c);
            }
            catch (Exception ex)
            {
                XmlDocument _undoc       = new System.Xml.XmlDocument();
                XmlNode     _NodoError   = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
                XmlNode     _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ex.Message);

                _NodoDetalle.InnerText = ex.Message;
                _NodoError.AppendChild(_NodoDetalle);
                SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError);
                throw _MiEx;
            }
        }
Esempio n. 51
0
        public List <Viaje> ListarViajes()
        {
            try
            {
                ILogicaViaje LViaje = FabricaLogica.GetLogicaViajes();
                return(LViaje.Listar());
            }
            catch (Exception ex)
            {
                XmlDocument _undoc       = new System.Xml.XmlDocument();
                XmlNode     _NodoError   = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
                XmlNode     _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ex.Message);

                _NodoDetalle.InnerText = ex.Message;
                _NodoError.AppendChild(_NodoDetalle);
                SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError);
                throw _MiEx;
            }
        }
Esempio n. 52
0
        public XmlDocument(string baseNodeName, string baseNodeValue)
        {
            _doc = new System.Xml.XmlDocument();

            var baseNode = _doc.CreateNode(System.Xml.XmlNodeType.Element, baseNodeName, null);

            baseNode.InnerText = baseNodeValue;

            _baseElement = new XmlElement(baseNode, null, 0);
        }
Esempio n. 53
0
        public System.Xml.XmlDocument GetMenu(string app)
        {
            _xdoc = new System.Xml.XmlDocument();

            XmlNode Nodo = _xdoc.CreateNode(XmlNodeType.Element, "menu", "");

            _xdoc.AppendChild(Nodo);
            this.ItemMenu(0, Nodo);
            return(_xdoc);
        }
Esempio n. 54
0
        /// <summary>
        /// 生成新的文档
        /// </summary>
        public void CreateNewXML()
        {
            XmlDoc = new System.Xml.XmlDocument();

            //生成根节点
            XmlNode xn = XmlDoc.CreateNode(XmlNodeType.XmlDeclaration, "xml", "");

            xn.Value = "version=\"1.0\" encoding=\"utf-8\"";

            XmlDoc.AppendChild(xn);
        }
Esempio n. 55
0
        /// <summary>
        /// 生成新的文档
        /// </summary>
        /// <param name="DeclarationValue">XML声明(如:version="1.0" encoding="utf-8")</param>
        public void CreateNewXML(string DeclarationValue)
        {
            XmlDoc = new System.Xml.XmlDocument();

            //生成根节点
            XmlNode xn = XmlDoc.CreateNode(XmlNodeType.XmlDeclaration, "xml", "");

            xn.Value = DeclarationValue;

            XmlDoc.AppendChild(xn);
        }
Esempio n. 56
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Constructor to call when creating a Root Node
        /// </summary>
        /// <param name="strNamespace">Namespace of node hierarchy</param>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [Jon Henning]	12/22/2004	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public XmlCollectionBase(string strNamespace)
        {
            InnerXMLDoc  = new System.Xml.XmlDocument();
            InnerXMLNode = InnerXMLDoc.CreateNode(XmlNodeType.Element, "root", "");

            System.Xml.XmlAttribute objAttr = InnerXMLDoc.CreateAttribute("id");
            objAttr.Value = strNamespace;
            InnerXMLNode.Attributes.Append(objAttr);

            InnerXMLDoc.AppendChild(InnerXMLNode);
        }
Esempio n. 57
0
        /// <summary>
        /// Stores the numeric option as an XML Node (calls base implementation)
        /// </summary>
        /// <param name="doc">The XML document to which the node will be added</param>
        /// <returns>The XML node containing the information of numeric option</returns>
        internal new XmlNode saveXML(System.Xml.XmlDocument doc)
        {
            XmlNode node = base.saveXML(doc);

            //Min_Value
            XmlNode minNode = doc.CreateNode(XmlNodeType.Element, "minValue", "");

            minNode.InnerText = this.min_value.ToString();
            node.AppendChild(minNode);

            //Max_Value
            XmlNode maxNode = doc.CreateNode(XmlNodeType.Element, "maxValue", "");

            maxNode.InnerText = this.max_value.ToString();
            node.AppendChild(maxNode);

            if (this.stepFunction != null)
            {
                //StepFunction
                XmlNode stepNode = doc.CreateNode(XmlNodeType.Element, "stepFunction", "");
                stepNode.InnerText = this.stepFunction.ToString();
                node.AppendChild(stepNode);
            }

            if (values != null)
            {
                //Values
                XmlNode valuesNode     = doc.CreateNode(XmlNodeType.Element, "values", "");
                String  valuesAsString = "";
                for (int i = 0; i < values.Count(); i++)
                {
                    valuesAsString += values[i] + ";";
                }
                // remove last ;
                valuesAsString = valuesAsString.Substring(0, valuesAsString.Count() - 2);

                valuesNode.InnerText = valuesAsString;
                node.AppendChild(valuesNode);
            }
            return(node);
        }
Esempio n. 58
0
        public XmlCollectionBase(string strNamespace, DotNetNuke.UI.WebControls.DNNTree objTreeControl)
        {
            m_objTree    = objTreeControl;
            InnerXMLDoc  = new System.Xml.XmlDocument();
            InnerXMLNode = InnerXMLDoc.CreateNode(XmlNodeType.Element, "root", "");

            System.Xml.XmlAttribute objAttr = InnerXMLDoc.CreateAttribute("id");
            objAttr.Value = strNamespace;
            InnerXMLNode.Attributes.Append(objAttr);

            InnerXMLDoc.AppendChild(InnerXMLNode);
        }
Esempio n. 59
0
 private void button1_Click(object sender, EventArgs e)
 {
     System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
     //System.Xml.XmlElement element = xmlDoc.CreateElement("xml",);
     //xmlDoc.Name = "xml";
     //xmlDoc.CreateElement();
     System.Xml.XmlNode node = xmlDoc.CreateNode(System.Xml.XmlNodeType.CDATA, "plan_id", "xml");
     node.Value = "456";
     //xmlDoc.AppendChild(node);
     System.Xml.XmlCDataSection cData = xmlDoc.CreateCDataSection("test");
     label1.Text = cData.ToString();
 }
Esempio n. 60
0
        public SoapException manejoError2(Exception ex, string Username, string Metodo)
        {
            log.Error("Error " + Metodo + ": " + ex.Message);

            // Build the detail element of the SOAP fault.
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            System.Xml.XmlNode node = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);

            System.Xml.XmlNode details = doc.CreateNode(XmlNodeType.Element, "Detalle", "http://z2.anses.gov.ar/");
            details.InnerText = "Metodo: " + Metodo + " Usuario - [" + Username + "] Mensaje: " + ex.Message;

            node.AppendChild(details);

            //Throw the exception
            SoapException se = new SoapException("Error", SoapException.ClientFaultCode, "", ex);

            log.Error(Metodo, ex);

            return(se);
        }