private void btnPublishFolder_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtFolderPath.Text))
            {
                //To Publish Folder, add Data to XML
                System.Xml.XmlDocument objXmlDocument = new System.Xml.XmlDocument();
                // Load XML
                objXmlDocument.Load(@".\Data\PublishedFolders.xml");
                System.Xml.XmlNode objXmlNode = objXmlDocument.CreateNode(System.Xml.XmlNodeType.Element,"Folder", "Folder");

                // Attribute Name
                System.Xml.XmlAttribute objXmlAttribute = objXmlDocument.CreateAttribute("Name");
                objXmlAttribute.Value = "Carpeta";
                objXmlNode.Attributes.Append(objXmlAttribute);
                // Attribute Status
                objXmlAttribute = objXmlDocument.CreateAttribute("Status");
                objXmlAttribute.Value = "Enabled";
                objXmlNode.Attributes.Append(objXmlAttribute);
                // Attribute Path
                objXmlAttribute = objXmlDocument.CreateAttribute("Path");
                objXmlAttribute.Value = txtFolderPath.Text;
                objXmlNode.Attributes.Append(objXmlAttribute);

                // Add Node
                objXmlDocument.SelectSingleNode("/PublishedFolders").AppendChild(objXmlNode);
                // Update File
                objXmlDocument.Save(@".\Data\PublishedFolders.xml");

                // Refresh List
                LoadFolders();
            }
        }
Exemple #2
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //Save the values to an XML file
            //Could save to data source, Message Queue, etc.
            System.Xml.XmlDocument  aDOM = new System.Xml.XmlDocument();
            System.Xml.XmlAttribute aAttribute;

            aDOM.LoadXml("<PersonnelData/>");

            //Add the First Name attribute to XML
            aAttribute       = aDOM.CreateAttribute("FirstName");
            aAttribute.Value = txtFName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the Last Name attribute to XML
            aAttribute       = aDOM.CreateAttribute("LastName");
            aAttribute.Value = txtLName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the DOB attribute to XML
            aAttribute       = aDOM.CreateAttribute("DOB");
            aAttribute.Value = txtDOB.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the SSN attribute to XML
            aAttribute       = aDOM.CreateAttribute("SSN");
            aAttribute.Value = txtSSN.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Save file to the file system
            aDOM.Save("PersonnelData.xml");
        }
Exemple #3
0
        public SVGArrow(ISVGElement parent, int x1, int y1, int x2, int y2, string units)
        {
            System.Xml.XmlElement  parentElement = parent.Element;
            System.Xml.XmlDocument document      = parentElement.OwnerDocument;
            System.Xml.XmlElement  element       = document.CreateElement("line");
            parentElement.AppendChild(element);

            System.Xml.XmlAttribute x1Attr = document.CreateAttribute("x1");
            x1Attr.Value = System.String.Format("{0}{1}", x1, units);
            element.Attributes.Append(x1Attr);

            System.Xml.XmlAttribute y1Attr = document.CreateAttribute("y1");
            y1Attr.Value = System.String.Format("{0}{1}", y1, units);
            element.Attributes.Append(y1Attr);

            System.Xml.XmlAttribute x2Attr = document.CreateAttribute("x2");
            x2Attr.Value = System.String.Format("{0}{1}", x2, units);
            element.Attributes.Append(x2Attr);

            System.Xml.XmlAttribute y2Attr = document.CreateAttribute("y2");
            y2Attr.Value = System.String.Format("{0}{1}", y2, units);
            element.Attributes.Append(y2Attr);

            (this as ISVGElement).Element = element;
        }
Exemple #4
0
        private void SaveFile()
        {
            //Save the values to an XML file
            //Could save to data source, Message Queue etc.
            System.Xml.XmlDocument  aDOM = new System.Xml.XmlDocument();
            System.Xml.XmlAttribute aAttribute;

            aDOM.LoadXml("<UserData/>");

            //Add the First Name attribute to XML
            aAttribute       = aDOM.CreateAttribute("FirstName");
            aAttribute.Value = txtFName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Add the Last Name attribute to XML
            aAttribute       = aDOM.CreateAttribute("LastName");
            aAttribute.Value = txtLName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Add the SSN attribute to XML
            aAttribute       = aDOM.CreateAttribute("SSN");
            aAttribute.Value = txtSSN.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Save the file to the file system
            aDOM.Save("../../UserData.xml");
        }
Exemple #5
0
        private static void SetNode(string cpath)
        {   
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(cpath);
            Console.WriteLine("Adding to machine.config path: {0}", cpath);

            foreach (DataProvider dp in dataproviders)
            {
                System.Xml.XmlNode node = doc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"" + dp.invariant + "\"]");
                if (node == null)
                {
                    System.Xml.XmlNode root = doc.SelectSingleNode("configuration/system.data/DbProviderFactories");
                    node = doc.CreateElement("add");
                    System.Xml.XmlAttribute at = doc.CreateAttribute("name");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("invariant");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("description");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("type");
                    node.Attributes.Append(at);
                    root.AppendChild(node);
                }
                node.Attributes["name"].Value = dp.name;
                node.Attributes["invariant"].Value = dp.invariant;
                node.Attributes["description"].Value = dp.description;
                node.Attributes["type"].Value = dp.type;
                Console.WriteLine("Added Data Provider node in machine.config.");
            }            

            doc.Save(cpath);
            Console.WriteLine("machine.config saved: {0}", cpath);
        }
Exemple #6
0
        public void Persist()
        {
            var doc  = new System.Xml.XmlDocument();
            var root = doc.CreateElement(nameof(Persons));

            doc.AppendChild(root);

            foreach (var p in Persons)
            {
                var e = doc.CreateElement(nameof(Person));
                var firstNameAttribute  = doc.CreateAttribute(nameof(Person.FirstName));
                var suretNameAttribute  = doc.CreateAttribute(nameof(Person.SureName));
                var streetNameAttribute = doc.CreateAttribute(nameof(Person.Street));
                var cityNameAttribute   = doc.CreateAttribute(nameof(Person.City));

                firstNameAttribute.Value  = p.FirstName;
                suretNameAttribute.Value  = p.SureName;
                streetNameAttribute.Value = p.Street;
                cityNameAttribute.Value   = p.City;

                e.Attributes.Append(firstNameAttribute);
                e.Attributes.Append(suretNameAttribute);
                e.Attributes.Append(streetNameAttribute);
                e.Attributes.Append(cityNameAttribute);
                root.AppendChild(e);
            }

            using (var stream = this.databaseFile.Open(FileMode.Create, FileAccess.Write, FileShare.None))
                doc.Save(stream);
        }
Exemple #7
0
        public void SaveLangPackage()
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml("<ServerCommon.Data.Tools.LangPackage></ServerCommon.Data.Tools.LangPackage>");

            var element = doc.CreateElement("Strings");
            var att     = doc.CreateAttribute("Type");

            att.Value = "List";
            element.Attributes.InsertAfter(null, att);

            att       = doc.CreateAttribute("DataType");
            att.Value = "*****@*****.**";
            element.Attributes.InsertAfter(null, att);
            doc.DocumentElement.AppendChild(element);

            foreach (var id in mIdMap.Keys)
            {
                var idElement = doc.CreateElement("StringId");
                idElement.SetAttribute("Type", "String");
                idElement.SetAttribute("Value", id);
                element.AppendChild(idElement);

                int contentIdx = -1;
                mIdMap.TryGetValue(id, out contentIdx);

                var contentElement = doc.CreateElement("Content");
                contentElement.SetAttribute("Type", "String");
                contentElement.SetAttribute("Value", GetString(contentIdx));
                element.AppendChild(contentElement);
            }

            doc.Save(mLangPackageFile);
        }
Exemple #8
0
        public SVGText(ISVGElement parent, string text, int x, int y, int width, int height, string units)
        {
            System.Xml.XmlElement  parentElement = parent.Element;
            System.Xml.XmlDocument document      = parentElement.OwnerDocument;
            System.Xml.XmlElement  element       = document.CreateElement("text");
            parentElement.AppendChild(element);

            element.InnerText = text;

            System.Xml.XmlAttribute xAttr = document.CreateAttribute("x");
            xAttr.Value = System.String.Format("{0}{1}", x, units);
            element.Attributes.Append(xAttr);

            System.Xml.XmlAttribute yAttr = document.CreateAttribute("y");
            yAttr.Value = System.String.Format("{0}{1}", y, units);
            element.Attributes.Append(yAttr);

            System.Xml.XmlAttribute widthAttr = document.CreateAttribute("width");
            widthAttr.Value = System.String.Format("{0}{1}", width, units);
            element.Attributes.Append(widthAttr);

            System.Xml.XmlAttribute heightAttr = document.CreateAttribute("height");
            heightAttr.Value = System.String.Format("{0}{1}", height, units);
            element.Attributes.Append(heightAttr);

            (this as ISVGElement).Element = element;
        }
Exemple #9
0
        private static void SetNode(string cpath)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(cpath);
            Console.WriteLine("Adding to machine.config path: {0}", cpath);

            foreach (DataProvider dp in dataproviders)
            {
                System.Xml.XmlNode node = doc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"" + dp.invariant + "\"]");
                if (node == null)
                {
                    System.Xml.XmlNode root = doc.SelectSingleNode("configuration/system.data/DbProviderFactories");
                    node = doc.CreateElement("add");
                    System.Xml.XmlAttribute at = doc.CreateAttribute("name");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("invariant");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("description");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("type");
                    node.Attributes.Append(at);
                    root.AppendChild(node);
                }
                node.Attributes["name"].Value        = dp.name;
                node.Attributes["invariant"].Value   = dp.invariant;
                node.Attributes["description"].Value = dp.description;
                node.Attributes["type"].Value        = dp.type;
                Console.WriteLine("Added Data Provider node in machine.config.");
            }

            doc.Save(cpath);
            Console.WriteLine("machine.config saved: {0}", cpath);
        }
        public string SystemXml()
        {
            var doc       = new SystemXmlDocument();
            var subChilds = new List <SystemXmlElement> {
                doc.CreateElement("subChild1"), doc.CreateElement("subChild2")
            };
            var attr2 = doc.CreateAttribute("attr2");

            attr2.Value = "value2";
            subChilds[0].Attributes.Append(attr2);
            var attr3 = doc.CreateAttribute("attr3");

            attr3.Value = "value3";
            subChilds[0].Attributes.Append(attr3);
            var child = doc.CreateElement("child0");
            var attr1 = doc.CreateAttribute("attr1");

            attr1.Value = "value1";
            child.Attributes.Append(attr1);
            var root = doc.CreateElement("root");

            child.AppendChild(subChilds[0]);
            child.AppendChild(subChilds[1]);
            root.AppendChild(child);
            doc.AppendChild(root);
            return(doc.InnerXml);
        }
Exemple #11
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //Save the values to an XML file
            //Could save to data source, Message Queue, etc.
            System.Xml.XmlDocument aDOM = new System.Xml.XmlDocument();
            System.Xml.XmlAttribute aAttribute;

            aDOM.LoadXml("<PersonnelData/>");

            //Add the First Name attribute to XML
            aAttribute = aDOM.CreateAttribute("FirstName");
            aAttribute.Value = txtFName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the Last Name attribute to XML
            aAttribute = aDOM.CreateAttribute("LastName");
            aAttribute.Value = txtLName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the DOB attribute to XML
            aAttribute = aDOM.CreateAttribute("DOB");
            aAttribute.Value = txtDOB.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the SSN attribute to XML
            aAttribute = aDOM.CreateAttribute("SSN");
            aAttribute.Value = txtSSN.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Save file to the file system
            aDOM.Save("PersonnelData.xml");
        }
