//public static void WriteFile(string name)
        //{
        //    ConstructFile file = ConstructFold.Instance.ConstructFiles.GetByName(name);
        //    if (file != null)
        //    {
        //        WriteFile(file);
        //    }
        //}

        public static void WriteFile(InnerStructInfo file)
        {
            if (file == null)
                return;

            string configPath = InnerStructConfig.INNERSTRUCT_FOLD_PATH + "/" + file.Name + ".xml";
            XmlDocument xmlDoc = new XmlDocument();
            if (!File.Exists(configPath))
            {
                XmlDeclaration dec = xmlDoc.CreateXmlDeclaration(InnerStructConfig.INIT_VERSION_STR, InnerStructConfig.INIT_ENCODING_STR, null);
                xmlDoc.AppendChild(dec);
                XmlElement rootInit = xmlDoc.CreateElement(InnerStructConfig.DOC_ROOT_STR);
                xmlDoc.AppendChild(rootInit);
                xmlDoc.Save(configPath);
            }
            else
            {
                xmlDoc.Load(configPath);
            }
            XmlNode root = xmlDoc.SelectSingleNode(InnerStructConfig.DOC_ROOT_STR);
            root.RemoveAll();

            XmlElement xmlItem = null;
            foreach (InnerStructItem item in file._InnerStructItemCollection)
            {
                XmlElement xmlColumn = xmlDoc.CreateElement(InnerStructConfig.INNERSTRUCT_ELEMENT_COLUMN);

                xmlItem = xmlDoc.CreateElement(InnerStructConfig.INNERSTRUCT_ELEMENT_NAME);
                xmlItem.InnerText = item.Name;
                xmlColumn.AppendChild(xmlItem);

                xmlItem = xmlDoc.CreateElement(InnerStructConfig.INNERSTRUCT_ELEMENT_CODE);
                xmlItem.InnerText = item.ItemCode;
                xmlColumn.AppendChild(xmlItem);

                xmlItem = xmlDoc.CreateElement(InnerStructConfig.INNERSTRUCT_ELEMENT_TYPE1);
                xmlItem.InnerText = item.ItemType1;
                xmlColumn.AppendChild(xmlItem);

                xmlItem = xmlDoc.CreateElement(InnerStructConfig.INNERSTRUCT_ELEMENT_TYPE2);
                foreach (TableBaseItem type2s in item.ItemType2)
                {
                    XmlElement type2Ele = xmlDoc.CreateElement(InnerStructConfig.INNERSTRUCT_ELEMENT_TYPE2);
                    type2Ele.InnerText = type2s.Name;
                    xmlItem.AppendChild(type2Ele);
                }
                xmlColumn.AppendChild(xmlItem);

                xmlItem = xmlDoc.CreateElement(InnerStructConfig.INNERSTRUCT_ELEMENT_DEFAULT);
                xmlItem.InnerText = item.ItemDefault;
                xmlColumn.AppendChild(xmlItem);

                xmlItem = xmlDoc.CreateElement(InnerStructConfig.INNERSTRUCT_ELEMENT_REPEAT);
                xmlItem.InnerText = item.ItemRepeat.ToString();
                xmlColumn.AppendChild(xmlItem);

                root.AppendChild(xmlColumn);
            }
            xmlDoc.Save(configPath);
        }
        public ControlResponse GetResponse(Exception ex)
        {
            var env = new XmlDocument();
            env.AppendChild(env.CreateXmlDeclaration("1.0", "utf-8", "yes"));
            var envelope = env.CreateElement("SOAP-ENV", "Envelope", NS_SOAPENV);
            env.AppendChild(envelope);
            envelope.SetAttribute("encodingStyle", NS_SOAPENV, "http://schemas.xmlsoap.org/soap/encoding/");

            var rbody = env.CreateElement("SOAP-ENV:Body", NS_SOAPENV);
            env.DocumentElement.AppendChild(rbody);

            var fault = env.CreateElement("SOAP-ENV", "Fault", NS_SOAPENV);
            var faultCode = env.CreateElement("faultcode");
            faultCode.InnerText = "500";
            fault.AppendChild(faultCode);
            var faultString = env.CreateElement("faultstring");
            faultString.InnerText = ex.ToString();
            fault.AppendChild(faultString);
            var detail = env.CreateDocumentFragment();
            detail.InnerXml = "<detail><UPnPError xmlns=\"urn:schemas-upnp-org:control-1-0\"><errorCode>401</errorCode><errorDescription>Invalid Action</errorDescription></UPnPError></detail>";
            fault.AppendChild(detail);
            rbody.AppendChild(fault);

            return new ControlResponse
            {
                Xml = env.OuterXml,
                IsSuccessful = false
            };
        }
Exemple #3
0
        static void Main(string[] args)
        {
            XmlDocument doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            doc.AppendChild(dec);

            XmlElement order = doc.CreateElement("Order");
            doc.AppendChild(order);

            XmlElement customerName = doc.CreateElement("CustomerName");
            customerName.InnerXml = "<p>aaa</p>";
            order.AppendChild(customerName);

            XmlElement customerNumber = doc.CreateElement("CustomerNumber");
            customerNumber.InnerText = "100001";
            order.AppendChild(customerNumber);

            XmlElement items = doc.CreateElement("Items");
            order.AppendChild(items);

            XmlElement orderItem1 = doc.CreateElement("OrderItem");
            orderItem1.SetAttribute("Name", "树");
            orderItem1.SetAttribute("Count", "10");
            items.AppendChild(orderItem1);

            doc.Save("Order.xml");
            Console.WriteLine("success");
        }
Exemple #4
0
        public static string ConvertFromPHP(string sPHP)
        {
            XmlDocument xml = new XmlDocument();
            xml.AppendChild(xml.CreateProcessingInstruction("xml" , "version=\"1.0\" encoding=\"UTF-8\""));
            xml.AppendChild(xml.CreateElement("USER_PREFERENCE"));
            try
            {
                byte[] abyPHP = Convert.FromBase64String(sPHP);
                StringBuilder sb = new StringBuilder();
                foreach(char by in abyPHP)
                    sb.Append(by);
                MemoryStream mem = new MemoryStream(abyPHP);

                string sSize = String.Empty;
                int nChar = mem.ReadByte();
                while ( nChar != -1 )
                {
                    char ch = Convert.ToChar(nChar);
                    if ( ch == 'a' )
                        PHPArray(xml, xml.DocumentElement, mem);
                    else if ( ch == 's' )
                        PHPString(mem);
                    else if ( ch == 'i' )
                        PHPInteger(mem);
                    nChar = mem.ReadByte();
                }
            }
            catch(Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
            }
            return xml.OuterXml;
        }
 public static bool SaveCfg(string filename, string NodeText, Hashtable list)
 {
     try
     {
         XmlDocument xmlDocument = new XmlDocument();
         XmlNode node = xmlDocument.CreateNode(XmlNodeType.XmlDeclaration, "", "");
         xmlDocument.AppendChild(node);
         XmlElement element1 = xmlDocument.CreateElement("", NodeText, "");
         xmlDocument.AppendChild((XmlNode)element1);
         foreach (DictionaryEntry dictionaryEntry in list)
         {
             XmlElement element2 = xmlDocument.CreateElement("", NodeText, "");
             XmlAttribute attribute1 = xmlDocument.CreateAttribute("key");
             attribute1.Value = dictionaryEntry.Key.ToString();
             element2.Attributes.Append(attribute1);
             XmlAttribute attribute2 = xmlDocument.CreateAttribute("value");
             attribute2.Value = dictionaryEntry.Value.ToString();
             element2.Attributes.Append(attribute2);
             element1.AppendChild((XmlNode)element2);
         }
         xmlDocument.Save(filename);
         return true;
     }
     catch (Exception ex)
     {
         throw new Exception("Save DatatypeMap file fail:" + ex.Message);
     }
 }
        /// <summary>
        /// Creates XML reports and save them as a XML file
        /// </summary>
        public static void XmlCreateReports(ICollection<DtoStadiumReport> stadiumReports)
        {
            var stadiumReport = stadiumReports;

            XmlDocument xmlReport = new XmlDocument();
            XmlDeclaration xmlDeclaration = xmlReport.CreateXmlDeclaration(Version, Encoding, null);
            XmlElement root = xmlReport.CreateElement(RootName);

            foreach (var stadium in stadiumReport)
            {
                XmlElement stadiumElement = xmlReport.CreateElement("stadium");
                stadiumElement.SetAttribute("id", stadium.Id.ToString());

                XmlElement stadiumName = xmlReport.CreateElement("name");
                stadiumName.InnerText = stadium.Name;

                XmlElement stadiumCapacity = xmlReport.CreateElement("capacity");
                stadiumCapacity.InnerText = stadium.Capacity.ToString();

                XmlElement stadiumTownName = xmlReport.CreateElement("town");
                stadiumTownName.InnerText = stadium.TownName;

                stadiumElement.AppendChild(stadiumName);
                stadiumElement.AppendChild(stadiumCapacity);
                stadiumElement.AppendChild(stadiumTownName);
                root.AppendChild(stadiumElement);
            }

            xmlReport.AppendChild(xmlDeclaration);
            xmlReport.AppendChild(root);
            xmlReport.Save(SaveFilePath+FileName);
            Process.Start(SaveFilePath);
        }
        public XmlDocument GenerateForGenerateSolution(string platform, IEnumerable<XmlElement> projectElements)
        {
            var doc = new XmlDocument();
            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));
            var input = doc.CreateElement("Input");
            doc.AppendChild(input);

            var generation = doc.CreateElement("Generation");
            var platformName = doc.CreateElement("Platform");
            platformName.AppendChild(doc.CreateTextNode(platform));
            var hostPlatformName = doc.CreateElement("HostPlatform");
            hostPlatformName.AppendChild(doc.CreateTextNode(_hostPlatformDetector.DetectPlatform()));
            generation.AppendChild(platformName);
            generation.AppendChild(hostPlatformName);
            input.AppendChild(generation);

            var featuresNode = doc.CreateElement("Features");
            foreach (var feature in _featureManager.GetAllEnabledFeatures())
            {
                var featureNode = doc.CreateElement(feature.ToString());
                featureNode.AppendChild(doc.CreateTextNode("True"));
                featuresNode.AppendChild(featureNode);
            }
            input.AppendChild(featuresNode);

            var projects = doc.CreateElement("Projects");
            input.AppendChild(projects);

            foreach (var projectElem in projectElements)
            {
                projects.AppendChild(doc.ImportNode(projectElem, true));
            }

            return doc;
        }
