/// <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);
        }
        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();
        }
        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;
        }
Example #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;
        }
Example #5
0
        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;
            }
        }
        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;
        }
Example #7
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;
        }
Example #8
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;
        }
Example #9
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;
        }
Example #10
0
        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);
        }
Example #11
0
 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;
     }
 }
Example #12
0
        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;
        }
Example #13
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;
 }
Example #14
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");
        }
Example #15
0
 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();
     }
 }
        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;
        }
        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 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);
        }
Example #19
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;
        }
 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");
 }
Example #21
0
        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);
        }
Example #22
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();
        }
        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;
        }
        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;
        }
Example #25
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/
        }
Example #26
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);
 }
        /// <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;
        }
Example #28
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);
        }
Example #29
0
        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
            };
        }
 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);
     }
 }