AppendChild() public méthode

public AppendChild ( XmlNode node ) : XmlNode
node XmlNode
Résultat XmlNode
Exemple #1
0
        public String SetDeviceConfig()
        {
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            System.Xml.XmlNode     xnRoot = xmlDoc.CreateElement("root");

            foreach (Devices devices in deviceList)
            {
                System.Xml.XmlDocument xmlDocChild = new System.Xml.XmlDocument();
                System.Xml.XmlNode     xnRecord    = xmlDoc.CreateElement("device");

                System.Xml.XmlNode xnSuite = xmlDoc.CreateElement("suite");
                xnSuite.InnerText = devices.suite.ToString();
                xnRecord.AppendChild(xnSuite);

                System.Xml.XmlNode xnAddress = xmlDoc.CreateElement("address");
                xnAddress.InnerText = devices.address.ToString();
                xnRecord.AppendChild(xnAddress);

                System.Xml.XmlNode xnDeviceType = xmlDoc.CreateElement("deviceType");
                xnDeviceType.InnerText = devices.deviceType.ToString();
                xnRecord.AppendChild(xnDeviceType);

                System.Xml.XmlNode xnFactory = xmlDoc.CreateElement("factory");
                xnFactory.InnerText = devices.factory.ToString();
                xnRecord.AppendChild(xnFactory);
            }
            return(xnRoot.OuterXml);
        }
Exemple #2
0
        /// <summary>
        /// Appends the XML.
        /// </summary>
        /// <param name="doc">The doc.</param>
        /// <param name="rootNode">The root node.</param>
        public override void AppendXml(XmlDocument doc, XmlNode rootNode)
        {
            XmlNode codeGroupNode = doc.CreateElement(CodeGroupKey);

            rootNode.AppendChild(codeGroupNode);
            XmlNode codeGroupTypeNode = doc.CreateElement(CodeGroupTypeKey);

            codeGroupTypeNode.InnerText = ElementTypeName;
            codeGroupNode.AppendChild(codeGroupTypeNode);
            XmlNode elementTypesNode = doc.CreateElement(ElementTypesName);

            codeGroupNode.AppendChild(elementTypesNode);

            foreach (LanguageElementType type in elementTypes)
            {
                XmlNode elementTypeNode = doc.CreateElement(ElementTypeName);
                elementTypeNode.InnerText = ((int)type).ToString();
                elementTypesNode.AppendChild(elementTypeNode);
            }

            XmlNode visibilitiesNode = doc.CreateElement(VisibilitiesName);

            codeGroupNode.AppendChild(visibilitiesNode);

            foreach (MemberVisibility visibility in memberVisibilty)
            {
                XmlNode visibiltyNode = doc.CreateElement(VisibilityName);
                visibiltyNode.InnerText = ((int)visibility).ToString();
                visibilitiesNode.AppendChild(visibiltyNode);
            }

            base.AppendXml(doc, codeGroupNode);
        }
Exemple #3
0
        public AssociationNode(WordDocument doc, string guid, string name, string endName, string endMP, string associationType, string connectionType)
        {
            IsRemained = true;
            AssociationGUID = guid;
            AssociationConnectionType = connectionType;
            _doc = doc;

            AssociationXmlNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_SECTION, guid, connectionType);
            XmlNode assocNameNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_NAME);
            if (associationType.Equals(Constants.Association))
                assocNameNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_NAME_PREFIX, name, Definitions.CLASS_ASSOC_NAME));
            else
                assocNameNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_COMPOSITION_NAME_PREFIX, name, Definitions.CLASS_ASSOC_NAME));
            AssociationXmlNode.AppendChild(assocNameNode);

            XmlNode assocDescrNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_DESCR);
            assocDescrNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_DESCR_PREFIX, string.Empty, Definitions.CLASS_ASSOC_DESCR));
            AssociationXmlNode.AppendChild(assocDescrNode);

            XmlNode assocNameEndNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_NAME_END);
            assocNameEndNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_NAME_END_PREFIX, endName, Definitions.CLASS_ASSOC_NAME_END));
            AssociationXmlNode.AppendChild(assocNameEndNode);

            XmlNode assocMultNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_MULT);
            assocMultNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_MULT_PREFIX, endMP, Definitions.CLASS_ASSOC_MULT));
            AssociationXmlNode.AppendChild(assocMultNode);

            XmlNode assocTypeNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_TYPE);
            assocTypeNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_TYPE_PREFIX, associationType, Definitions.CLASS_ASSOC_TYPE));
            AssociationXmlNode.AppendChild(assocTypeNode);
        }
        public XmlSecurityRatings()
        {
            _document = new XmlDocument();

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

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

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

            _lowSecurity = _document.CreateNode(XmlNodeType.Element, "Low", null);
            _securityRatings.AppendChild(_lowSecurity);
            appendAttribute(_lowSecurity, @"title", @"LOW RISK");
            appendAttribute(_lowSecurity, @"comment", @"This document contains normal elements");
            appendAttribute(_lowSecurity, @"color", @"#4E7C49");
            appendAttribute(_lowSecurity, @"include-in-summary", @"no");
            appendAttribute(_lowSecurity, @"hiddendata", @"This document contains low risk hidden data");
            appendAttribute(_lowSecurity, @"contentpolicy", @"This document contains low risk content policy violations");
        }
Exemple #5
0
 private XmlDocument DaiKaiZYFPZuofeiCreateXml(List <SWDKDMHM> fpList)
 {
     if ((fpList != null) && (fpList.Count != 0))
     {
         try
         {
             XmlDocument    document = new XmlDocument();
             XmlDeclaration newChild = document.CreateXmlDeclaration("1.0", "UTF-8", "");
             document.AppendChild(newChild);
             System.Xml.XmlNode node = document.CreateNode(XmlNodeType.Element, "INVALID", "");
             document.AppendChild(node);
             foreach (SWDKDMHM swdkdmhm in fpList)
             {
                 System.Xml.XmlNode node2 = document.CreateElement("FP");
                 node.AppendChild(node2);
                 System.Xml.XmlNode node3 = document.CreateElement("FPHM");
                 node3.InnerText = ShareMethods.FPHMTo8Wei(swdkdmhm.fphm);
                 node2.AppendChild(node3);
                 System.Xml.XmlNode node4 = document.CreateElement("FPDM");
                 node4.InnerText = swdkdmhm.fpdm;
                 node2.AppendChild(node4);
             }
             fpList = null;
             return(document);
         }
         catch (Exception exception)
         {
             this.loger.Error("税务代开发票作废构造XML异常:" + exception.ToString());
         }
     }
     return(null);
 }
