Esempio n. 1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     string uNo = Label1.Text;
     string oADDRESS = null;
     string oEmail = null;
     string oName = null;
     string Count = null;
     int i;
     for (i = 1; i < mytable.Rows.Count; i++)
     {
         if (mytable.Rows[i]["UNO"].ToString().Trim().Equals(uNo))
         {
             oADDRESS = mytable.Rows[i]["UADDRESS"].ToString();
             oEmail = mytable.Rows[i]["UEMAIL"].ToString();
         }
     }
     for (i = 0; i < Table1.Rows.Count-1; i++)
     {
         oName += Table1.Rows[i].Cells[0].Text+";";
         Count += Table1.Rows[i].Cells[1].Text + ";";
     }
     oName += Table1.Rows[i].Cells[0].Text;
     Count += Table1.Rows[i].Cells[1].Text;
     db.add_BItem(int.Parse(uNo), oName, oADDRESS, oEmail, "OrderForm", Count);
     root = xd.DocumentElement;
     root.RemoveAll();
     xd.Save(Server.MapPath("gouwuche.xml"));
     Response.Write("<script>window.alert('下单成功')</script>");
     Response.Redirect("~/index.aspx?id=" + Label1.Text);
 }
Esempio n. 2
0
 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);
         }
     }
 }
Esempio n. 3
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     root = xd.DocumentElement;
     root.RemoveAll();
     xd.Save(Server.MapPath("gouwuche.xml"));
     Response.Redirect("~/index.aspx?id=" + Label1.Text);
 }
Esempio n. 4
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); //加入新的
            }
        }
Esempio n. 5
0
        public void SetPropertiesInstance(System.Xml.XmlNode node, object inst)
        {
            node.RemoveAll();       // Get rid of all properties

            BarCodePropertiesQR bcp = inst as BarCodePropertiesQR;

            if (bcp == null)
            {
                return;
            }


            XmlHelpers.CreateChild(node, "QrCode", bcp.QrCode);
        }
Esempio n. 6
0
 /// <summary>
 /// 删除指定节点下的子节点
 /// </summary>
 /// <param name="XmlFile">Xml文件路径</param>
 /// <param name="fatherNode">制定节点</param>
 /// <returns>返回真为更新成功,否则失败</returns>
 public bool DeleteNodes(string XmlFile, string fatherNode)
 {
     try
     {
         xmldoc = new XmlDocument();
         xmldoc.Load(XmlFile);
         xmlnode = xmldoc.SelectSingleNode(fatherNode);
         xmlnode.RemoveAll();
         xmldoc.Save(XmlFile);
         return true;
     }
     catch (XmlException xe)
     {
         throw new XmlException(xe.Message);
     }
 }
Esempio n. 7
0
 private void clearReplaceValues()
 {
     ReplaceField.SelectedIndex    = -1;
     ReplaceOperator.SelectedIndex = -1;
     ReplaceValue.Text             = "";
     ReplaceByCheckBox.IsChecked   = false;
     System.Xml.XmlNode node = _xml.SelectSingleNode("//Datasets/ReplaceBy");
     if (node != null)
     {
         node.RemoveAll();
         saveFieldGrid();
     }
     _skipSelectionChanged = true;
     ReplaceByCheckBox_Unchecked(ReplaceByCheckBox, null);
     _skipSelectionChanged = false;
 }
Esempio n. 8
0
        public void Apply(XmlNode oldNode, XmlNode newNode)
        {
            if (newNode == null)
                throw new ArgumentNullException(nameof(newNode));
            if (oldNode == null)
                throw new ArgumentNullException(nameof(oldNode));

            Contract.Requires(newNode != null);
            Contract.Requires(oldNode != null);

            //ToDo: Implement Binding

            if(Query.IsBindingQuery(newNode.InnerText))
            {
                Query.Parse(newNode.InnerText);

                // Children Binding - not deep
                if(Query.Children)
                {
                    foreach (XmlNode node in oldNode.ChildNodes)
                    {
                        var tmpN = newNode.OwnerDocument.ImportNode(node, true);

                        newNode.RemoveAll();

                        newNode.AppendChild(tmpN);
                    }
                }
                else
                {
                    

                    
                }
            }

            foreach (XmlAttribute att in newNode.Attributes)
            {
                if (Query.IsBindingQuery(att.Value))
                {
                    Query.Parse(att.Value);

                    newNode.Attributes[Query.Property].Value = oldNode.Attributes[Query.Property]?.Value;
                }
            }
        }
