Exemplo n.º 1
0
        public VisualFunction(XmlNode xnode)
        {
            //keep a record for future use (and self clone)
            functionXml = xnode.Clone();
            XmlNode tempFunctionXml = updateInputIDs(functionXml);
            //MessageBox.Show(printer.PrintToString(xnode) + "\n\n" + printer.PrintToString(tempFunctionXml));

            //interaction handlers
            this.MouseDown += new MouseButtonEventHandler(VisualFunction_MouseDown);
            this.MouseMove += new MouseEventHandler(VisualFunction_MouseMove);

            //method data (arguments: inputs and outputs)
            XmlNode xdata = tempFunctionXml.SelectSingleNode("args");
            //XmlNode xdataTemp = updateInputIDs(xdata);
            this.Data = xdata.Clone();

            //method reverse data (arguments: args -> reverse operation on data.output, and inputs -> placeholder of data outputs)
            XmlNode xdataR = tempFunctionXml.SelectSingleNode("argsR");
            //this.DataR = xdataR.Clone();
            this.DataR = xdataR.Clone();

            //create the picture content
            imageName = tempFunctionXml.SelectSingleNode("image").InnerXml;
            //MessageBox.Show(imageName);
            this.Content = getImage();
        }
Exemplo n.º 2
0
        public VisualCondition(XmlNode xnode)
        {
            //keep a record for future use (and self clone)
            functionXml = xnode.Clone();

            //interaction handlers
            this.MouseDown += new MouseButtonEventHandler(VisualCondition_MouseDown);
            this.MouseMove += new MouseEventHandler(VisualCondition_MouseMove);

            //method data (arguments: inputs and outputs)
            //XmlNode xdata = xnode.SelectSingleNode("args");
            this.Data = xnode.Clone();

            //method reverse data (arguments: args -> reverse operation on data.output, and inputs -> placeholder of data outputs)
            //XmlNode xdataR = xnode.SelectSingleNode("argsR");
            //if (xdataR != null)
            //{
            //    this.DataR = xdataR.Clone();
            //    hasReverse = true;
            //}
            //else
            //{
            //    hasReverse = false;
            //    this.DataR = null;
            //}

            //get condition string
            //conditions = xnode.SelectSingleNode("conditions");

            //if (conditions.ChildNodes.Count > 1)
             //   isMultiCondition = true;
            //else
               //     isMultiCondition = false;

            //create the picture content
            imageName = Data.SelectSingleNode("image").InnerXml;

            if(!String.IsNullOrEmpty(imageName))
                this.Content = getImage();
        }
        private static void ImplementTemplate(XmlDocument xml, XmlNode templateNode, string imageName, Dictionary<string, string> strings)
        {
            var newNode = templateNode.Clone();

            var childNodes = new List<XmlNode>();
            childNodes.AddRange(TemplateXmlGenerator.Flatten(newNode.ChildNodes));

            TemplateXmlGenerator.ReplaceText(strings, childNodes);

            newNode = xml.ImportNode(newNode, deep: true);
            childNodes.Clear();
            childNodes.AddRange(newNode.ChildNodes.Cast<XmlNode>());

            foreach (var childNode in childNodes)
            {
                templateNode.ParentNode.InsertBefore(childNode, templateNode);
            }
        }
Exemplo n.º 4
0
		/// <summary>
		/// Selects child nodes from a parent node satisfying the xpath
		/// </summary>
		/// <param name="xmlNode"></param>
		/// <param name="xpath"></param>
		/// <returns></returns>
		public static XmlNodeList SelectNodes (XmlNode xmlNode, string xpath)
		{

			XmlNode retXmlNode = xmlNode.Clone();
			retXmlNode.RemoveAll();
	
			IEnumerator iEnumerator = xmlNode.GetEnumerator();
			
			while (iEnumerator.MoveNext())
			{	
				XmlNode childXmlNode = (XmlNode)iEnumerator.Current;
				if (childXmlNode.LocalName.ToString() == xpath)
				{
					retXmlNode.AppendChild(childXmlNode.CloneNode(true));
				}
			}
		
			XmlNodeList retXmlNodeList = retXmlNode.ChildNodes;
			return retXmlNodeList; 
			
		}
Exemplo n.º 5
0
        private void SetNumLink(int start, int end)
        {
            string numLinks = string.Empty;

            System.Xml.XmlNode node = doc.GetByID("labForNum");
            if (node != null)
            {
                string             activeCss = doc.GetAttrValue(node, "active");
                System.Xml.XmlNode newNode   = null;
                for (int i = end; i >= start; i--)
                {
                    doc.Set("labNum", SetType.A, i.ToString(), URLPara.Replace("{0}", i.ToString()));
                    newNode = node.Clone();
                    if (i == PageIndex && activeCss.Length > 0)
                    {
                        doc.Set(newNode, SetType.Class, activeCss);
                    }
                    doc.InsertAfter(newNode, node);
                }
                doc.Remove(node);
            }
        }
Exemplo n.º 6
0
 public virtual void AssignContent(XmlNode contentNode, object instance, Type instanceType, Func<Type, IParcer> valueParcerResolver)
 {
     var objectFactoryInstance = instance as ModernFactory.ObjectFactory;
       if (objectFactoryInstance == null)
       {
     throw new Exception("Unexpected value");
       }
       var contentNodeClone = contentNode.Clone();
       var typeAttribute = contentNodeClone.Attributes["type"];
       if (typeAttribute == null)
       {
     throw new Exception("Unexpected value");
       }
       var indexOfColon = typeAttribute.Value.IndexOf(":");
       if (indexOfColon == -1)
       {
     throw new Exception("Unexpected value");
       }
       var newTypeValue = typeAttribute.Value.Substring(indexOfColon + 1);
       typeAttribute.Value = newTypeValue;
       objectFactoryInstance.Initialize(contentNodeClone);
 }