Exemple #12
0
 public void AddTextEx(int color, Font ft, string text)
 {
     System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
     if (Value == null)
     {
         xml.LoadXml("<root></root>");
     }
     else
     {
         xml.LoadXml(Value.ToString());
     }
     System.Xml.XmlNode root = xml.FirstChild;
     if (root == null)
     {
         xml.LoadXml("<root></root>");
         root = xml.FirstChild;
     }
     System.Xml.XmlNode node = xml.CreateElement("text");
     if (color != -1)
     {
         System.Xml.XmlAttribute xmlAttr = xml.CreateAttribute("color");
         xmlAttr.Value = color.ToString();
         node.Attributes.Append(xmlAttr);
     }
     if (ft != null)
     {
         System.Xml.XmlAttribute xmlAttr = xml.CreateAttribute("font");
         xmlAttr.Value = Core.General.FontToString(ft);
         node.Attributes.Append(xmlAttr);
     }
     node.InnerText = text;
     root.AppendChild(node);
     Value = xml.InnerXml;
 }
Exemple #13
0
        /// <summary>
        /// 获取当前筛选器的状态,将序列化的内容填充至 XmlNode 的 InnerText 属性或者 ChildNodes 子节点中。
        /// </summary>
        /// <param name="xmlDoc">创建 XmlNode 时所需使用到的 System.Xml.XmlDocument。</param>
        public System.Xml.XmlNode GetFilterConfig(System.Xml.XmlDocument xmlDoc)
        {
            System.Xml.XmlNode xn = xmlDoc.CreateElement(this.GetType().Name);

            System.Xml.XmlAttribute xaFilterLogicOperator = xmlDoc.CreateAttribute("FilterLogicOperator");
            xaFilterLogicOperator.InnerText = Function.ToInt(this.LogicOperator).ToString();
            xn.Attributes.Append(xaFilterLogicOperator);

            foreach (F _Filter in this)
            {
                System.Xml.XmlNode xnFilter = _Filter.GetFilterConfig(xmlDoc);

                //类型名
                System.Xml.XmlAttribute xaType = xmlDoc.CreateAttribute("Type");
                xaType.Value = _Filter.GetType().FullName;
                xnFilter.Attributes.Append(xaType);

                //程序集名
                System.Xml.XmlAttribute xaAssembly = xmlDoc.CreateAttribute("Assembly");
                xaAssembly.Value = _Filter.GetType().Assembly.FullName.Substring(0, _Filter.GetType().Assembly.FullName.IndexOf(","));
                xnFilter.Attributes.Append(xaAssembly);

                xn.AppendChild(xnFilter);
            }
            return(xn);
        }
Exemple #14
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //Save the values to an XML file
            //Could save to data source, Message Queue, etc.
            System.Xml.XmlDocument  aDOM = new System.Xml.XmlDocument();
            System.Xml.XmlAttribute aAttribute;

            aDOM.LoadXml("<AutomobileData/>");

            //Add the First Name attribute to XML
            aAttribute       = aDOM.CreateAttribute("Manufacturer");
            aAttribute.Value = txtManufact.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the Last Name attribute to XML
            aAttribute       = aDOM.CreateAttribute("Model");
            aAttribute.Value = txtModel.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the DOB attribute to XML
            aAttribute       = aDOM.CreateAttribute("Year");
            aAttribute.Value = txtYear.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the SSN attribute to XML
            aAttribute       = aDOM.CreateAttribute("Color");
            aAttribute.Value = txtColor.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Save file to the file system
            aDOM.Save("AutomobileData.xml");
        }
Exemple #15
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //Save the values to an XML file
            //Could save to data source, Message Queue, etc.
            System.Xml.XmlDocument aDOM = new System.Xml.XmlDocument();
            System.Xml.XmlAttribute aAttribute;

            aDOM.LoadXml("<AutomobileData/>");

            //Add the First Name attribute to XML
            aAttribute = aDOM.CreateAttribute("Manufacturer");
            aAttribute.Value = txtManufact.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the Last Name attribute to XML
            aAttribute = aDOM.CreateAttribute("Model");
            aAttribute.Value = txtModel.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the DOB attribute to XML
            aAttribute = aDOM.CreateAttribute("Year");
            aAttribute.Value = txtYear.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);
            //Add the SSN attribute to XML
            aAttribute = aDOM.CreateAttribute("Color");
            aAttribute.Value = txtColor.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Save file to the file system
            aDOM.Save("AutomobileData.xml");
        }
Exemple #16
0
        public string ToXml()
        {
            StringBuilder sbXml = new StringBuilder();

            System.Xml.XmlDocument document = new System.Xml.XmlDocument();
            System.Xml.XmlNode     root     = document.CreateElement("Condictions");

            foreach (QueryItem qc in queryItems)
            {
                System.Xml.XmlNode node = document.CreateElement("Condiction");

                System.Xml.XmlAttribute attributeName = document.CreateAttribute("Name");
                attributeName.Value = qc.Name;

                System.Xml.XmlAttribute attributeFields = document.CreateAttribute("MappingField");
                attributeFields.Value = qc.MappingFeild;

                System.Xml.XmlAttribute attributeDataType = document.CreateAttribute("DataType");
                attributeDataType.Value = qc.DataType.ToString();

                node.Attributes.Append(attributeName);
                node.Attributes.Append(attributeFields);
                node.Attributes.Append(attributeDataType);

                node.InnerText = qc.Value == null ? "" : qc.Value.ToString();

                root.AppendChild(node);
            }
            document.AppendChild(root);
            return(document.InnerXml.ToString());
        }
Exemple #17
0
        public void WriteLocalSetting(string sectionName, string settingName, string settingValue)
        {
            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='" + sectionName + "']");
                if (SectionNode == null)
                {
                    //Crear la sección
                    SectionNode     = ConfigDocument.CreateElement("Section");
                    Attribute       = ConfigDocument.CreateAttribute("name");
                    Attribute.Value = sectionName;
                    SectionNode.Attributes.Append(Attribute);
                    ConfigDocument.DocumentElement.AppendChild(SectionNode);
                }
                System.Xml.XmlNode SettingNode = ConfigDocument.SelectSingleNode("/LocalConfig/Section[@name='" + sectionName + "']/Setting[@name='" + settingName + "']");
                if (SettingNode == null)
                {
                    //Agregar el nodo
                    SettingNode     = ConfigDocument.CreateElement("Setting");
                    Attribute       = ConfigDocument.CreateAttribute("name");
                    Attribute.Value = settingName;
                    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 #18
0
        /// <summary>
        /// 获取或设置配置[推荐使用]
        /// </summary>
        /// <param name="ClassName">类名</param>
        /// <param name="PropertyName">属性名(特殊值:InnerText)</param>
        /// <returns></returns>
        public override string this[string ClassName, string PropertyName]
        {
            get
            {
                if (xn != null)
                {
                    System.Xml.XmlNode xn1 = xn.SelectSingleNode(ClassName);
                    if (xn1 != null)
                    {
                        if (xn1.Attributes[PropertyName] != null)
                        {
                            return(xn1.Attributes[PropertyName].Value);
                        }

                        if (PropertyName == "InnerText")
                        {
                            return(xn1.InnerText);
                        }

                        // 支持子节点
                        if (xn1.HasChildNodes)
                        {
                            System.Xml.XmlNodeList xnl = xn1.SelectNodes(PropertyName);
                            if (xnl.Count > 0)
                            {
                                return(xnl[xnl.Count - 1].InnerText);
                            }
                        }
                    }
                }
                return(null);
            }
            set
            {
                if (xn == null)
                {
                    throw new System.Exception("请先设置 Root!");
                }

                System.Xml.XmlNode xn1 = xn.SelectSingleNode(ClassName);
                if (xn1 == null)
                {
                    xn1 = xd.CreateElement(ClassName);
                    xn.AppendChild(xn1);
                }
                if (xn1.Attributes[PropertyName] == null)
                {
                    xn1.Attributes.Append(xd.CreateAttribute(PropertyName));
                }
                xn1.Attributes[PropertyName].Value = value;
            }
        }
Exemple #19
0
        public System.Xml.XmlElement GenerateDefinitionXmlElement(EntitiesGenerator.Definitions.DataTable table)
        {
            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            System.Xml.XmlElement definitionElement = xmlDocument.CreateElement("Definition");
            System.Xml.XmlElement xmlElement = xmlDocument.CreateElement("DataTable");

            System.Xml.XmlAttribute tableNameXmlAttribute = xmlDocument.CreateAttribute("TableName");
            tableNameXmlAttribute.Value = table.TableName.Trim();
            xmlElement.Attributes.Append(tableNameXmlAttribute);

            System.Xml.XmlAttribute sourceNameXmlAttribute = xmlDocument.CreateAttribute("SourceName");
            sourceNameXmlAttribute.Value = table.SourceName.Trim();
            xmlElement.Attributes.Append(sourceNameXmlAttribute);

            foreach (EntitiesGenerator.Definitions.DataColumn column in table.Columns)
            {
                System.Xml.XmlElement dataColumnXmlElement = xmlDocument.CreateElement("DataColumn");

                System.Xml.XmlAttribute dataColumnColumnNameXmlAttribute = xmlDocument.CreateAttribute("ColumnName");
                dataColumnColumnNameXmlAttribute.Value = column.ColumnName.Trim();
                dataColumnXmlElement.Attributes.Append(dataColumnColumnNameXmlAttribute);

                System.Xml.XmlAttribute dataColumnSourceNameXmlAttribute = xmlDocument.CreateAttribute("SourceName");
                dataColumnSourceNameXmlAttribute.Value = column.SourceName.Trim();
                dataColumnXmlElement.Attributes.Append(dataColumnSourceNameXmlAttribute);

                System.Xml.XmlAttribute dataColumnDataTypeXmlAttribute = xmlDocument.CreateAttribute("DataType");
                dataColumnDataTypeXmlAttribute.Value = column.DataType.Trim();
                dataColumnXmlElement.Attributes.Append(dataColumnDataTypeXmlAttribute);

                if (column.PrimaryKey)
                {
                    System.Xml.XmlAttribute dataColumnPrimaryKeyXmlAttribute = xmlDocument.CreateAttribute("PrimaryKey");
                    dataColumnPrimaryKeyXmlAttribute.Value = column.PrimaryKey ? "true" : "false";
                    dataColumnXmlElement.Attributes.Append(dataColumnPrimaryKeyXmlAttribute);
                }

                if (!column.AllowDBNull)
                {
                    System.Xml.XmlAttribute dataColumnAllowDBNullXmlAttribute = xmlDocument.CreateAttribute("AllowDBNull");
                    dataColumnAllowDBNullXmlAttribute.Value = column.AllowDBNull ? "true" : "false";
                    dataColumnXmlElement.Attributes.Append(dataColumnAllowDBNullXmlAttribute);
                }

                if (column.AutoIncrement)
                {
                    System.Xml.XmlAttribute dataColumnAutoIncrementXmlAttribute = xmlDocument.CreateAttribute("AutoIncrement");
                    dataColumnAutoIncrementXmlAttribute.Value = column.AutoIncrement ? "true" : "false";
                    dataColumnXmlElement.Attributes.Append(dataColumnAutoIncrementXmlAttribute);
                }

                // TODO: caption.

                xmlElement.AppendChild(dataColumnXmlElement);
            }
            definitionElement.AppendChild(xmlElement);
            xmlDocument.AppendChild(definitionElement);
            return xmlDocument.DocumentElement;
        }
Exemple #20
0
        private string EncodeFilterAsXml(List <FilterDialog.FilterEntry> list)
        {
            System.Xml.XmlDocument doc  = new System.Xml.XmlDocument();
            System.Xml.XmlNode     root = doc.AppendChild(doc.CreateElement("root"));

            foreach (FilterDialog.FilterEntry f in list)
            {
                System.Xml.XmlNode filter = root.AppendChild(doc.CreateElement("filter"));
                filter.Attributes.Append(doc.CreateAttribute("include")).Value  = f.Include.ToString();
                filter.Attributes.Append(doc.CreateAttribute("filter")).Value   = f.Filter;
                filter.Attributes.Append(doc.CreateAttribute("globbing")).Value = f.Globbing;
            }

            return(doc.OuterXml);
        }
Exemple #21
0
        }     // End Sub SaveRows

        private void SaveCell(System.Data.DataRow row
                              , System.Xml.XmlNode rowNode,
                              System.Xml.XmlDocument ownerDocument)
        {
            object[] cells = row.ItemArray;

            for (int i = 0; i < cells.Length; i++)
            {
                System.Xml.XmlElement cellNode =
                    ownerDocument.CreateElement("table:table-cell", this.GetNamespaceUri("table"));

                if (row[i] != System.DBNull.Value)
                {
                    // We save values as text (string)
                    System.Xml.XmlAttribute valueType =
                        ownerDocument.CreateAttribute("office:value-type", this.GetNamespaceUri("office"));
                    valueType.Value = "string";
                    cellNode.Attributes.Append(valueType);

                    System.Xml.XmlElement cellValue =
                        ownerDocument.CreateElement("text:p", this.GetNamespaceUri("text"));
                    cellValue.InnerText = row[i].ToString();
                    cellNode.AppendChild(cellValue);
                } // End if (row[i] != System.DBNull.Value)

                rowNode.AppendChild(cellNode);
            } // Next i
        }     // End Sub SaveCell