Exemple #6
0
        /// <summary>
        /// Permet de générer la partie XML de Astronaute
        /// </summary>
        /// <param name="xmlDoc">XmlDocument global</param>
        /// <param name="xmlDocActs">XmlDocument pour les activités de base</param>
        /// <param name="astronaute">Le noeud de l'astronaute</param>
        /// <param name="acts">Le noeud de l'activité (base)</param>
        /// <param name="progression">L'interface de progression</param>
        public void genererXML(XmlDocument xmlDoc, XmlDocument xmlDocActs, XmlNode astronaute, XmlNode acts, Progression progression)
        {
            XmlNode nom = xmlDoc.CreateElement("Nom");
            nom.InnerText = this.nom;
            astronaute.AppendChild(nom);

            XmlNode prenom = xmlDoc.CreateElement("Prenom");
            prenom.InnerText = this.prenom;
            astronaute.AppendChild(prenom);

            XmlNode age = xmlDoc.CreateElement("Age");
            age.InnerText = this.age.ToString();
            astronaute.AppendChild(age);

            XmlNode journees = xmlDoc.CreateElement("JourneesMission");
            astronaute.AppendChild(journees);

            for (int i = 1; i <= journeesMission.Count; ++i)
            {
                XmlNode journee = xmlDoc.CreateElement("Journee");
                journees.AppendChild(journee);

                journeesMission[i].genererXML(xmlDoc, xmlDocActs, journee, acts, progression);
                progression.incrementer();
            }
        }
Exemple #7
0
 public void fAppendNode(ref XmlNode WhereToAppend, ref XmlNode WhatToAppend)
 {
     try
     {
         WhereToAppend.AppendChild(WhatToAppend);
     }
     catch (Exception ex)
     {
         if (ex.Message.ToUpper() == "THE NODE TO BE INSERTED IS FROM A DIFFERENT DOCUMENT CONTEXT.")
         {
             try
             {
                 WhereToAppend.AppendChild(WhereToAppend.OwnerDocument.ImportNode(WhatToAppend, true));
             }
             catch (Exception e)
             {
                 throw e;
             }
         }
         else
         {
             throw ex;
         }
     }
 }
Exemple #8
0
        public static void AddOutputColumns(XmlDocument doc, XmlNode outputNode, XmlNode resultRow)
        {
            foreach (XmlNode childNode in outputNode.ChildNodes)
            {
                XmlAttribute outStatusAttr = GetAttributeByName(childNode, "status");
                XmlAttribute outExpectedAttr = GetAttributeByName(childNode, "expected");
                XmlAttribute outActualAttr = GetAttributeByName(childNode, "actual");

                string outStatus = "outputvalue_" + outStatusAttr.Value;
                if (outStatusAttr.Value == ResultParser.ResultType.UNMATCH)
                {
                    XmlElement outputData = CreateDataElement(doc, outExpectedAttr.Value, outputExpectedColor, outStatus);
                    XmlElement resultData = CreateDataElement(doc, outActualAttr.Value, outputUnMatchColor, outStatus);
                    resultRow.AppendChild(outputData);
                    resultRow.AppendChild(resultData);
                    if (outActualAttr.Value == "")
                    {
                        resultData.SetAttribute("width", "3px");
                    }
                }
                else
                {
                    string outBgcolor = GetOutputColor(outStatusAttr.Value);
                    string outValue = outActualAttr.Value;
                    if (outExpectedAttr.Value != "")
                    {
                        outValue = outExpectedAttr.Value;
                    }
                    XmlElement outputData = CreateDataElement(doc, outValue, outBgcolor, outStatus);
                    outputData.SetAttribute("colspan", "2");
                    resultRow.AppendChild(outputData);
                }
            }
        }
Exemple #9
0
        public void SaveConfiguration(System.Xml.XmlNode configNode)
        {
            System.Xml.XmlNode node = configNode.OwnerDocument.CreateElement("ShowSelectedDetails");
            configNode.AppendChild(node);
            node.InnerText = Settings.ShowDetails.ToString();

            node = configNode.OwnerDocument.CreateElement("ShowAllAccessible");
            configNode.AppendChild(node);
            node.InnerText = Settings.ShowAllAccessible.ToString();
        }
        /// <summary>
        /// Appends the XML.
        /// </summary>
        /// <param name="doc">The doc.</param>
        /// <param name="rootNode">The root node.</param>
        public virtual void AppendXml(XmlDocument doc, XmlNode rootNode)
        {
            XmlNode displayNode = doc.CreateElement(DisplayTextKey);

            rootNode.AppendChild(displayNode);
            displayNode.InnerText = DisplayText;
            XmlNode commentNode = doc.CreateElement(CommentKey);

            rootNode.AppendChild(commentNode);
            commentNode.InnerText = Comment;
        }
Exemple #11
0
 /// <summary>
 /// Save Dynamic GDALImageStores on Exit
 /// </summary>
 /// <param name="worldDoc">Create Relevant ImageAccessor Node</param>
 /// <returns></returns>
 public override System.Xml.XmlNode ToXml(System.Xml.XmlDocument worldDoc)
 {
     System.Xml.XmlNode baseNode        = base.ToXml(worldDoc);
     System.Xml.XmlNode sourceFileNode  = worldDoc.CreateElement("GDALFileName");
     System.Xml.XmlNode datasetnameNode = worldDoc.CreateElement("DatasetName");
     sourceFileNode.AppendChild(worldDoc.CreateTextNode(this.m_sourcefilename));
     datasetnameNode.AppendChild(worldDoc.CreateTextNode(this.m_dataSetName));
     baseNode.AppendChild(sourceFileNode);
     baseNode.AppendChild(datasetnameNode);
     return(baseNode);
 }
Exemple #12
0
        public AttributeNode(WordDocument doc, string attribute)
        {
            AttrName = attribute;
            AttributeXMLNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ATTR_SECTION);
            XmlNode attrNameNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ATTR_NAME);
            attrNameNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ATTR_NAME_PREFIX, attribute, Definitions.CLASS_ATTR_NAME));
            AttributeXMLNode.AppendChild(attrNameNode);

            XmlNode attrDescrNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ATTR_DESCR);
            attrDescrNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ATTR_NAME_DESCR_PREFIX, string.Empty, Definitions.CLASS_ATTR_DESCR));
            AttributeXMLNode.AppendChild(attrDescrNode);
        }