Exemple #8
0
        private static System.Xml.XmlDocument CreateFileExpirationsFile(System.Xml.XmlDocument doc, ref SQLOptions o)
        {
            string FileName = GetCacheFilePath("cache_expirations");

            if (doc == null)
            {
                doc = new System.Xml.XmlDocument();
                System.Xml.XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "ASCII", "yes");
                doc.AppendChild(dec);
                System.Xml.XmlElement ele = doc.CreateElement("SQLHelper_FileExpirations");
                doc.AppendChild(ele);
            }
            //General.IO.IOTools.QueueWriteFile(doc,FileName, "cache_expirations", new General.IO.IOTools.QueueWriteFileCompletedCallback(CreateFileExpirationsFileCallback));
            try
            {
                o.WriteToLog("saving cache_expirations.xml");
                doc.Save(FileName);
            }
            catch (System.UnauthorizedAccessException)
            {
                o.WriteToLog("failure to save cache_expirations.xml");
                //DO NOTHING
            }
            return(doc);
        }
Exemple #9
0
        /// <summary>
        /// XML-Datei mit XmlDocument erstellen.
        /// </summary>
        static void CreateXmlDocument()
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlDeclaration declaration = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "no");  // XML Deklaration
            xmlDoc.AppendChild(declaration);

            XmlNode rootNode = xmlDoc.CreateElement("books");   // Wurzelelement
            xmlDoc.AppendChild(rootNode);   // Wurzelelement zum Dokument hinzufuegen

            // <book> Element
            XmlNode userNode = xmlDoc.CreateElement("book");
            // mit einem Attribut
            XmlAttribute attribute = xmlDoc.CreateAttribute("release");
            attribute.Value = "2013/02/15";
            userNode.Attributes.Append(attribute);  // Attribut zum <book> Ele hinzufuegen
            // und Textinhalt
            userNode.InnerText = "Elizabeth Corley - Pretty Little Things";
            rootNode.AppendChild(userNode); // Textinhalt zum <book> Ele hinzufuegen

            // und noch ein <book>
            userNode = xmlDoc.CreateElement("book");
            attribute = xmlDoc.CreateAttribute("release");
            attribute.Value = "2011/11/11";
            userNode.Attributes.Append(attribute);
            userNode.InnerText = "Stephen Hawking - A Brief History Of Time";
            rootNode.AppendChild(userNode);

            // XML Dokument speichern
            xmlDoc.Save("xmlDocument_books.xml");   // in ../projectname/bin/debug/
        }
        public void CreateXml(string xmlPath, string xmlName, string[] value, string[] xmlElementNode)
        {
            try
            {
                string str = inType.ToString();
                if (str.Length < 5)
                {
                    return;
                }
                string rootName = str.Substring(str.Length - 5, 4);
                XmlDocument doc = new XmlDocument();
                XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                doc.AppendChild(dec);

                XmlElement root = doc.CreateElement(rootName);
                doc.AppendChild(root);
                XmlNode childElement = doc.CreateElement(str);
                for (int i = 0; i < xmlElementNode.Length; i++)
                {
                    XmlElement xe = doc.CreateElement(xmlElementNode[i]);
                    xe.InnerText = value[i];
                    childElement.AppendChild(xe);
                }
                root.AppendChild(childElement);
                doc.Save(string.Concat(@"", xmlPath, xmlName));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        private void btn_OK_Click(object sender, EventArgs e)
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlNode docNode = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);
            xmlDoc.AppendChild(docNode);

            XmlNode version = xmlDoc.CreateElement("version");
            xmlDoc.AppendChild(version);

            XmlNode sbtNode = xmlDoc.CreateElement("SBT");
            XmlAttribute sbtAttribute = xmlDoc.CreateAttribute("Path");
            sbtAttribute.Value = textBox1.Text;
            sbtNode.Attributes.Append(sbtAttribute);
            version.AppendChild(sbtNode);

            XmlNode garenaNode = xmlDoc.CreateElement("Garena");
            XmlAttribute garenaAttribute = xmlDoc.CreateAttribute("Path");
            garenaAttribute.Value = textBox2.Text;
            garenaNode.Attributes.Append(garenaAttribute);
            version.AppendChild(garenaNode);

            XmlNode superNode = xmlDoc.CreateElement("Super");
            XmlAttribute superAttribute = xmlDoc.CreateAttribute("Path");
            superAttribute.Value = textBox3.Text;
            superNode.Attributes.Append(superAttribute);
            version.AppendChild(superNode);

            xmlDoc.Save("path");
            this.Close();
        }
        /// <summary>
        /// Serializes the specified play list items.
        /// </summary>
        /// <param name="items">The play list.</param>
        /// <returns>The serielized play list as xml document.</returns>
        public XmlDocument Serialize(IEnumerable<ListViewItem> items)
        {
            var doc = new XmlDocument();

            XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "utf-8", "yes");
            doc.AppendChild(declaration);

            XmlElement root = doc.CreateElement("items");
            doc.AppendChild(root);

            foreach (ListViewItem item in items)
            {
                XmlElement element = doc.CreateElement("item");
                element.InnerText = item.Text;

                XmlAttribute startTime = doc.CreateAttribute("start");
                startTime.InnerText = item.SubItems[1].Text;
                element.Attributes.Append(startTime);

                XmlAttribute endTime = doc.CreateAttribute("end");
                endTime.InnerText = item.SubItems[2].Text;
                element.Attributes.Append(endTime);

                XmlAttribute duration = doc.CreateAttribute("duration");
                duration.InnerText = item.SubItems[3].Text;
                element.Attributes.Append(duration);

                root.AppendChild(element);
            }

            return doc;
        }
        public string InvokeResponse(string funcName, List<UPnPArg> args)
        {
            XmlDocument doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
            doc.AppendChild(dec);

            XmlElement env = doc.CreateElement("s", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
            doc.AppendChild(env);
            env.SetAttribute("encodingStyle", "http://schemas.xmlsoap.org/soap/envelope/", "http://schemas.xmlsoap.org/soap/encoding/");

            XmlElement body = doc.CreateElement("Body", "http://schemas.xmlsoap.org/soap/envelope/");
            body.Prefix = "s";
            env.AppendChild(body);

            XmlElement func = doc.CreateElement("u", funcName + "Response", "urn:schemas-upnp-org:service:AVTransport:1");
            body.AppendChild(func);
            func.SetAttribute("xmlns:u", "urn:schemas-upnp-org:service:AVTransport:1");

            if (args != null)
            {
                foreach (UPnPArg s in args)
                {
                    XmlElement f = doc.CreateElement(s.ArgName);
                    func.AppendChild(f);
                    f.InnerText = s.ArgVal;
                }
            }

            //Saved for debugging:
            doc.Save(@"InvokeResponse.xml");

            string msg = AppendHead(doc.OuterXml);
            return msg;
        }
        private void GenerateStrings(string inputPath, string outputFile)
        {
            XElement rootElement = XElement.Load(inputPath);
            IEnumerable<Tuple<string, string>> items = from dataElement in rootElement.Descendants("data")
                                                       let key = dataElement.Attribute("name").Value
                                                       let valueElement = dataElement.Element("value")
                                                       where valueElement != null
                                                       let value = valueElement.Value
                                                       select new Tuple<string, string>(key, value);
            XmlDocument document = new XmlDocument();
            document.AppendChild(document.CreateXmlDeclaration("1.0", "utf-8", null));
            XmlNode rootNode = document.CreateElement("resources");
            document.AppendChild(rootNode);

            foreach (var pair in items)
            {
                XmlNode elementNode = document.CreateElement("string");
                elementNode.InnerText = processValue(pair.Item2);
                XmlAttribute attributeName = document.CreateAttribute("name");
                attributeName.Value = processKey(pair.Item1);
                // ReSharper disable once PossibleNullReferenceException
                elementNode.Attributes.Append(attributeName);

                rootNode.AppendChild(elementNode);
            }

            document.Save(outputFile);
        }
Exemple #15
0
        public static TreeNodeCollection BuildTreeNodes(bool refreshSiteMap)
        {
            XmlDocument map = null;
            XmlElement root = null;
            XmlElement examplesNode = null;

            if (refreshSiteMap)
            {
                map = new XmlDocument();
                XmlDeclaration dec = map.CreateXmlDeclaration("1.0", "utf-8", null);
                map.AppendChild(dec);

                root = map.CreateElement("siteMap");
                root.SetAttribute("xmlns", "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0");
                map.AppendChild(root);

                examplesNode = map.CreateElement("siteMapNode");
                examplesNode.SetAttribute("title", "Examples");
                root.AppendChild(examplesNode);
            }

            string path = HttpContext.Current.Server.MapPath("~/Examples/");
            TreeNodeCollection result = BuildTreeLevel(new DirectoryInfo(path), 1, 3, examplesNode);

            if (root != null && root.ChildNodes.Count > 0)
            {
                map.Save(HttpContext.Current.Server.MapPath("Web.sitemap"));
            }

            return result;
        }
        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;
        }