Esempio n. 9
0
        private static void ProcessRadioGroupLabels(XmlNode node)
        {
            StringCollection optionalValues =
                TYml2Xml.GetElements(TXMLParser.GetChild(node, "OptionalValues"));

            node.RemoveAll();
            XmlNode OptionalValuesLabel = node.OwnerDocument.CreateElement("LabelsForOptionalValues");
            node.AppendChild(OptionalValuesLabel);

            foreach (string s in optionalValues)
            {
                string label = s;

                if (label.StartsWith("="))
                {
                    label = label.Substring(1).Trim();
                }

                XmlNode LabelNode = node.OwnerDocument.CreateElement(TYml2Xml.XMLLIST);
                OptionalValuesLabel.AppendChild(LabelNode);
                TXMLParser.SetAttribute(LabelNode, "name", Catalog.GetString(label));
            }
        }
		/// ------------------------------------------------------------------------------------
		private void SetStringCollection(SettingsPropertyValue propVal, XmlNode propNode)
		{
			if (propVal.PropertyValue == null)
				return;

			propNode.RemoveAll();
			var attrib = m_settingsXml.CreateAttribute("type");
			attrib.Value = typeof(StringCollection).FullName;
			propNode.Attributes.Append(attrib);
			int i = 0;
			foreach (string str in propVal.PropertyValue as StringCollection)
			{
				var node = m_settingsXml.CreateElement(propVal.Name + i++);
				node.AppendChild(m_settingsXml.CreateTextNode(str));
				propNode.AppendChild(node);
			}
		}
Esempio n. 11
0
        /// <summary>
        /// Set the custom properties given the properties object
        /// </summary>
        /// <param name="node"></param>
        /// <param name="inst"></param>
        public void SetPropertiesInstance(XmlNode node, object inst)
        {
            node.RemoveAll();       // Get rid of all properties

            BarCodeBooklandProperties bcp = inst as BarCodeBooklandProperties;
            if (bcp == null)
                return;

            // ISBN
            CreateChild(node, "ISBN", bcp.ISBN);
        }
        private void StripLangTag(XmlNode docNode, XmlNode langNode)
        {
            List<XmlNode> innerNodeList = new List<XmlNode>();
            foreach (XmlNode innerNode in langNode.ChildNodes)
            {
                innerNodeList.Add(innerNode);
            }
            langNode.RemoveAll();

            foreach (XmlNode innerNode in innerNodeList)
            {
                docNode.InsertBefore(innerNode, langNode);
            }

            docNode.RemoveChild(langNode);
        }
		public static void StripChildNodes(XmlNode node)
		{
			if (node.Attributes.Count > 0) {
				List<XmlAttribute> attrs = new List<XmlAttribute>();
				foreach (XmlAttribute attr in node.Attributes)
					attrs.Add(attr);

				node.RemoveAll();

				foreach (XmlAttribute attr in attrs)
					node.Attributes.SetNamedItem(attr);
			} else {
				node.RemoveAll();
			}
		}