Exemple #22
0
 public static System.Xml.XmlAttribute NewAttribute(System.Xml.XmlDocument xmlDoc, string name, string value)
 {
     System.Xml.XmlAttribute nodeAttribute;
     nodeAttribute       = xmlDoc.CreateAttribute(name);
     nodeAttribute.Value = value;
     return(nodeAttribute);
 }
Exemple #23
0
 private System.Xml.XmlAttribute setAtributo(System.Xml.XmlDocument doc, string nombre, string valor)
 {
     System.Xml.XmlAttribute atributo;
     atributo           = doc.CreateAttribute(nombre);
     atributo.InnerText = valor;
     return(atributo);
 }
Exemple #24
0
        public System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc)
        {
            string visibleLayersCsv = string.Empty;
            string xmlString        = string.Empty;

            if (visibleLayers != null)
            {
                foreach (int x in visibleLayers)
                {
                    visibleLayersCsv += x.ToString() + ",";
                }
                visibleLayersCsv = visibleLayersCsv.Substring(0, visibleLayersCsv.Length - 1);
                xmlString        = "<referenceLayer><serverName>" + lblServerName.Content + "</serverName><visibleLayers>" + visibleLayersCsv + "</visibleLayers></referenceLayer>";
            }
            else
            {
                xmlString = "<referenceLayer><serverName>" + lblServerName.Content + "</serverName><visibleLayers/></referenceLayer>";
            }
            System.Xml.XmlElement element = doc.CreateElement("referenceLayer");
            element.InnerXml = xmlString;

            System.Xml.XmlAttribute type = doc.CreateAttribute("layerType");
            type.Value = "EpiDashboard.Mapping.MapServerLayerProperties";
            element.Attributes.Append(type);

            return(element);
        }
        public System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc)
        {
            string connectionString = string.Empty;
            string tableName        = string.Empty;
            string projectPath      = string.Empty;
            string viewName         = string.Empty;

            if (dashboardHelper.View == null)
            {
                connectionString = dashboardHelper.Database.ConnectionString;
                tableName        = dashboardHelper.TableName;
            }
            else
            {
                projectPath = dashboardHelper.View.Project.FilePath;
                viewName    = dashboardHelper.View.Name;
            }
            string          dataKey   = cbxDataKey.SelectedItem.ToString();
            string          shapeKey  = cbxShapeKey.SelectedItem.ToString();
            string          value     = cbxValue.SelectedItem.ToString();
            SolidColorBrush dotColor  = (SolidColorBrush)rctDotColor.Fill;
            string          xmlString = "<shapeFile>" + shapeFilePath + "</shapeFile><dotColor>" + dotColor.Color.ToString() + "</dotColor><dotValue>" + txtDotValue.Text + "</dotValue><dataKey>" + dataKey + "</dataKey><shapeKey>" + shapeKey + "</shapeKey><value>" + value + "</value>";

            System.Xml.XmlElement element = doc.CreateElement("dataLayer");
            element.InnerXml = xmlString;
            element.AppendChild(dashboardHelper.Serialize(doc));

            System.Xml.XmlAttribute type = doc.CreateAttribute("layerType");
            type.Value = "EpiDashboard.Mapping.DotDensityKmlLayerProperties";
            element.Attributes.Append(type);

            return(element);
        }
Exemple #26
0
        public static void SerializeRuleList(ListView requestRuleListView, ListView reponseRuleListView)
        {
            string rulePath = "FreeHttp\\RuleData.xml";

            if (requestRuleListView != null && reponseRuleListView != null)
            {
                //dynamic
                List <FiddlerRequestChange>  requestList  = new List <FiddlerRequestChange>();
                List <FiddlerResponseChange> responseList = new List <FiddlerResponseChange>();
                foreach (ListViewItem tempItem in requestRuleListView.Items)
                {
                    requestList.Add((FiddlerRequestChange)tempItem.Tag);
                }
                foreach (ListViewItem tempItem in reponseRuleListView.Items)
                {
                    responseList.Add((FiddlerResponseChange)tempItem.Tag);
                }
                //Stream stream = File.Open("data.xml", FileMode.Create);
                TextWriter    writer     = new StreamWriter(rulePath, false);
                XmlSerializer serializer = new XmlSerializer(typeof(FiddlerModificHttpRuleCollection));
                //serializer = new XmlSerializer(typeof(List<IFiddlerHttpTamper>));
                serializer.Serialize(writer, new FiddlerModificHttpRuleCollection(requestList, responseList));
                writer.Close();

                //写入版本
                System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
                xmlDocument.Load(rulePath);
                System.Xml.XmlAttribute dbAtt = xmlDocument.CreateAttribute("ruleVersion");
                dbAtt.Value = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                xmlDocument.SelectSingleNode("/FiddlerModificHttpRuleCollection")?.Attributes.Append(dbAtt);
                xmlDocument.Save(rulePath);
            }
        }
        static void AppendAttribute(System.Xml.XmlDocument doc, System.Xml.XmlElement element, string name, string value)
        {
            var attr = doc.CreateAttribute(name);

            attr.Value = value;
            element.Attributes.Append(attr);
        }
        //--

        public System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc)
        {
            string connectionString = string.Empty;
            string tableName        = string.Empty;
            string projectPath      = string.Empty;
            string viewName         = string.Empty;

            if (dashboardHelper.View == null)
            {
                connectionString = dashboardHelper.Database.ConnectionString;
                tableName        = dashboardHelper.TableName;
            }
            else
            {
                projectPath = dashboardHelper.View.Project.FilePath;
                viewName    = dashboardHelper.View.Name;
            }
            string          latitude    = cbxLatitude.SelectedItem.ToString();
            string          longitude   = cbxLongitude.SelectedItem.ToString();
            SolidColorBrush color       = (SolidColorBrush)rctColor.Fill;
            string          style       = cbxStyle.SelectedItem.ToString();
            string          description = txtDescription.Text;
            string          xmlString   = "<description>" + description + "</description><color>" + color.Color.ToString() + "</color><style>" + style + "</style><latitude>" + latitude + "</latitude><longitude>" + longitude + "</longitude>";

            System.Xml.XmlElement element = doc.CreateElement("dataLayer");
            element.InnerXml = xmlString;
            element.AppendChild(dashboardHelper.Serialize(doc));

            System.Xml.XmlAttribute type = doc.CreateAttribute("layerType");
            type.Value = "EpiDashboard.Mapping.PointLayerProperties";
            element.Attributes.Append(type);

            return(element);
        }
Exemple #29
0
        /// <summary>
        /// Writes the current element's content
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="currentNode"></param>
        public void WriteXml(System.Xml.XmlDocument doc, System.Xml.XmlNode currentNode)
        {
            var layer = doc.CreateElement("Layer");  //NOXLATE
            var n     = doc.CreateAttribute("name"); //NOXLATE

            n.Value = this.Name;
            layer.Attributes.Append(n);
            {
                var style = doc.CreateElement("Style");  //NOXLATE
                var s     = doc.CreateAttribute("name"); //NOXLATE
                s.Value = this.Style;
                style.Attributes.Append(s);
                layer.AppendChild(style);
            }
            currentNode.AppendChild(layer);
        }
Exemple #30
0
        public static System.Xml.XmlAttribute SetAttrib(System.Xml.XmlNode node, string nodeAttrib, string nodeAttribValue)
        {
            if (node != null)
            {
                System.Xml.XmlAttribute xmlAttr = default(System.Xml.XmlAttribute);
                xmlAttr = node.Attributes[nodeAttrib];

                if (ReferenceEquals(xmlAttr, null))
                {
                    System.Xml.XmlDocument xmlDoc = node.OwnerDocument;
                    xmlAttr       = xmlDoc.CreateAttribute(nodeAttrib);
                    xmlAttr.Value = nodeAttribValue;
                    node.Attributes.Append(xmlAttr);
                }
                else
                {
                    xmlAttr.Value = nodeAttribValue;
                }

                return(xmlAttr);
            }
            else
            {
                return(null);
            }
        }