Exemple #17
0
        public static void Save()
        {
            if (File.Exists(sourceFile))
                File.Delete(sourceFile);

            XmlDocument doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", "no");
            doc.AppendChild(dec);

            XmlElement data = doc.CreateElement("usync.data");
            XmlElement content = doc.CreateElement("content");

            foreach (KeyValuePair<Guid, Tuple<string, int>> info in source)
            {
                XmlElement p = doc.CreateElement("info");
                p.SetAttribute("guid", info.Key.ToString());
                p.SetAttribute("name", info.Value.Item1);
                p.SetAttribute("parent", info.Value.Item2.ToString());

                content.AppendChild(p);
            }

            data.AppendChild(content);
            doc.AppendChild(data);
            doc.Save(sourceFile);
        }
Exemple #18
0
        public static void Save()
        {
            try
            {
                if (!Directory.Exists(SettingsFolder))
                {
                    Directory.CreateDirectory(SettingsFolder);
                }

                System.Xml.XmlDocument Xml = new System.Xml.XmlDocument();
                Xml.AppendChild(Xml.CreateXmlDeclaration("1.0", "utf-8", null));
                XmlNode Pnode = Xml.CreateElement("Settings");
                XmlNode Temp;
                Temp           = Xml.CreateElement("GradientTop");
                Temp.InnerText = ColorTranslator.ToHtml(GradientTopColor);
                Pnode.AppendChild(Temp);
                Temp           = Xml.CreateElement("GradientBottom");
                Temp.InnerText = ColorTranslator.ToHtml(GradientBottomColor);
                Pnode.AppendChild(Temp);
                Temp           = Xml.CreateElement("OutlineColor");
                Temp.InnerText = ColorTranslator.ToHtml(OutlineColor);
                Pnode.AppendChild(Temp);
                Temp           = Xml.CreateElement("TextColor");
                Temp.InnerText = ColorTranslator.ToHtml(TextColor);
                Pnode.AppendChild(Temp);

                Xml.AppendChild(Pnode);
                Xml.Save(SettingsPath);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "An Error Occured");
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Equals(textBox2.Text))
     {
         XmlDocument xmldoc = new XmlDocument();
         XmlElement xmlelem;
         XmlNode xmlnode;
         XmlText xmltext;
         xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
         xmldoc.AppendChild(xmlnode);
         xmlelem = xmldoc.CreateElement("", "ROOT", "");
         xmltext = xmldoc.CreateTextNode(textBox1.Text);
         xmlelem.AppendChild(xmltext);
         xmldoc.AppendChild(xmlelem);
         xmldoc.Save(path + "\\p.xml");
         this.Close();
     }
     else
     {
         MessageBox.Show("Two text do not match", "Error");
         textBox1.Clear();
         textBox2.Clear();
         textBox1.Focus();
     }
 }
Exemple #20
0
        public void Export(string fileOut)
        {
            XmlDocument doc = new XmlDocument();
            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));

            XmlElement root = doc.CreateElement("DungeonList");
            for (int i = 0; i < dl.Length; i++)
            {
                XmlElement b = doc.CreateElement("Block");
                XmlElement title = doc.CreateElement("Title");
                title.InnerText = Helper.Format(dl[i].title, 6);
                b.AppendChild(title);

                for (int j = 0; j < dl[i].entries.Length; j++)
                {
                    XmlElement msg = doc.CreateElement("Message");
                    msg.InnerText = Helper.Format(dl[i].entries[j].text, 8);
                    msg.SetAttribute("Script", dl[i].entries[j].script_name);
                    b.AppendChild(msg);
                }
                root.AppendChild(b);
            }

            doc.AppendChild(root);
            root = null;
            doc.Save(fileOut);
            doc = null;
        }
        static bool BuildOrderPrintConfirmXmlDoc(string sOrderNum, ref XmlDocument orderPrintConfirmXMLDoc)
        {
            string sRequestXml = "";

            try
            {
                sRequestXml = ConfigurationManager.AppSettings["ShipOrderXmlLocation"] + sOrderNum + "_print_confirm_request.xml";

                XmlDeclaration XmlDeclaration = orderPrintConfirmXMLDoc.CreateXmlDeclaration("1.0", "UTF-8", "");
                orderPrintConfirmXMLDoc.AppendChild(XmlDeclaration);

                XmlElement requestKey = orderPrintConfirmXMLDoc.CreateElement("request");
                requestKey.SetAttribute("apiKey", "9791c338-153f-4371-9f44-62b09ef528dc");
                orderPrintConfirmXMLDoc.AppendChild(requestKey);

                XmlElement userName = orderPrintConfirmXMLDoc.CreateElement("username");
                userName.InnerText = "MylanEpipenAutoShip"; // use 'autoship' user to confirm printed orders
                orderPrintConfirmXMLDoc.DocumentElement.AppendChild(userName);

                orderPrintConfirmXMLDoc.Save(sRequestXml);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occurred building order print confirm XML request document '" + sRequestXml + "'.  Error=" + ex.Message);

                return false;
            }

            return true;
        }