Esempio n. 14
0
        // 清空目录配置事项
        // parameters:
        //		strDirCfgItemPath	配置目录的路径
        //		nodeDir	            dir节点,如果为null,则根据路径来找
        //		strError        	out参数,返回出错信息
        // return:
        //		-1	出错
        //      -4  未指定路径对应的对象
        //		0	成功
        // 清空dir配置事项,包括所有下级及属性,也删除下级对应的物理文件
        public int ClearDirCfgItem(string strDirCfgItemPath,
            XmlNode nodeDir,
            out string strError)
        {
            strError = "";
            if (nodeDir == null)
            {
                if (String.IsNullOrEmpty(strDirCfgItemPath) == true)
                {
                    strError = "ClearDirCfgItem()调用错误,strDirCfgItemPath参数不能为null或者空字符串。";
                    return -1;
                }

                List<XmlNode> nodes = DatabaseUtil.GetNodes(this.NodeDbs,
                    strDirCfgItemPath);
                if (nodes.Count == 0)
                {
                    strError = "ClearDirCfgItem(),未找到路径为'" + strDirCfgItemPath + "'的配置事项。";
                    return -4;
                }

                if (nodes.Count > 1)
                {
                    strError = "ClearDirCfgItem(),路径为'" + strDirCfgItemPath + "'的配置事项有'" + Convert.ToString(nodes.Count) + "'个,databases.xml配置文件不合法。";
                    return -1;
                }

                nodeDir = nodes[0];
            }

            // 删除定义的本地目录
            string strLocalDir = "";
            strLocalDir = DatabaseUtil.GetLocalDir(this.NodeDbs,
                nodeDir).Trim();

            string strDir = "";
            if (strLocalDir != "")
                strDir = this.DataDir + "\\" + strLocalDir + "\\";
            else
                strDir = this.DataDir + "\\";

            DirectoryInfo di = new DirectoryInfo(strDir);

            // 删除所有的下级目录
            DirectoryInfo[] dirs = di.GetDirectories();
            foreach (DirectoryInfo childDir in dirs)
            {
                Directory.Delete(childDir.FullName, true);
            }

            // 删除所有的下级文件
            FileInfo[] files = di.GetFiles();
            foreach (FileInfo childFile in files)
            {
                File.Delete(childFile.FullName);
            }

            // 移出内存对象
            nodeDir.RemoveAll();

            this.Changed = true;

            return 0;
        }