Exemple #31
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确认使用该数据库连接吗?", "数据库连接", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
            {
                IDb  db       = this.Db;
                bool bolIsAdd = true;
                for (int intIndex = 0; intIndex < this.lstDbs.Count; intIndex++)
                {
                    if (this.lstDbs[intIndex].GetType().Equals(db.GetType()))
                    {
                        this.lstDbs[intIndex] = db;
                        bolIsAdd = false;
                        break;
                    }
                }
                if (bolIsAdd)
                {
                    this.lstDbs.Add(db);
                }

                System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
                System.Xml.XmlNode     xnDbs  = xmlDoc.CreateElement("Dbs");
                xmlDoc.AppendChild(xnDbs);

                foreach (IDb db1 in this.lstDbs)
                {
                    System.Xml.XmlNode xnDb = db1.GetConfig(xmlDoc);

                    System.Xml.XmlAttribute xaDbType = xmlDoc.CreateAttribute("DbType");
                    xaDbType.InnerText = db1.GetType().FullName;
                    xnDb.Attributes.Append(xaDbType);

                    if (db1.Equals(db))
                    {
                        System.Xml.XmlAttribute xaDefault = xmlDoc.CreateAttribute("Default");
                        xnDb.Attributes.Append(xaDefault);
                    }

                    xnDbs.AppendChild(xnDb);
                }

                //Properties.Settings.Default.DbSelection = xmlDoc;
                //Properties.Settings.Default.Save();

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
        private System.Xml.XmlAttribute XmlDocument_CreateAttribute(System.Xml.XmlDocument document, String prefix, String localName, String namespaceURI, String content)
        {
            System.Xml.XmlAttribute attribute = document.CreateAttribute(prefix, localName, namespaceURI);

            attribute.InnerText = content;

            return(attribute);
        }
Exemple #33
0
 public static void SetRootAttribute(System.Xml.XmlDocument xmlDocument, string attributeName, string attributeValue)
 {
     if (xmlDocument.DocumentElement.Attributes[attributeName] == null)
     {
         xmlDocument.DocumentElement.Attributes.Append(xmlDocument.CreateAttribute(attributeName));
     }
     xmlDocument.DocumentElement.Attributes[attributeName].Value = attributeValue;
 }
        private static void AddRepo(string path, string name)
        {
            var rootPath   = Path.GetDirectoryName(typeof(Program).Assembly.Location);
            var repoConfig = Path.Combine(rootPath, Constants.RepoList);

            if (!File.Exists(repoConfig))
            {
                var sr = File.CreateText(repoConfig);
                using (sr)
                {
                    sr.Write(@"<?xml version=""1.0"" encoding=""utf-8""?>");
                    sr.WriteLine();
                    sr.Write("<repos>");
                    sr.WriteLine();
                    sr.Write("</repos>");
                }
            }

            if (name == null)
            {
                name = "";
            }

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

            doc.LoadXml(File.ReadAllText(repoConfig));

            if (doc.DocumentElement.SelectSingleNode($"descendant::repo[@path='{path}' and @name='{name}']") != null)
            {
                return;
            }

            var node = doc.CreateNode(System.Xml.XmlNodeType.Element, "repo", null);
            var attr = doc.CreateAttribute("path");

            attr.Value = path;
            node.Attributes.Append(attr);

            attr       = doc.CreateAttribute("name");
            attr.Value = name;
            node.Attributes.Append(attr);

            doc.SelectSingleNode("repos").AppendChild(node);
            doc.Save(repoConfig);
        }
Exemple #35
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pDoc"></param>
        /// <param name="pNode"></param>
        /// <param name="pVec"></param>
        public static void ToXmlAttribute(this System.Drawing.Color pCol, System.Xml.XmlDocument pDoc, System.Xml.XmlNode pNode, string pAttribNamePrefixToRGBA)
        {
            System.Xml.XmlAttribute att = pDoc.CreateAttribute(pAttribNamePrefixToRGBA + "R");
            att.InnerText = pCol.R.ToString();
            pNode.Attributes.Append(att);

            att           = pDoc.CreateAttribute(pAttribNamePrefixToRGBA + "G");
            att.InnerText = pCol.G.ToString();
            pNode.Attributes.Append(att);

            att           = pDoc.CreateAttribute(pAttribNamePrefixToRGBA + "B");
            att.InnerText = pCol.B.ToString();
            pNode.Attributes.Append(att);

            att           = pDoc.CreateAttribute(pAttribNamePrefixToRGBA + "A");
            att.InnerText = pCol.A.ToString();
            pNode.Attributes.Append(att);
        }
Exemple #36
0
 public string ToDocumentXmlText()
 {
     System.Xml.XmlDocument datagram = new System.Xml.XmlDocument();
     System.Xml.XmlNode b1 = datagram.CreateElement(_Datagram.ToUpper());
     foreach (KeyValuePair<string, string> curr in Parameters)
     {
         System.Xml.XmlAttribute b2 = datagram.CreateAttribute(curr.Key);
         b2.Value = curr.Value;
         b1.Attributes.Append(b2);
     }
     b1.InnerText = this._InnerText;
     datagram.AppendChild(b1);
     return datagram.InnerXml;
 }
Exemple #37
0
        /// <summary>
        /// Get the kml for this list of datasets
        /// </summary>
        /// <param name="strWmsUrl"></param>
        /// <param name="oDatasets"></param>
        /// <param name="oSelectedDatasets"></param>
        /// <returns></returns>
        public static System.Xml.XmlDocument GetKML(string strWmsUrl, System.Collections.SortedList oDatasets, System.Collections.ArrayList oSelectedDatasets)
        {
            System.Xml.XmlDocument oOutputXml = new System.Xml.XmlDocument();

            oOutputXml.AppendChild(oOutputXml.CreateXmlDeclaration("1.0", "UTF-8", string.Empty));

            System.Xml.XmlElement oKml = oOutputXml.CreateElement("kml", "http://earth.google.com/kml/2.1");
            oOutputXml.AppendChild(oKml);

            System.Xml.XmlElement oDocument = oOutputXml.CreateElement("Document", "http://earth.google.com/kml/2.1");
            System.Xml.XmlAttribute oAttr = oOutputXml.CreateAttribute("id");
            oAttr.Value = "Geosoft";
            oDocument.Attributes.Append(oAttr);
            oKml.AppendChild(oDocument);

            System.Xml.XmlElement oName = oOutputXml.CreateElement("name", "http://earth.google.com/kml/2.1");
            oName.InnerText = "Geosoft Catalog";
            oDocument.AppendChild(oName);

            System.Xml.XmlElement oVisibility = oOutputXml.CreateElement("visibility", "http://earth.google.com/kml/2.1");
            oVisibility.InnerText = "1";
            oDocument.AppendChild(oVisibility);

            System.Xml.XmlElement oOpen = oOutputXml.CreateElement("open", "http://earth.google.com/kml/2.1");
            oOpen.InnerText = "1";
            oDocument.AppendChild(oOpen);

            foreach (string strKey in oSelectedDatasets)
            {
                Dap.Common.DataSet oDataset = (Dap.Common.DataSet)oDatasets[strKey];

                if (oDataset != null)
                    OutputDataset(strWmsUrl, oDocument, oDataset);
            }
            return oOutputXml;
        }
Exemple #38
0
        /// <summary>
        /// Create and Save a default configuration Xml file based on a easily specific or default defined xml string
        /// </summary>
        /// <param name="FilePath">The fullpath including filename.xml to save to</param>
        /// <param name="XmlConfigurationFileString">If not specified, then will use the XmlDefaultConfigurationFileString</param>
        /// <returns>True if succesfull created</returns>
        /// <remarks></remarks>
        public bool SaveXmlDefaultConfigurationFile(string FilePath, string XmlConfigurationFileString)
        {
            string theXmlString = ((XmlConfigurationFileString != null) ? XmlConfigurationFileString : XmlDefaultConfigurationFileString);
            //What Method You want to use ?, try any by simply change the var XmlSaveMethod declared at top
            switch (XmlSaveMethod) {
                case enumXmlSaveMethod.StreamWrite:
                    //Easy Method
                    using (System.IO.StreamWriter StreamWriter = new System.IO.StreamWriter(FilePath)) {
                        //Without Compact Framework more easily using file.WriteAllText but, CF doesn't have this method
                        StreamWriter.Write(theXmlString);
                        StreamWriter.Close();
                    }

                    return true;

                case enumXmlSaveMethod.XmlTextWriter:
                    //Alternative Method
                    using (System.Xml.XmlTextWriter XmlTextWriter = new System.Xml.XmlTextWriter(FilePath, System.Text.UTF8Encoding.UTF8)) {
                        XmlTextWriter.WriteStartDocument();
                        XmlTextWriter.WriteStartElement("configuration");
                        XmlTextWriter.WriteStartElement("appSettings");
                        foreach (string Item in GetListItems(theXmlString)) {
                            XmlTextWriter.WriteStartElement("add");

                            XmlTextWriter.WriteStartAttribute("key", string.Empty);
                            XmlTextWriter.WriteRaw(GetKey(Item));
                            XmlTextWriter.WriteEndAttribute();

                            XmlTextWriter.WriteStartAttribute("value", string.Empty);
                            XmlTextWriter.WriteRaw(GetValue(Item));
                            XmlTextWriter.WriteEndAttribute();

                            XmlTextWriter.WriteEndElement();

                        }

                        XmlTextWriter.WriteEndElement();
                        XmlTextWriter.WriteEndElement();
                        //XmlTextWriter.WriteEndDocument()
                        XmlTextWriter.Close();

                    }

                    return true;

                case enumXmlSaveMethod.XmlDocument:
                    //Method you will practice
                    System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
                    System.Xml.XmlElement xRoot = XmlDoc.CreateElement("configuration");
                    XmlDoc.AppendChild(xRoot);
                    System.Xml.XmlElement xAppSettingsElement = XmlDoc.CreateElement("appSettings");
                    xRoot.AppendChild(xAppSettingsElement);

                    System.Xml.XmlElement xElement = default(System.Xml.XmlElement);
                    System.Xml.XmlAttribute xAttrKey = default(System.Xml.XmlAttribute);
                    System.Xml.XmlAttribute xAttrValue = default(System.Xml.XmlAttribute);
                    foreach (string Item in GetListItems(theXmlString)) {
                        xElement = XmlDoc.CreateElement("add");
                        xAttrKey = XmlDoc.CreateAttribute("key");
                        xAttrValue = XmlDoc.CreateAttribute("value");
                        xAttrKey.InnerText = GetKey(Item);
                        xElement.SetAttributeNode(xAttrKey);
                        xAttrValue.InnerText = GetValue(Item);
                        xElement.SetAttributeNode(xAttrValue);
                        xAppSettingsElement.AppendChild(xElement);
                    }

                    System.Xml.XmlProcessingInstruction XmlPI = XmlDoc.CreateProcessingInstruction("xml", "version='1.0' encoding='utf-8'");
                    XmlDoc.InsertBefore(XmlPI, XmlDoc.ChildNodes[0]);
                    XmlDoc.Save(FilePath);

                    return true;
            }
            return false;
        }
        internal VerificationFile(IEnumerable<ManifestEntry> parentChain, FilenameStrategy str)
        {
            m_doc = new System.Xml.XmlDocument();
            System.Xml.XmlNode root = m_doc.AppendChild(m_doc.CreateElement("Verify"));
            root.Attributes.Append(m_doc.CreateAttribute("hash-algorithm")).Value = Utility.Utility.HashAlgorithm;
            root.Attributes.Append(m_doc.CreateAttribute("version")).Value = "1";

            m_node = root.AppendChild(m_doc.CreateElement("Files"));

            foreach (ManifestEntry mfe in parentChain)
            {
                System.Xml.XmlNode f = m_node.AppendChild(m_doc.CreateElement("File"));
                f.Attributes.Append(m_doc.CreateAttribute("type")).Value = "manifest";
                f.Attributes.Append(m_doc.CreateAttribute("name")).Value = mfe.Filename;
                f.Attributes.Append(m_doc.CreateAttribute("size")).Value = mfe.Filesize.ToString();
                f.InnerText = Utility.Utility.ByteArrayAsHexString(Convert.FromBase64String(mfe.RemoteHash));

                for (int i = 0; i < mfe.ParsedManifest.SignatureHashes.Count; i++)
                {
                    string sigfilename = mfe.ParsedManifest.SignatureHashes[i].Name;
                    string contentfilename = mfe.ParsedManifest.ContentHashes[i].Name;
                    bool missing = i >= mfe.Volumes.Count;

                    if (string.IsNullOrEmpty(sigfilename) || string.IsNullOrEmpty(contentfilename))
                    {
                        if (missing)
                        {
                            sigfilename = str.GenerateFilename(new SignatureEntry(mfe.Time, mfe.IsFull, i + 1));
                            contentfilename = str.GenerateFilename(new ContentEntry(mfe.Time, mfe.IsFull, i + 1));

                            //Since these files are missing, we have to guess what their real names were
                            string compressionGuess;
                            if (mfe.Volumes.Count <= 0)
                                compressionGuess = ".zip"; //Default if we have no knowledge
                            else
                                compressionGuess = "." + mfe.Volumes[0].Key.Compression; //Most likely the same as all the others

                            //Encryption will likely be the same as the one the manifest uses
                            string encryptionGuess = string.IsNullOrEmpty(mfe.EncryptionMode) ? "" : "." + mfe.EncryptionMode;

                            sigfilename += compressionGuess + encryptionGuess;
                            contentfilename += compressionGuess + encryptionGuess;
                        }
                        else
                        {
                            sigfilename = mfe.Volumes[i].Key.Filename;
                            contentfilename = mfe.Volumes[i].Value.Filename;
                        }
                    }

                    f = m_node.AppendChild(m_doc.CreateElement("File"));
                    f.Attributes.Append(m_doc.CreateAttribute("type")).Value = "signature";
                    f.Attributes.Append(m_doc.CreateAttribute("name")).Value = sigfilename;
                    f.Attributes.Append(m_doc.CreateAttribute("size")).Value = mfe.ParsedManifest.SignatureHashes[i].Size.ToString();
                    if (missing) f.Attributes.Append(m_doc.CreateAttribute("missing")).Value = "true";
                    f.InnerText = Utility.Utility.ByteArrayAsHexString(Convert.FromBase64String(mfe.ParsedManifest.SignatureHashes[i].Hash));

                    f = m_node.AppendChild(m_doc.CreateElement("File"));
                    f.Attributes.Append(m_doc.CreateAttribute("type")).Value = "content";
                    f.Attributes.Append(m_doc.CreateAttribute("name")).Value = contentfilename;
                    f.Attributes.Append(m_doc.CreateAttribute("size")).Value = mfe.ParsedManifest.ContentHashes[i].Size.ToString();
                    if (missing) f.Attributes.Append(m_doc.CreateAttribute("missing")).Value = "true";
                    f.InnerText = Utility.Utility.ByteArrayAsHexString(Convert.FromBase64String(mfe.ParsedManifest.ContentHashes[i].Hash));
                }
            }
        }
Exemple #40
0
        void CheckAndFixXMLInput(string Filename)
        {
            System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
            xmld.Load(Filename);
            if (xmld.FirstChild.NodeType != System.Xml.XmlNodeType.XmlDeclaration)
            {
                System.Xml.XmlAttribute atr;
                System.Xml.XmlNode node;
                DateTime dt;

                atr = xmld.CreateAttribute("xmlns:xsd");
                atr.Value = "http://www.w3.org/2001/XMLSchema";
                xmld.FirstChild.Attributes.Append(atr);
                atr = xmld.CreateAttribute("xmlns:xsi");
                atr.Value = "http://www.w3.org/2001/XMLSchema-instance" ;
                xmld.FirstChild.Attributes.Append(atr);
                atr = xmld.CreateAttribute("xmlns");
                atr.Value = "http://carverlab.com/xsd/VideoExchange.xsd";
                xmld.FirstChild.Attributes.Append(atr);
                xmld.InsertBefore(xmld.CreateXmlDeclaration("1.0","utf-8",""),xmld.FirstChild);
                node = xmld.SelectSingleNode("CARDVIDEO/TIMESTART");
                dt = DateTime.Parse(node.InnerText);
                node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
                node = xmld.SelectSingleNode("CARDVIDEO/TIMESTOP");
                dt = DateTime.Parse(node.InnerText);
                node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
                xmld.Save(Filename);
            }
        }
Exemple #41
0
        public void SaveDruzina(TreeNode tnode)
        {
            String file = tnode.Tag.ToString();

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", ""));

            System.Xml.XmlElement root = doc.CreateElement("druzina");
            System.Xml.XmlAttribute att = doc.CreateAttribute("nazev");
            att.Value = tnode.Text;
            root.Attributes.Append(att);

            foreach (TreeNode n in tnode.Nodes)
            {
                ((Postava)n.Tag).Save();
                System.Xml.XmlNode node = doc.CreateElement("postava");
                node.AppendChild(doc.CreateTextNode(((Postava)n.Tag).xmlFileName));
                root.AppendChild(node);
            }
            doc.AppendChild(root);

            doc.Save(file);
        }
Exemple #42
0
 bool svgconcat(List<string> files, string output, uint delay, uint loop) {
     if (controller_ != null) controller_.appendOutput("TeX2img: Making animation svg...");
     try {
         var outxml = new System.Xml.XmlDocument();
         outxml.XmlResolver = null;
         outxml.AppendChild(outxml.CreateXmlDeclaration("1.0", "utf-8", "no"));
         outxml.AppendChild(outxml.CreateDocumentType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null));
         var svg = outxml.CreateElement("svg", "http://www.w3.org/2000/svg");
         var attr = outxml.CreateAttribute("xmlns:xlink");
         attr.Value = "http://www.w3.org/1999/xlink";
         svg.Attributes.Append(attr);
         attr = outxml.CreateAttribute("version");
         attr.Value = "1.1";
         svg.Attributes.Append(attr);
         outxml.AppendChild(svg);
         var defs = outxml.CreateElement("defs", "http://www.w3.org/2000/svg");
         svg.AppendChild(defs);
         var idreg = new System.Text.RegularExpressions.Regex(@"(?<!\&)#");
         foreach (var f in files) {
             var id = Path.GetFileNameWithoutExtension(f);
             var xml = new System.Xml.XmlDocument();
             xml.XmlResolver = null;
             xml.Load(Path.Combine(workingDir, f));
             foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("*")) {
                 foreach (System.Xml.XmlAttribute a in tag.Attributes) {
                     if (a.Name.ToLower() == "id") a.Value = id + "-" + a.Value;
                     else a.Value = idreg.Replace(a.Value, "#" + id + "-");
                 }
             }
             foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("svg")) {
                 var idattr = xml.CreateAttribute("id");
                 idattr.Value = id;
                 tag.Attributes.Append(idattr);
             }
             foreach (System.Xml.XmlNode n in xml.ChildNodes) {
                 if (n.NodeType != System.Xml.XmlNodeType.DocumentType && n.NodeType != System.Xml.XmlNodeType.XmlDeclaration) {
                     defs.AppendChild(outxml.ImportNode(n, true));
                 }
             }
         }
         var use = outxml.CreateElement("use", "http://www.w3.org/2000/svg");
         svg.AppendChild(use);
         var animate = outxml.CreateElement("animate", "http://www.w3.org/2000/svg");
         use.AppendChild(animate);
         attr = outxml.CreateAttribute("attributeName");
         attr.Value = "xlink:href"; animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("begin");
         attr.Value = "0s"; animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("dur");
         attr.Value = ((decimal)(delay * files.Count) / 100).ToString() + "s";
         animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("repeatCount");
         attr.Value = loop > 0 ? loop.ToString() : "indefinite";
         animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("values");
         attr.Value = String.Join(";", files.Select(d => "#" + Path.GetFileNameWithoutExtension(d)).ToArray());
         animate.Attributes.Append(attr);
         outxml.Save(Path.Combine(workingDir, output));
         if (controller_ != null) controller_.appendOutput(" done\n");
         return true;
     }
     catch (Exception) { return false; }
 }