Exemple #22
0
 private string GetAppSettingsXml(object config, Encoding encode)
 {
     BaseAttributeConfigBean c = config as BaseAttributeConfigBean;
     if (c == null)
     {
         return string.Empty;
     }
     string[] keys = null;
     if (!string.IsNullOrEmpty(c.GetSearchConfigKey()))
     {
         keys = c.GetSearchConfigKey().Split('|');
     }   
     var doc = new XmlDocument();
     doc.AppendChild(doc.CreateXmlDeclaration("1.0", encode.BodyName, null));
     var root = doc.CreateElement("config");
     doc.AppendChild(root);
     foreach (ConfigEntity entity in c.GetEntries())
     {
         if (entity.CanRead)
         {
             if (keys == null||keys.Contains<string>(entity.Key))
             {
                 var bel = doc.CreateElement("item");
                 root.AppendChild(bel);
                 bel.SetAttribute("name", entity.Key);
                 bel.SetAttribute("value", entity.Value != null ? entity.Value.ToString() : string.Empty);
             }
         }
     }
     return doc.OuterXml;
 }
Exemple #23
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;
                }
            }
        }
        public static bool Init(string spath)
        {
            lock(CExceptionContainer_WuQi.obj_lock)
            {
                if (false != CExceptionContainer_WuQi.b_initguid)
                    return true;
                CExceptionContainer_WuQi.s_xmlfilepath = spath+"\\exceptionstore.xml";
                //删除以前的异常信息记录,也可考虑更名保存
                if (File.Exists(CExceptionContainer_WuQi.s_xmlfilepath))
                {
                    File.Delete(CExceptionContainer_WuQi.s_xmlfilepath);
                }
                //新建异常信息存储文件
                XmlDocument xmldoc = new XmlDocument();
                XmlDeclaration declaration = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
                xmldoc.AppendChild(declaration);
                XmlNode rootnode = xmldoc.CreateNode(XmlNodeType.Element, "exceptions", null);
                xmldoc.AppendChild(rootnode);

                xmldoc.Save(CExceptionContainer_WuQi.s_xmlfilepath);

                CExceptionContainer_WuQi.l_exception = new List<CExceptionInfo_WuQi>();
                //存储发生异常时向用户提供的信息,约定从 1 开始。
                CExceptionContainer_WuQi.dictionary_msg = new Dictionary<int, string>();
                CExceptionContainer_WuQi.dictionary_msg.Add(0, "异常管理系统发生故障!请与系统管理人员联系。");
                CExceptionContainer_WuQi.dictionary_msg.Add(1, "对不起,系统发生故障!请与系统管理人员联系。");

                CExceptionContainer_WuQi.b_initguid = true;
                return CExceptionContainer_WuQi.b_initguid;
            }
        }
 public Boolean analizuj()
 {
     if (sciezka == "")
     {
         return true;
     }
     XmlDocument tempXML = new XmlDocument();
     XmlDeclaration dec = tempXML.CreateXmlDeclaration("1.0", "UTF-8", null);
     tempXML.AppendChild(dec);
     XmlElement main = tempXML.CreateElement("body");
     XmlElement sc = tempXML.CreateElement("schemat");
     XmlText wartosc = tempXML.CreateTextNode(schemat);
     sc.AppendChild(wartosc);
     main.AppendChild(sc);
     generuj_elementy(sciezka, main, tempXML);
     tempXML.AppendChild(main);
     String p = sciezka + "\\" + "temp.xml";
     String q = sciezka + "\\" + "struktura_logiczna.xml";
     tempXML.Save(p);
     if (System.IO.File.ReadAllText(p) == System.IO.File.ReadAllText(q))
     {
         System.IO.File.Delete(p);
         return true;
     }
     else
     {
         System.IO.File.Delete(p);
         return false;
     }
 }
        public XmlDocument Read(out string title)
        {
            var result = new XmlDocument();
              var pkgDoc = new XmlDocument();
              pkgDoc.Load(_path);
              string folderPath;
              result.AppendChild(result.CreateElement("AML"));
              XmlElement child;

              var scripts = new List<InstallItem>();
              title = null;
              foreach (var pkg in pkgDoc.DocumentElement.Elements("package"))
              {
            title = pkg.Attribute("name", "");
            folderPath = pkg.Attribute("path");
            if (folderPath == ".\\") folderPath = InnovatorPackage.CleanFileName(title).Replace('.', '\\');
            foreach (var file in Directory.GetFiles(Path.Combine(Path.GetDirectoryName(_path), folderPath), "*.xml", SearchOption.AllDirectories))
            {
              child = result.CreateElement("AML");
              child.InnerXml = System.IO.File.ReadAllText(file);
              foreach (var item in child.Element("AML").Elements("Item"))
              {
            result.AppendChild(item);
              }
            }
              }

              return result;
        }
        public void pullData()
        {
            dataPulled = true;
            if (elements.Count != 0)
            {
                writeData();
            }
            XmlDocument myXmlDocument = new XmlDocument();
            try
            {
                myXmlDocument.Load(fileLoc);
            }
            catch (XmlException exception)
            {
                //file not setup
                Console.WriteLine("Exception Reading XML: " + exception.ToString());
                XmlDeclaration dec = myXmlDocument.CreateXmlDeclaration("1.0", null, null);
                myXmlDocument.AppendChild(dec);
                myXmlDocument.AppendChild(myXmlDocument.CreateElement("myData"));
            }

            XmlNodeList currentLetters = myXmlDocument.DocumentElement.SelectNodes("DataElement");
            foreach (XmlElement element in currentLetters)
            {
                elements.Add( getDataElement(element));
            }
            myXmlDocument.Save(fileLoc);
        }
        public string GetXMLString()
        {
            XmlDocument xmlDocument = new XmlDocument();
            XmlDeclaration xmlDeclaration = xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null);
            xmlDocument.AppendChild(xmlDeclaration);
            XmlElement root = xmlDocument.CreateElement("ServiceResponse", "http://www.phonebook.com/ServiceResponse");
            xmlDocument.AppendChild(root);
            XmlElement status = xmlDocument.CreateElement("Status", xmlDocument.DocumentElement.NamespaceURI);
            status.InnerText = m_Status.ToString();
            root.AppendChild(status);
            if (m_Information.Length > 0)
            {
                XmlElement information = xmlDocument.CreateElement("Information", xmlDocument.DocumentElement.NamespaceURI);
                information.InnerText = m_Information;
                root.AppendChild(information);
            }
            if (m_Payload.Length > 0)
            {
                XmlElement payload = xmlDocument.CreateElement("Payload", xmlDocument.DocumentElement.NamespaceURI);
                XmlDocument payloadXmlDocument = new XmlDocument();
                payloadXmlDocument.LoadXml(m_Payload);
                XmlNode payloadXmlNode = xmlDocument.ImportNode(payloadXmlDocument.DocumentElement, true);
                payload.AppendChild(payloadXmlNode);
                root.AppendChild(payload);
            }

            string outputxml = xmlDocument.OuterXml;
            outputxml = outputxml.Replace(" xmlns=\"\"", "");
            return outputxml;
        }
Exemple #29
0
        public static string GetPartInfoXMLRequest(string cliinfo,string productid)
        {
            XmlDocument doc = new XmlDocument();
               XmlElement root,node,node_1;
               XmlDeclaration dec;
             //  doc.CreateXmlDeclaration("1.0", "utf-8", null);
               doc.AppendChild(dec=  doc.CreateXmlDeclaration("1.0", "", ""));
               root= doc.CreateElement("REQ");
               doc.AppendChild(root);

               node= doc.CreateElement("CLIINFO");
               node.InnerText = cliinfo;
               root.AppendChild(node);
               node = doc.CreateElement("FUNCTION");
               node.InnerText="PT000V_PartInfo";
               root.AppendChild(node);
               node = doc.CreateElement("VERSION");
               node.InnerText = "1.0.0.0";
               root.AppendChild(node);
               node=doc.CreateElement("ELE");
               XmlAttribute attr=doc.CreateAttribute("NAME");
               attr.Value="PARTINFO";
               node.Attributes.Append(attr);
               attr = doc.CreateAttribute("NAME");
               attr.Value = "PARTINFO";
               node_1=doc.CreateElement("ATTR");
               node_1.Attributes.Append(attr);
               node_1.InnerText=productid;
            node.AppendChild(node_1);
            root.AppendChild(node);
            return doc.InnerXml;
        }