Exemple #13
0
        internal virtual void SaveXml(XmlNode xmlParent)
        {
            XmlAttribute xmlAttribute = null;
            XmlElement xmlElement = null;
		
		      
            if ( _id != 0 )
            {
                xmlAttribute = xmlParent.OwnerDocument.CreateAttribute("id");
                xmlAttribute.Value = _id.ToString();
                xmlParent.Attributes.Append(xmlAttribute);
            }
          
            if ( _timestamp != DateTime.MinValue )
            {
                xmlAttribute = xmlParent.OwnerDocument.CreateAttribute("timestamp");
                xmlAttribute.Value = _timestamp.ToString("yyyy/MM/dd HH:mm:ss");;
                xmlParent.Attributes.Append(xmlAttribute);
            }
          
            if ( _visible != "" )
            {
                xmlAttribute = xmlParent.OwnerDocument.CreateAttribute("visible");
                xmlAttribute.Value = _visible;
                xmlParent.Attributes.Append(xmlAttribute);
            }
          
            if ( _action != "" )
            {
                xmlAttribute = xmlParent.OwnerDocument.CreateAttribute("action");
                xmlAttribute.Value = _action;
                xmlParent.Attributes.Append(xmlAttribute);
            }
          
            foreach ( nd item in _ndCollection )
            {
                xmlElement = xmlParent.OwnerDocument.CreateElement("nd");
                item.SaveXml(xmlElement);
                // When nothing is on the xmlElement then don't add it				
                if ( xmlElement.ChildNodes.Count != 0 || xmlElement.Attributes.Count != 0 || xmlElement.InnerXml.Length != 0 )
                    xmlParent.AppendChild(xmlElement);
            }
          
            foreach ( tag item in _tagCollection )
            {
                xmlElement = xmlParent.OwnerDocument.CreateElement("tag");
                item.SaveXml(xmlElement);
                // When nothing is on the xmlElement then don't add it				
                if ( xmlElement.ChildNodes.Count != 0 || xmlElement.Attributes.Count != 0 || xmlElement.InnerXml.Length != 0 )
                    xmlParent.AppendChild(xmlElement);
            }
          
        }
Exemple #14
0
        public static XmlNode AppendElement( XmlNode node, string newElementName, string innerValue )
        {
            XmlNode oNode ;

            if ( node is XmlDocument )
                oNode = node.AppendChild( ((XmlDocument)node).CreateElement( newElementName ) ) ;
            else
                oNode = node.AppendChild( node.OwnerDocument.CreateElement( newElementName ) ) ;

            if ( innerValue != null )
                oNode.AppendChild( node.OwnerDocument.CreateTextNode( innerValue ) ) ;

            return oNode ;
        }
        public bool SetValue(string key, string value)
        {
            //增加 

            // retrieve the appSettings node    
            node = cfgDoc.SelectSingleNode("//appSettings");
            if (node == null)
            {
                throw new InvalidOperationException("appSettings section not found");
            }

            // XPath select setting "add" element that contains this key        
            var addElem = (XmlElement) node.SelectSingleNode("//add[@key='" + key + "']");
            if (addElem != null)
            {
                message = "此key已经存在!";
                return false;
            }
                // not found, so we need to add the element, key and value    
            else
            {
                XmlElement entry = cfgDoc.CreateElement("add");
                entry.SetAttribute("key", key);
                entry.SetAttribute("value", value);
                node.AppendChild(entry);
            }
            //save it    
            saveConfigDoc(cfgDoc, docName);
            message = "添加成功!";
            return true;
        }
Exemple #16
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 schema = doc.CreateElement("xs", "schema", XmlNamespaces.XS);                       //NOXLATE

            schema.SetAttribute("xmlns:xs", XmlNamespaces.XS);                                      //NOXLATE
            schema.SetAttribute("targetNamespace", XmlNamespaces.FDO + "/feature/" + this.Name);    //NOXLATE
            schema.SetAttribute("xmlns:fdo", XmlNamespaces.FDO);                                    //NOXLATE
            schema.SetAttribute("xmlns:" + this.Name, XmlNamespaces.FDO + "/feature/" + this.Name); //NOXLATE
            schema.SetAttribute("elementFormDefault", "qualified");                                 //NOXLATE
            schema.SetAttribute("attributeFormDefault", "unqualified");                             //NOXLATE

            //Write description node
            var anno = doc.CreateElement("xs", "annotation", XmlNamespaces.XS);    //NOXLATE
            var docN = doc.CreateElement("xs", "documentation", XmlNamespaces.XS); //NOXLATE

            docN.InnerText = this.Description;
            schema.AppendChild(anno);
            anno.AppendChild(docN);

            foreach (IFdoSerializable cls in this.Classes)
            {
                cls.WriteXml(doc, schema);
            }

            currentNode.AppendChild(schema);
        }
Exemple #17
0
 public static XmlNode AddNode(XmlNode destination, XmlNode child)
 {
     if ((destination == null) || (child == null))
     {
         return null;
     }
     bool isOwnerDocument;
     var destnationDocument = GetXmlDocument(destination, out isOwnerDocument);
     var appendNode = CloneNode(destnationDocument, child, true);
     if (appendNode != null)
     {
         if (isOwnerDocument)
         {
             if (destnationDocument.DocumentElement == null)
             {
                 destnationDocument.AppendChild(appendNode);
             }
             else
             {
                 destnationDocument.DocumentElement.AppendChild(appendNode);
             }
             return appendNode;
         }
         destination.AppendChild(appendNode);
     }
     return appendNode;
 }
Exemple #18
0
 public static XmlElement AddChild(XmlNode parent, string name)
 {
     XmlDocument document = (parent is XmlDocument) ? (XmlDocument) parent : parent.OwnerDocument;
     XmlElement node = document.CreateElement(name);
     parent.AppendChild(node);
     return node;
 }
 private static void AddContent(XmlNode nodeModule, ModuleInfo objModule)
 {
     XmlAttribute xmlattr;
     if (!String.IsNullOrEmpty(objModule.DesktopModule.BusinessControllerClass) && objModule.DesktopModule.IsPortable)
     {
         try
         {
             object objObject = Framework.Reflection.CreateObject(objModule.DesktopModule.BusinessControllerClass, objModule.DesktopModule.BusinessControllerClass);
             if (objObject is IPortable)
             {
                 string Content = Convert.ToString(((IPortable)objObject).ExportModule(objModule.ModuleID));
                 if (!String.IsNullOrEmpty(Content))
                 {
                     XmlNode newnode = nodeModule.OwnerDocument.CreateElement("content");
                     xmlattr = nodeModule.OwnerDocument.CreateAttribute("type");
                     xmlattr.Value = Globals.CleanName(objModule.DesktopModule.ModuleName);
                     newnode.Attributes.Append(xmlattr);
                     xmlattr = nodeModule.OwnerDocument.CreateAttribute("version");
                     xmlattr.Value = objModule.DesktopModule.Version;
                     newnode.Attributes.Append(xmlattr);
                     Content = HttpContext.Current.Server.HtmlEncode(Content);
                     newnode.InnerXml = XmlUtils.XMLEncode(Content);
                     nodeModule.AppendChild(newnode);
                 }
             }
         }
         catch
         {
         }
     }
 }
 /// <summary>
 /// Write this document's schema mappings to the given XML document
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="currentNode"></param>
 protected override void WriteSchemaMappings(System.Xml.XmlDocument doc, System.Xml.XmlNode currentNode)
 {
     foreach (var el in _mappings)
     {
         currentNode.AppendChild(el);
     }
 }
 public static void appendElement(XmlNode xmlNode, String element, Hashtable properties, Hashtable eventProperties)
 {
     xmlNode.RemoveAll();
     if (properties != null)
     {
         foreach (string name in properties.Keys)
         {
             XmlAttribute attr = xmlNode.OwnerDocument.CreateAttribute(name);
             attr.InnerText = (string)properties[name];
             xmlNode.Attributes.Append(attr);
         }
     }
     if (eventProperties != null)
     {
         foreach (string name in eventProperties.Keys)
         {
             XmlNode eventNode = xmlNode.OwnerDocument.CreateNode(XmlNodeType.Element, XMLServicesConstants.XmlNodeEventElt, null);
             eventNode.InnerText = (string)eventProperties[name];
             xmlNode.AppendChild(eventNode);
             XmlAttribute attr = eventNode.OwnerDocument.CreateAttribute(XMLServicesConstants.XmlNodeNameAtt);
             attr.InnerText = name;
             eventNode.Attributes.Append(attr);
         }
     }
 }
        public void generateAndPopulateBodyNode(XmlNode envelopeNode)
        {

            var bodyNode = xmlDocument.CreateElement(bodyTag, rootNamespace);
            generateAndPopulateActionNode(bodyNode);
            envelopeNode.AppendChild(bodyNode);
        } 
        public void LoadData()
        {
            lock (this)
            {
                doc = new XmlDocument();
                if (File.Exists(fileName))
                {
                    XmlTextReader reader = new XmlTextReader(fileName);
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    doc.Load(reader);
                    reader.Close();
                }
                else
                {
                    createdFile = true;
                    rootNode = doc.CreateNode(XmlNodeType.Element, "Root", String.Empty);
                    doc.AppendChild(rootNode);
                    configNode = doc.CreateNode(XmlNodeType.Element, "Config", String.Empty);
                    rootNode.AppendChild(configNode);
                }

                LoadDataToClass();

                if (createdFile)
                {
                    Commit();
                }
            }
        }
 private void WritePolicyItem(XmlNode parentNode, KeyValuePair<Guid, string> languageItem)
 {
     XmlNode xmlLanguageItemNode = m_xmlDocument.CreateElement("Item");
     parentNode.AppendChild(xmlLanguageItemNode);
     XmlHelpers.AddAttribute(xmlLanguageItemNode, "id", languageItem.Key.ToString("B", CultureInfo.InvariantCulture).ToUpper(CultureInfo.InvariantCulture));
     XmlHelpers.AddAttribute(xmlLanguageItemNode, "value", languageItem.Value.ToString());
 }