Esempio n. 15
0
        private XmlNode UpdateMovieNode(XmlDocument document, XmlNode movieNode, XMLMovieProperties objMovie)
        {
            try
            {
                movieNode.Attributes["name"].Value = objMovie.MovieName;
                movieNode.Attributes["link"].Value = objMovie.MovieLink;
                movieNode.Attributes["santaposterlink"].Value = objMovie.SantaPosterLink;
                movieNode.Attributes["saavnsonglink"].Value = objMovie.SaavnSongLink;

                movieNode.RemoveAll();

                foreach (XMLReivewProperties xmlReviews in objMovie.Reviews)
                {
                    XmlNode review = document.CreateNode(XmlNodeType.Element, "Review", "");

                    XmlAttribute reviewName = document.CreateAttribute("name");
                    review.Value = xmlReviews.Name.ToString();
                    review.Attributes.Append(reviewName);

                    XmlAttribute reviewLink = document.CreateAttribute("link");
                    reviewLink.Value = xmlReviews.Link.ToString();
                    review.Attributes.Append(reviewLink);

                    movieNode.AppendChild(review);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }

            return null;
        }
Esempio n. 16
0
		private void CreateZugriffsAuswertung (XmlNode AbgegebenNode, DataRow [] RowsForThisSprengel,
						NameValueCollection AvailableMachines, NameValueCollection AvailableDays)
			{
			AbgegebenNode.RemoveAll ();
			Int32 [] MaschinenCounter = new Int32 [AvailableMachines.AllKeys.Length];
			foreach (String Tag in AvailableDays.AllKeys)
				{
				XmlNode TagNode = InsertContainerNode(AbgegebenNode, MBRStatics.MBR_IM_ZEITRAUM);
				if (Tag == MBRStatics.ALLE_TAGE)
					{
					InsertAttributeNode(TagNode, MBRStatics.MBR_VON, "2008.10.20");
					InsertAttributeNode(TagNode, MBRStatics.MBR_BIS, "2008.11.10");
					}
				else
					{
					InsertAttributeNode(TagNode, MBRStatics.MBR_VON, Tag);
					InsertAttributeNode(TagNode, MBRStatics.MBR_BIS, Tag);
					}
				int Index = 0;
				while (Index < AvailableMachines.AllKeys.Length)
					MaschinenCounter [Index++] = 0;
				foreach (DataRow Zugriff in RowsForThisSprengel)
					{
					if (Tag != MBRStatics.ALLE_TAGE)
						if (Tag != Convert.ToDateTime(Zugriff["Am"]).Date.ToString(MBRStatics.TAG_FORMAT))
							continue;
					String Maschine = Zugriff ["Maschine"].ToString ();
					String CounterIndexString = AvailableMachines [Maschine];
					Int32 CounterIndex = Convert.ToInt32 (CounterIndexString);
					MaschinenCounter [CounterIndex]++;
					CounterIndex = Convert.ToInt32(AvailableMachines[MBRStatics.ALLE_MASCHINEN]);
					MaschinenCounter [CounterIndex]++;
					}
				foreach (String Maschine in AvailableMachines.AllKeys)
					{
					int CounterIndex = Convert.ToInt32 (AvailableMachines [Maschine]);
					InsertTextNode (TagNode, Maschine, Convert.ToString (MaschinenCounter [CounterIndex]));
					}
				}
			}
Esempio n. 17
0
		private void CreateStundenProfil (XmlNode StundenProfilContainer, SortedList StundenProfil)
			{
			StundenProfilContainer.RemoveAll ();
			String OldMaschine = "";
			XmlNode MaschineNode = null;
			foreach (DictionaryEntry ProfilEntry in StundenProfil)
				{
				String [] EntryContent = ((String)ProfilEntry.Key).Split (' ');
				if (OldMaschine != EntryContent [0])
					{
					OldMaschine = EntryContent [0];
					MaschineNode = InsertContainerNode (StundenProfilContainer, OldMaschine);
					}
				InsertTextNode (MaschineNode, "H_" + EntryContent [1], (String) ProfilEntry.Value);
				}
			}
Esempio n. 18
0
        /// <summary>
        /// Set the custom properties given the properties object
        /// </summary>
        /// <param name="node"></param>
        /// <param name="inst"></param>
        public void SetPropertiesInstance(XmlNode node, object inst)
        {
            node.RemoveAll();       // Get rid of all properties

            BarCodeProperties bcp = inst as BarCodeProperties;
            if (bcp == null)
                return;

            // NumberSystem
            CreateChild(node, "NumberSystem", bcp.NumberSystem);

            // ManufacturerCode
            CreateChild(node, "ManufacturerCode", bcp.ManufacturerCode);

            // ProductCode
            CreateChild(node, "ProductCode", bcp.ProductCode);
        }
Esempio n. 19
0
    public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference)
    {
      if (reference == null)
      {
        // Update reference.xml file
        if (node.Name != "controls")
        {
          throw new MpeParserException("Invalid root node <" + node.Name + "> provided.");
        }
        // Update the skin node
        XmlNode skin = node.SelectSingleNode("skin");
        if (skin == null)
        {
          throw new MpeParserException(
            "Invalid reference.xml file. The <skin> element must be the first child in the document.");
        }
        skin.RemoveAll();
        parser.SetValue(doc, skin, "width", Width.ToString());
        parser.SetValue(doc, skin, "height", Height.ToString());
        // Update the image control node that defines the window background
        XmlNode image = skin.NextSibling;
        if (image == null || image.Name.Equals("control") == false)
        {
          throw new MpeParserException(
            "Invalid reference.xml file. A <control> element of type image must follow the <skin> element.");
        }
        XmlNode test = image.SelectSingleNode("type");
        if (test == null || test.InnerXml.Equals("image") == false)
        {
          throw new MpeParserException(
            "Invalid reference.xml file. A <control> element of type image must follow the <skin> element.");
        }
        image.RemoveAll();
        backImage.Save(doc, image, parser, null);
      }
      else
      {
        // Update screen.xml file
        if (node == null || node.Name.Equals("window") == false)
        {
          throw new MpeParserException("Invalid root node <" + node.Name + "> provided. Looking for a <window> element.");
        }
        node.RemoveAll();

        if (screenType != MpeScreenType.Window)
        {
          parser.SetValue(doc, node, "type", screenType.ToString().ToLower());
        }

        parser.SetValue(doc, node, "id", Id.ToString());
        parser.SetValue(doc, node, "defaultcontrol", DefaultControl.ToString());
        parser.SetValue(doc, node, "allowoverlay", AllowOverlay ? "yes" : "no");
        parser.SetValue(doc, node, "autohidetopbar", AutohideTopbar ? "yes" : "no");

        XmlElement controls = doc.CreateElement("controls");
        node.AppendChild(controls);

        if (ScreenType == MpeScreenType.Dialog)
        {
          MpeGroup dg = DialogGroup;

          //if (dg.TextureBack != null) {
          XmlElement image = doc.CreateElement("control");
          dg.TextureBackImage.Save(doc, image, parser, parser.GetControl(MpeControlType.Image));
          controls.AppendChild(image);
          //}

          for (int i = dg.Controls.Count - 1; i >= 0; i--)
          {
            if (dg.Controls[i] is MpeControl)
            {
              MpeControl control = (MpeControl) dg.Controls[i];
              try
              {
                XmlElement element = doc.CreateElement("control");
                MpeControl referenceControl = parser.GetControl(control.Type);
                control.Save(doc, element, parser, referenceControl);
                controls.AppendChild(element);
              }
              catch (Exception e)
              {
                MpeLog.Debug(e);
                MpeLog.Error(e);
                throw new MpeParserException(e.Message);
              }
            }
          }
        }
        else
        {
          if (TextureBack != null)
          {
            XmlElement image = doc.CreateElement("control");
            backImage.Save(doc, image, parser, parser.GetControl(MpeControlType.Image));
            controls.AppendChild(image);
          }

          for (int i = Controls.Count - 1; i >= 0; i--)
          {
            if (Controls[i] is MpeControl)
            {
              MpeControl control = (MpeControl) Controls[i];
              try
              {
                XmlElement element = doc.CreateElement("control");
                MpeControl referenceControl = parser.GetControl(control.Type);
                control.Save(doc, element, parser, referenceControl);
                controls.AppendChild(element);
              }
              catch (Exception e)
              {
                MpeLog.Debug(e);
                MpeLog.Error(e);
                throw new MpeParserException(e.Message);
              }
            }
          }
        }
      }
    }