Exemplo n.º 7
0
 public override XmlNode InsertBefore(XmlNode newChild, XmlNode refChild)
 {
     bool flag1 = this.ownerDocument.AcceptChanges;
     if (newChild.OwnerDocument != this.OwnerDocument)
     {
         XmlNode node1 = newChild.Clone();
         this.ownerDocument.AcceptChanges = false;
         XmlNode node2 = this.ownerDocument.ImportNode(node1, true);
         newChild = node2;
         this.ownerDocument.AcceptChanges = flag1;
     }
     this.CreateID(newChild);
     XmlNode node3 = base.InsertBefore(newChild, refChild);
     if (node3 is ItopVector.Core.Animate.Animate)
     {
         XmlNode node4 = refChild;
         while (!(node4 is ItopVector.Core.Animate.Animate))
         {
             if (node4 == null)
             {
                 break;
             }
             node4 = node4.NextSibling;
         }
         if (node4 is ItopVector.Core.Animate.Animate)
         {
             if (!this.animatelist.Contains((SvgElement) node3))
             {
                 int num1 = this.animatelist.IndexOf((SvgElement) node4);
                 if (num1 >= 0)
                 {
                     this.animatelist.Insert(num1, (SvgElement) node3);
                     num1 = this.ownerDocument.FlowChilds.IndexOf((SvgElement) node4);
                     this.InsertFlowElment(num1 + this.animatelist.IndexOf((SvgElement) node3), (SvgElement) node3);
                     goto Label_016B;
                 }
                 this.animatelist.Insert(0, (SvgElement) node3);
                 this.InsertFlowElment(0, (SvgElement) node3);
             }
         }
         else if (!this.animatelist.Contains((SvgElement) node3))
         {
             this.animatelist.Insert(0, (SvgElement) node3);
             this.InsertFlowElment(0, (SvgElement) node3);
         }
     }
     Label_016B:
     if (node3 is SvgElement)
     {
         CodeFunc.FormatElement((SvgElement) node3);
     }
     return node3;
 }
Exemplo n.º 8
0
        private XmlNode SetStains(XmlNode tableNodeSS,
			XmlNode rowStainHeaderNode,
			XmlNode rowTestHeaderNode,
			XmlNode insertAfterRowSS,
			XmlNode rowSpecialStainNode,
			SurgicalSpecimen surgicalSpecimen,
			YellowstonePathology.Business.SpecialStain.StainResultItemCollection stainResultCollection)
        {
            XmlNode rowStainHeaderNodeClone = rowStainHeaderNode.Clone();
            tableNodeSS.InsertAfter(rowStainHeaderNodeClone, insertAfterRowSS);
            insertAfterRowSS = rowStainHeaderNodeClone;

            XmlNode rowTestHeaderNodeClone = rowTestHeaderNode.Clone();
            tableNodeSS.InsertAfter(rowTestHeaderNodeClone, insertAfterRowSS);
            insertAfterRowSS = rowTestHeaderNodeClone;

            foreach (YellowstonePathology.Business.SpecialStain.StainResultItem stainResultItem in stainResultCollection)
            {
                XmlNode rowSpecialStainClone = rowSpecialStainNode.Clone();
                string stainDescription = stainResultItem.ProcedureName;
                string stainResult = stainResultItem.Result;

                if (string.IsNullOrEmpty(stainResult) == true)
                {
                    stainResult = "Pending";
                }
                else if (stainResult.ToUpper() == "SEE COMMENT")
                {
                    stainResult = stainResultItem.ReportComment;
                }
                else
                {
                    string specialStainReportComment = stainResultItem.ReportComment;

                    if (!string.IsNullOrEmpty(specialStainReportComment))
                    {
                        stainResult += " - " + specialStainReportComment;
                    }
                }

                rowSpecialStainClone.SelectSingleNode("descendant::w:r[w:t='stain_description']/w:t", this.m_NameSpaceManager).InnerText = stainDescription;
                rowSpecialStainClone.SelectSingleNode("descendant::w:r[w:t='stain_result']/w:t", this.m_NameSpaceManager).InnerText = stainResult;

                string block = surgicalSpecimen.GetBlockFromTestOrderId(stainResultItem.TestOrderId);
                rowSpecialStainClone.SelectSingleNode("descendant::w:r[w:t='block_description']/w:t", this.m_NameSpaceManager).InnerText = block;

                tableNodeSS.InsertAfter(rowSpecialStainClone, insertAfterRowSS);
                insertAfterRowSS = rowSpecialStainClone;
            }

            return insertAfterRowSS;
        }
Exemplo n.º 9
0
        public override XmlNode AppendChild(XmlNode newChild)
        {
            if (newChild == null)
            {
                return null;
            }
            bool flag1 = this.ownerDocument.AcceptChanges;
            if (newChild.OwnerDocument != this.OwnerDocument)
            {
                XmlNode node1 = newChild.Clone();
                this.ownerDocument.AcceptChanges = false;
                XmlNode node2 = this.ownerDocument.ImportNode(node1, true);
                newChild = node2;
                this.ownerDocument.AcceptChanges = flag1;
            }
            else if (!(newChild is Symbol))
            {

                this.CreateID(newChild);
            }

            XmlNode node3 = base.AppendChild(newChild);
            if ((node3 is ItopVector.Core.Animate.Animate) && !this.animatelist.Contains((SvgElement) node3))
            {
                if (this.showParticular)
                {
                    this.AddFlowElement((SvgElement) node3);
                }
                this.animatelist.Add((SvgElement) node3);
            }
            if (node3 is SvgElement)
            {
                CodeFunc.FormatElement((SvgElement) node3);
            }
            return node3;
        }