Exemple #43
0
        private string EncodeFilterAsXml(List<FilterDialog.FilterEntry> list)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            System.Xml.XmlNode root = doc.AppendChild(doc.CreateElement("root"));

            foreach (FilterDialog.FilterEntry f in list)
            {
                System.Xml.XmlNode filter = root.AppendChild(doc.CreateElement("filter"));
                filter.Attributes.Append(doc.CreateAttribute("include")).Value = f.Include.ToString();
                filter.Attributes.Append(doc.CreateAttribute("filter")).Value = f.Filter;
                filter.Attributes.Append(doc.CreateAttribute("globbing")).Value = f.Globbing;
            }

            return doc.OuterXml;
        }
Exemple #44
0
        void ExportXml(string in_path, System.Collections.Generic.IEnumerable<Google.GData.Spreadsheets.WorksheetEntry> in_entries)
        {

            ShowNotification(new GUIContent("Saving to: " + in_path));
            Debug.Log("Saving to: " + in_path);

            // Create the System.Xml.XmlDocument.
            var xmlDoc = new System.Xml.XmlDocument();
            var rootNode = xmlDoc.CreateElement("Sheets");
            xmlDoc.AppendChild(rootNode);

            foreach (Google.GData.Spreadsheets.WorksheetEntry entry in in_entries)
            {
                // Define the URL to request the list feed of the worksheet.
                Google.GData.Client.AtomLink listFeedLink = entry.Links.FindService(Google.GData.Spreadsheets.GDataSpreadsheetsNameTable.ListRel, null);

                // Fetch the list feed of the worksheet.
                var listQuery = new Google.GData.Spreadsheets.ListQuery(listFeedLink.HRef.ToString());
                var listFeed = _Service.Query(listQuery);

                //int rowCt = listFeed.Entries.Count;
                //int colCt = ((Google.GData.Spreadsheets.ListEntry)listFeed.Entries[0]).Elements.Count;

                System.Xml.XmlNode sheetNode = xmlDoc.CreateElement("sheet");
                System.Xml.XmlAttribute sheetName = xmlDoc.CreateAttribute("name");
                sheetName.Value = entry.Title.Text;
                if (sheetNode.Attributes != null)
                {
                    sheetNode.Attributes.Append(sheetName);
                    rootNode.AppendChild(sheetNode);

                    if (listFeed.Entries.Count <= 0) continue;
                    // Iterate through each row, printing its cell values.
                    foreach (var atomEntry in listFeed.Entries)
                    {
                        var row = (Google.GData.Spreadsheets.ListEntry)atomEntry;
                        // Don't process rows or columns marked for _Ignore
                        if (GfuStrCmp(row.Title.Text, "VOID"))
                        {
                            continue;
                        }

                        System.Xml.XmlNode rowNode = xmlDoc.CreateElement("row");
                        System.Xml.XmlAttribute rowName = xmlDoc.CreateAttribute("name");
                        rowName.Value = row.Title.Text;
                        if (rowNode.Attributes == null) continue;
                        rowNode.Attributes.Append(rowName);
                        sheetNode.AppendChild(rowNode);

                        // Iterate over the remaining columns, and print each cell value
                        foreach (Google.GData.Spreadsheets.ListEntry.Custom element in row.Elements)
                        {
                            // Don't process rows or columns marked for _Ignore
                            if (GfuStrCmp(element.LocalName, "VOID"))
                            {
                                continue;
                            }

                            System.Xml.XmlNode colNode = xmlDoc.CreateElement("col");
                            System.Xml.XmlAttribute colName = xmlDoc.CreateAttribute("name");
                            colName.Value = element.LocalName;
                            if (colNode.Attributes != null) colNode.Attributes.Append(colName);
                            colNode.InnerText = element.Value;
                            rowNode.AppendChild(colNode);
                        }
                    }
                }
            }

            // Save the document to a file and auto-indent the output.
            var writer = new System.Xml.XmlTextWriter(in_path, null) { Formatting = System.Xml.Formatting.Indented };
            xmlDoc.Save(writer);
            writer.Close();
            ShowNotification(new GUIContent("Saving to: " + in_path));
            Debug.Log("Saving to: " + in_path);
        }
        /// <summary>
        /// Write the latest version of the XML definition file.
        /// Always refer to the schema location as a relative path to the bam executable.
        /// Always reference the default namespace in the first element.
        /// Don't use a namespace prefix on child elements, as the default namespace covers them.
        /// </summary>
        public void Write()
        {
            if (System.IO.File.Exists(this.XMLFilename))
            {
                var attributes = System.IO.File.GetAttributes(this.XMLFilename);
                if (0 != (attributes & System.IO.FileAttributes.ReadOnly))
                {
                    throw new Exception("File '{0}' cannot be written to as it is read only", this.XMLFilename);
                }
            }

            this.Dependents.Sort();

            var document = new System.Xml.XmlDocument();
            var namespaceURI = "http://www.buildamation.com";
            var packageDefinition = document.CreateElement("PackageDefinition", namespaceURI);
            {
                var xmlns = "http://www.w3.org/2001/XMLSchema-instance";
                var schemaAttribute = document.CreateAttribute("xsi", "schemaLocation", xmlns);
                var mostRecentSchemaRelativePath = "./Schema/BamPackageDefinitionV1.xsd";
                schemaAttribute.Value = System.String.Format("{0} {1}", namespaceURI, mostRecentSchemaRelativePath);
                packageDefinition.Attributes.Append(schemaAttribute);
                packageDefinition.SetAttribute("name", this.Name);
                if (null != this.Version)
                {
                    packageDefinition.SetAttribute("version", this.Version);
                }
            }
            document.AppendChild(packageDefinition);

            // package description
            if (!string.IsNullOrEmpty(this.Description))
            {
                var descriptionElement = document.CreateElement("Description", namespaceURI);
                descriptionElement.InnerText = this.Description;
                packageDefinition.AppendChild(descriptionElement);
            }

            // package repositories
            var packageRepos = new StringArray(this.PackageRepositories);
            // TODO: could these be marked as transient?
            // don't write out the repo that this package resides in
            packageRepos.Remove(this.GetPackageRepository());
            // nor an associated repo for tests
            var associatedRepo = this.GetAssociatedPackageDirectoryForTests();
            if (null != associatedRepo)
            {
                packageRepos.Remove(associatedRepo);
            }
            if (packageRepos.Count > 0)
            {
                var packageRootsElement = document.CreateElement("PackageRepositories", namespaceURI);
                var bamDir = this.GetBamDirectory() + System.IO.Path.DirectorySeparatorChar; // slash added to make it look like a directory
                foreach (string repo in packageRepos)
                {
                    var relativePackageRepo = RelativePathUtilities.GetPath(repo, bamDir);
                    if (OSUtilities.IsWindowsHosting)
                    {
                        // standardize on non-Windows directory separators
                        relativePackageRepo = relativePackageRepo.Replace(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
                    }

                    var rootElement = document.CreateElement("Repo", namespaceURI);
                    rootElement.SetAttribute("dir", relativePackageRepo);
                    packageRootsElement.AppendChild(rootElement);
                }

                packageDefinition.AppendChild(packageRootsElement);
            }

            if (this.Dependents.Count > 0)
            {
                var dependentsEl = document.CreateElement("Dependents", namespaceURI);
                foreach (var package in this.Dependents)
                {
                    var packageName = package.Item1;
                    var packageVersion = package.Item2;
                    var packageIsDefault = package.Item3;
                    System.Xml.XmlElement packageElement = null;

                    {
                        var node = dependentsEl.FirstChild;
                        while (node != null)
                        {
                            var attributes = node.Attributes;
                            var nameAttribute = attributes["Name"];
                            if ((null != nameAttribute) && (nameAttribute.Value == packageName))
                            {
                                packageElement = node as System.Xml.XmlElement;
                                break;
                            }

                            node = node.NextSibling;
                        }
                    }

                    if (null == packageElement)
                    {
                        packageElement = document.CreateElement("Package", namespaceURI);
                        packageElement.SetAttribute("name", packageName);
                        if (null != packageVersion)
                        {
                            packageElement.SetAttribute("version", packageVersion);
                        }
                        if (packageIsDefault.HasValue)
                        {
                            packageElement.SetAttribute("default", packageIsDefault.Value.ToString().ToLower());
                        }
                        dependentsEl.AppendChild(packageElement);
                    }
                }
                packageDefinition.AppendChild(dependentsEl);
            }

            if (this.BamAssemblies.Count > 0)
            {
                var requiredAssemblies = document.CreateElement("BamAssemblies", namespaceURI);
                foreach (var assembly in this.BamAssemblies)
                {
                    var assemblyElement = document.CreateElement("BamAssembly", namespaceURI);
                    assemblyElement.SetAttribute("name", assembly.Name);
                    if (assembly.MajorVersion.HasValue)
                    {
                        assemblyElement.SetAttribute("major", assembly.MajorVersion.ToString());
                        if (assembly.MinorVersion.HasValue)
                        {
                            assemblyElement.SetAttribute("minor", assembly.MinorVersion.ToString());
                            if (assembly.PatchVersion.HasValue)
                            {
                                // honour any existing BamAssembly with a specific patch version
                                assemblyElement.SetAttribute("patch", assembly.PatchVersion.ToString());
                            }
                        }
                    }
                    requiredAssemblies.AppendChild(assemblyElement);
                }
                packageDefinition.AppendChild(requiredAssemblies);
            }

            if (this.DotNetAssemblies.Count > 0)
            {
                var requiredDotNetAssemblies = document.CreateElement("DotNetAssemblies", namespaceURI);
                foreach (var desc in this.DotNetAssemblies)
                {
                    var assemblyElement = document.CreateElement("DotNetAssembly", namespaceURI);
                    assemblyElement.SetAttribute("name", desc.Name);
                    if (null != desc.RequiredTargetFramework)
                    {
                        assemblyElement.SetAttribute("requiredTargetFramework", desc.RequiredTargetFramework);
                    }
                    requiredDotNetAssemblies.AppendChild(assemblyElement);
                }
                packageDefinition.AppendChild(requiredDotNetAssemblies);
            }

            // supported platforms
            {
                var supportedPlatformsElement = document.CreateElement("SupportedPlatforms", namespaceURI);

                if (EPlatform.Windows == (this.SupportedPlatforms & EPlatform.Windows))
                {
                    var platformElement = document.CreateElement("Platform", namespaceURI);
                    platformElement.SetAttribute("name", "Windows");
                    supportedPlatformsElement.AppendChild(platformElement);
                }
                if (EPlatform.Linux == (this.SupportedPlatforms & EPlatform.Linux))
                {
                    var platformElement = document.CreateElement("Platform", namespaceURI);
                    platformElement.SetAttribute("name", "Linux");
                    supportedPlatformsElement.AppendChild(platformElement);
                }
                if (EPlatform.OSX == (this.SupportedPlatforms & EPlatform.OSX))
                {
                    var platformElement = document.CreateElement("Platform", namespaceURI);
                    platformElement.SetAttribute("name", "OSX");
                    supportedPlatformsElement.AppendChild(platformElement);
                }

                packageDefinition.AppendChild(supportedPlatformsElement);
            }

            // definitions
            this.Definitions.Remove(this.GetPackageDefinitionName());
            if (this.Definitions.Count > 0)
            {
                var definitionsElement = document.CreateElement("Definitions", namespaceURI);

                foreach (string define in this.Definitions)
                {
                    var defineElement = document.CreateElement("Definition", namespaceURI);
                    defineElement.SetAttribute("name", define);
                    definitionsElement.AppendChild(defineElement);
                }

                packageDefinition.AppendChild(definitionsElement);
            }

            var xmlWriterSettings = new System.Xml.XmlWriterSettings();
            xmlWriterSettings.Indent = true;
            xmlWriterSettings.CloseOutput = true;
            xmlWriterSettings.OmitXmlDeclaration = false;
            xmlWriterSettings.NewLineOnAttributes = false;
            xmlWriterSettings.NewLineChars = "\n";
            xmlWriterSettings.ConformanceLevel = System.Xml.ConformanceLevel.Document;
            xmlWriterSettings.Encoding = new System.Text.UTF8Encoding(false);

            using (var xmlWriter = System.Xml.XmlWriter.Create(this.XMLFilename, xmlWriterSettings))
            {
                document.WriteTo(xmlWriter);
                xmlWriter.WriteWhitespace(xmlWriterSettings.NewLineChars);
            }

            if (this.validate)
            {
                this.Validate();
            }
        }
Exemple #46
0
        /// <summary>
        /// Save to a file
        /// </summary>
        public void Save()
        {
            update = true;
            try
            {
                if (File.Exists(datafile_xml))
                {
                    core.backupData(datafile_xml);
                    if (!File.Exists(config.tempName(datafile_xml)))
                    {
                        core.Log("Unable to create backup file for " + this.Channel);
                    }
                }
                System.Xml.XmlDocument data = new System.Xml.XmlDocument();
                System.Xml.XmlNode xmlnode = data.CreateElement("database");

                lock (Alias)
                {
                    foreach (staticalias key in Alias)
                    {
                        System.Xml.XmlAttribute name = data.CreateAttribute("alias_key_name");
                        name.Value = key.Name;
                        System.Xml.XmlAttribute kk = data.CreateAttribute("alias_key_key");
                        kk.Value = key.Key;
                        System.Xml.XmlAttribute created = data.CreateAttribute("date");
                        created.Value = "";
                        System.Xml.XmlNode db = data.CreateElement("alias");
                        db.Attributes.Append(name);
                        db.Attributes.Append(kk);
                        db.Attributes.Append(created);
                        xmlnode.AppendChild(db);
                    }
                }
                lock (text)
                {
                    foreach (item key in text)
                    {
                        System.Xml.XmlAttribute name = data.CreateAttribute("key_name");
                        name.Value = key.key;
                        System.Xml.XmlAttribute kk = data.CreateAttribute("data");
                        kk.Value = key.text;
                        System.Xml.XmlAttribute created = data.CreateAttribute("created_date");
                        created.Value = key.created.ToBinary().ToString();
                        System.Xml.XmlAttribute nick = data.CreateAttribute("nickname");
                        nick.Value = key.user;
                        System.Xml.XmlAttribute last = data.CreateAttribute("touched");
                        last.Value = key.lasttime.ToBinary().ToString();
                        System.Xml.XmlAttribute triggered = data.CreateAttribute("triggered");
                        triggered.Value = key.Displayed.ToString();
                        System.Xml.XmlNode db = data.CreateElement("key");
                        db.Attributes.Append(name);
                        db.Attributes.Append(kk);
                        db.Attributes.Append(nick);
                        db.Attributes.Append(created);
                        db.Attributes.Append(last);
                        db.Attributes.Append(triggered);
                        xmlnode.AppendChild(db);
                    }
                }

                data.AppendChild(xmlnode);
                data.Save(datafile_xml);
                if (File.Exists(config.tempName(datafile_xml)))
                {
                    File.Delete(config.tempName(datafile_xml));
                }
            }
            catch (Exception b)
            {
                try
                {
                    if (core.recoverFile(datafile_xml, Channel))
                    {
                        core.Log("Recovered db for channel " + Channel);
                    }
                    else
                    {
                        core.handleException(b, Channel);
                    }
                }
                catch (Exception bb)
                {
                    core.handleException(bb, Channel);
                }
            }
        }
        public async Task ExecuteNonQuery_WithTableParameterWhichTakesXmlElement_ExecutesSuccessfully()
        {
            System.Xml.XmlDocument document = new System.Xml.XmlDocument();
            System.Xml.XmlElement rootNode = document.CreateElement("MyTestRoot");
            System.Xml.XmlElement childNode = document.CreateElement("MyTestChild");
            System.Xml.XmlAttribute anAttribute = document.CreateAttribute("anattribute");

            childNode.InnerText = Random.RandomString(20);
            anAttribute.Value = Random.RandomInt32().ToString();
            rootNode.Attributes.Append(anAttribute);
            document.AppendChild(rootNode);
            rootNode.AppendChild(childNode);

            SqlProgram<IEnumerable<System.Xml.XmlElement>> xmlTypeTest =
                await SqlProgram<IEnumerable<System.Xml.XmlElement>>.Create((Connection)DifferentLocalDatabaseConnectionString, "spTakesTableXml");

            int nonQueryResult =
                xmlTypeTest.ExecuteNonQuery(new List<System.Xml.XmlElement> { rootNode, rootNode });
            Assert.AreEqual(-1, nonQueryResult);
        }
Exemple #48
0
        private void UpgradeFromVersionOne()
        {
            //Upgrade from the previous design with one source folder and multiple filters
            MessageBox.Show(this, Strings.SelectFiles.UpgradeWarning, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);

            string p = Library.Utility.Utility.AppendDirSeparator(m_wrapper.SourcePath);
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(m_wrapper.EncodedFilterXml);

            List<KeyValuePair<bool, string>> filters = new List<KeyValuePair<bool,string>>();
            foreach (System.Xml.XmlNode n in doc.SelectNodes("root/filter"))
                filters.Add(new KeyValuePair<bool, string>(bool.Parse(n.Attributes["include"].Value), n.Attributes["filter"].Value));

            //See what folders are included with the current setup
            Library.Utility.FilenameFilter filter = new XervBackup.Library.Utility.FilenameFilter(filters);
            IncludeDocuments.Checked = filter.ShouldInclude(p, m_myDocuments);
            IncludeImages.Checked = filter.ShouldInclude(p, m_myPictures);
            IncludeMusic.Checked = filter.ShouldInclude(p, m_myMusic);
            IncludeDesktop.Checked = filter.ShouldInclude(p, m_desktop);
            IncludeSettings.Checked = filter.ShouldInclude(p, m_appData);

            //Remove any filters relating to the special folders
            for (int i = 0; i < filters.Count; i++)
                foreach (string s in m_specialFolders)
                    if (s.StartsWith(p))
                    {
                        if (filters[i].Value == Library.Utility.FilenameFilter.ConvertGlobbingToRegExp(s.Substring(p.Length - 1) + "*"))
                        {
                            filters.RemoveAt(i);
                            i--;
                            break;
                        }
                    }

            //Remove any "exclude all" filters
            for (int i = 0; i < filters.Count; i++)
                if (filters[i].Key == false && filters[i].Value == ".*")
                {
                    filters.RemoveAt(i);
                    i--;
                }

            //See if there are extra filters that are not supported
            bool unsupported = false;
            foreach (KeyValuePair<bool, string> f in filters)
                if (f.Value.StartsWith(Library.Utility.FilenameFilter.ConvertGlobbingToRegExp(System.IO.Path.DirectorySeparatorChar.ToString())))
                {
                    unsupported = true;
                    break;
                }

            //If none of the special folders are included, we don't support the setup with simple mode
            unsupported |= !(IncludeDocuments.Checked | IncludeImages.Checked | IncludeMusic.Checked | IncludeDesktop.Checked | IncludeSettings.Checked);

            InnerControlContainer.Controls.Clear();
            AddFolderControl().SelectedPath = m_wrapper.SourcePath;

            //Make sure the extra filters are not included
            if (!unsupported)
            {
                doc = new System.Xml.XmlDocument();
                System.Xml.XmlNode root = doc.AppendChild(doc.CreateElement("root"));
                foreach (KeyValuePair<bool, string> f in filters)
                {
                    System.Xml.XmlNode n = root.AppendChild(doc.CreateElement("filter"));
                    n.Attributes.Append(doc.CreateAttribute("include")).Value = f.Key.ToString();
                    n.Attributes.Append(doc.CreateAttribute("filter")).Value = f.Value;
                    n.Attributes.Append(doc.CreateAttribute("globbing")).Value = "";
                }

                m_wrapper.EncodedFilterXml = doc.OuterXml;
            }

            if (unsupported)
                FolderRadio.Checked = true;
            else
                DocumentsRadio.Checked = true;
        }
Exemple #49
0
        private string RemoveBackupSets(BackendWrapper backend, List<ManifestEntry> entries)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(backend.FinishDeleteTransaction(false));

            if (entries.Count > 0)
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                System.Xml.XmlNode root = doc.AppendChild(doc.CreateElement("files"));
                root.Attributes.Append(doc.CreateAttribute("version")).Value = "1";

                foreach (ManifestEntry me in entries)
                {
                    if (me.Alternate != null)
                        root.AppendChild(doc.CreateElement("file")).InnerText = me.Alternate.Filename;
                    root.AppendChild(doc.CreateElement("file")).InnerText = me.Filename;

                    if (me.Verification != null)
                        root.AppendChild(doc.CreateElement("file")).InnerText = me.Verification.Filename;

                    foreach (KeyValuePair<SignatureEntry, ContentEntry> kx in me.Volumes)
                    {
                        root.AppendChild(doc.CreateElement("file")).InnerText = kx.Key.Filename;
                        root.AppendChild(doc.CreateElement("file")).InnerText = kx.Value.Filename;
                    }
                }

                if (m_options.Force)
                {
                    using (TempFile tf = new TempFile())
                    {
                        doc.Save(tf);
                        tf.Protected = true;
                        backend.WriteDeleteTransactionFile(tf);
                    }
                }

                foreach (ManifestEntry me in entries)
                {
                    sb.AppendLine(string.Format(Strings.Interface.DeletingBackupSetMessage, me.Time.ToString(System.Globalization.CultureInfo.InvariantCulture)));

                    if (m_options.Force)
                    {
                        //Delete manifest
                        if (me.Alternate != null)
                            backend.Delete(me.Alternate);

                        backend.Delete(me);

                        if (me.Verification != null)
                            backend.Delete(me.Verification);

                        foreach (KeyValuePair<SignatureEntry, ContentEntry> kx in me.Volumes)
                        {
                            backend.Delete(kx.Key);
                            backend.Delete(kx.Value);
                        }
                    }
                }

                if (m_options.Force)
                    backend.RemoveDeleteTransactionFile();

                if (!m_options.Force && entries.Count > 0)
                    sb.AppendLine(Strings.Interface.FilesAreNotForceDeletedMessage);
            }

            return sb.ToString();
        }