Exemple #25
0
 private void AddChild(String xml, XmlNode node)
 {
     XmlDocument temp = new XmlDocument();
     temp.LoadXml(xml);
     XmlNode child = node.OwnerDocument.ImportNode(temp.DocumentElement, true);
     node.AppendChild(child);
 }
		public static XmlElement AppendElement(XmlNode node, string name, object value) {

			XmlDocument parent = node.OwnerDocument;

			//Something went wrong - assume this is a document
			if (parent == null) {
				parent = node as XmlDocument;
			}

			XmlElement newElement = null;

			if (parent != null) {

				newElement = parent.CreateElement(name);
				node.AppendChild(newElement);

				//Append value if it is supplied
				if (value != null) {
					
					string stringValue = value.ToString();

					if (stringValue.Length > 0) {
						newElement.AppendChild(parent.CreateTextNode(stringValue));
					}
				}
			}

			return newElement;
		}
 private XmlNode WriteChildNode(XmlNode parentNode, string nodeName, object nodeValue, WriteNodeValueKind writeKind)
 {
     if (parentNode == null)
     {
         throw new FireSpiderException("���ڵ�Ϊ�գ��޷������ӽڵ㣡");
     }
     if (nodeName == null)
     {
         return parentNode;
     }
     else
     {
         XmlNode valueNode;
         if (writeKind == WriteNodeValueKind.NewNodeWrite)
         {
             valueNode = media.CreateNode(nodeName, nodeValue);
             valueNode = parentNode.AppendChild((XmlNode)valueNode);
         }
         else
         {
             valueNode = media.GetNode(parentNode, nodeName);
             if (valueNode == null)
             {
                 if (writeKind == WriteNodeValueKind.NotExistsError)
                 {
                     throw new NodeNotFoundException("�޷��ҵ�����Ϊ" + nodeName + "��Xml�ڵ㡣");
                 }
                 valueNode = media.CreateNode(nodeName, nodeValue);
                 valueNode = parentNode.AppendChild((XmlNode)valueNode);
             }
         }
         return valueNode;
     }
 }
Exemple #28
0
        /// <summary>
        /// Encodes an mxCell and wraps the XML up inside the
        /// XML of the user object (inversion).
        /// </summary>
        public override XmlNode AfterEncode(mxCodec enc, Object obj, XmlNode node)
        {
            if (obj is mxCell && node is XmlElement)
            {
                mxCell cell = (mxCell)obj;

                if (cell.Value != null)
                {
                    if (cell.Value is XmlNode)
                    {
                        // Wraps the graphical annotation up in the
                        // user object (inversion) by putting the
                        // result of the default encoding into
                        // a clone of the user object (node type 1)
                        // and returning this cloned user object.
                        XmlElement tmp = (XmlElement)node;
                        node = enc.Document.ImportNode((XmlNode)cell.Value, true);
                        node.AppendChild(tmp);

                        // Moves the id attribute to the outermost
                        // XML node, namely the node which denotes
                        // the object boundaries in the file.
                        String id = tmp.GetAttribute("id");
                        ((XmlElement)node).SetAttribute("id", id);
                        tmp.RemoveAttribute("id");
                    }
                }
            }

            return node;
        }
Exemple #29
0
        /// <summary>
        /// Appends the XML.
        /// </summary>
        /// <param name="doc">The doc.</param>
        /// <param name="rootNode">The root node.</param>
        public override void AppendXml(XmlDocument doc, XmlNode rootNode)
        {
            XmlNode codeGroupNode = doc.CreateElement(CodeGroupKey);

            rootNode.AppendChild(codeGroupNode);
            XmlNode codeGroupTypeNode = doc.CreateElement(CodeGroupTypeKey);

            codeGroupTypeNode.InnerText = RegexKey;
            codeGroupNode.AppendChild(codeGroupTypeNode);
            XmlNode groupRegexNode = doc.CreateElement(RegexKey);

            groupRegexNode.InnerText = groupRegex.ToString();
            codeGroupNode.AppendChild(groupRegexNode);

            base.AppendXml(doc, codeGroupNode);
        }