Exemple #30
0
 public void Save(string fileName)
 {
     XmlDocument doc = new XmlDocument();
     XmlNode declNode = doc.CreateXmlDeclaration("1.0", "utf-8", null);
     doc.AppendChild(declNode);
     var regNode = doc.CreateElement(@"Реестр");
     doc.AppendChild(regNode);
     var packNode = doc.CreateElement(@"Пакет");
     regNode.AppendChild(packNode);
     var recipNode = doc.CreateElement(@"Получатель");
     recipNode.SetAttribute("ИНН", RecipientINN);
     recipNode.SetAttribute("КПП", RecipientKPP);
     packNode.AppendChild(recipNode);
     var sendNode = doc.CreateElement(@"Отправитель");
     sendNode.SetAttribute("ИНН", SenderINN);
     sendNode.SetAttribute("КПП", SenderKPP);
     packNode.AppendChild(sendNode);
     foreach (var attachment in _Attachments)
     {
         var attNode = doc.CreateElement(@"Вложение");
         attNode.SetAttribute("ИмяФайла", attachment);
         packNode.AppendChild(attNode);
     }
     doc.Save(fileName);
 }
Exemple #31
0
        public OpenFileForm(String path)
        {
            //create contact.xml while opening the OpenFile Dialog first time
            kChatFileFolderPath = path;
            if (!Directory.Exists(kChatFileFolderPath + "Common Files"))
            {
                Directory.CreateDirectory(kChatFileFolderPath + "Common Files");
            }
            if (!File.Exists(kChatFileFolderPath + "Common Files\\contact.xml"))
            {
                try
                {
                    XmlDocument contact = new XmlDocument();
                    XmlDeclaration dec = contact.CreateXmlDeclaration("1.0", "UTF-8", null);
                    contact.AppendChild(dec);
                    XmlElement root = contact.CreateElement("contactlist");
                    contact.AppendChild(root);
                    XmlElement group = contact.CreateElement("group");
                    group.SetAttribute("name", "default");
                    root.AppendChild(group);
                    contact.Save(kChatFileFolderPath + "Common Files\\contact.xml");
                }

                catch (IOException ex)
                {
                    MessageBox.Show(ex.ToString(), "IOError");
                    return;
                }
            }
            InitializeComponent();
        }
Exemple #32
0
        public bool Save(string path)
        {
            bool saved = true;
            XmlDocument m_Xdoc = new XmlDocument();
            try
            {
                m_Xdoc.RemoveAll();

                XmlNode node = m_Xdoc.CreateXmlDeclaration("1.0", "utf-8", string.Empty);
                m_Xdoc.AppendChild(node);

                node = m_Xdoc.CreateComment($" Profile Configuration Data. {DateTime.Now} ");
                m_Xdoc.AppendChild(node);

                node = m_Xdoc.CreateWhitespace("\r\n");
                m_Xdoc.AppendChild(node);

                node = m_Xdoc.CreateNode(XmlNodeType.Element, "Profile", null);

                m_Xdoc.AppendChild(node);

                m_Xdoc.Save(path);
            }
            catch
            {
                saved = false;
            }

            return saved;
        }
 public static void WriteConfigErrorXML()
 {
     XmlDocument ErrorEX = new XmlDocument();
     //Set Declare
     XmlDeclaration xmldec = ErrorEX.CreateXmlDeclaration("1.0", "UTF-8", null);
     ErrorEX.AppendChild(xmldec);
     //Create Root
     XmlElement root = ErrorEX.CreateElement("errorcatch");
     ErrorEX.AppendChild(root);
     //Create Error ID
     XmlElement EID = ErrorEX.CreateElement("eid");
     EID.InnerText = "E10001";
     root.AppendChild(EID);
     //Create Log infomation
     XmlElement Log = ErrorEX.CreateElement("log");
     root.AppendChild(Log);
     //Create Error information
     XmlElement DES = ErrorEX.CreateElement("detail");
     root.AppendChild(DES);
     //Create User information
     XmlElement INFO = ErrorEX.CreateElement("info");
     root.AppendChild(INFO);
     //Save the file
     ErrorEX.Save(FileVerify.GetPath() + "/error.dat");
     Application.OpenURL(FileVerify.GetPath() + "/bugreport.exe");
 }
Exemple #34
0
        public static void Write(string key, string value)
        {
            key   = System.Web.HttpUtility.HtmlEncode(key);
            value = System.Web.HttpUtility.HtmlEncode(value);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            XmlNode root;

            if (!File.Exists(xml_path))
            {
                doc.CreateXmlDeclaration("1.0", "utf-8", "yes");
                root = doc.CreateElement("config");
                XmlNode node = doc.CreateElement(key);
                node.InnerText = value;
                root.AppendChild(node);
                doc.AppendChild(root);
                doc.Save(xml_path);
                return;
            }

            doc.Load(xml_path);
            root = doc.DocumentElement;
            if (root == null)
            {
                root = doc.CreateElement("config");
                doc.AppendChild(root);
            }
            XmlNode nod;

            try
            {
                nod = root.SelectSingleNode("/config/" + key);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                return;
            }

            if (nod == null)
            {
                nod           = doc.CreateElement(key);
                nod.InnerText = value;
                root.AppendChild(nod);
                doc.Save(xml_path);
                return;
            }
            if (nod.InnerText != value)
            {
                nod.InnerText = value;
                doc.Save(xml_path);
            }
        }