Exemple #50
0
        public object SaveXmlCurrentConfiguration(string StrPath, string StrFilename /*= "AppSettings.xml"*/)
        {
            //Conform the Path
            string FilePath = (!(StrPath == null) ? StrPath : System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) + "\\" + StrFilename;

            System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
            System.Xml.XmlElement xRoot = XmlDoc.CreateElement("configuration");
            XmlDoc.AppendChild(xRoot);
            System.Xml.XmlElement xAppSettingsElement = XmlDoc.CreateElement("appSettings");
            xRoot.AppendChild(xAppSettingsElement);

            System.Xml.XmlElement xElement = default(System.Xml.XmlElement);
            System.Xml.XmlAttribute xAttrKey = default(System.Xml.XmlAttribute);
            System.Xml.XmlAttribute xAttrValue = default(System.Xml.XmlAttribute);
            //For Each Item As String In Me.ListItems
            for (int i = 0; i <= this.ListItems.Count - 1; i++) {
                xElement = XmlDoc.CreateElement("add");
                xAttrKey = XmlDoc.CreateAttribute("key");
                xAttrValue = XmlDoc.CreateAttribute("value");
                xAttrKey.InnerText = this.ListItems.GetKey(i);
                xElement.SetAttributeNode(xAttrKey);
                xAttrValue.InnerText = this.ListItems[i];
                xElement.SetAttributeNode(xAttrValue);
                xAppSettingsElement.AppendChild(xElement);
            }
            System.Xml.XmlProcessingInstruction XmlPI = XmlDoc.CreateProcessingInstruction("xml", "version='1.0' encoding='utf-8'");
            XmlDoc.InsertBefore(XmlPI, XmlDoc.ChildNodes[0]);
            XmlDoc.Save(FilePath);
            return true;
        }
        private void CreatePlist()
        {
            var doc = new System.Xml.XmlDocument();
            // don't resolve any URLs, or if there is no internet, the process will pause for some time
            doc.XmlResolver = null;

            {
                var type = doc.CreateDocumentType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
                doc.AppendChild(type);
            }
            var plistEl = doc.CreateElement("plist");
            {
                var versionAttr = doc.CreateAttribute("version");
                versionAttr.Value = "1.0";
                plistEl.Attributes.Append(versionAttr);
            }

            var dictEl = doc.CreateElement("dict");
            plistEl.AppendChild(dictEl);
            doc.AppendChild(plistEl);

            #if true
            // TODO: this seems to be the only way to get the target settings working
            CreateKeyValuePair(doc, dictEl, "BuildLocationStyle", "UseTargetSettings");
            #else
            // build and intermediate file locations
            CreateKeyValuePair(doc, dictEl, "BuildLocationStyle", "CustomLocation");
            CreateKeyValuePair(doc, dictEl, "CustomBuildIntermediatesPath", "XcodeIntermediates"); // where xxx.build folders are stored
            CreateKeyValuePair(doc, dictEl, "CustomBuildLocationType", "RelativeToWorkspace");
            CreateKeyValuePair(doc, dictEl, "CustomBuildProductsPath", "."); // has to be the workspace folder, in order to write files to expected locations

            // derived data
            CreateKeyValuePair(doc, dictEl, "DerivedDataCustomLocation", "XcodeDerivedData");
            CreateKeyValuePair(doc, dictEl, "DerivedDataLocationStyle", "WorkspaceRelativePath");
            #endif

            this.Document = doc;
        }
                    public override void SaveDB(string filename, DataBase tDataBase)
                    {
                        //tDataBase.WriteXml(filename)

                        System.Xml.XmlDocument XMLDOC = new System.Xml.XmlDocument();
                        XMLDOC.LoadXml("<data></data>");

                        XmlAttribute attr;

                        XmlNode newTable;
                        XmlNode newRow;
                        XmlNode newColumn;

                        foreach (BlackLight.Services.DB.Table tTable in tDataBase)
                        {
                            newTable = XMLDOC.CreateNode(XmlNodeType.Element, "table", "");
                            XMLDOC.DocumentElement.AppendChild(newTable);

                            attr = XMLDOC.CreateAttribute("name");
                            attr.Value = tTable.Name;
                            newTable.Attributes.Append(attr);

                            attr = XMLDOC.CreateAttribute("columns");
                            attr.Value = Convert.ToString(tTable.Columns.Count);
                            newTable.Attributes.Append(attr);

                            attr = XMLDOC.CreateAttribute("primary");
                            attr.Value = tTable.PrimaryColumn;
                            newTable.Attributes.Append(attr);

                            foreach (BlackLight.Services.DB.Column tColumn in tTable.Columns)
                            {
                                newColumn = XMLDOC.CreateNode(XmlNodeType.Element, "column", "");
                                newTable.AppendChild(newColumn);

                                attr = XMLDOC.CreateAttribute("name");
                                attr.Value = tColumn.Name;
                                newColumn.Attributes.Append(attr);

                                attr = XMLDOC.CreateAttribute("type");
                                attr.Value = Convert.ToString(tColumn.DType);
                                newColumn.Attributes.Append(attr);

                            }

                            foreach (BlackLight.Services.DB.Row tRow in tTable)
                            {
                                newRow = XMLDOC.CreateNode(XmlNodeType.Element, "row", "");
                                newTable.AppendChild(newRow);
                                foreach (BlackLight.Services.DB.Column tColumn in tTable.Columns)
                                {
                                    attr = XMLDOC.CreateAttribute(tColumn.Name);
                                    attr.Value = System.Convert.ToString(tRow[tColumn.Name]);
                                    newRow.Attributes.Append(attr);

                                }
                            }

                        }

                        if (System.IO.Directory.Exists("data") == false)
                        {
                            System.IO.Directory.CreateDirectory("data");
                        }

                        XMLDOC.Save("data\\" + filename);
                    }