Exemple #30
0
 private void AddPlayerValue(XmlDocument file, XmlNode node, string name, string value)
 {
     XmlElement element = file.CreateElement(name);
     XmlText text = file.CreateTextNode(value);
     element.AppendChild(text);
     node.AppendChild(element);
 }
        private static void AddRootLoggingElement(XmlDocument doc, string appenderName, XmlNode log4netElement)
        {
            var appenderRefElement = doc.CreateElement("appender-ref");
            appenderRefElement.SetAttribute("ref", appenderName);

            log4netElement.AppendChild(doc.CreateElement("root")).AppendChild(appenderRefElement);
        }
        void AddPatchInfo(string patchinfofilename, string nodename, string filestring)
        {
            if (filestring == null)
            {
                return;
            }

            string [] filenames = filestring.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            if (System.IO.File.Exists(patchinfofilename))
            {
                System.Xml.XmlDocument xml = new XmlDocument();
                xml.Load(patchinfofilename);

                System.Xml.XmlNode patchinfo = xml.SelectSingleNode("Patchinfo");

                System.Xml.XmlElement node = (System.Xml.XmlElement)patchinfo.SelectSingleNode(nodename);
                if (node == null)
                {
                    node = xml.CreateElement(nodename);
                    patchinfo.AppendChild(node);
                }

                foreach (string name in filenames)
                {
                    System.Xml.XmlElement file = xml.CreateElement("File");
                    file.SetAttribute("Name", name);
                    node.AppendChild(file);
                }

                xml.Save(patchinfofilename);
            }
        }
        public System.Xml.XmlNode ToXML(System.Xml.XmlNode parentNode)
        {
            System.Xml.XmlNode      questionNode;
            System.Xml.XmlAttribute idAttrib;
            System.Xml.XmlAttribute nameAttrib;


            questionNode = parentNode.OwnerDocument.CreateElement("question");

            //ID attribute
            idAttrib       = parentNode.OwnerDocument.CreateAttribute("id");
            idAttrib.Value = _question_id.ToString();
            questionNode.Attributes.Append(idAttrib);

            //Name attribute
            nameAttrib       = parentNode.OwnerDocument.CreateAttribute("name");
            nameAttrib.Value = _text;
            questionNode.Attributes.Append(nameAttrib);

            _answer.ToXML(questionNode);

            parentNode.AppendChild(questionNode);

            return(questionNode);
        }
        public override void SerializeProperty(object proValue, XmlNode parent)
        {
            var sets = (List<MultyTimeframeIndexSettings>) proValue;
            foreach (var set in sets)
            {
                var node = parent.AppendChild(parent.OwnerDocument.CreateElement("chartSeries"));
                var atr = node.Attributes.Append(parent.OwnerDocument.CreateAttribute("chartId"));
                atr.Value = set.chartId;

                atr = node.Attributes.Append(parent.OwnerDocument.CreateAttribute("seriesDest"));
                atr.Value = set.FullyQualifiedSeriesDestName;

                atr = node.Attributes.Append(parent.OwnerDocument.CreateAttribute("seriesSrc"));
                atr.Value = set.FullyQualifiedSeriesSrcName;

                atr = node.Attributes.Append(parent.OwnerDocument.CreateAttribute("tfSmb"));
                atr.Value = set.TimeframeAndSymbol;

                atr = node.Attributes.Append(parent.OwnerDocument.CreateAttribute("diverType"));
                atr.Value = set.DiverType.ToString();

                atr = node.Attributes.Append(parent.OwnerDocument.CreateAttribute("maxPastExtr"));
                atr.Value = set.maxPastExtremum.ToString();

                atr = node.Attributes.Append(parent.OwnerDocument.CreateAttribute("periodExtremum"));
                atr.Value = set.periodExtremum.ToString();

                atr = node.Attributes.Append(parent.OwnerDocument.CreateAttribute("marginUpper"));
                atr.Value = set.marginUpper.ToStringUniform();

                atr = node.Attributes.Append(parent.OwnerDocument.CreateAttribute("marginLower"));
                atr.Value = set.marginLower.ToStringUniform();
            }
        }
 private void AddChildElementAndValue(XmlNode cardElement, string propertyName, string propertyValue)
 {
     var xmlElement = _xmlfile.CreateElement(string.Empty, propertyName.ToLower(), string.Empty);
     var xmlTextValue = _xmlfile.CreateTextNode(propertyValue);
     xmlElement.AppendChild(xmlTextValue);
     cardElement.AppendChild(xmlElement);
 }
Exemple #36
0
 /// <summary>
 /// Saves this PList data to XML.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public void SaveToXml(XmlNode parent)
 {
     var doc = parent.OwnerDocument;
     var node = doc.CreateElement("string");
     node.InnerText = this.Value;
     parent.AppendChild(node);
 }