Exemple #35
0
        private void GenerateMetaData()
        {
            string MetaDataFileName     = string.Format("{0}.MetaData.xml", Convert.ToString(this.cbxLanguages.SelectedValue).Trim());
            string metadataFileFullName = productScreenshotDirectory + MetaDataFileName;

            XmlDocument doc = new System.Xml.XmlDocument();

            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);

            // Create the root element
            XmlElement root = doc.CreateElement("screenshots");

            doc.AppendChild(root);


            foreach (ProductImage screenshot in this.images)
            {
                XmlElement filename = doc.CreateElement(MetaDataNodeFileName);
                filename.InnerText = screenshot.Url;

                XmlElement description = doc.CreateElement(MetaDataNodeDescription);
                description.InnerText = screenshot.Description;

                XmlElement width = doc.CreateElement(MetaDataNodeWidth);
                width.InnerText = screenshot.ImageSize.Width.ToString();

                XmlElement height = doc.CreateElement(MetaDataNodeHeight);
                height.InnerText = screenshot.ImageSize.Height.ToString();

                XmlElement thumbfilename = doc.CreateElement(MetaDataNodeFileName);
                thumbfilename.InnerText = screenshot.Thumbnail.Url;

                XmlElement thumbtitle = doc.CreateElement(MetaDataNodeTitle);
                thumbtitle.InnerText = screenshot.Thumbnail.Title;

                XmlElement thumbnail = doc.CreateElement(MetaDataNodeThumbnail);
                thumbnail.AppendChild(thumbfilename);
                thumbnail.AppendChild(thumbtitle);

                XmlElement image = doc.CreateElement("image");
                image.AppendChild(filename);
                image.AppendChild(description);
                image.AppendChild(width);
                image.AppendChild(height);
                image.AppendChild(thumbnail);

                root.AppendChild(image);
            }

            doc.Save(metadataFileFullName);
        }
        private void SaveParameterFile()
        {
            string NowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            try
            {
                DataSet saveData = paramFile.Copy();

                saveData.Tables["Device"].Rows[0]["UpdateTime"] = NowTime;

                saveData.Tables["Var"].Columns.Remove("Message_Name");
                saveData.Tables["Var"].Columns.Remove("Var_Desc");
                saveData.Tables["Var"].Columns.Remove("Var_Obj");
                saveData.Tables["Var"].Columns.Remove("Tables");
                saveData.Tables["Var"].Columns.Remove("Modify");

                using (MemoryStream ms = new MemoryStream())
                {
                    saveData.WriteXml(ms);
                    ms.Position = 0;
                    XmlDocument doc = new System.Xml.XmlDocument();
                    doc.Load(ms);

                    XmlNode root   = doc.SelectSingleNode("NewDataSet");
                    XmlNode device = root.SelectSingleNode("Device");
                    doc.RemoveChild(root);

                    XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "utf-8", "yes");
                    doc.AppendChild(declaration);

                    doc.AppendChild(device);
                    doc.Save(FileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存定值文件失败!\n错误信息:" + ex.Message);
                return;
            }

            deviceTable.Rows[0]["UpdateTime"] = NowTime;
            this.textBoxCreateTime.Text       = NowTime;

            foreach (DataRow var in varTable.Rows)
            {
                var["Modify"] = false;
            }

            SaveToolStripMenuItem.Enabled   = false;
            ReloadToolStripMenuItem.Enabled = false;
        }
        /// <summary>
        /// Saves the current collection of Host Instances to disk
        /// </summary>
        /// <param name="xmlDocName">Filename (verbatim) to save data to - User AppData Path is prepended
        /// if the path does not start with either ?: or \\</param>
        public virtual void ToXml(String xmlDocName)
        {
            System.Xml.XmlDocument xmlData = new System.Xml.XmlDocument();

            // Create the XML Declaration (well formed)
            XmlDeclaration xmlDeclaration = xmlData.CreateXmlDeclaration("1.0", "utf-8", null);

            xmlData.InsertBefore(xmlDeclaration, xmlData.DocumentElement);

            // Create the root element
            System.Xml.XmlElement xmlRoot = xmlData.CreateElement("Hosts");

            // Loop through the collection and serialize the lot
            foreach (KeyValuePair <String, Base> de in this)
            {
                Base        fi     = (Base)de.Value;
                XmlDocument xmlDoc = fi.ToXml();

                foreach (XmlNode xn in xmlDoc.ChildNodes)
                {
                    xmlRoot.AppendChild(xmlData.ImportNode(xn, true));
                }
            }
            xmlData.AppendChild(xmlRoot);

            // Save the XML stream to the file
            if ((xmlDocName.Substring(1, 1) == ":") || (xmlDocName.StartsWith("\\\\")))
            {
                xmlData.Save(xmlDocName);
            }
            else
            {
                xmlData.Save(Preferences.PreferenceSet.Instance.AppDataPath + "\\" + xmlDocName);
            }
        }
Exemple #38
0
        private static void UpdateProjectFile(ParsedArgs pa)
        {
            //load the project file
            var template = new System.Xml.XmlDocument();

            template.Load(pa.TemplateFile);

            //update it

            RemoveTargets(template);
            AddTargets(template, pa.TargetsDirectory);

            UpdateReferencePaths(template);

            //write it back to disk

            var output = new System.Xml.XmlDocument();

            foreach (var node in template.ChildNodes.Cast <XmlNode>().Where(w => w.NodeType != XmlNodeType.XmlDeclaration))
            {
                var importNode = output.ImportNode(node, true);
                output.AppendChild(importNode);
            }

            using (var xWriter = XmlWriter.Create(pa.TemplateFile, new XmlWriterSettings()
            {
                Indent = true, IndentChars = " "
            }))
            {
                output.WriteTo(xWriter);
            }
        }
Exemple #39
0
        internal void Save()
        {
            XmlDocument doc      = new System.Xml.XmlDocument();
            XmlElement  rootElem = doc.CreateElement("root");

            foreach (string channelName in associations.Keys)
            {
                XmlElement channelElem = doc.CreateElement("channel");
                channelElem.SetAttribute("name", channelName);

                foreach (string eventName in associations[channelName].Keys)
                {
                    XmlElement eventElem = doc.CreateElement("event");
                    eventElem.SetAttribute("name", eventName);
                    eventElem.SetAttribute("scriptName", associations[channelName][eventName].ScriptName);
                    eventElem.SetAttribute("handlerName", associations[channelName][eventName].HandlerName);
                    channelElem.AppendChild(eventElem);
                }
                rootElem.AppendChild(channelElem);
            }
            doc.AppendChild(rootElem);

            using (MemoryStream stream = new MemoryStream())
            {
                doc.Save(stream);
                Env.Current.Project.SetData(ProjectEntityType.Settings, "channels_script_handlers", stream);
            }
        }
        /// <summary>
        /// Saves settings to XML.
        /// </summary>
        /// <param name="doc">The doc.</param>
        /// <param name="infoEvents">The info events.</param>
        void IDTSComponentPersist.SaveToXML(System.Xml.XmlDocument doc, IDTSInfoEvents infoEvents)
        {
            try
            {
                XmlElement taskElement = doc.CreateElement(string.Empty, "ZipTask", string.Empty);
                doc.AppendChild(taskElement);

                taskElement.SetAttribute(CONSTANTS.ZIPFILEACTION, null, this.fileAction.ToString());
                taskElement.SetAttribute(CONSTANTS.ZIPCOMPRESSIONTYPE, null, this.compressionType.ToString());
                taskElement.SetAttribute(CONSTANTS.ZIPCOMPRESSIONLEVEL, null, this.zipCompressionLevel.ToString());
                taskElement.SetAttribute(CONSTANTS.TARCOMPRESSIONLEVEL, null, this.tarCompressionLevel.ToString());
                taskElement.SetAttribute(CONSTANTS.ZIPPASSWORD, null, this.zipPassword);
                taskElement.SetAttribute(CONSTANTS.ZIPSOURCE, null, this.sourceFile);
                taskElement.SetAttribute(CONSTANTS.ZIPTARGET, null, this.targetFile);
                taskElement.SetAttribute(CONSTANTS.ZIPREMOVESOURCE, null, this.removeSource.ToString());
                taskElement.SetAttribute(CONSTANTS.ZIPRECURSIVE, null, this.recursive.ToString());
                taskElement.SetAttribute(CONSTANTS.ZIPOVERWRITE, null, this.overwriteTarget.ToString());
                taskElement.SetAttribute(CONSTANTS.ZIPFILEFILTER, null, this.fileFilter);
                taskElement.SetAttribute(CONSTANTS.ZIPLOGLEVEL, null, this.logLevel.ToString());
            }
            catch (Exception ex)
            {
                infoEvents.FireError(0, "Save To XML: ", ex.Message + ex.StackTrace, "", 0);
            }
        }
Exemple #41
0
        void Save()
        {
            var doc            = new System.Xml.XmlDocument();
            var xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            var root           = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);
            var records = doc.CreateElement("records");

            doc.AppendChild(records);
            var tables        = doc.CreateElement(string.Empty, "tables", string.Empty);
            var singleRecords = doc.CreateElement(string.Empty, "srec", string.Empty);
            var teamRecords   = doc.CreateElement(string.Empty, "trec", string.Empty);

            records.AppendChild(singleRecords);
            records.AppendChild(teamRecords);
            records.AppendChild(tables);

            // single records:
            foreach (var s in this.mSingleStorage)
            {
                var r     = doc.CreateElement(string.Empty, "record", string.Empty);
                var dsvId = doc.CreateAttribute("id");
                dsvId.Value = s.SwimmerId;
                r.Attributes.Append(dsvId);
            }
        }
    // 파티클 저장
    void OnApplicationQuit()
    {
        string path = Application.streamingAssetsPath + "/" + MovieName;

        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
        if (!di.Exists)
        {
            di.Create();
        }

        System.Xml.XmlDocument Document      = new System.Xml.XmlDocument();
        System.Xml.XmlElement  MovieDataList = Document.CreateElement("MovieDataList");
        Document.AppendChild(MovieDataList);

        foreach (var it in recoderQueue)
        {
            // 경로 지정
            it.Save(Document, MovieDataList);
        }
        recoderQueue.Clear();

        path = Application.streamingAssetsPath + "/Movie/" + MovieName + ".xml";

#if !NETFX_CORE
        Document.Save(path);
#endif
    }