Esempio n. 20
0
        /// <summary>
        /// Adds or updates an existing query node in the mock connection file
        /// </summary>
        /// <param name="node"></param>
        /// <param name="request"></param>
        /// <param name="response"></param>
        private void addUpdateResponseNode(XmlNode node, string request, string response)
        {
            if (isFileWorthy(response))
            {
                // save response to dat file
                string dataFileName = "";

                XmlAttribute type = node.Attributes["type"];
                if (null == type)
                {
                    type = siteDoc.CreateAttribute("type");
                    type.Value = "file";
                    node.Attributes.Append(type);

                    dataFileName = (siteId + request).GetHashCode().ToString() + ".dat";
                }
                else
                {
                    dataFileName = node.InnerText;
                }

                node.InnerText = dataFileName;

                FileIOUtils.writeToFile(
                    Path.Combine(DataResourcePath, dataFileName),
                    response);
            }
            else
            {
                node.RemoveAll();
                // save response directly to the xml file
                XmlCDataSection cdata = siteDoc.CreateCDataSection(response);
                node.AppendChild(cdata);
                node.Attributes.RemoveAll();
            }
        }
		/// ------------------------------------------------------------------------------------
		private void SetGridSettings(SettingsPropertyValue propVal, XmlNode propNode)
		{
			var gridSettings = propVal.PropertyValue as GridSettings;
			if (gridSettings == null)
				return;

			propNode.RemoveAll();
			var attrib = m_settingsXml.CreateAttribute("type");
			attrib.Value = typeof(GridSettings).FullName;
			propNode.Attributes.Append(attrib);

			propNode.InnerXml =
				(XmlSerializationHelper.SerializeToString(gridSettings, true) ?? string.Empty);
		}