Exemple #37
0
        /// <summary>
        /// 基于web.config模型的AppSettings设置
        /// </summary>
        /// <param name="configPath">配置文件路径,相对或完整路径。</param>
        /// <param name="key">健</param>
        /// <param name="Value">健的值</param>
        /// <returns>成功则为0,失败则返回异常信息。</returns>
        public static string SetAppSettings(string configPath, string key, string Value)
        {
            string configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configPath);

            try
            {
                System.Configuration.ConfigXmlDocument xmlConfig = new System.Configuration.ConfigXmlDocument();
                xmlConfig.Load(configFile);

                System.Xml.XmlNode node = xmlConfig.SelectSingleNode("configuration/appSettings/add[@key='" + key + "']");
                if (node != null)
                {
                    node.Attributes["value"].Value = Value;
                }
                else
                {
                    XmlElement element = xmlConfig.CreateElement("add");
                    element.SetAttribute("key", key);
                    element.SetAttribute("value", Value);
                    node = xmlConfig.SelectSingleNode("configuration/appSettings");
                    node.AppendChild(element);
                }
                xmlConfig.Save(configFile);
                return("0");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemple #38
0
    //
    //createDataElement
    //
    private static void createDataElement(
        ref System.Xml.XmlDocument pdoc,
        string pname, string pvalue,
        string pcomment)
    {
        System.Xml.XmlElement data = pdoc.CreateElement("data");
        data.SetAttribute("name", pname);
        data.SetAttribute("xml:space", "preserve");

        System.Xml.XmlElement value = pdoc.CreateElement("value");
        value.InnerText = pvalue;
        data.AppendChild(value);

        if (!(pcomment == null))
        {
            System.Xml.XmlElement comment = pdoc.CreateElement("comment");
            comment.InnerText = pcomment;
            data.AppendChild(comment);
        }

        System.Xml.XmlNode root     = pdoc.SelectSingleNode("//root");
        System.Xml.XmlNode old_data = root.SelectSingleNode("//data[@name='" + pname + "']");
        if (old_data == null)
        {
            root.AppendChild(data);
        }
        else
        {
            root.ReplaceChild(data, old_data);
        }
    }
 /// <summary>
 /// Adds a new name/value pair in appSettings collection or modifies existing one
 /// </summary>
 /// <returns>A value indicating if the operation was successfull or not</returns>
 public bool SetValue(string key, string value)
 {
     XmlDocument ConfigToObject = new XmlDocument();
     LoadConfigToObject(ConfigToObject);
     appSettingsNode = ConfigToObject.SelectSingleNode("//appSettings");
     if (appSettingsNode == null)
         throw new System.InvalidOperationException("appSettings section not found");
     try
     {
         // XPath
         XmlElement addElement = (XmlElement)appSettingsNode.SelectSingleNode("//add[@key='" + key + "']");
         if (addElement != null)
             addElement.SetAttribute("value", value);
         else
         {
             XmlElement entry = ConfigToObject.CreateElement("add");
             entry.SetAttribute("key", key);
             entry.SetAttribute("value", value);
             appSettingsNode.AppendChild(entry);
         }
         SaveObjectToConfig(ConfigToObject, ConfigFileName);
         return true;
     }
     catch
     {
         return false;
     }
 }
        /// <summary>
        /// Creates the entity.
        /// </summary>
        /// <param name="objRequestInfo">The requestinfo object.</param>
        /// <param name="EntitiesElement">The entities element.</param>
        private void CreateRecord(Records records, XmlNode recordsNode)
        {
            XmlElement RecordElement;

            foreach (Record objRecord in records.Record)
            {
                RecordElement = objXmlDocument.CreateElement("record");
                recordsNode.AppendChild(RecordElement);
                if (objRecord.Order.Length > 0)
                {
                    XmlAttribute OrderAttribute = objXmlDocument.CreateAttribute("order");
                    RecordElement.Attributes.Append(OrderAttribute);
                    OrderAttribute.Value = objRecord.Order;
                }
                if (objRecord.RecordNumber.Length > 0)
                {
                    XmlAttribute RecordNumberAttribute = objXmlDocument.CreateAttribute("recordNumber");
                    RecordElement.Attributes.Append(RecordNumberAttribute);
                    RecordNumberAttribute.Value = objRecord.RecordNumber;
                }
                if (objRecord.RecordInfo != null)
                {
                    CreateRecordInfo(objRecord.RecordInfo, RecordElement);
                }
                //if (objRecord.RecordHistories != null)
                //{
                //    CreateRecordHistories(objRecord.RecordHistories, RecordElement);
                //}
            }
        }
Exemple #41
0
 /// <summary>
 /// 设置是否使用XCoreSessionStateStore来存储会话状态
 /// </summary>
 /// <param name="use"></param>
 /// <returns></returns>
 public static Boolean UseXCoreSessionStateStore(Boolean use)
 {
     try
     {
         //指定超级管理员
         String XmlPath = PathHelper.Map("~/web.config");
         System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
         xmldoc.Load(XmlPath);
         System.Xml.XmlNode root = xmldoc.DocumentElement.SelectSingleNode("//sessionState");
         string             mode = "InProc";
         if (use)
         {
             mode = "Custom";
         }
         if (root != null)
         {
             root.ParentNode.RemoveChild(root);
         }
         root = xmldoc.DocumentElement.SelectSingleNode("//system.web");
         XmlElement subElement = xmldoc.CreateElement("sessionState");
         subElement.SetAttribute("mode", mode);
         subElement.SetAttribute("customProvider", "XCoreSessionProvider");
         subElement.InnerXml = "<providers><add name=\"XCoreSessionProvider\" type=\"System.XCoreSessionStateStore\" /></providers>";
         root.AppendChild(subElement);
         xmldoc.Save(XmlPath);
         xmldoc.Save(XmlPath);
         return(true);
     }
     catch { return(false); }
 }
Exemple #42
0
 /// <summary>
 /// 设置 web.config 的 AppSettings 中某项的值
 /// </summary>
 /// <param name="key">项的名称</param>
 /// <param name="value">项的值</param>
 /// <returns>返回结果</returns>
 public static Boolean SetAppSettings(String Target, String Value)
 {
     try
     {
         //指定超级管理员
         String XmlPath = PathHelper.Map("~/web.config");
         System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
         xmldoc.Load(XmlPath);
         System.Xml.XmlNode root       = xmldoc.DocumentElement.SelectSingleNode("appSettings");
         XmlElement         subElement = (XmlElement)root.SelectSingleNode("//add[@key='" + Target + "']");
         if (subElement == null)
         {
             subElement = xmldoc.CreateElement("add");
             subElement.SetAttribute("key", Target);
             subElement.SetAttribute("value", Value);
             root.AppendChild(subElement);
             xmldoc.Save(XmlPath);
         }
         else
         {
             subElement.SetAttribute("value", Value);
             xmldoc.Save(XmlPath);
         }
         return(true);
     }
     catch { return(false); }
 }
Exemple #43
0
 public static XmlNode SetNewValue(XmlNode contextNode, string nodeName, string nodeValue)
 {
     XmlNode node = (contextNode.OwnerDocument ?? ((XmlDocument) contextNode)).CreateElement(nodeName);
     contextNode.AppendChild(node);
     node.InnerText = nodeValue;
     return node;
 }
		public static XmlElement AppendNewElement(ref XmlNode objNode, string name, string value) {

			XmlDocument parent;
			XmlElement newElement = null;

			parent = objNode.OwnerDocument;

			//Something went wrong - assume this is a document
			if (parent == null) {
				parent = objNode as XmlDocument;
			}

			if (parent != null) {
				newElement = parent.CreateElement(name);
				objNode.AppendChild(newElement);

				//Append text if it is supplied
				if (value != null && value.Length > 0) {
					newElement.AppendChild(parent.CreateTextNode(value));
				}

			}

			return newElement;

		}
Exemple #45
0
 /// <summary>
 /// Saves this PList data to XML.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public void SaveToXml(XmlNode parent)
 {
     var doc = parent.OwnerDocument;
     var node = doc.CreateElement("date");
     node.InnerText = this.Value.ToString("u").Replace(' ', 'T');
     parent.AppendChild(node);
 }
Exemple #46
0
        public override void Serialize(AnnSerializeOptions options, System.Xml.XmlNode parentNode, System.Xml.XmlDocument document)
        {
            base.Serialize(options, parentNode, document);

            XmlNode element = document.CreateElement("AnglePrecision");

            element.InnerText = AnglePrecision.ToString();
            parentNode.AppendChild(element);
        }
Exemple #47
0
        public override void Serialize(AnnSerializeOptions options, System.Xml.XmlNode parentNode, System.Xml.XmlDocument document)
        {
            base.Serialize(options, parentNode, document);

            XmlNode element = document.CreateElement("CenterPointRadius");

            element.InnerText = _centerPointRadius.Value.ToString();
            parentNode.AppendChild(element);
        }
Exemple #48
0
        public void WriteLocalSetting(string sectionName, string settingName, string settingValue)
        {
            string sectionNameValid = RemoveInvalidXmlChars(sectionName);
            string settingNameValid = RemoveInvalidXmlChars(settingName);

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

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

                System.Xml.XmlAttribute Attribute;
                System.Xml.XmlNode      SectionNode = ConfigDocument.SelectSingleNode("/LocalConfig/Section[@name='" + sectionNameValid + "']");
                if (SectionNode == null)
                {
                    //Crear la sección
                    SectionNode     = ConfigDocument.CreateElement("Section");
                    Attribute       = ConfigDocument.CreateAttribute("name");
                    Attribute.Value = sectionNameValid;
                    SectionNode.Attributes.Append(Attribute);
                    ConfigDocument.DocumentElement.AppendChild(SectionNode);
                }
                System.Xml.XmlNode SettingNode = ConfigDocument.SelectSingleNode("/LocalConfig/Section[@name='" + sectionNameValid + "']/Setting[@name='" + settingNameValid + "']");
                if (SettingNode == null)
                {
                    //Agregar el nodo
                    SettingNode     = ConfigDocument.CreateElement("Setting");
                    Attribute       = ConfigDocument.CreateAttribute("name");
                    Attribute.Value = settingNameValid;
                    SettingNode.Attributes.Append(Attribute);
                    Attribute       = ConfigDocument.CreateAttribute("value");
                    Attribute.Value = settingValue;
                    SettingNode.Attributes.Append(Attribute);
                    SectionNode.AppendChild(SettingNode);
                }
                System.Xml.XmlAttribute SettingAttribute = SettingNode.Attributes["value"];
                if (SettingAttribute != null)
                {
                    SettingAttribute.Value = settingValue;
                }
                ConfigDocument.Save(ConfigFileName);
            }
        }