Exemple #53
0
        private void SaveFile()
        {
            //Save the values to an XML file
            //Could save to data source, Message Queue etc.
            System.Xml.XmlDocument aDOM = new System.Xml.XmlDocument();
            System.Xml.XmlAttribute aAttribute;

            aDOM.LoadXml("<UserData/>");

            //Add the First Name attribute to XML
            aAttribute = aDOM.CreateAttribute("FirstName");
            aAttribute.Value = txtFName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Add the Last Name attribute to XML
            aAttribute = aDOM.CreateAttribute("LastName");
            aAttribute.Value = txtLName.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Add the SSN attribute to XML
            aAttribute = aDOM.CreateAttribute("SSN");
            aAttribute.Value = txtSSN.Text;
            aDOM.DocumentElement.Attributes.Append(aAttribute);

            //Save the file to the file system
            aDOM.Save("../../UserData.xml");
        }
Exemple #54
0
            /// <summary>
            /// Saves the USN data to an XmlDocument
            /// </summary>
            /// <returns>An XmlDocument with the USN data</returns>
            public System.Xml.XmlDocument Save()
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                System.Xml.XmlNode root = doc.AppendChild(doc.CreateElement("usnroot"));
                foreach (KeyValuePair<string, KeyValuePair<long, long>> kv in m_values)
                {
                    System.Xml.XmlNode n = root.AppendChild(doc.CreateElement("usnrecord"));
                    n.Attributes.Append(doc.CreateAttribute("root")).Value = kv.Key;
                    n.Attributes.Append(doc.CreateAttribute("journalid")).Value = kv.Value.Key.ToString();
                    n.Attributes.Append(doc.CreateAttribute("usn")).Value = kv.Value.Value.ToString();
                }

                return doc;
            }
        /// <summary>
        /// Returns an Xml document containing information on all of the functions in the TemplateGen
        /// type from the current assembly
        /// </summary>
        /// <returns></returns>
        public string GetFunctionsXml()
        {
            object obj = CurrentAssembly.CreateInstance(_ProjectNamespace + ".TemplateGen");
            Type objType = obj.GetType();

            MethodInfo[] methods = objType.GetMethods(BindingFlags.Public | BindingFlags.Static);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            System.Xml.XmlNode rootNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "functions", "");

            foreach (MethodInfo method in methods)
            {
                System.Xml.XmlNode functionNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "function", "");
                System.Xml.XmlAttribute attName = doc.CreateAttribute("name");
                attName.Value = method.Name;
                System.Xml.XmlAttribute attParamTypeName = doc.CreateAttribute("parametertypename");
                ParameterInfo[] parameters = method.GetParameters();

                switch (parameters.Length)
                {
                    case 0:
                        attParamTypeName.Value = "";
                        break;
                    case 1:
                        attParamTypeName.Value = parameters[0].ParameterType.ToString();
                        break;
                    default:
                        attParamTypeName.Value = parameters[0].ParameterType.ToString();
                        // TODO: Determine how to handle Template vs. normal functions WRT number of parameters
                        //throw new Exception("Template functions can't have more than one parameter: "+ method.Name);
                        break;
                }
                functionNode.Attributes.Append(attName);
                functionNode.Attributes.Append(attParamTypeName);
                rootNode.AppendChild(functionNode);
            }
            doc.AppendChild(rootNode);
            return doc.OuterXml;
        }
        public void WriteUserSetting(string SectionName, string EntryName, string EntryValue)
        {
            //  Make sure all of the necessary information was passed to this routine before attempting to write to
              //  the Settings File.
              if (SectionName == null || SectionName == "" || EntryName == null || EntryName == "" || EntryValue == "")
              {
            //  Exit the Method.
            return;
              }

              try
              {
            // If the value is null, remove the entry
            if (EntryValue == null)
            {
              RemoveUserSetting(SectionName, EntryValue);
              return;
            }

            //  Verify that the file is available for reading and that the XML Section and Entry Name values are valid.
            VerifyNotReadOnly();
            string section = SectionName;
            VerifyAndAdjustSection(ref section);
            string entry = EntryName;
            VerifyAndAdjustEntry(ref entry);

            //  If the File does not exist, create it.
            if (System.IO.File.Exists(_filePath))
            {
              System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(_filePath, System.Text.Encoding.UTF8);
              writer.Formatting = System.Xml.Formatting.Indented;
              writer.WriteStartDocument();
              writer.WriteStartElement("profile");
              writer.WriteStartElement("section");
              writer.WriteAttributeString("name", null, section);
              writer.WriteStartElement("entry");
              writer.WriteAttributeString("name", null, entry);
              writer.WriteString(EntryValue);
              writer.WriteEndElement();
              writer.WriteEndElement();
              writer.WriteEndElement();
              writer.Close();

              //  Exit the method now that the file has been created.
              return;

            }

            // The file exists, edit it
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(_filePath);
            System.Xml.XmlElement root = doc.DocumentElement;

            // Get the section element and add it if it's not there
            System.Xml.XmlNode sectionNode = root.SelectSingleNode(GetSectionsPath(section));
            if (sectionNode == null)
            {
              System.Xml.XmlElement element = doc.CreateElement("section");
              System.Xml.XmlAttribute attribute = doc.CreateAttribute("name");
              attribute.Value = section;
              element.Attributes.Append(attribute);
              sectionNode = root.AppendChild(element);
            }

            // Get the entry element and add it if it's not there
            System.Xml.XmlNode entryNode = sectionNode.SelectSingleNode(GetEntryPath(entry));
            if (entryNode == null)
            {
              System.Xml.XmlElement element = doc.CreateElement("entry");
              System.Xml.XmlAttribute attribute = doc.CreateAttribute("name");
              attribute.Value = entry;
              element.Attributes.Append(attribute);
              entryNode = sectionNode.AppendChild(element);
            }

            // Add the value and save the file
            entryNode.InnerText = EntryValue;
            doc.Save(_filePath);

              }
              catch
              {
            //  Exit this Method.
            return;
              }
        }
