/// <summary> /// Non recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; if (this.placeHolderNameToContentControlXmlMetadataCollection.ContainsKey(tagPlaceHolderValue)) { tagValue = this.GetNodeText(openXmlElementDataContext.DataContext, this.placeHolderNameToContentControlXmlMetadataCollection[tagPlaceHolderValue].ControlTagXPath); content = this.GetNodeText(openXmlElementDataContext.DataContext, this.placeHolderNameToContentControlXmlMetadataCollection[tagPlaceHolderValue].ControlValueXPath); } // Set the tag for the content control if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } // Set text without data binding this.SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, content); }
/// <summary> /// Parses the specified open XML element data context. /// </summary> /// <param name="openXmlElementDataContext">The open XML element data context.</param> /// <param name="tagPlaceHolderValue">The tag place holder value.</param> /// <param name="refTagValue">The ref tag value.</param> /// <param name="refControlValue">The ref control value.</param> /// <returns></returns> private XPathNavigator Parse(OpenXmlElementDataContext openXmlElementDataContext, string tagPlaceHolderValue, ref string refTagValue, ref string refControlValue) { XPathNavigator contentControlsNavigator = (this.GetDataContext() as XmlNode).CreateNavigator(); XPathNodeIterator contentControlsIterator = contentControlsNavigator.SelectDescendants("contentControl", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI, true); while (contentControlsIterator.MoveNext()) { string contentControlTagAttr = contentControlsIterator.Current.GetAttribute("tag", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI); refControlValue = contentControlsIterator.Current.GetAttribute("refControlValue", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI); refTagValue = contentControlsIterator.Current.GetAttribute("refTagValue", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI); if ((!string.IsNullOrEmpty(contentControlTagAttr)) && contentControlTagAttr == tagPlaceHolderValue) { XPathNavigator navigator = (openXmlElementDataContext.DataContext as XmlNode).CreateNavigator(); XPathNodeIterator iterator = navigator.SelectDescendants("field", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI, true); while (iterator.MoveNext()) { string attr = iterator.Current.GetAttribute("contentControlTagREFS", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI); if (!string.IsNullOrEmpty(attr)) { if ((new List <string>(attr.Split(' '))).Contains(contentControlTagAttr)) { return(iterator.Current); } } } break; } } return(null); }
/// <summary> /// Containers the placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void ContainerPlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; switch (tagPlaceHolderValue) { case PlaceholderContainerA: SdtElement parentContainer = openXmlElementDataContext.Element as SdtElement; // Sets the parentContainer from CustomXmlPart if refresh else saves the parentContainer markup to CustomXmlPart this.GetParentContainer(ref parentContainer, tagPlaceHolderValue); base.ContainerPlaceholderFound(placeholderTag, new OpenXmlElementDataContext() { Element = parentContainer, DataContext = openXmlElementDataContext.DataContext }); break; } }
/// <summary> /// Non recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; string refTagValue = string.Empty; string refControlValue = string.Empty; XPathNavigator navigator = Parse(openXmlElementDataContext, tagPlaceHolderValue, ref refTagValue, ref refControlValue); if (navigator != null) { tagValue = navigator.GetAttribute(refTagValue, (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI); content = navigator.GetAttribute(refControlValue, (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI); } // Set the tag for the content control if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } // Set text without data binding this.SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, content); }
/// <summary> /// Recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void RecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string refTagValue = string.Empty; string refControlValue = string.Empty; XPathNavigator navigator = Parse(openXmlElementDataContext, tagPlaceHolderValue, ref refTagValue, ref refControlValue); if (navigator != null) { XPathNodeIterator nodeIterator = navigator.SelectDescendants("field", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI, false); while (nodeIterator.MoveNext()) { XmlDocument e = new XmlDocument(); e.LoadXml(nodeIterator.Current.OuterXml); SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = e.DocumentElement }); } } openXmlElementDataContext.Element.Remove(); }
protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { var row = openXmlElementDataContext.DataContext as Row; var value = GetCell(placeholderTag, row); SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, value); if (placeholderTag == TypePlaceHolder) { if (_lookupPaths.ContainsKey(value)) { var path = _lookupPaths[value]; MakeContentHyperlink(openXmlElementDataContext.Element as SdtElement, path); } } if (placeholderTag == LookupPlaceHolder) { var lookup = value; var element = (openXmlElementDataContext.Element as SdtRun).SdtContentRun.FirstChild; var bookmark = "_" + lookup; _lookupPaths.Add(lookup, bookmark); var bookMarkStart = new BookmarkStart { Id = bookmark, Name = bookmark }; element.FirstChild.InsertBeforeSelf(bookMarkStart); bookMarkStart.InsertAfterSelf(new BookmarkEnd { Id = bookmark }); } }
/// <summary> /// Recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void RecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext, WordprocessingDocument document) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); switch (tagPlaceHolderValue) { case AddressLabelRow: foreach (DummyAddressStickerRow row in openXmlElementDataContext.DataContext as IEnumerable <DummyAddressStickerRow> ) { SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = row }, document); } openXmlElementDataContext.Element.Remove(); break; } }
/// <summary> /// Recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void RecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); if (this.placeHolderNameToContentControlXmlMetadataCollection.ContainsKey(tagPlaceHolderValue)) { XmlNode node = GetNode(openXmlElementDataContext.DataContext, this.placeHolderNameToContentControlXmlMetadataCollection[tagPlaceHolderValue].ControlValueXPath); foreach (XmlNode childNode in node.ChildNodes) { SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = childNode }); } openXmlElementDataContext.Element.Remove(); } }
/// <summary> /// Container placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void ContainerPlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; if (this.placeHolderNameToContentControlXmlMetadataCollection.ContainsKey(tagPlaceHolderValue)) { tagValue = GetNodeText(openXmlElementDataContext.DataContext, this.placeHolderNameToContentControlXmlMetadataCollection[tagPlaceHolderValue].ControlTagXPath); if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } foreach (var v in openXmlElementDataContext.Element.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }); } } }
/// <summary> /// Container placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void ContainerPlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; if (this.placeHolderNameToContentControlXmlMetadataCollection.ContainsKey(tagPlaceHolderValue)) { if (!this.isRefreshable) { tagValue = GetNodeText(openXmlElementDataContext.DataContext, this.placeHolderNameToContentControlXmlMetadataCollection[tagPlaceHolderValue].ControlTagXPath); if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } foreach (var v in openXmlElementDataContext.Element.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }); } } else { SdtElement parentContainer = openXmlElementDataContext.Element as SdtElement; // Sets the parentContainer from CustomXmlPart if refresh else saves the parentContainer markup to CustomXmlPart this.GetParentContainer(ref parentContainer, tagPlaceHolderValue); tagValue = GetNodeText(openXmlElementDataContext.DataContext, this.placeHolderNameToContentControlXmlMetadataCollection[tagPlaceHolderValue].ControlTagXPath); if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(parentContainer, GetFullTagValue(tagPlaceHolderValue, tagValue)); } foreach (var v in parentContainer.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }); } } } }
/// <summary> /// Non recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; // Index is used to build XPath for controls that are bound to collection item int index = -1; // XPath to be used for data binding string xPath = string.Empty; switch (tagPlaceHolderValue) { case PlaceholderNonRecursiveA: tagValue = ((openXmlElementDataContext.DataContext) as Vendor).Id.ToString(); index = (this.GetDataContext() as Order).vendors.IndexOf((openXmlElementDataContext.DataContext) as Vendor); xPath = "/ns0:DocumentRootNode[1]/ns0:DataBoundControlsDataStore[1]/ns0:Data[1]/Order[1]/vendors[1]/Vendor[" + (index + 1).ToString() + "]/Name[1]"; break; case PlaceholderNonRecursiveB: tagValue = ((openXmlElementDataContext.DataContext) as Item).Id.ToString(); index = (this.GetDataContext() as Order).items.IndexOf((openXmlElementDataContext.DataContext) as Item); xPath = "/ns0:DocumentRootNode[1]/ns0:DataBoundControlsDataStore[1]/ns0:Data[1]/Order[1]/items[1]/Item[" + (index + 1).ToString() + "]/Name[1]"; break; case PlaceholderNonRecursiveC: tagValue = (this.GetDataContext() as Order).Id.ToString(); xPath = "/ns0:DocumentRootNode[1]/ns0:DataBoundControlsDataStore[1]/ns0:Data[1]/Order[1]/Name[1]"; break; case PlaceholderNonRecursiveD: tagValue = (this.GetDataContext() as Order).Id.ToString(); xPath = "/ns0:DocumentRootNode[1]/ns0:DataBoundControlsDataStore[1]/ns0:Data[1]/Order[1]/Description[1]"; break; } // Set the tag for the content control if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } // Set the data binding for content control if (!string.IsNullOrEmpty(xPath)) { this.SetDataBinding(xPath, (openXmlElementDataContext.Element) as SdtElement); } }
/// <summary> /// Recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void RecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string refTagValue = string.Empty; string refControlValue = string.Empty; XPathNavigator navigator = Parse(openXmlElementDataContext, tagPlaceHolderValue, ref refTagValue, ref refControlValue); if (navigator != null) { XPathNodeIterator nodeIterator = navigator.SelectDescendants("field", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI, false); while (nodeIterator.MoveNext()) { // Get the Ancestors XPathNodeIterator xIterator = nodeIterator.Current.SelectAncestors("field", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI, false); // Only the first Ancestor of Node if (xIterator.MoveNext()) { // Get the attribute of the first Ancestor string attr = xIterator.Current.GetAttribute("contentControlTagREFS", (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI); if (!string.IsNullOrEmpty(attr)) { // If Ancestor attribute contains the current place holder then only clone element if ((new List <string>(attr.Split(' '))).Contains(tagPlaceHolderValue)) { XmlDocument e = new XmlDocument(); e.LoadXml(nodeIterator.Current.OuterXml); SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = e.DocumentElement }); } } } } } openXmlElementDataContext.Element.Remove(); }
/// <summary> /// Non recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; // Reuse base class code and handle only tags unavailable in base class bool bubblePlaceHolder = true; switch (tagPlaceHolderValue) { case VendorId: bubblePlaceHolder = false; tagValue = ((openXmlElementDataContext.DataContext) as Vendor).Id.ToString(); content = tagValue; break; case VendorName: bubblePlaceHolder = false; tagValue = ((openXmlElementDataContext.DataContext) as Vendor).Id.ToString(); content = ((openXmlElementDataContext.DataContext) as Vendor).Name; break; } if (bubblePlaceHolder) { // Use base class code as tags are already defined in base class. base.NonRecursivePlaceholderFound(placeholderTag, openXmlElementDataContext); } else { // Set the tag for the content control if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } // Set the content for the content control this.SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, content); } }
/// <summary> /// Non recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; switch (tagPlaceHolderValue) { case PlaceholderNonRecursiveA: tagValue = ((openXmlElementDataContext.DataContext) as Vendor).Id.ToString(); content = ((openXmlElementDataContext.DataContext) as Vendor).Name; break; case PlaceholderNonRecursiveB: tagValue = ((openXmlElementDataContext.DataContext) as Item).Id.ToString(); content = ((openXmlElementDataContext.DataContext) as Item).Name; break; case PlaceholderNonRecursiveC: tagValue = ((openXmlElementDataContext.DataContext) as Order).Id.ToString(); content = ((openXmlElementDataContext.DataContext) as Order).Name; break; case PlaceholderNonRecursiveD: tagValue = ((openXmlElementDataContext.DataContext) as Order).Id.ToString(); content = ((openXmlElementDataContext.DataContext) as Order).Description; break; } // Set the tag for the content control if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } // Set text without data binding this.SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, content); }
/// <summary> /// Non recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; if (this.placeHolderNameToContentControlXmlMetadataCollection.ContainsKey(tagPlaceHolderValue)) { tagValue = this.GetNodeText(openXmlElementDataContext.DataContext, this.placeHolderNameToContentControlXmlMetadataCollection[tagPlaceHolderValue].ControlTagXPath); } // Set the tag for the content control if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } int index = 1; XmlNode tempNode = (openXmlElementDataContext.DataContext as XmlNode); while (tempNode.PreviousSibling != null) { index += 1; tempNode = tempNode.PreviousSibling; } string xPath = string.Format(this.placeHolderNameToContentControlXmlMetadataCollection[tagPlaceHolderValue].ControlValueXPath, index); // Set the data binding for content control if (!string.IsNullOrEmpty(xPath)) { this.SetDataBinding(xPath, (openXmlElementDataContext.Element) as SdtElement); } }
/// <summary> /// Recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void RecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); switch (tagPlaceHolderValue) { case PlaceholderRecursiveA: foreach (Vendor testB in ((openXmlElementDataContext.DataContext) as Order).vendors) { SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = testB }); } openXmlElementDataContext.Element.Remove(); break; case PlaceholderRecursiveB: foreach (Item testC in ((openXmlElementDataContext.DataContext) as Order).items) { SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = testC }); } openXmlElementDataContext.Element.Remove(); break; } }
/// <summary> /// Container placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void ContainerPlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; string refTagValue = string.Empty; string refControlValue = string.Empty; XPathNavigator navigator = Parse(openXmlElementDataContext, tagPlaceHolderValue, ref refTagValue, ref refControlValue); if (navigator != null) { tagValue = navigator.GetAttribute(refTagValue, (openXmlElementDataContext.DataContext as XmlNode).NamespaceURI); } if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } foreach (var v in openXmlElementDataContext.Element.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }); } }
/// <summary> /// Recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void RecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); // Reuse base class code and handle only tags unavailable in base class bool bubblePlaceHolder = true; switch (tagPlaceHolderValue) { case VendorDetailRow: bubblePlaceHolder = false; foreach (Vendor testB in ((openXmlElementDataContext.DataContext) as Order).vendors) { SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = testB }); } openXmlElementDataContext.Element.Remove(); break; } if (bubblePlaceHolder) { // Use base class code as tags are already defined in base class. base.RecursivePlaceholderFound(placeholderTag, openXmlElementDataContext); } }
/// <summary> /// Container placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void ContainerPlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; switch (tagPlaceHolderValue) { case PlaceholderContainerA: // As this sample is non-refreshable hence we don't call GetRecursiveTemplateElementForContainer method( Sets the parentContainer from CustomXmlPart if refresh else saves the parentContainer markup to CustomXmlPart) tagValue = (openXmlElementDataContext.DataContext as Order).Id.ToString(); if (!string.IsNullOrEmpty(tagValue)) { this.SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } foreach (var v in openXmlElementDataContext.Element.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }); } break; } }
protected override void ContainerPlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; switch (tagPlaceHolderValue) { case DocumentPlaceHolders.PlaceholderContainerA: tagValue = openXmlElementDataContext.DataContext.Hit.Id.ToString(); if (!string.IsNullOrEmpty(tagValue)) { SetTagValue(openXmlElementDataContext.Element as SdtElement, GetFullTagValue(tagPlaceHolderValue, tagValue)); } foreach (var v in openXmlElementDataContext.Element.Elements()) { SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }); } break; } }
protected override void IgnorePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { throw new NotImplementedException(); }
/// <summary> /// Recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void RecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext, WordprocessingDocument document) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue; string tagGuidPart; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); switch (tagPlaceHolderValue) { case RGReportRow: foreach (var row in ((RGReport)(openXmlElementDataContext.DataContext)).RGReportRows) { CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = row }, document); } openXmlElementDataContext.Element.Remove(); break; case IsotopeCollection: case AreaCollection: foreach (var pair in ((RGReport)(openXmlElementDataContext.DataContext)).EnergyAreas) { CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = pair }, document); } openXmlElementDataContext.Element.Remove(); break; case ExposedIsotopeCollection: case ExposedAreaCollection: foreach (var pair in ((RGReport)(openXmlElementDataContext.DataContext)).ExposedEnergyAreas) { CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = pair }, document); } openXmlElementDataContext.Element.Remove(); break; case RetakeIsotopeCollection: case RetakeAreaCollection: foreach (var pair in ((RGReport)(openXmlElementDataContext.DataContext)).RetakeEnergyAreas) { CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = pair }, document); } openXmlElementDataContext.Element.Remove(); break; } }
protected override void ContainerPlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext, WordprocessingDocument document) { throw new NotImplementedException(); }
/// <summary> /// Picture container placeholder found. /// </summary> /// <param name="placeholderTag">The picture containerplaceholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void PictureContainerPlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } var tagPlaceHolderValue = string.Empty; var tagGuidPart = string.Empty; DocumentGenerator.GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; // Reuse base class code and handle only tags unavailable in base class bool bubblePlaceHolder = true; switch (tagPlaceHolderValue) { case BuildState: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildState; switch (tagValue.ToUpper()) { case "SUCCEEDED": content = @"Graphics\Succeeded.JPG"; break; case "PARTIALLYSUCCEEDED": content = @"Graphics\PartiallySucceeded.PNG"; break; case "FAILED": content = @"Graphics\Failed.JPG"; break; case "STOPPED": content = @"Graphics\Stopped.PNG"; break; default: content = @"Graphics\NotStarted.JPG"; break; } break; case BuildRetainIndefinitely: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildRetainIndefinitely; switch (tagValue.ToUpper()) { case "TRUE": content = @"Graphics\Lock.PNG"; break; case "FALSE": content = @"Graphics\Unlock.PNG"; break; } break; case CheckInInformationImg: bubblePlaceHolder = false; content = @"Graphics\Changeset.PNG"; break; case TestResultDetailsImage: bubblePlaceHolder = false; content = @"Graphics\TestSuite.Png"; break; } if (bubblePlaceHolder) { // Use base class code as tags are already defined in base class. // base. this.NonRecursivePlaceholderFound(placeholderTag, openXmlElementDataContext); } else { // Set the tag for the content control if (!string.IsNullOrEmpty(tagValue)) { DocumentGenerator.SetTagValue(openXmlElementDataContext.Element as SdtElement, DocumentGenerator.GetFullTagValue(tagPlaceHolderValue, tagValue)); } // Set the content for the content control DocumentGenerator.SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, content); } }
/// <summary> /// Non recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext, WordprocessingDocument document) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue; string tagGuidPart; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); var content = string.Empty; if (openXmlElementDataContext.DataContext is RGReport) { var row = openXmlElementDataContext.DataContext as RGReport; switch (tagPlaceHolderValue) { case FPNo: content = row.FixedPattern.FPNo; break; case CustomerName: content = row.FixedPattern.Customer.CustomerName; break; case ReportNo: content = row.ReportNo; break; case Coverage: content = row.Coverage.CoverageName; break; case ProcedureRef: content = row.ProcedureRef; break; case Source: content = row.Source; break; case SourceSize: content = row.SourceSize; break; case Strength: content = row.Strength; break; case Description: content = row.FixedPattern.Description; break; case Specification: content = row.Specifications; break; case DrawingNo: content = row.DrawingNo; break; case Viewing: content = row.Viewing; break; case LeadScreen: content = row.LeadScreen; break; case HeatNo: content = row.HeatNo; break; case Date: content = row.ReportDate.ToString("dd/MM/yyyy"); break; case Film: content = row.Film; break; case RTNo: content = row.RTNo; break; case DateOfTest: content = row.DateOfTest.ToString("dd/MM/yyyy"); break; case Evaluation: content = row.EvaluationAsPer; break; case Acceptance: content = row.AcceptanceAsPer; break; case TotalArea: content = row.TotalArea; break; case TotalFilmCount: content = row.TotalFilmCount; break; case ExposedTotalArea: content = row.ExposedTotalArea; break; case RetakeTotalArea: content = row.RetakeTotalArea; break; case Result: content = row.Status.Status; break; case Logo: //get the company logo var logo = row.getCompanyLogo(); SetLogo(openXmlElementDataContext.Element as SdtElement, logo, document); break; case ReportTypeNo: content = row.ReportTypeAndNo; break; } } else if (openXmlElementDataContext.DataContext is RGReportRow) { var reportRow = openXmlElementDataContext.DataContext as RGReportRow; switch (tagPlaceHolderValue) { case SlNo: content = reportRow.SlNo.ToString(); break; case Location: content = reportRow.Location; break; case Segment: content = reportRow.Segment; break; case LocationSegment: content = reportRow.LocationAndSegment; break; case Thickness: content = reportRow.ThicknessRange; break; case SFD: content = reportRow.SFD.ToString(); break; case Designation: content = reportRow.Designation; break; case Sensitivity: content = reportRow.Sensitivity; break; case Density: content = reportRow.Density; break; case FilmSize: content = reportRow.FilmSizeWithCount; break; case Observation: content = reportRow.Observations; break; case Finding: content = reportRow.Findings; break; case Classification: content = reportRow.Classifications; break; case Remarks: content = reportRow.RemarkText; break; case Technique: content = reportRow.Technique; break; } } else if (openXmlElementDataContext.DataContext is KeyValuePair <String, float> ) { var keyvalue = (KeyValuePair <String, float>)openXmlElementDataContext.DataContext; switch (tagPlaceHolderValue) { case Isotope: content = keyvalue.Key; break; case Area: content = keyvalue.Value.ToString(); break; } } if (tagPlaceHolderValue != Logo) { // Set the content for the content control this.SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, content); } }
protected override void RecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue; string tagGuidPart; DocumentGenerator.GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); // Reuse base class code and handle only tags unavailable in base class bool bubblePlaceHolder = true; switch (tagPlaceHolderValue) { case BuildConfigurationSolutionContentControlRow: bubblePlaceHolder = false; foreach (BuildConfigurationSolution bcs in (openXmlElementDataContext.DataContext as BuildDetail).BuildConfigurationSolutions) { // SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = bcs }); } openXmlElementDataContext.Element.Remove(); break; case BuildConfigurationContentControlRow: bubblePlaceHolder = false; foreach (BuildConfiguration bc in (openXmlElementDataContext.DataContext as BuildDetail).BuildConfigurations) { // SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = bc }); } openXmlElementDataContext.Element.Remove(); break; case ChangesetContentControlRow: bubblePlaceHolder = false; foreach (Changeset cs in (openXmlElementDataContext.DataContext as BuildDetail).Changesets) { // SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = cs }); } openXmlElementDataContext.Element.Remove(); break; case ChangesetChangeContentControlRow: bubblePlaceHolder = false; foreach (ChangesetChangeDetail ccd in (openXmlElementDataContext.DataContext as BuildDetail).ChangesetChangeDetails) { // SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = ccd }); } openXmlElementDataContext.Element.Remove(); break; case ChangesetChangeServerPaths: bubblePlaceHolder = false; foreach (var ccsp in (openXmlElementDataContext.DataContext as ChangesetChangeDetail).ChangesetChangeServerPaths) { // SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = ccsp }); } openXmlElementDataContext.Element.Remove(); break; case WorkItemContentControlRow: bubblePlaceHolder = false; foreach (WorkItem wi in (openXmlElementDataContext.DataContext as BuildDetail).WorkItems) { // SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = wi }); } openXmlElementDataContext.Element.Remove(); break; case TestResultPassedItemDetailContentControlRow: bubblePlaceHolder = false; foreach (TestResultPassedItem trpi in (openXmlElementDataContext.DataContext as BuildDetail).TestResultPassedItems) { // SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = trpi }); } openXmlElementDataContext.Element.Remove(); break; case TestResultFailedItemDetailContentControlRow: bubblePlaceHolder = false; foreach (TestResultFailedItem trfi in (openXmlElementDataContext.DataContext as BuildDetail).TestResultFailedItems) { // SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = trfi }); } openXmlElementDataContext.Element.Remove(); break; case TestResultInconclusiveItemDetailContentControlRow: bubblePlaceHolder = false; foreach (TestResultInconclusiveItem trii in (openXmlElementDataContext.DataContext as BuildDetail).TestResultInconclusiveItems) { // SdtElement clonedElement = this.CloneElementAndSetContentInPlaceholders(new OpenXmlElementDataContext() { Element = openXmlElementDataContext.Element, DataContext = trii }); } openXmlElementDataContext.Element.Remove(); break; } if (bubblePlaceHolder) { // Use base class code as tags are already defined in base class. // base. this.RecursivePlaceholderFound(placeholderTag, openXmlElementDataContext); } }
protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } var tagPlaceHolderValue = string.Empty; var tagGuidPart = string.Empty; DocumentGenerator.GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; // Reuse base class code and handle only tags unavailable in base class bool bubblePlaceHolder = true; switch (tagPlaceHolderValue) { case DocumentCreatedOn: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).DocumentDetail.CreatedOn; content = (openXmlElementDataContext.DataContext as BuildDetail).DocumentDetail.CreatedOn; break; case DocumentCreatedBy: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).DocumentDetail.CreatedBy; content = (openXmlElementDataContext.DataContext as BuildDetail).DocumentDetail.CreatedBy; break; case BuildNumber: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildNumber; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildNumber; break; case BuildReason: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildReason; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildReason; break; case BuildQuality: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildQuality; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildQuality; break; case BuildRequestedBy: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildRequestedBy; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildRequestedBy; break; case BuildDefinitionName: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildDefinition; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildDefinition; break; case BuildTeamProject: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildTeamProject; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildTeamProject; break; case BuildTotalExecutionTimeInSeconds: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildTotalExecutionTimeInSeconds; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildTotalExecutionTimeInSeconds; break; case BuildController: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildController; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildController; break; case BuildUri: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildUri.ToString(); content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildUri.ToString(); break; case BuildSourceGetVersion: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildSourceGetVersion; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildSourceGetVersion; break; case BuildShelvesetName: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildShelvesetName; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildShelvesetName; break; case BuildLabelName: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLabelName; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLabelName; break; case BuildLogLocation: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLogLocation; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLogLocation; break; case BuildDropLocation: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildDropLocation; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildDropLocation; break; case BuildLastModifiedBy: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLastChangedBy; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLastChangedBy; break; case BuildLastModifiedOn: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLastChangedOn; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLastChangedOn; break; case BuildLastModifiedNoOfDaysAgo: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLastModifiedNoOfDaysAgo; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildLastModifiedNoOfDaysAgo; break; case BuildCompletedNoOfDaysAgo: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildCompletedNoOfDaysAgo; content = (openXmlElementDataContext.DataContext as BuildDetail).Build.BuildCompletedNoOfDaysAgo; break; case BuildRootNodeSolutionServerPath: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildConfigurationSolution).BuildRootNodeSolutionServerPath; content = (openXmlElementDataContext.DataContext as BuildConfigurationSolution).BuildRootNodeSolutionServerPath; break; case BuildRootNodeErrorCount: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildConfigurationSolution).BuildRootNodeErrorCount; content = (openXmlElementDataContext.DataContext as BuildConfigurationSolution).BuildRootNodeErrorCount; break; case BuildRootNodeWarningCount: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildConfigurationSolution).BuildRootNodeWarningCount; content = (openXmlElementDataContext.DataContext as BuildConfigurationSolution).BuildRootNodeWarningCount; break; case BuildRootNodeLogFile: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildConfigurationSolution).BuildRootNodeLogFile; content = (openXmlElementDataContext.DataContext as BuildConfigurationSolution).BuildRootNodeLogFile; break; case BuildPlatform: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildConfiguration).BuildConfigPlatform; content = (openXmlElementDataContext.DataContext as BuildConfiguration).BuildConfigPlatform; break; case BuildFlavor: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildConfiguration).BuildConfigFlavor; content = (openXmlElementDataContext.DataContext as BuildConfiguration).BuildConfigFlavor; break; case BuildConfigTotalErrors: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildConfiguration).BuildConfigTotalErrors; content = (openXmlElementDataContext.DataContext as BuildConfiguration).BuildConfigTotalErrors; break; case BuildConfigTotalWarnings: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildConfiguration).BuildConfigTotalWarnings; content = (openXmlElementDataContext.DataContext as BuildConfiguration).BuildConfigTotalWarnings; break; case ChangesetId: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as Changeset).ChangesetId; content = (openXmlElementDataContext.DataContext as Changeset).ChangesetId; break; case ChangesetComment: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as Changeset).ChangesetComment; content = (openXmlElementDataContext.DataContext as Changeset).ChangesetComment; break; case ChangesetCommittedBy: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as Changeset).ChangesetCommittedBy; content = (openXmlElementDataContext.DataContext as Changeset).ChangesetCommittedBy; break; case ChangesetCommittedOn: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as Changeset).ChangesetCommittedOn; content = (openXmlElementDataContext.DataContext as Changeset).ChangesetCommittedOn; break; case ChangesetTotalCount: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).ChangesetTotalCount; content = (openXmlElementDataContext.DataContext as BuildDetail).ChangesetTotalCount; break; case ChangesetChangeId: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as ChangesetChangeDetail).ChangesetChangeId; content = (openXmlElementDataContext.DataContext as ChangesetChangeDetail).ChangesetChangeId; break; case ChangesetChangeServerPath: bubblePlaceHolder = false; tagValue = openXmlElementDataContext.DataContext as string; content = openXmlElementDataContext.DataContext as string; break; case WorkItemId: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as WorkItem).WorkItemId; content = (openXmlElementDataContext.DataContext as WorkItem).WorkItemId; break; case WorkItemTitle: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as WorkItem).WorkItemTitle; content = (openXmlElementDataContext.DataContext as WorkItem).WorkItemTitle; break; case WorkItemType: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as WorkItem).WorkItemType; content = (openXmlElementDataContext.DataContext as WorkItem).WorkItemType; break; case WorkItemState: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as WorkItem).WorkItemState; content = (openXmlElementDataContext.DataContext as WorkItem).WorkItemState; break; case WorkItemAssignedTo: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as WorkItem).WorkItemAssignedTo; content = (openXmlElementDataContext.DataContext as WorkItem).WorkItemAssignedTo; break; case WorkItemIteration: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as WorkItem).WorkItemIterationPath; content = (openXmlElementDataContext.DataContext as WorkItem).WorkItemIterationPath; break; case WorkItemAreaPath: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as WorkItem).WorkItemAreaPath; content = (openXmlElementDataContext.DataContext as WorkItem).WorkItemAreaPath; break; case WorkItemIntroduction: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).WorkItemIntroduction; content = (openXmlElementDataContext.DataContext as BuildDetail).WorkItemIntroduction; break; case TestResultId: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultId; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultId; break; case TestResultTitle: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTitle; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTitle; break; case TestResultStatus: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultStatus; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultStatus; break; case TestResultTotalTest: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTest; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTest; break; case TestResultTotalTestCompleted: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestCompleted; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestCompleted; break; case TestResultTotalTestPassed: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestPassed; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestPassed; break; case TestResultTotalTestFailed: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestFailed; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestFailed; break; case TestResultTotalTestPassRate: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestPassRate; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestPassRate; break; case TestResultTotalTestInconclusive: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestInconclusive; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultTotalTestInconclusive; break; case TestResultIsAutomated: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultIsAutomated; content = (openXmlElementDataContext.DataContext as BuildDetail).TestResult.TestResultIsAutomated; break; case TestResultPassedListTitle: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as TestResultPassedItem).TestResultPassedListTitle; content = (openXmlElementDataContext.DataContext as TestResultPassedItem).TestResultPassedListTitle; break; case TestResultPassedListStatus: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as TestResultPassedItem).TestResultPassedListStatus; content = (openXmlElementDataContext.DataContext as TestResultPassedItem).TestResultPassedListStatus; break; case TestResultFailedListTitle: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as TestResultFailedItem).TestResultFailedListTitle; content = (openXmlElementDataContext.DataContext as TestResultFailedItem).TestResultFailedListTitle; break; case TestResultFailedListReason: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as TestResultFailedItem).TestResultFailedListReason; content = (openXmlElementDataContext.DataContext as TestResultFailedItem).TestResultFailedListReason; break; case TestResultInconclusiveListTitle: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as TestResultInconclusiveItem).TestResultInconclusiveListTitle; content = (openXmlElementDataContext.DataContext as TestResultInconclusiveItem).TestResultInconclusiveListTitle; break; case TestResultInconclusiveListStatus: bubblePlaceHolder = false; tagValue = (openXmlElementDataContext.DataContext as TestResultInconclusiveItem).TestResultInconclusiveListStatus; content = (openXmlElementDataContext.DataContext as TestResultInconclusiveItem).TestResultInconclusiveListStatus; break; } if (bubblePlaceHolder) { // Use base class code as tags are already defined in base class. // base. this.NonRecursivePlaceholderFound(placeholderTag, openXmlElementDataContext); } else { // Set the tag for the content control if (!string.IsNullOrEmpty(tagValue)) { DocumentGenerator.SetTagValue(openXmlElementDataContext.Element as SdtElement, DocumentGenerator.GetFullTagValue(tagPlaceHolderValue, tagValue)); } // Set the content for the content control DocumentGenerator.SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, content); } }
/// <summary> /// Non recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext, WordprocessingDocument document) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; var reportRow = openXmlElementDataContext.DataContext as DummyAddressStickerRow; if (reportRow != null) { if (reportRow.AddressLabelCol1 != null) { switch (tagPlaceHolderValue) { case AddressStickerCol1: foreach (var v in openXmlElementDataContext.Element.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }, document); } break; case RTNo1: content = reportRow.RTNo; break; case Location1: content = reportRow.AddressLabelCol1.Location; break; case HeatNo1: content = reportRow.HeatNo; break; case Designation1: content = reportRow.AddressLabelCol1.Designation; break; case Thickness1: content = reportRow.AddressLabelCol1.Thickness.ToString(); break; case Density1: content = reportRow.AddressLabelCol1.Density; break; case Energy1: content = reportRow.AddressLabelCol1.EnergyName; break; case Sensitivity1: content = reportRow.AddressLabelCol1.Sensitivity; break; case LocationOnly1: content = reportRow.AddressLabelCol1.Location; break; case Segment1: content = reportRow.AddressLabelCol1.Segment; break; case ThicknessRange1: content = reportRow.AddressLabelCol1.ThicknessRange; break; case FilmSize1: content = reportRow.AddressLabelCol1.FilmSizeString; break; } } else { if (placeholderTag == AddressStickerCol1) { content = " "; } } if (reportRow.AddressLabelCol2 != null) { switch (placeholderTag) { case AddressStickerCol2: foreach (var v in openXmlElementDataContext.Element.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }, document); } break; case RTNo2: content = reportRow.RTNo; break; case Location2: content = reportRow.AddressLabelCol2.Location; break; case HeatNo2: content = reportRow.HeatNo; break; case Designation2: content = reportRow.AddressLabelCol2.Designation; break; case Thickness2: content = reportRow.AddressLabelCol2.Thickness.ToString(); break; case Density2: content = reportRow.AddressLabelCol2.Density; break; case Energy2: content = reportRow.AddressLabelCol2.EnergyName; break; case Sensitivity2: content = reportRow.AddressLabelCol2.Sensitivity; break; case LocationOnly2: content = reportRow.AddressLabelCol2.Location; break; case Segment2: content = reportRow.AddressLabelCol2.Segment; break; case ThicknessRange2: content = reportRow.AddressLabelCol2.ThicknessRange; break; case FilmSize2: content = reportRow.AddressLabelCol2.FilmSizeString; break; } } else { if (placeholderTag == AddressStickerCol2) { content = " "; } } if (reportRow.AddressLabelCol3 != null) { switch (placeholderTag) { case AddressStickerCol3: foreach (var v in openXmlElementDataContext.Element.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }, document); } break; case RTNo3: content = reportRow.RTNo; break; case Location3: content = reportRow.AddressLabelCol3.Location; break; case Segment3: content = reportRow.AddressLabelCol3.Segment; break; case FilmSize3: content = reportRow.AddressLabelCol3.FilmSizeString; break; } } else { if (placeholderTag == AddressStickerCol3) { content = " "; } } } // Set the content for the content control if (content != "") { this.SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, content); } }
/// <summary> /// Non recursive placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void NonRecursivePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext, WordprocessingDocument document) { if (openXmlElementDataContext == null || openXmlElementDataContext.Element == null || openXmlElementDataContext.DataContext == null) { return; } string tagPlaceHolderValue = string.Empty; string tagGuidPart = string.Empty; GetTagValue(openXmlElementDataContext.Element as SdtElement, out tagPlaceHolderValue, out tagGuidPart); string tagValue = string.Empty; string content = string.Empty; var reportRow = openXmlElementDataContext.DataContext as AddressStickerRow; if (reportRow != null) { if (reportRow.AddressLabelCol1 != null) { switch (tagPlaceHolderValue) { case AddressStickerCol1: foreach (var v in openXmlElementDataContext.Element.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }, document); } break; case CustomerName1: content = reportRow.AddressLabelCol1.RGReport.FixedPattern.Customer.CustomerName; break; case City1: content = reportRow.AddressLabelCol1.RGReport.FixedPattern.Customer.Address; break; case EndCustomerName1: content = reportRow.AddressLabelCol1.RGReport.EndCustomerName; break; case Description1: content = reportRow.AddressLabelCol1.RGReport.FixedPattern.Description; break; case RTNo1: content = reportRow.AddressLabelCol1.RGReport.RTNo; break; case Location1: content = reportRow.AddressLabelCol1.LocationAndSegment; break; case HeatNo1: content = reportRow.AddressLabelCol1.RGReport.HeatNo; break; case Designation1: content = reportRow.AddressLabelCol1.Designation; break; case Thickness1: content = reportRow.AddressLabelCol1.Thickness.ToString(); break; case Density1: content = reportRow.AddressLabelCol1.Density; break; case Energy1: content = reportRow.AddressLabelCol1.Energy.Name; break; case Sensitivity1: content = reportRow.AddressLabelCol1.Sensitivity; break; case Technique1: content = reportRow.AddressLabelCol1.Technique; break; case DateOfTest1: content = reportRow.AddressLabelCol1.RGReport.DateOfTest.ToString("dd-MM-yyyy"); break; case Specification1: content = reportRow.AddressLabelCol1.RGReport.Specifications; break; case LocationOnly1: content = reportRow.AddressLabelCol1.Location; break; case Segment1: content = reportRow.AddressLabelCol1.Segment; break; case ThicknessRange1: content = reportRow.AddressLabelCol1.ThicknessRange; break; } } else { if (placeholderTag == AddressStickerCol1) { content = " "; } } if (reportRow.AddressLabelCol2 != null) { switch (placeholderTag) { case AddressStickerCol2: foreach (var v in openXmlElementDataContext.Element.Elements()) { this.SetContentInPlaceholders(new OpenXmlElementDataContext() { Element = v, DataContext = openXmlElementDataContext.DataContext }, document); } break; case CustomerName2: content = reportRow.AddressLabelCol2.RGReport.FixedPattern.Customer.CustomerName; break; case City2: content = reportRow.AddressLabelCol2.RGReport.FixedPattern.Customer.Address; break; case EndCustomerName2: content = reportRow.AddressLabelCol2.RGReport.EndCustomerName; break; case Description2: content = reportRow.AddressLabelCol2.RGReport.FixedPattern.Description; break; case RTNo2: content = reportRow.AddressLabelCol2.RGReport.RTNo; break; case Location2: content = reportRow.AddressLabelCol2.LocationAndSegment; break; case HeatNo2: content = reportRow.AddressLabelCol2.RGReport.HeatNo; break; case Designation2: content = reportRow.AddressLabelCol2.Designation; break; case Thickness2: content = reportRow.AddressLabelCol2.Thickness.ToString(); break; case Density2: content = reportRow.AddressLabelCol2.Density; break; case Energy2: content = reportRow.AddressLabelCol2.Energy.Name; break; case Sensitivity2: content = reportRow.AddressLabelCol2.Sensitivity; break; case Technique2: content = reportRow.AddressLabelCol2.Technique; break; case DateOfTest2: content = reportRow.AddressLabelCol2.RGReport.DateOfTest.ToString("dd-MM-yyyy"); break; case Specification2: content = reportRow.AddressLabelCol2.RGReport.Specifications; break; case LocationOnly2: content = reportRow.AddressLabelCol2.Location; break; case Segment2: content = reportRow.AddressLabelCol2.Segment; break; case ThicknessRange2: content = reportRow.AddressLabelCol2.ThicknessRange; break; } } else { if (placeholderTag == AddressStickerCol2) { content = " "; } } } // Set the content for the content control if (content != "") { this.SetContentOfContentControl(openXmlElementDataContext.Element as SdtElement, content); } }
/// <summary> /// Ignore placeholder found. /// </summary> /// <param name="placeholderTag">The placeholder tag.</param> /// <param name="openXmlElementDataContext">The open XML element data context.</param> protected override void IgnorePlaceholderFound(string placeholderTag, OpenXmlElementDataContext openXmlElementDataContext) { }