Exemplo n.º 10
0
        public override XmlNode InsertAfter(XmlNode newChild, XmlNode refChild)
        {
            if (newChild.OwnerDocument != this.OwnerDocument)
            {
                XmlNode node1 = newChild.Clone();
                bool flag1 = this.ownerDocument.AcceptChanges;
                this.ownerDocument.AcceptChanges = false;
                XmlNode node2 = this.ownerDocument.ImportNode(node1, true);
                newChild = node2;
                this.ownerDocument.AcceptChanges = flag1;
            }

            this.CreateID(newChild);
            XmlNode node3 = base.InsertAfter(newChild, refChild);
            if (node3 is ItopVector.Core.Animate.Animate)
            {
                XmlNode node4 = refChild;
                while (!(node4 is ItopVector.Core.Animate.Animate))
                {
                    if (node4 == null)
                    {
                        break;
                    }
                    node4 = node4.PreviousSibling;
                }
                if ((node4 is ItopVector.Core.Animate.Animate) && !this.animatelist.Contains((SvgElement) node3))
                {
                    int num1 = this.animatelist.IndexOf((SvgElement) node4);
                    if ((num1 + 1) < this.animatelist.Count)
                    {
                        this.animatelist.Add((SvgElement) node3);
                    }
                    else
                    {
                        this.animatelist.Insert(num1 + 1, (SvgElement) node3);
                    }
                }
            }
            if (node3 is SvgElement)
            {
                CodeFunc.FormatElement((SvgElement) node3);
            }
            return node3;
        }