Esempio n. 22
0
        public static void SerializeToXmlNode(XmlNode Node, object Object, bool UseNodeParam)
        {
            try
            {
                XmlDocument xmlDoc = Node.OwnerDocument;

                XmlNode objNode = null;
                if (!UseNodeParam)
                {
                    Type objType = Object.GetType();

                    XmlAttribute attrAssembly = xmlDoc.CreateAttribute("Assembly");
                    XmlAttribute attrClass = xmlDoc.CreateAttribute("Class");
                    if (objType.IsGenericType)
                    {
                        string[] typeNameParts = objType.Name.Split('`');
                        objNode = xmlDoc.CreateElement(typeNameParts[0]);
                    }
                    else
                        objNode = xmlDoc.CreateElement(objType.Name);

                    attrAssembly.Value = objType.Assembly.GetName().Name;
                    attrClass.Value = objType.FullName;

                    objNode.Attributes.Append(attrAssembly);
                    objNode.Attributes.Append(attrClass);

                    Node.AppendChild(objNode);
                }
                else
                {
                    objNode = Node;
                    objNode.RemoveAll();

                    Type objType = Object.GetType();

                    XmlAttribute attrAssembly = xmlDoc.CreateAttribute("Assembly");
                    XmlAttribute attrClass = xmlDoc.CreateAttribute("Class");
                    if (objType.IsGenericType)
                    {
                        string[] typeNameParts = objType.Name.Split('`');
                        objNode = xmlDoc.CreateElement(typeNameParts[0]);
                    }
                    else
                        objNode = xmlDoc.CreateElement(objType.Name);

                    attrAssembly.Value = objType.Assembly.GetName().Name;
                    attrClass.Value = objType.FullName;

                    objNode.Attributes.Append(attrAssembly);
                    objNode.Attributes.Append(attrClass);
                }

                if (Object.GetType().IsPrimitive || Object is String || Object is Enum)
                {
                    XmlAttribute attr = xmlDoc.CreateAttribute("Value");
                    objNode.Attributes.Append(attr);

                    HandlerBase typeHandler = HandlerBase.GetTypeHandler(Object.GetType());
                    attr.Value = typeHandler.ConvertToString(Object);
                }
                else
                {
                    PropertyInfo[] props = Object.GetType().GetProperties();

                    foreach (PropertyInfo prop in props)
                    {
                        if(prop.GetCustomAttributes(typeof(NonSerializedAttribute), true).Length == 0)
                        {
                            object propValue = prop.GetValue(Object, null);
                            if (propValue != null)
                            {
                                Type propValueType = propValue.GetType();
                                if (propValueType.IsPrimitive || propValue is String || propValue is Enum || propValue is DateTime)
                                {
                                    XmlAttribute attr = xmlDoc.CreateAttribute(prop.Name);
                                    if (attr != null)
                                    {
                                        HandlerBase typeHandler = HandlerBase.GetTypeHandler(propValueType);
                                        attr.Value = typeHandler.ConvertToString(propValue);

                                        objNode.Attributes.Append(attr);
                                    }
                                }
                                else
                                {
                                    XmlNode objElement = xmlDoc.CreateNode(XmlNodeType.Element, prop.Name, string.Empty);

                                    //XmlNode objElement = null;
                                    XmlAttribute attrAssembly = xmlDoc.CreateAttribute("Assembly");
                                    XmlAttribute attrClass = xmlDoc.CreateAttribute("Class");
                                    //if (prop.PropertyType.IsGenericType)
                                    //{
                                    //    string[] typeNameParts = prop.PropertyType.Name.Split('`');
                                    //    objElement = xmlDoc.CreateElement(typeNameParts[0]);
                                    //}
                                    //else
                                    //    objElement = xmlDoc.CreateElement(prop.PropertyType.Name);

                                    attrAssembly.Value = prop.PropertyType.Assembly.GetName().Name;
                                    attrClass.Value = prop.PropertyType.FullName;

                                    objElement.Attributes.Append(attrAssembly);
                                    objElement.Attributes.Append(attrClass);

                                    objNode.AppendChild(objElement);

                                    if (propValue is ICollection)
                                        saveCollection(propValue, objElement);
                                    else
                                        SerializeToXmlNode(objElement, propValue, true);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Exception occurred in XmlSerializer SerializeToXmlNode", ex);
            }
        }
Esempio n. 23
0
        private static void AdjustLabel(XmlNode node, TCodeStorage CodeStorage, XmlDocument AOrigLocalisedYaml)
        {
            XmlNode TranslatedNode = TXMLParser.FindNodeRecursive(AOrigLocalisedYaml, node.Name);
            string TranslatedLabel = string.Empty;

            if (TranslatedNode != null)
            {
                TranslatedLabel = TXMLParser.GetAttribute(TranslatedNode, "Label");
            }

            TControlDef ctrlDef = new TControlDef(node, CodeStorage);
            string Label = ctrlDef.Label;

            if ((ctrlDef.GetAttribute("NoLabel") == "true") || (ctrlDef.controlTypePrefix == "pnl")
                || (TXMLParser.FindNodeRecursive(node.OwnerDocument, "act" + ctrlDef.controlName.Substring(ctrlDef.controlTypePrefix.Length)) != null)
                || ctrlDef.GetAttribute("Action").StartsWith("act"))
            {
                Label = string.Empty;
            }

            if ((ctrlDef.controlTypePrefix == "rgr") && (TXMLParser.GetChild(node, "OptionalValues") != null))
            {
                ProcessRadioGroupLabels(node);
            }
            else if (ctrlDef.controlTypePrefix == "mni")
            {
                // drop all attributes
                node.Attributes.RemoveAll();

                foreach (XmlNode menu in node.ChildNodes)
                {
                    if (menu.Name.Contains("Separator"))
                    {
                        continue;
                    }

                    AdjustLabel(menu, CodeStorage, AOrigLocalisedYaml);
                }
            }
            else
            {
                // drop all attributes and children nodes
                node.RemoveAll();
            }

            if (Label.Length > 0)
            {
                if ((TranslatedLabel != Label) && (TranslatedLabel != Catalog.GetString(Label)) && (TranslatedLabel.Length > 0))
                {
                    // add to po file
                    if (!NewTranslations.ContainsKey(Label))
                    {
                        NewTranslations.Add(Label, TranslatedLabel);
                    }

                    TXMLParser.SetAttribute(node, "Label", TranslatedLabel);
                }
                else
                {
                    TXMLParser.SetAttribute(node, "Label", Catalog.GetString(Label));
                }
            }
        }
Esempio n. 24
0
 /// <summary>
 /// ����ڵ�,������ڵ�������/����
 /// </summary>
 /// <param name="OldNode"></param>
 public void Clear(XmlNode node)
 {
     node.RemoveAll();
 }
Esempio n. 25
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets the value of a node to that found in the specified property. This method
        /// specially handles properties that are string collections.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SetPropNodeValue(XmlNode propNode, SettingsPropertyValue propVal)
        {
            if (propVal.Property.PropertyType != typeof(StringCollection))
            {
                propNode.InnerText = propVal.SerializedValue.ToString();
                return;
            }

            if (propVal.PropertyValue == null)
                return;

            // At this point, we know we're dealing with a string collection, therefore,
            // create child nodes for each item in the collection.
            propNode.RemoveAll();
            var attrib = m_settingsXml.CreateAttribute(StrCollectionAttrib);
            attrib.Value = "true";
            propNode.Attributes.Append(attrib);
            int i = 0;
            foreach (string str in propVal.PropertyValue as StringCollection)
            {
                var node = m_settingsXml.CreateElement(propVal.Name + i++);
                node.AppendChild(m_settingsXml.CreateTextNode(str));
                propNode.AppendChild(node);
            }
        }
Esempio n. 26
0
 /// <summary>
 /// �ڵ��滻[֧���������ĵ����滻]
 /// </summary>
 /// <param name="NewXNode"></param>
 /// <param name="OldXNode"></param>
 public void ReplaceNode(XmlNode newNode, XmlNode oldNode)
 {
     if (newNode != null && oldNode != null)
     {
         oldNode.RemoveAll();
         //if (!string.IsNullOrEmpty(newNode.InnerXml) && !string.IsNullOrEmpty(newNode.NamespaceURI))
         //{
         //    oldNode.InnerXml = newNode.InnerXml.Replace("xmlns=\"" + newNode.NamespaceURI+"\"", string.Empty);
         //}
         //else
         //{
         oldNode.InnerXml = newNode.InnerXml;
         //}
         XmlAttributeCollection xAttributes = newNode.Attributes;
         if (xAttributes != null && xAttributes.Count > 0)
         {
             for (int i = 0; i < xAttributes.Count; i++)
             {
                 ((XmlElement)oldNode).SetAttribute(xAttributes[i].Name, xAttributes[i].Value);
             }
         }
     }
 }
Esempio n. 27
0
 private void addAllChildNodes(XmlDocument mergedDocument, XmlNode contentParentNode, XmlNode substitutionsParentNode)
 {
     XmlNode substitutionNode = substitutionsParentNode.FirstChild;
     while (substitutionNode != null)
     {
         switch(substitutionNode.NodeType)
         {
             case XmlNodeType.Element:
                 if (shouldDeleteElement(substitutionNode))
                 {
                     removeChildNode(mergedDocument, contentParentNode, substitutionNode);
                 }
                 else
                 {
                     XmlNode mergedNode = addChildNode(mergedDocument, contentParentNode, substitutionNode);
                     addAllChildNodes(mergedDocument, mergedNode, substitutionNode);
                 }
                 break;
             case XmlNodeType.Text:
                 contentParentNode.InnerText = substitutionNode.Value;
                 break;
             case XmlNodeType.CDATA:
                 contentParentNode.RemoveAll();
                 contentParentNode.AppendChild(mergedDocument.CreateCDataSection(substitutionNode.Value));
                 break;
             default:
                 break;
         }
         substitutionNode = substitutionNode.NextSibling;
     }
 }
		/// <summary>
		/// Moves the master styles.
		/// </summary>
		/// <param name="contentDocument">The content document.</param>
		/// <param name="nodeAutomaticStyles">The node automatic styles.</param>
		/// <param name="nodeMasterPages">The node master pages.</param>
		/// <param name="namespaceMng">The namespace MNG.</param>
		/// <remarks>
		/// We will move the whole master style and master pages stuff
		/// from the style document to the text document. This is
		/// necessary for avoiding xml document owner errors.
		/// Notice: When the document will be saved this nodes have
		/// to move back to the styles document. Otherwise they wont
		/// work resp. diplayed not correct within OpenOffice.
		/// </remarks>
		public static void MoveMasterStyles(XmlDocument contentDocument,XmlNode nodeAutomaticStyles, XmlNode nodeMasterPages, XmlNamespaceManager namespaceMng)
		{
			// First import all automatic styles
			XmlNode contentAutomaticStyles = contentDocument.SelectSingleNode(
				"//office:automatic-styles", namespaceMng);
			if (contentAutomaticStyles != null && nodeAutomaticStyles.HasChildNodes)
			{
				foreach(XmlNode childNode in nodeAutomaticStyles.ChildNodes)
				{
					XmlNode importNode = contentDocument.ImportNode(childNode, true);
					contentAutomaticStyles.AppendChild(importNode);
				}
			}
			// Second import master pages
			XmlNode importedMasterPages = contentDocument.ImportNode(nodeMasterPages, true);
			contentDocument.LastChild.AppendChild(importedMasterPages);

			// clear nodes in style.xml
			nodeAutomaticStyles.RemoveAll();
			// clear master pages in style.xml
			nodeMasterPages.RemoveAll();
		}
Esempio n. 29
0
        public void SetPropertiesInstance(XmlNode node, object inst)
        {
            node.RemoveAll();       // Get rid of all properties

            BarCodeProperties bcp = inst as BarCodeProperties;
            if (bcp == null)
                return;


            XmlHelpers.CreateChild(node, "Code", bcp.Code);
        }
Esempio n. 30
0
 /// <summary>
 /// Sets the child node.
 /// </summary>
 /// <param name="currentNode">The current node.</param>
 /// <param name="childNode">The child node.</param>
 public static void SetChildNode(XmlNode currentNode, XmlNode childNode)
 {
     if (childNode != null)
     {
         //currentNode.InnerXml = childNode.InnerXml;
         currentNode.RemoveAll();
         currentNode.AppendChild(childNode);
     }
 }