Exemple #43
0
        ///////////////////////////////////////////////////////////////////////////////
        //
        //  Create the xml document.
        //
        ///////////////////////////////////////////////////////////////////////////////

        XmlDocument _createXmlDocument()
        {
            System.Xml.XmlDocument xml = new System.Xml.XmlDocument();

            XmlElement pluginTemplate = xml.CreateElement("PluginTemplate");

            pluginTemplate.SetAttribute("name", _pluginName.Text.Replace(" ", ""));

            // Append the user element
            pluginTemplate.AppendChild(this._createUserElement(xml));

            // Append the compile guard element.
            pluginTemplate.AppendChild(this._createCompileGuardElement(xml));

            // Append the Component Source Element.
            pluginTemplate.AppendChild(this._createComponentSourceElement(xml));

            // Append the Component Header Element.
            pluginTemplate.AppendChild(this._createComponentHeaderElement(xml));

            // Append the Factory Source element.
            pluginTemplate.AppendChild(this._createFactorySourceElement(xml));

            // Append the Factory Header element.
            pluginTemplate.AppendChild(this._createFactoryHeaderElement(xml));

            // Append the plugin template element to the document.
            xml.AppendChild(pluginTemplate);

            return(xml);
        }
    // 파티클 저장
    void OnApplicationQuit()
    {
        string path = Application.streamingAssetsPath + "/" + MovieName;

        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
        if (!di.Exists)
        {
            di.Create();
        }

        System.Xml.XmlDocument Document      = new System.Xml.XmlDocument();
        System.Xml.XmlElement  MovieDataList = Document.CreateElement("MovieDataList");
        Document.AppendChild(MovieDataList);

        for (int i = 0; i < effectRecoderObjects.Count; i++)
        {
            // 경로 지정
            effectRecoderObjects[i].Save(Document, MovieDataList);
        }
        effectRecoderObjects.Clear();

        path = Application.streamingAssetsPath + "/Movie/" + MovieName + "Object.xml";

#if !NETFX_CORE
        Document.Save(path);
#endif
    }
        public void SaveSettings()
        {
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                if (ms.Length != 0)
                {
                    ms.SetLength(0);
                    ms.Seek(0, System.IO.SeekOrigin.Begin);
                }

                XmlDocument doc       = new System.Xml.XmlDocument();
                XmlElement  root_elem = doc.CreateElement("root");
                foreach (IModbusStation stat in stations)
                {
                    XmlElement elem = doc.CreateElement("station");
                    StationFactory.SaveStation(elem, stat);
                    root_elem.AppendChild(elem);
                }

                foreach (IChannel ch in channels)
                {
                    XmlElement elem = doc.CreateElement("channel");
                    ChannelFactory.SaveChannel(elem, ch);
                    root_elem.AppendChild(elem);
                }
                doc.AppendChild(root_elem);
                doc.Save(ms);
                environment.Project.SetData("settings/" + StringConstants.PluginId + "_channels", ms);
            }
        }
Exemple #46
0
        public static XmlDocument GenerateXMLDoc(Sprite a_sp, bool a_bOnlyChildren)
        {
            if (a_sp == null)
            {
                a_sp = EH.Instance.Stage.RootSprite;
            }
            XmlDocument doc = new System.Xml.XmlDocument();
            XmlElement  elm = doc.CreateElement("root");

            doc.AppendChild(elm);
            if (a_bOnlyChildren)
            {
                if (a_sp.ChildCount > 0)
                {
                    for (int i = 0; i < a_sp.ChildCount; i++)
                    {
                        RecurseSpritesToXML(elm, a_sp.GetChildByIndex(i));
                    }
                }
            }
            else
            {
                RecurseSpritesToXML(elm, a_sp);
            }
            return(doc);
        }
        public void WritePictureXMLFile()
        {
            GlobalDataStore.Logger.Debug("Updating Pictures.xml ...");
            List <LabelX.Toolbox.LabelXItem> items        = new List <LabelX.Toolbox.LabelXItem>();
            DirectoryInfo PicturesRootFolderDirectoryInfo = new DirectoryInfo(PicturesRootFolder);

            LabelX.Toolbox.Toolbox.GetPicturesFromFolderTree(PicturesRootFolderDirectoryInfo.FullName, ref items);

            //items = alle ingelezen pictures. Nu gaan wegschrijven.
            System.Xml.XmlDocument doc  = new System.Xml.XmlDocument();
            System.Xml.XmlElement  root = doc.CreateElement("LabelXItems");

            foreach (LabelX.Toolbox.LabelXItem item in items)
            {
                System.Xml.XmlElement itemXML = doc.CreateElement("item");
                itemXML.SetAttribute("name", item.Name);
                itemXML.SetAttribute("hash", item.Hash);

                root.AppendChild(itemXML);
            }

            doc.AppendChild(root);

            MemoryStream ms = new MemoryStream();

            System.Xml.XmlTextWriter tw = new System.Xml.XmlTextWriter(ms, Encoding.UTF8);
            tw.Formatting = System.Xml.Formatting.Indented;
            doc.WriteContentTo(tw);
            doc.Save(PicturesRootFolder + "pictures.xml");


            tw.Close();
        }
 internal static void SaveMappingProfileToXml()
 {
     try
     {
         XmlDocument doc = new System.Xml.XmlDocument();
         doc.AppendChild(doc.CreateElement("root"));
         foreach (MappingProfile mp in MappingProfiles)
         {
             XmlElement xMP = doc.CreateElement("MappingProfile");
             doc.DocumentElement.AppendChild(xMP);
             xMP.Attributes.Append(Util.MakeAttribute(doc, "ProfileName", mp.ProfileName));
             xMP.Attributes.Append(Util.MakeAttribute(doc, "TargetContentTypeName", mp.TargetContentTypeName));
             foreach (MappingItem mi in mp.MappingItems)
             {
                 XmlElement xMI = doc.CreateElement("MappingItem");
                 xMP.AppendChild(xMI);
                 xMI.Attributes.Append(Util.MakeAttribute(doc, "SourceColumn", mi.SourceColumn));
                 xMI.Attributes.Append(Util.MakeAttribute(doc, "DestColumn", mi.DestColumn));
             }
         }
         GlobalVars.SETTINGS.metadata_MappingProfiles = doc;
     }
     catch (Exception ex)
     {
         Eh.GlobalErrorHandler(ex);
     }
 }
Exemple #49
0
    public XMLFile()
    {
        doc  = new System.Xml.XmlDocument();
        node = doc.CreateNode(System.Xml.XmlNodeType.Element, "root", null);

        doc.AppendChild(node);
    }
Exemple #50
0
        internal static string GetShaderOpPayload(string shaderText, string xml)
        {
            System.Xml.XmlDocument d = new System.Xml.XmlDocument();
            d.LoadXml(xml);
            XmlElement opElement;

            if (d.DocumentElement.LocalName != "ShaderOpSet")
            {
                var setElement = d.CreateElement("ShaderOpSet");
                opElement = (XmlElement)d.RemoveChild(d.DocumentElement);
                setElement.AppendChild(opElement);
                d.AppendChild(setElement);
            }
            else
            {
                opElement = d.DocumentElement;
            }
            if (opElement.LocalName != "ShaderOp")
            {
                throw new InvalidOperationException("Expected 'ShaderOp' or 'ShaderOpSet' root elements.");
            }

            var shaders = opElement.ChildNodes.OfType <XmlElement>().Where(elem => elem.LocalName == "Shader").ToList();

            foreach (var shader in shaders)
            {
                if (!shader.HasChildNodes || String.IsNullOrWhiteSpace(shader.InnerText))
                {
                    shader.InnerText = shaderText;
                }
            }

            return(d.OuterXml);
        }
Exemple #51
0
 /// <summary>
 /// Saves settings to XML.
 /// </summary>
 /// <param name="doc">The doc.</param>
 /// <param name="infoEvents">The info events.</param>
 void IDTSComponentPersist.SaveToXML(System.Xml.XmlDocument doc, IDTSInfoEvents infoEvents)
 {
     try
     {
         //create node in the package xml document
         XmlElement taskElement = doc.CreateElement(string.Empty, "SFTPTask", string.Empty);
         doc.AppendChild(taskElement);
         taskElement.SetAttribute(CONSTANTS.SFTPLOCALFILE, null, this.localFile);
         taskElement.SetAttribute(CONSTANTS.SFTPREMOTEFILE, null, this.remoteFile);
         taskElement.SetAttribute(CONSTANTS.SFTPFILEACTION, null, this.fileAction.ToString());
         taskElement.SetAttribute(CONSTANTS.SFTPFILEINFO, null, this.fileInfo);
         taskElement.SetAttribute(CONSTANTS.SFTPOVERWRITEDEST, null, this.overwriteDest.ToString());
         taskElement.SetAttribute(CONSTANTS.SFTPREMOVESOURCE, null, this.removeSource.ToString());
         taskElement.SetAttribute(CONSTANTS.SFTPISRECURSIVE, null, this.isRecursive.ToString());
         taskElement.SetAttribute(CONSTANTS.SFTPFILEFILTER, null, this.fileFilter);
         //taskElement.SetAttribute(CONSTANTS.SFTPRETRIES, null, this.reTries.ToString());
         taskElement.SetAttribute(CONSTANTS.SFTPHOST, null, this.hostName);
         taskElement.SetAttribute(CONSTANTS.SFTPPORT, null, this.portNumber);
         taskElement.SetAttribute(CONSTANTS.SFTPUSER, null, this.userName);
         taskElement.SetAttribute(CONSTANTS.SFTPPASSWORD, null, this.passWord);
         taskElement.SetAttribute(CONSTANTS.SFTPSTOPONFAILURE, null, this.stopOnFailure.ToString());
         taskElement.SetAttribute(CONSTANTS.SFTPREMOTEFILELISTVAR, null, this.remoteFileListVariable);
         taskElement.SetAttribute(CONSTANTS.SFTPLOGLEVEL, null, this.logLevel.ToString());
     }
     catch (Exception ex)
     {
         infoEvents.FireError(0, "Save To XML: ", ex.Message + Environment.NewLine + ex.StackTrace, "", 0);
     }
 }