Exemplo n.º 11
0
 private void ExchengeNodes(XmlNode vNode_1, XmlNode vNode_2){
   XmlNode vParentNode = vNode_2.ParentNode;
   XmlNode vNode_1_clone = vNode_1.Clone();
   vParentNode.InsertBefore(vNode_1_clone, vNode_2);
   vParentNode.ReplaceChild(vNode_2, vNode_1);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Assign values to the attributes of the report, from the instance passed as parameter.
        /// </summary>
        /// <param name="nodeProperties">XmlNode to be filled. It contains tha empty attributes.</param>
        /// <param name="Instance">Instance object that contains the values for the attributes.</param>
        /// <param name="Cloning">If True: the returned node is a new one (cloned from original). False: the returned node is the same, but modified.</param>
        /// <param name="attPos">Attributes value positions in the DataRow, keyed by the Attribute name.</param>
        /// <returns>A XmlNode, that can be a new one or a modified one.</returns>
        private static XmlNode SetValueOfNodeAttributeFromInstance(XmlNode nodeProperties, DataRow Instance, bool Cloning, Dictionary<string, int> attPos)
        {
            XmlNode nodeProp = null;
            if (nodeProperties != null)
            {
                if (Cloning)
                    nodeProp = nodeProperties.Clone();
                else
                    nodeProp = nodeProperties;

                XmlNode[] aNodes = XMLQuery.SelectNodes(nodeProp ,"Attribute",false);

                int numReportAttr = aNodes.Length;
                for (int It = 0; It < numReportAttr; It++)
                {
                    string Name = aNodes[It].Attributes["Name"].Value;

                    XmlAttribute att =  aNodes[It].OwnerDocument.CreateAttribute("Value");
                    if (Instance.ItemArray[attPos[Name]] == null)
                        att.Value = "";
                    else
                        att.Value = Instance.ItemArray[attPos[Name]].ToString();

                    aNodes[It].Attributes.Append(att);
                }
            }
            return nodeProp;
        }
Exemplo n.º 13
0
		private static XmlNode CreateWsSpecficLayoutType(XmlNode xnLayoutType, string sWsLabel,
			string sWsLayout, string sWsTag)
		{
			XmlNode xnRealLayout = xnLayoutType.Clone();
			xnRealLayout.Attributes["label"].Value = sWsLabel;
			xnRealLayout.Attributes["layout"].Value = sWsLayout;
			foreach (XmlNode config in xnRealLayout.ChildNodes)
			{
				if (config is XmlComment || config.Name != "configure")
					continue;
				string sInternalLayout = XmlUtils.GetAttributeValue(config, "layout");
				Debug.Assert(sInternalLayout.EndsWith("-$ws"));
				config.Attributes["layout"].Value = sInternalLayout.Replace("$ws", sWsTag);
			}
			return xnRealLayout;
		}
Exemplo n.º 14
0
        private XmlNode updateInputIDs(XmlNode data)
        {
            //copy the whole thing
            XmlNode xdataTemp = data.Clone();

            //get forward and reverse
            XmlNode args = xdataTemp.SelectSingleNode("args");
            XmlNode argsR = xdataTemp.SelectSingleNode("argsR");

            //get forward arguments
            XmlNode inputs = args.SelectSingleNode("inputs");
            XmlNode outputs = args.SelectSingleNode("outputs");
            XmlNode newInputs = inputs.OwnerDocument.CreateElement("inputs");
            XmlNode newOutputs = outputs.OwnerDocument.CreateElement("outputs");

            //getreverse reverse arguments
            XmlNode inputsR = argsR.SelectSingleNode("inputs");
            XmlNode outputsR = argsR.SelectSingleNode("outputs");
            XmlNode newInputsR = inputsR.OwnerDocument.CreateElement("inputs");
            XmlNode newOutputsR = outputsR.OwnerDocument.CreateElement("outputs");

            foreach (XmlNode i in inputs.ChildNodes)
            {
                XmlNode ida = i.Attributes.GetNamedItem("ID");
                if (ida != null)
                {
                    //forward area
                    int iid = int.Parse(ida.Value);
                    int newID = ID++;
                    string previousArgName = "arg" + iid.ToString();
                    string newArgName = "arg" + newID;

                    XmlNode newChild = i.OwnerDocument.CreateElement(newArgName);
                    newChild.AppendChild(newChild.OwnerDocument.CreateTextNode(i.InnerText));//assuming the child has only values as text

                    newInputs.AppendChild(newChild);

                    //reverse (inputs of forward become outputs of reverse)
                    XmlNode reverseUpdatee = argsR.SelectSingleNode("outputs/output[@ID='"+iid+"']");
                    if (reverseUpdatee != null)
                    {
                        XmlNode newReverseOutput = reverseUpdatee.OwnerDocument.CreateElement("output" + newID);
                        newReverseOutput.AppendChild(newReverseOutput.OwnerDocument.CreateTextNode(reverseUpdatee.InnerText));
                        newOutputsR.AppendChild(newReverseOutput);
                    }

                    //update output templates
                    foreach (XmlNode o in outputs.ChildNodes)
                    {
                        string oldValue = o.InnerText;
                        if (!String.IsNullOrEmpty(oldValue))
                        {
                            if (oldValue.IndexOf(previousArgName) != -1)
                            {
                                string newValue = oldValue.Replace(previousArgName+" ", newArgName+ " ");

                                o.ReplaceChild(o.OwnerDocument.CreateTextNode(newValue),o.ChildNodes[0]);
                            }
                        }
                    }
                }
            }
            //replace old and new inputs
            args.ReplaceChild(newInputs, inputs);

            foreach (XmlNode o in outputs.ChildNodes)
            {
                XmlNode ida = o.Attributes.GetNamedItem("ID");
                if (ida != null)
                {
                    int iid = int.Parse(ida.InnerText);
                    int newID = ID++;
                    string previousOutputName = "output" + iid.ToString();
                    string newOutputName = "output" + newID;

                    XmlNode newChild = o.OwnerDocument.CreateElement(newOutputName);
                    newChild.AppendChild(newChild.OwnerDocument.CreateTextNode(o.InnerText));//assuming the child has only values as text

                    newOutputs.AppendChild(newChild);

                    //outputs of forward become inputs of reverse
                    XmlNode reverseInputUpdatee = argsR.SelectSingleNode("inputs/arg[@ID='" + iid + "']");
                    if (reverseInputUpdatee != null)
                    {
                        XmlNode newReverseInput = reverseInputUpdatee.OwnerDocument.CreateElement("arg" + newID);
                        newReverseInput.AppendChild(newReverseInput.OwnerDocument.CreateTextNode(reverseInputUpdatee.InnerText));
                        newInputsR.AppendChild(newReverseInput);

                        foreach (XmlNode oR in newOutputsR.ChildNodes)
                        {
                            string oldValue = oR.InnerText;
                            string previousArgName = "arg" + iid.ToString();
                            string newArgName = "arg" + newID;
                            if (!String.IsNullOrEmpty(oldValue))
                            {
                                if (oldValue.IndexOf(previousArgName) != -1)
                                {
                                    string newValue = oldValue.Replace(previousArgName+" ", newArgName+" ");

                                    oR.ReplaceChild(oR.OwnerDocument.CreateTextNode(newValue), oR.ChildNodes[0]);
                                }
                            }
                        }
                    }

                }
            }
            //replace old and new outputs
            args.ReplaceChild(newOutputs, outputs);

            argsR.ReplaceChild(newOutputsR, outputsR);
            argsR.ReplaceChild(newInputsR, inputsR);

            return xdataTemp;
        }
Exemplo n.º 15
0
 private void convertXmlNode(XmlNode page, XmlNode source, string font, Point offset)
 {
     XmlElement destNode = null;
     if (((source.Name == "label") || (source.Name == "ranlabel")) || ((source.Name == "checkbox") || (source.Name == "radio")))
     {
         destNode = page.OwnerDocument.CreateElement(source.Name);
         this.setAttribute(destNode, source);
         if (this.mPrintFlg || !string.IsNullOrEmpty(font))
         {
             setParentFont(destNode, font);
         }
         adjustLocation(destNode, offset);
         page.AppendChild(destNode);
     }
     else if ((((source.Name == "textbox") || (source.Name == "maskedtextbox")) || ((source.Name == "combobox") || (source.Name == "inputcombobox"))) || ((source.Name == "datetimepicker") || (source.Name == "commatext")))
     {
         destNode = page.OwnerDocument.CreateElement("prttextbox");
         this.setAttribute(destNode, source);
         if (this.mPrintFlg || !string.IsNullOrEmpty(font))
         {
             setParentFont(destNode, font);
         }
         System.Type textBox = DesignControls.TextBox;
         if (source.Name == "maskedtextbox")
         {
             textBox = DesignControls.MaskedTextBox;
             XmlFunc.setStringAttribute(destNode, "Format", getMaskFormat(source));
         }
         else if (source.Name == "datetimepicker")
         {
             textBox = DesignControls.DataTimePicker;
             XmlFunc.setStringAttribute(destNode, "Format", getDateTimeFormat(source));
         }
         else if (source.Name == "commatext")
         {
             textBox = DesignControls.CommaText;
             XmlFunc.setStringAttribute(destNode, "Format", getCommaFormat(source));
         }
         if (XmlFunc.getStringAttribute(source, "isGrid") != "True")
         {
             string borderStyle = XmlFunc.getStringAttribute(source, "BorderStyle").Trim();
             if (borderStyle.Length == 0)
             {
                 borderStyle = ComponentProperty.getPropertyDefault(textBox, "BorderStyle");
                 if (borderStyle == null)
                 {
                     borderStyle = BorderStyle.None.ToString();
                 }
             }
             int num = SizeDef.prtTextMargin(borderStyle);
             Point location = getLocationAttribute(destNode);
             location.Y += num;
             setLocationAttribute(destNode, location);
             System.Drawing.Size size = getSizeAttribute(destNode);
             size.Height -= num * 2;
             setSizeAttribute(destNode, size);
             XmlFunc.setStringAttribute(destNode, "BorderStyle", BorderStyle.None.ToString());
         }
         adjustLocation(destNode, offset);
         page.AppendChild(destNode);
     }
     else if (source.Name == "div-textbox")
     {
         destNode = page.OwnerDocument.CreateElement("prttextbox");
         this.setAttribute(destNode, source);
         if (this.mPrintFlg || !string.IsNullOrEmpty(font))
         {
             setParentFont(destNode, font);
         }
         System.Type maskedTextBox = DesignControls.MaskedTextBox;
         int cnt = XmlFunc.getNumericAttribute(source, "L_MaxLength");
         int num3 = XmlFunc.getNumericAttribute(source, "R_MaxLength");
         StrFunc func = StrFunc.CreateInstance();
         string str2 = func.MakeCycleStr(cnt, "_") + " - " + func.MakeCycleStr(num3, "_");
         XmlFunc.setStringAttribute(destNode, "Format", str2);
         string str3 = XmlFunc.getStringAttribute(source, "BorderStyle").Trim();
         if (str3.Length == 0)
         {
             str3 = BorderStyle.None.ToString();
         }
         int num4 = SizeDef.prtTextMargin(str3) + SizeDef.prtTextMargin(BorderStyle.Fixed3D.ToString());
         Point point2 = getLocationAttribute(destNode);
         point2.Y += num4;
         setLocationAttribute(destNode, point2);
         System.Drawing.Size size2 = getSizeAttribute(destNode);
         size2.Width -= num4 * 2;
         size2.Height -= num4 * 2;
         setSizeAttribute(destNode, size2);
         XmlFunc.setStringAttribute(destNode, "BorderStyle", BorderStyle.None.ToString());
         adjustLocation(destNode, offset);
         page.AppendChild(destNode);
     }
     else if ((source.Name == "container") && isContinueType(source))
     {
         if (XmlFunc.getStringAttribute(source, "type") == "TitlePanel")
         {
             page.AppendChild(source.Clone());
         }
         else if (!isRepetition(source))
         {
             if (!this.isConvertContainer(source))
             {
                 throw new NaccsException(MessageKind.Error, 0x25e, "Tab page structure is too complicated to be converted. (Multiple tabs contain other child elements than repetitive part.)");
             }
             if (this.isContainerChilds(source))
             {
                 string str4 = XmlFunc.getStringAttribute(source, "Font");
                 if (str4.Length == 0)
                 {
                     str4 = font;
                 }
                 foreach (XmlNode node in source.ChildNodes)
                 {
                     this.convertXmlNode(page, node, str4, getOffset(node));
                 }
                 this.convertContainer(page, source);
             }
         }
     }
 }
Exemplo n.º 16
0
		XmlNode EvaluateNode (XmlNode source)
		{
			var elemSource = source as XmlElement;
			if (elemSource != null) {
				var elem = source.OwnerDocument.CreateElement (elemSource.Prefix, elemSource.LocalName, elemSource.NamespaceURI);
				foreach (XmlAttribute attr in elemSource.Attributes)
					elem.Attributes.Append ((XmlAttribute)EvaluateNode (attr));
				foreach (XmlNode child in elemSource.ChildNodes)
					elem.AppendChild (EvaluateNode (child));
				return elem;
			}

			var attSource = source as XmlAttribute;
			if (attSource != null) {
				bool oldResolved = allResolved;
				var att = source.OwnerDocument.CreateAttribute (attSource.Prefix, attSource.LocalName, attSource.NamespaceURI);
				att.Value = Evaluate (attSource.Value);

				// Condition attributes don't change the resolution status. Conditions are handled in the property and item objects
				if (attSource.Name == "Condition")
					allResolved = oldResolved;

				return att;
			}
			var textSource = source as XmlText;
			if (textSource != null) {
				return source.OwnerDocument.CreateTextNode (Evaluate (textSource.InnerText));
			}
			return source.Clone ();
		}
Exemplo n.º 17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Copies the replacing param default.
		/// </summary>
		/// <param name="input">The input.</param>
		/// <param name="paramId">The param id.</param>
		/// <param name="val">The val.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public static XmlNode CopyReplacingParamDefault(XmlNode input, string paramId, string val)
		{
			XmlNode result = input.Clone();

			ReplaceParamDefault replacer = new ReplaceParamDefault(paramId, val);
			XmlUtils.VisitAttributes(result, replacer);

			return result;
		}
Exemplo n.º 18
0
		/// <summary>
		/// If any attributes of input (or its children) are of the form "$param=default",
		/// generate a complete copy of input in which "$param=default" is replaced with
		/// "default", and return it. Otherwise just return input.
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		public static XmlNode CopyWithParamDefaults(XmlNode input)
		{
			if (!HasParam(input))
				return input;
			XmlNode result = input.Clone();

			ReplaceParamWithDefault replacer = new ReplaceParamWithDefault();
			XmlUtils.VisitAttributes(result, replacer);

			return result;
		}
Exemplo n.º 19
0
		protected void DoCustomElements(TextWriter contentsStream, CmObject currentObject, XmlNode node)
		{
			string sClass = XmlUtils.GetManditoryAttributeValue(node, "class");
			string sType = XmlUtils.GetOptionalAttributeValue(node, "fieldType", "");
			int[] flids;
			if (!m_customFlids.TryGetValue(sClass + sType, out flids))
			{
				int clid = 0;
				try
				{
					clid = (int)m_cache.MetaDataCacheAccessor.GetClassId(sClass);
				}
				catch
				{
					clid = 0;
				}
				if (clid == 0)
				{
					m_customFlids[sClass + sType] = new int[0];
					return;		// we don't know what to do!
				}
				StringBuilder sbTypes = new StringBuilder();
				switch (sType)
				{
					case "mlstring":
						sbTypes.AppendFormat(" AND Type IN ({0}, {1}, {2}, {3})",
							(int)CellarModuleDefns.kcptMultiUnicode,
							(int)CellarModuleDefns.kcptMultiBigUnicode,
							(int)CellarModuleDefns.kcptMultiString,
							(int)CellarModuleDefns.kcptMultiBigString);
						break;
					case "simplestring":
						sbTypes.AppendFormat(" AND Type IN ({0}, {1})",
							(int)CellarModuleDefns.kcptString,
							(int)CellarModuleDefns.kcptBigString);
						break;
				}
				StringBuilder sb = new StringBuilder("SELECT Id From Field$ WHERE Custom=1 AND Class=");
				sb.Append(clid.ToString());
				if (sbTypes.Length > 0)
					sb.Append(sbTypes.ToString());
				string sql = sb.ToString();
				flids = DbOps.ReadIntArrayFromCommand(m_cache, sql, null);
				m_customFlids[sClass + sType] = flids;
			}
			if (flids.Length == 0)
				return;		// nothing to do.
			for (int i = 0; i < flids.Length; ++i)
			{
				XmlNode parentNode = node.Clone();
				uint flid = (uint)flids[i];
				string labelName = m_cache.MetaDataCacheAccessor.GetFieldLabel(flid);
				string fieldName = m_cache.MetaDataCacheAccessor.GetFieldName(flid);
				string className = m_cache.MetaDataCacheAccessor.GetOwnClsName(flid);
				if (String.IsNullOrEmpty(labelName))
					labelName = fieldName;
				string sfMarker = "zz";
				if (fieldName.StartsWith("custom"))
				{
					sfMarker = String.Format("z{0}", fieldName.Substring(6));
					if (sfMarker == "z")
						sfMarker = "z0";
				}
				ReplaceSubstringInAttr visitorFn = new ReplaceSubstringInAttr("${fieldName}", fieldName);
				ReplaceSubstringInAttr visitorLab = new ReplaceSubstringInAttr("${label}", labelName);
				ReplaceSubstringInAttr visitorSfm = new ReplaceSubstringInAttr("${sfm}", sfMarker);
				foreach (XmlNode xn in parentNode.ChildNodes)
				{
					XmlUtils.VisitAttributes(xn, visitorFn);
					XmlUtils.VisitAttributes(xn, visitorLab);
					XmlUtils.VisitAttributes(xn, visitorSfm);
				}
				if (parentNode.InnerText.Contains("${definition}"))
					FillInCustomFieldDefinition(parentNode, flid);
				if (parentNode.InnerText.Contains("${description}"))
					FillInCustomFieldDescription(parentNode, flid);
				DoChildren(contentsStream, currentObject, parentNode, null);
			}
		}
Exemplo n.º 20
0
 private static XmlNode assembleLayoutNode(XmlNode source, Point offset)
 {
     XmlNode destNode = source.Clone();
     adjustLocation(destNode, offset);
     return destNode;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Initializes the task and verifies parameters.
        /// </summary>
        /// <param name="TaskNode">Node that contains the XML fragment used to define this task instance.</param>
        protected override void InitializeTask(XmlNode TaskNode)
        {
            XmlElement taskXml = (XmlElement) TaskNode.Clone();

            // Expand all properties in the task and its child elements
            if (taskXml.ChildNodes != null) {
                ExpandPropertiesInNodes(taskXml.ChildNodes);
                if (taskXml.Attributes != null) {
                    foreach (XmlAttribute attr in taskXml.Attributes) {
                        attr.Value = Properties.ExpandProperties(attr.Value, Location);
                    }
                }
            }

            // Get the [SchemaValidator(type)] attribute
            SchemaValidatorAttribute[] taskValidators =
                (SchemaValidatorAttribute[])GetType().GetCustomAttributes(
                typeof(SchemaValidatorAttribute), true);

            if (taskValidators.Length > 0) {
                SchemaValidatorAttribute taskValidator = taskValidators[0];
                XmlSerializer taskSerializer = new XmlSerializer(taskValidator.ValidatorType);

                // get embedded schema resource stream
                Stream schemaStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    taskValidator.ValidatorType.Namespace);

                // ensure schema resource was embedded
                if (schemaStream == null) {
                    throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                        "Schema resource '{0}' could not be found.",
                        taskValidator.ValidatorType.Namespace), Location);
                }

                // load schema resource
                XmlTextReader tr = new XmlTextReader(
                    schemaStream, XmlNodeType.Element, null);

                // Add the schema to a schema collection
                XmlSchema schema = XmlSchema.Read(tr, null);
                XmlSchemaCollection schemas = new XmlSchemaCollection();
                schemas.Add(schema);

                string xmlNamespace = (taskValidator.XmlNamespace != null ? taskValidator.XmlNamespace : GetType().FullName);

                // Create a namespace manager with the schema's namespace
                NameTable nt = new NameTable();
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
                nsmgr.AddNamespace(string.Empty, xmlNamespace);

                // Create a textreader containing just the Task's Node
                XmlParserContext ctx = new XmlParserContext(
                    null, nsmgr, null, XmlSpace.None);
                taskXml.SetAttribute("xmlns", xmlNamespace);
                XmlTextReader textReader = new XmlTextReader(taskXml.OuterXml,
                    XmlNodeType.Element, ctx);

                // Copy the node from the TextReader and indent it (for error
                // reporting, since NAnt does not retain formatting during a load)
                StringWriter stringWriter = new StringWriter();
                XmlTextWriter textWriter = new XmlTextWriter(stringWriter);
                textWriter.Formatting = Formatting.Indented;

                textWriter.WriteNode(textReader, true);

                //textWriter.Close();
                XmlTextReader formattedTextReader = new XmlTextReader(
                    stringWriter.ToString(), XmlNodeType.Document, ctx);

                // Validate the Task's XML against its schema
                XmlValidatingReader validatingReader = new XmlValidatingReader(
                    formattedTextReader);
                validatingReader.ValidationType = ValidationType.Schema;
                validatingReader.Schemas.Add(schemas);
                validatingReader.ValidationEventHandler +=
                    new ValidationEventHandler(Task_OnSchemaValidate);

                while (validatingReader.Read()) {
                    // Read strictly for validation purposes
                }
                validatingReader.Close();

                if (!_validated) {
                    // Log any validation errors that have ocurred
                    for (int i = 0; i < _validationExceptions.Count; i++) {
                        BuildException ve = (BuildException) _validationExceptions[i];
                        if (i == _validationExceptions.Count - 1) {
                            // If this is the last validation error, throw it
                            throw ve;
                        }
                        Log(Level.Info, ve.Message);
                    }
                }

                NameTable taskNameTable = new NameTable();
                XmlNamespaceManager taskNSMgr = new XmlNamespaceManager(taskNameTable);
                taskNSMgr.AddNamespace(string.Empty, xmlNamespace);

                XmlParserContext context = new XmlParserContext(
                    null, taskNSMgr, null, XmlSpace.None);

                XmlTextReader taskSchemaReader = new XmlTextReader(
                    taskXml.OuterXml, XmlNodeType.Element, context);

                // Deserialize from the Task's XML to the schema wrapper object
                _schemaObject = taskSerializer.Deserialize(taskSchemaReader);
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// �����ڵ㽻��λ��
 /// </summary>
 /// <param name="XNodeFirst">��һ���ڵ�</param>
 /// <param name="XNodeLast">�ڶ����ڵ�</param>
 public void InterChange(XmlNode xNodeFirst, XmlNode xNodeLast)
 {
     if (xNodeFirst != null && xNodeLast != null)
     {
         if (xNodeFirst.ParentNode != null && xNodeLast.ParentNode != null)
         {
             xNodeFirst.ParentNode.ReplaceChild(xNodeLast.Clone(), xNodeFirst);
             xNodeLast.ParentNode.ReplaceChild(xNodeFirst.Clone(), xNodeLast);
         }
         else
         {
             _XmlDocument.DocumentElement.ReplaceChild(xNodeLast.Clone(), xNodeFirst);
             _XmlDocument.DocumentElement.ReplaceChild(xNodeFirst.Clone(), xNodeLast);
         }
     }
 }
Exemplo n.º 23
0
 private static XmlNode MakeClone(XmlNode node)
 {
     var clone = node.Clone();
     while (clone.HasChildNodes)
     {
         clone.RemoveChild(clone.FirstChild);
     }
     return clone;
 }
Exemplo n.º 24
0
        /// <summary>
        /// Установить XML-узлу текст, содержащий переносы строк, разбив при необходимости элемент на несколько
        /// </summary>
        /// <param name="xmlNode">XML-узел</param>
        /// <param name="text">Устанавливаемый текст</param>
        /// <param name="textBreak">Обозначение переноса строки в устанавливаемом тексте</param>
        protected void SetNodeTextWithBreak(XmlNode xmlNode, string text, string textBreak)
        {
            XmlNode parNode = xmlNode.ParentNode;
            if (parNode == null)
                throw new Exception("Parent XML element is missing.");

            // отсоединить разбиваемый узел
            parNode.RemoveChild(xmlNode);
            XmlNode cloneNode = xmlNode.Clone();

            if (text == null) text = "";
            string uri = parNode.NamespaceURI;
            int breakLen = textBreak.Length;

            do
            {
                // определение строки текста
                int breakPos = text.IndexOf(textBreak);
                bool haveBreak = breakPos >= 0;
                string line = haveBreak ? text.Substring(0, breakPos) : text;

                // добавление строки текста
                XmlNode newNode = cloneNode.Clone();
                newNode.InnerText = line;
                parNode.AppendChild(newNode);

                // добавление тега переноса строки при необходимости
                if (haveBreak)
                    parNode.AppendChild(xmlDoc.CreateElement(BrPref, BrName, uri));

                // обрезание обработанной части текста
                text = haveBreak && breakPos + breakLen < text.Length ?
                    text.Substring(breakPos + breakLen) : "";
            } while (text != "");
        }
        private void SetTestResults(string test, string result, string reportNo, string block, XmlNode tableNode, XmlNode rowNode, XmlNode insertAfterRow)
        {
            XmlNode rowNodeClone = rowNode.Clone();
            rowNodeClone.SelectSingleNode("descendant::w:r[w:t='" + test + "_result']/w:t", this.m_NameSpaceManager).InnerText = result;
            rowNodeClone.SelectSingleNode("descendant::w:r[w:t='" + test + "_reportno']/w:t", this.m_NameSpaceManager).InnerText = reportNo;
            rowNodeClone.SelectSingleNode("descendant::w:r[w:t='" + test + "_label']/w:t", this.m_NameSpaceManager).InnerText = block;
            tableNode.InsertAfter(rowNodeClone, insertAfterRow);

            //insertAfterRow = rowNodeClone;
        }
Exemplo n.º 26
0
		private static XmlNode GetNodeOverrideable(XmlNode n)
		{
			XmlNode workNode = n.Clone();  //clone as to not mess up the acctual xml document
			XmlNode parrentNode = n.SelectSingleNode("../..");
			XmlNode sourceNode = null;
			if (parrentNode != null && parrentNode["id"] != null)
			{
				sourceNode = GetNodeOverrideable(parrentNode);
				if (sourceNode != null)
				{
					foreach (XmlNode node in sourceNode.ChildNodes)
					{
						if (workNode[node.LocalName] == null && node.LocalName != "versions")
						{
							workNode.AppendChild(node.Clone());
						}
						else if (node.LocalName == "bonus" && workNode["bonus"] != null)
						{
							foreach (XmlNode childNode in node.ChildNodes)
							{
								workNode["bonus"].AppendChild(childNode.Clone());
							}
						}
						else
						{ }
					}
				}
			}

			return workNode;
		}
Exemplo n.º 27
0
		protected void DoCustomElements(TextWriter contentsStream, ICmObject currentObject, XmlNode node)
		{
			string sClass = XmlUtils.GetManditoryAttributeValue(node, "class");
			string sType = XmlUtils.GetOptionalAttributeValue(node, "fieldType", "");
			int[] flids;
			if (!m_customFlids.TryGetValue(sClass + sType, out flids))
			{
				int clid = 0;
				try
				{
					clid = m_mdc.GetClassId(sClass);
				}
				catch
				{
					clid = 0;
				}
				if (clid == 0)
				{
					m_customFlids[sClass + sType] = new int[0];
					return; // we don't know what to do!
				}
				int[] flidsT = m_mdc.GetFields(clid, true, (int)CellarPropertyTypeFilter.All);
				List<int> rgcustom = new List<int>();
				for (int i = 0; i < flidsT.Length; ++i)
				{
					int flid = flidsT[i];
					if (!m_mdc.IsCustom(flid))
						continue;
					CellarPropertyType cpt = (CellarPropertyType)m_mdc.GetFieldType(flid);
					if ((sType == "simplestring" &&
						cpt != CellarPropertyType.Unicode &&
						cpt != CellarPropertyType.String) ||
						(sType == "mlstring" &&
						cpt != CellarPropertyType.MultiString &&
						cpt != CellarPropertyType.MultiUnicode))
					{
						continue;
					}
					rgcustom.Add(flid);
				}
				flids = rgcustom.ToArray();
				m_customFlids[sClass + sType] = flids;
			}
			if (flids.Length == 0)
				return; // nothing to do.

			for (int i = 0; i < flids.Length; ++i)
			{
				int flid = flids[i];
				XmlNode parentNode = node.Clone();
				string labelName = m_mdc.GetFieldLabel(flid);
				string fieldName = m_mdc.GetFieldName(flid);
				if (String.IsNullOrEmpty(labelName))
					labelName = fieldName;
				string sfMarker = m_customSfms[flid];
				ReplaceSubstringInAttr visitorFn = new ReplaceSubstringInAttr("${fieldName}", fieldName);
				ReplaceSubstringInAttr visitorLab = new ReplaceSubstringInAttr("${label}", labelName);
				ReplaceSubstringInAttr visitorSfm = new ReplaceSubstringInAttr("${sfm}", sfMarker);
				foreach (XmlNode xn in parentNode.ChildNodes)
				{
					XmlUtils.VisitAttributes(xn, visitorFn);
					XmlUtils.VisitAttributes(xn, visitorLab);
					XmlUtils.VisitAttributes(xn, visitorSfm);
				}
				if (parentNode.InnerText.Contains("${definition}"))
					FillInCustomFieldDefinition(parentNode, flid);
				if (parentNode.InnerText.Contains("${description}"))
					FillInCustomFieldDescription(parentNode, flid);
				DoChildren(contentsStream, currentObject, parentNode, null);
			}
		}
Exemplo n.º 28
0
 private XmlNode _addDictionary(XmlNode node, Dictionary<string,string> dictValues)
 {
     XmlNode newNode = node.Clone();
     foreach (KeyValuePair<string, string> item in dictValues)
     {
         newNode.AppendChild(_nodify(item.Key,item.Value));
     }
     return newNode;
 }
Exemplo n.º 29
0
 /// <summary>
 /// This should be used when we want to replace a child element in our document with the contents
 /// found in their equivalent child.
 /// </summary>
 internal static void ReplaceOursWithTheirs(XmlNode ourParent, ref XmlNode ours, XmlNode theirs)
 {
     if (ourParent == null)
         throw new ArgumentNullException("ourParent");
     var ourOwnerDocument = ourParent.OwnerDocument;
     if (ourOwnerDocument == null)
         throw new ArgumentException("This method can not be used to replace root nodes.");
     if (theirs == null)
     {
         if (ours != null) // If both are null there is nothing to do, but if theirs is null delete ours
         {
             ourParent.RemoveChild(ours);
             ours = null;
         }
     }
     else
     {
         var theirData = theirs.Clone();
         theirData = ourOwnerDocument.ImportNode(theirData, true);
         if (ours == null)
             ourParent.AppendChild(theirData);
         else
             ourParent.ReplaceChild(theirData, ours);
         ours = theirData;
     }
 }
Exemplo n.º 30
0
        public XmlNode ReadXmlFromNode(XmlNode node)
        {
            if (!runDetails.HasParameters() || node == null)
            {
                return node;
            }
            XmlNode inputNode = node.Clone();
            UpdateAttributes(inputNode);

            return inputNode;
        }
Exemplo n.º 31
0
        /// <summary>
        /// Reads XML node and creates a tree lattice based on it.
        /// </summary>
        /// <param name="modelFile"></param>
        public void processXmlData(XmlNode x1)
        {
            //detach x1 from its parent
            XmlNode xnode = x1.Clone();

            _root = new AbstractTreeLatticeNode(xnode.Name,AbstractTreeNodeType.Element);
            //MessageBox.Show(Root.Name);

            XmlNode x = xnode.SelectSingleNode("text()");
            if (x != null)
            {
                if (!String.IsNullOrEmpty(x.InnerText))
                {
                    _root.addValue(x.InnerText);
                }
            }

            foreach (XmlAttribute at in xnode.Attributes)//read attributes
            {
                AbstractTreeLatticeNode attnode = _root.addChild(at.Name, AbstractTreeNodeType.Attribute, -1);
                attnode.Values.Add(at.Value);
            }

            foreach (XmlNode xn in xnode.ChildNodes)
                if (xn.NodeType != XmlNodeType.Text)
                    processXmlNodes(xn);
        }