Exemple #49
0
        public override void ToXml(System.Xml.XmlNode node)
        {
            base.ToXml(node);

            XmlDocument doc = node.OwnerDocument;

            XmlElement el = doc.CreateElement("ProductionTeamRank");

            el.InnerText = teamRank.ToString();
            node.AppendChild(el);
        }
Exemple #50
0
        public String SetRecordConfig()
        {
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            System.Xml.XmlNode     xnRoot = xmlDoc.CreateElement("root");

            foreach (RecordValue recordValue in recordValueList)
            {
                System.Xml.XmlDocument xmlDocChild = new System.Xml.XmlDocument();
                System.Xml.XmlNode     xnRecord    = xmlDoc.CreateElement("record");

                System.Xml.XmlNode xnRecordId = xmlDoc.CreateElement("recordId");
                xnRecordId.InnerText = recordValue.RecordId;
                xnRecord.AppendChild(xnRecordId);

                System.Xml.XmlNode xnValue = xmlDoc.CreateElement("value");
                xnValue.InnerText = recordValue.Value;
                xnRecord.AppendChild(xnValue);
                xnRoot.AppendChild(xnRecord);
            }
            return(xnRoot.InnerXml);
        }
Exemple #51
0
 private static void RecurseSpritesToXML(System.Xml.XmlNode a_node, Sprite a_sp)
 {
     System.Xml.XmlNode newNode = Serialization.Serializer.Serialize(a_sp, a_node, null);
     if (a_sp.ChildCount > 0)
     {
         System.Xml.XmlNode childNode = a_node.OwnerDocument.CreateElement("ChildSprites");
         newNode.AppendChild(childNode);
         for (int i = 0; i < a_sp.ChildCount; i++)
         {
             RecurseSpritesToXML(childNode, a_sp.GetChildByIndex(i));
         }
     }
 }
Exemple #52
0
        public SoapException ToSoapException(SoapMessage soapMessage, bool hidePrivateDetails)
        {
            // Build the detail element of the SOAP fault.
            System.Xml.XmlDocument document = new System.Xml.XmlDocument();
            System.Xml.XmlNode     node     = document.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);

            // Create node for Error Code
            System.Xml.XmlNode code = document.CreateNode(XmlNodeType.Element, "ErrorCode", null);
            code.InnerText = ((int)PhotoMixError).ToString();
            node.AppendChild(code);

            // Create node for Error Enum
            System.Xml.XmlNode codeEnum = document.CreateNode(XmlNodeType.Element, "ErrorEnum", null);
            codeEnum.InnerText = PhotoMixError.ToString();
            node.AppendChild(codeEnum);


            // Create node for Partner Error Code
            if (!string.IsNullOrEmpty(partnerErrorCode))
            {
                System.Xml.XmlNode partnerErrorCodeNode = document.CreateNode(XmlNodeType.Element, "PartnerErrorCode", null);
                partnerErrorCodeNode.InnerText = partnerErrorCode;
                node.AppendChild(partnerErrorCodeNode);
            }

            // Create node for Partner Error Detail
            if (!string.IsNullOrEmpty(partnerErrorDetail) && !hidePrivateDetails)
            {
                System.Xml.XmlNode partnerErrorDetailNode = document.CreateNode(XmlNodeType.Element, "PartnerErrorDetail", null);
                partnerErrorDetailNode.InnerText = partnerErrorDetail;
                node.AppendChild(partnerErrorDetailNode);
            }

            return(new SoapException(
                       this.message == null ? PhotoMixError.ToString() : string.Format("{0}: {1}", PhotoMixError.ToString(), this.message),
                       SoapException.ClientFaultCode,
                       soapMessage == null ? "" : soapMessage.Url,
                       node));
        }
Exemple #53
0
        public static void AddExpress(string name, string kuaidi100Code, string taobaoCode)
        {
            XmlDocument xmlNode = GetXmlNode();

            System.Xml.XmlNode node     = xmlNode.SelectSingleNode("companys");
            XmlElement         newChild = xmlNode.CreateElement("company");

            newChild.SetAttribute("name", name);
            newChild.SetAttribute("Kuaidi100Code", kuaidi100Code);
            newChild.SetAttribute("TaobaoCode", taobaoCode);
            node.AppendChild(newChild);
            xmlNode.Save(path);
        }
Exemple #54
0
        private void SetInitialConfig()
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml("<?xml version=\"1.0\"?> <Configuration> </Configuration>");
            System.Xml.XmlNode root = doc.SelectSingleNode("Configuration");

            System.Xml.XmlNode tmpNode = root.SelectSingleNode("PicturePath");
            if (tmpNode == null)
            {
                tmpNode          = (System.Xml.XmlNode)doc.CreateElement("PicturePath");
                this.PicturePath = tmpNode.InnerText = @"D:\TestPicture\";
                root.AppendChild(tmpNode);
            }

            tmpNode = root.SelectSingleNode("DocName");
            if (tmpNode == null)
            {
                tmpNode      = (System.Xml.XmlNode)doc.CreateElement("DocName");
                this.DocName = tmpNode.InnerText = @"Test.docx";
                root.AppendChild(tmpNode);
            }
        }
Exemple #55
0
        /// <summary>
        /// 设置最后审批历史记录

        /// </summary>
        /// <param name="Name"></param>
        /// <param name="DomainAccount"></param>
        /// <param name="ApprovalResult"></param>
        /// <param name="ApprovalComment"></param>
        /// <param name="ActivityName"></param>
        public void SetLastApproval(string Name, string DomainAccount, string ApprovalResult, string ApprovalComment, string ActivityName)
        {
            string strDomainAccount = DomainAccount;

            strDomainAccount = GetShortADUserID(strDomainAccount);

            System.Xml.XmlNode ApprovalNode = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "Approval", "");

            System.Xml.XmlNode tmp = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "Name", "");
            tmp.InnerText = Name;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "DomainAccount", "");
            tmp.InnerText = strDomainAccount;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalResult", "");
            tmp.InnerText = ApprovalResult;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalComment", "");
            tmp.InnerText = ApprovalComment;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalTime", "");
            tmp.InnerText = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ActivityName", "");
            tmp.InnerText = ActivityName;
            ApprovalNode.AppendChild(tmp);

            System.Xml.XmlNode pobj = this.mobj.SelectSingleNode("Root/Approvals");
            if (pobj == null)
            {
                throw new Exception("没有找到XML节点[Root/Approvals],请检查数据格式定义是否正确!");
            }
            else
            {
                tmp = pobj.FirstChild;
                if (tmp != null)
                {
                    if (tmp.InnerText.Trim() == "")
                    {
                        pobj.RemoveChild(tmp);
                    }
                }
                pobj.RemoveAll();               //清空旧的
                pobj.AppendChild(ApprovalNode); //加入新的
            }
        }