Exemple #52
0
        private static async System.Threading.Tasks.Task UpdateCRMOnlineIPs(bool force)
        {
            if (LastCRMOnlineIPUpdate.AddHours(12) <= DateTime.Now | force)
            {
                String CRMOnlineStep1 = await GetIPsasString(new Uri("https://support.microsoft.com/api/content/kb/2655102"));

                System.Xml.XmlDocument _result = new System.Xml.XmlDocument();
                XmlElement             root    = _result.CreateElement("crmonline");
                _result.AppendChild(root);
                System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();

                String CRMOnlineStep2 = RemoveStrayHTML(CRMOnlineStep1);

                //this splits everything into 7 objects
                string[] stringSeparators = new string[] { "<span class='text-base'>" };
                String[] CRMOnlineStep3   = CRMOnlineStep2.Split(stringSeparators, StringSplitOptions.None);

                //since the first one is all the text *before* the URLs,
                //we can drop the first one
                foreach (String org in CRMOnlineStep3.Skip(1))
                {
                    //now, split it on <br/>
                    //skip the first one
                    String       url1;
                    XmlElement   region     = _result.CreateElement("region");
                    XmlAttribute regionname = _result.CreateAttribute("name");
                    regionname.Value = org.Substring(0, org.IndexOf("based organizations")).Replace(" area", "").Trim();
                    region.Attributes.Append(regionname);

                    //build the addresslist type attribute
                    XmlElement   addressTypeNode = _result.CreateElement("addresslist");
                    XmlAttribute addressTypeName = _result.CreateAttribute("type");
                    addressTypeName.Value = "url";
                    addressTypeNode.Attributes.Append(addressTypeName);

                    foreach (string url0 in org.Split(new string[] { @"<br/>" }, StringSplitOptions.None).Skip(1))
                    {
                        if (url0.Length > 0)
                        {
                            url1 = ReplaceNonPrintableCharacters(url0);
                            System.Diagnostics.Debug.WriteLine("org: " + org.Substring(0, org.IndexOf(":")));
                            System.Diagnostics.Debug.WriteLine(url1.IndexOf(@"://"));
                            if (url1.IndexOf(@"://") > 0 && url1.IndexOf(@"://") < 7)
                            {
                                url1 = url1.Substring(url1.IndexOf("h"));
                                XmlElement urlnode = _result.CreateElement("address");
                                urlnode.InnerText = url1;
                                addressTypeNode.AppendChild(urlnode);
                            }
                        }
                    }
                    region.AppendChild(addressTypeNode);
                    root.AppendChild(region);
                }

                CRMOnlineIPs          = _result;
                LastCRMOnlineIPUpdate = DateTime.UtcNow;
            }
        }
Exemple #53
0
 public void SaveRuleList(List <RewriterRule> ruleList)
 {
     System.Xml.XmlDocument    xml = new System.Xml.XmlDocument();
     System.Xml.XmlDeclaration xmldecl;
     xmldecl = xml.CreateXmlDeclaration("1.0", "utf-8", null);
     xml.AppendChild(xmldecl);
     System.Xml.XmlElement xmlelem = xml.CreateElement("", "rewrite", "");
     foreach (RewriterRule rule in ruleList)
     {
         System.Xml.XmlElement e = xml.CreateElement("", "item", "");
         e.SetAttribute("lookfor", rule.LookFor);
         e.SetAttribute("sendto", rule.SendTo);
         xmlelem.AppendChild(e);
     }
     xml.AppendChild(xmlelem);
     xml.Save(HttpContext.Current.Server.MapPath(string.Format("//config/rewrite.config", "/")));
 }
Exemple #54
0
        /// <summary>
        /// Serializes the WaitForTime component into the DTSX package
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="infoEvents"></param>
        void IDTSComponentPersist.SaveToXML(System.Xml.XmlDocument doc, IDTSInfoEvents infoEvents)
        {
            XmlElement data = doc.CreateElement("WaitForTimeData");

            doc.AppendChild(data);

            data.SetAttribute("waitTime", waitTime.ToString());
            data.SetAttribute("waitNextDayIfTimePassed", WaitNextDayIfTimePassed.ToString());
        }
Exemple #55
0
        public void WriteLocalSetting(string sectionName, string settingName, string settingValue)
        {
            string sectionNameValid = RemoveInvalidXmlChars(sectionName);
            string settingNameValid = RemoveInvalidXmlChars(settingName);

            if (ConfigDocument == null)
            {
                ConfigDocument = new System.Xml.XmlDocument();
                if (System.IO.File.Exists(ConfigFileName))
                {
                    ConfigDocument.Load(ConfigFileName);
                }
                else
                {
                    ConfigDocument.AppendChild(ConfigDocument.CreateElement("LocalConfig"));
                }
            }

            lock (ConfigDocument) {
                if (ConfigDocument.DocumentElement == null)
                {
                    ConfigDocument.LoadXml("<?xml version='1.0' ?><LocalConfig></LocalConfig>");
                }

                System.Xml.XmlAttribute Attribute;
                System.Xml.XmlNode      SectionNode = ConfigDocument.SelectSingleNode("/LocalConfig/Section[@name='" + sectionNameValid + "']");
                if (SectionNode == null)
                {
                    //Crear la sección
                    SectionNode     = ConfigDocument.CreateElement("Section");
                    Attribute       = ConfigDocument.CreateAttribute("name");
                    Attribute.Value = sectionNameValid;
                    SectionNode.Attributes.Append(Attribute);
                    ConfigDocument.DocumentElement.AppendChild(SectionNode);
                }
                System.Xml.XmlNode SettingNode = ConfigDocument.SelectSingleNode("/LocalConfig/Section[@name='" + sectionNameValid + "']/Setting[@name='" + settingNameValid + "']");
                if (SettingNode == null)
                {
                    //Agregar el nodo
                    SettingNode     = ConfigDocument.CreateElement("Setting");
                    Attribute       = ConfigDocument.CreateAttribute("name");
                    Attribute.Value = settingNameValid;
                    SettingNode.Attributes.Append(Attribute);
                    Attribute       = ConfigDocument.CreateAttribute("value");
                    Attribute.Value = settingValue;
                    SettingNode.Attributes.Append(Attribute);
                    SectionNode.AppendChild(SettingNode);
                }
                System.Xml.XmlAttribute SettingAttribute = SettingNode.Attributes["value"];
                if (SettingAttribute != null)
                {
                    SettingAttribute.Value = settingValue;
                }
                ConfigDocument.Save(ConfigFileName);
            }
        }
Exemple #56
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);
        }
Exemple #57
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);
        }
Exemple #58
0
    private void SetupXmlDoc()
    {
        XmlProcessingInstruction Version = null;

        //<?xml version="1.0"?>

        //Create a new document object
        MyXMLDoc = new XmlDocument();
        MyXMLDoc.PreserveWhitespace = false;
        //MyXMLDoc.async = False
        //tell the parser to automatically load externally defined DTD's or XSD's
        //MyXMLDoc.resolveExternals = True

        Version = MyXMLDoc.CreateProcessingInstruction("xml", "version=" + Strings.Chr(34) + "1.0" + Strings.Chr(34));
        //create the root element
        //and append it and the XML version to the document
        MyXMLDoc.AppendChild(Version);

        MyXMLDoc.AppendChild(MyXMLDoc.CreateElement("Alugen3"));
    }
Exemple #59
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);
        }
Exemple #60
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);
        }