Exemple #57
0
        /// <summary>
        /// Create a new request
        /// </summary>
        /// <returns></returns>
        private System.Xml.XmlElement CreateRequest(string strHandle, string strCommand)
        {
            System.Xml.XmlDocument oXmlRequest = new System.Xml.XmlDocument();
            System.Xml.XmlElement oGeosoftNode = oXmlRequest.CreateElement(Constant.Tag.GEO_XML_TAG);
            System.Xml.XmlElement oRequestNode = oXmlRequest.CreateElement(Constant.Tag.REQUEST_TAG);
            System.Xml.XmlElement oCommandNode = oXmlRequest.CreateElement(strCommand);

            // --- set the version attribute ---

            oGeosoftNode.SetAttribute(Constant.Attribute.VERSION_ATTR, Constant.XmlVersion[Convert.ToInt32(m_eVersion)]);
            oGeosoftNode.AppendChild(oRequestNode);

            // --- add the command to the request ---

            oRequestNode.AppendChild(oCommandNode);
            SetHandle(oCommandNode, strHandle);

            // --- add the user name/password if available ---

            if (m_eVersion == Command.Version.GEOSOFT_XML_1_1)
            {
                System.Xml.XmlAttribute oAttr;

                oAttr = oXmlRequest.CreateAttribute(Constant.Attribute.TOKEN_ATTR);
                oAttr.Value = m_strToken;
                oCommandNode.Attributes.Append(oAttr);
            }

            // --- add this request to the document ---

            oXmlRequest.AppendChild(oGeosoftNode);

            return oCommandNode;
        }
Exemple #58
0
        private void SaveFile()
        {
            SaveFileDialog aSaveFileDialog = new SaveFileDialog();
            aSaveFileDialog.Filter = "Text Files (*.txt)|*.txt|Word Documents" +
                "(*.doc)|*.doc|All Files (*.*)|*.*";
            aSaveFileDialog.CreatePrompt = true;
                aSaveFileDialog.OverwritePrompt = true;
            aSaveFileDialog.Title = "Save file for custom application";
            if (aSaveFileDialog.ShowDialog() == DialogResult.OK)
            {

                //Save the values to an XML file
                //Could save to data source, Message Queue, etc.
                System.Xml.XmlDocument aDOM = new System.Xml.XmlDocument();
                System.Xml.XmlAttribute aAttribute;

                aDOM.LoadXml("<UserData/>");

                //Add the First Name attribute to XML
                aAttribute = aDOM.CreateAttribute("FirstName");
                aAttribute.Value = txtFName.Text;
                aDOM.DocumentElement.Attributes.Append(aAttribute);

                //Add the Last Name attribute to XML
                aAttribute = aDOM.CreateAttribute("LastName");
                aAttribute.Value = txtLName.Text;
                aDOM.DocumentElement.Attributes.Append(aAttribute);

                //Add the SSN attribute to XML
                aAttribute = aDOM.CreateAttribute("SSN");
                aAttribute.Value = txtSSN.Text;
                aDOM.DocumentElement.Attributes.Append(aAttribute);

                //Save file to the file system
                aDOM.Save(aSaveFileDialog.FileName.ToString());
                //Do something useful with aSaveFileDialog.FileName;
            }

            aSaveFileDialog.Dispose();
        }