Exemple #56
0
        /// <summary>
        /// 增加一个历史审批记录

        /// </summary>
        /// <param name="Name"></param>
        /// <param name="DomainAccount"></param>
        /// <param name="ApprovalResult"></param>
        /// <param name="ApprovalComment"></param>
        /// <param name="ActivityName"></param>
        public void AddApproval(string Name, string DomainAccount, string ApprovalResult, string ApprovalComment, string ActivityName)
        {
            string strDomainAccount = DomainAccount;

            strDomainAccount = strDomainAccount.ToLower();
            strDomainAccount = strDomainAccount.Replace("centaline\\\\", "");

            System.Xml.XmlNode ApprovalNode = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "Approval", "");

            System.Xml.XmlNode tmp = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "Name", "");
            tmp.InnerText = Name;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "DomainAccount", "");
            tmp.InnerText = strDomainAccount;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalResult", "");
            tmp.InnerText = ApprovalResult;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalComment", "");
            tmp.InnerText = ApprovalComment;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalTime", "");
            tmp.InnerText = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ActivityName", "");
            tmp.InnerText = ActivityName;
            ApprovalNode.AppendChild(tmp);

            System.Xml.XmlNode pobj = this.mobj.SelectSingleNode("Root/Approvals");
            if (pobj == null)
            {
                throw new Exception("没有找到XML节点[Root/Approvals],请检查数据格式定义是否正确!");
            }
            else
            {
                tmp = pobj.FirstChild;
                if (tmp != null)
                {
                    if (tmp.InnerText.Trim() == "")     //如果<Approval></Approval>为空则要删除掉
                    {
                        pobj.RemoveChild(tmp);
                    }
                }
                pobj.AppendChild(ApprovalNode);
            }
        }
Exemple #57
0
        public void SaveConfiguration(System.Xml.XmlNode configNode)
        {
            XmlNode minimizeNode = configNode["StartMinimized"];
            XmlNode trayNode     = configNode["MinimizeToTray"];
            XmlNode startupNode  = configNode["RunAtStartup"];
            XmlNode languageNode = configNode["Language"];

            if (null == minimizeNode)
            {
                minimizeNode = configNode.OwnerDocument.CreateNode(XmlNodeType.Element, "StartMinimized", null);
                configNode.AppendChild(minimizeNode);
            }

            if (null == trayNode)
            {
                trayNode = configNode.OwnerDocument.CreateNode(XmlNodeType.Element, "MinimizeToTray", null);
                configNode.AppendChild(trayNode);
            }

            if (null == startupNode)
            {
                startupNode = configNode.OwnerDocument.CreateNode(XmlNodeType.Element, "RunAtStartup", null);
                configNode.AppendChild(startupNode);
            }

            if (null == languageNode)
            {
                languageNode = configNode.OwnerDocument.CreateNode(XmlNodeType.Element, "Language", null);
                configNode.AppendChild(languageNode);
            }

            minimizeNode.InnerText = checkBoxStartAppMinimized.Checked.ToString();
            trayNode.InnerText     = checkBoxMinimizeToTray.Checked.ToString();
            startupNode.InnerText  = checkBoxStartAppWithWindows.Checked.ToString();
            languageNode.InnerText = (comboBoxLanguage.SelectedItem as Translation.ToolLanguage).LCID.ToString();

            SetupAutoRunEntry();
        }
Exemple #58
0
        /// <summary>
        /// Saves the component specific data to the specified save game node.
        /// </summary>
        /// <param name="node">The node.</param>
        public void SaveGame(System.Xml.XmlNode node)
        {
            var doc = node.OwnerDocument;

            XmlElement xmlStations = doc.CreateElement("Stations");

            node.AppendChild(xmlStations);
            foreach (var station in stations)
            {
                var el = doc.CreateElement("Station");
                station.Value.SaveXml(el);
                xmlStations.AppendChild(el);
            }
        }
Exemple #59
0
        public void Save()
        {
            try
            {
                if (File.Exists(DB))
                {
                    core.backupData(DB);
                    if (!File.Exists(config.tempName(DB)))
                    {
                        core.Log("Unable to create backup file for " + owner.Name);
                    }
                }
                System.Xml.XmlDocument data    = new System.Xml.XmlDocument();
                System.Xml.XmlNode     xmlnode = data.CreateElement("database");

                lock (Content)
                {
                    foreach (Item key in Content)
                    {
                        XmlAttribute name = data.CreateAttribute("name");
                        name.Value = key.name;
                        XmlAttribute url = data.CreateAttribute("url");
                        url.Value = key.URL;
                        XmlAttribute disabled = data.CreateAttribute("disb");
                        disabled.Value = key.disabled.ToString();
                        XmlAttribute template = data.CreateAttribute("template");
                        template.Value = key.template;
                        XmlAttribute scan = data.CreateAttribute("so");
                        template.Value = key.ScannerOnly.ToString();
                        System.Xml.XmlNode db = data.CreateElement("data");
                        db.Attributes.Append(name);
                        db.Attributes.Append(url);
                        db.Attributes.Append(disabled);
                        db.Attributes.Append(template);
                        db.Attributes.Append(scan);
                        xmlnode.AppendChild(db);
                    }
                }
                data.AppendChild(xmlnode);
                data.Save(DB);
                if (System.IO.File.Exists(config.tempName(DB)))
                {
                    System.IO.File.Delete(config.tempName(DB));
                }
            }
            catch (Exception fail)
            {
                RSS.m.handleException(fail);
            }
        }
Exemple #60
0
        /// <summary>
        /// Saves the component specific data to the specified save game node.
        /// </summary>
        /// <param name="node">The node.</param>
        public void SaveGame(System.Xml.XmlNode node)
        {
            var doc = node.OwnerDocument;

            XmlElement xmlResearchedItems = doc.CreateElement("ResearchedItems");

            node.AppendChild(xmlResearchedItems);

            foreach (var item in storeItems)
            {
                var el = doc.CreateElement(item.Key);
                el.Attributes.Append(doc.CreateAttributeWithValue("researchProgress", item.Value.ResearchProgress.ToString()));
                xmlResearchedItems.AppendChild(el);
            }
        }