/// <summary> /// ?abc? /// </summary> public static void CreateSourceObject() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode formSourceObjectNode = metaDataDocMgt.XmlDocument.CreateNode(XmlNodeType.Element, "SourceObject", metaDataDocMgt.XmlNamespace); XmlNode formPropertyNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties", metaDataDocMgt.XmlNamespaceMgt); if (formPropertyNode != null) { metaDataDocMgt.XmlCurrentFormNode.InsertAfter(formSourceObjectNode, formPropertyNode); } else { metaDataDocMgt.XmlCurrentFormNode.AppendChild(formSourceObjectNode); } XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:SourceTable", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:SourceTableView", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:InsertAllowed", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:ModifyAllowed", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:InsertAllowed", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:DeleteAllowed", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:DelayedInsert", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:MultipleNewLines", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:SourceTableTemporary", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:DataCaptionFields", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); XmlUtility.MoveNode(metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Properties/a:AutoSplitKey", metaDataDocMgt.XmlNamespaceMgt), formSourceObjectNode); }
private static void PageSectionDelegation(XmlNode currentNode) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; foreach (XmlNode section in currentNode.ChildNodes) { switch (section.Name) { case "Properties": MergeSimpleSection(section, metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:" + section.Name, metaDataDocMgt.XmlNamespaceMgt)); break; case "SourceObject": MergeSimpleSection(section, metaDataDocMgt.XmlCurrentFormNode); break; case "Triggers": MergeSimpleSection(section, metaDataDocMgt.XmlCurrentFormNode); break; case "Actions": MergeStructure(section, SectionType.Actions); break; case "Controls": MergeStructure(section, SectionType.Controls); break; case "Code": MergeSimpleSection(section, metaDataDocMgt.XmlCurrentFormNode); break; } } }
/// <summary> /// ?abc? /// </summary> public static void Start() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; if (metaDataDocMgt.DeleteElementsDoc == null) { return; } XmlNodeList pageNodeList = metaDataDocMgt.DeleteElementsDoc.SelectNodes(@"./a:DeletePageElements/a:Page[@ID='" + metaDataDocMgt.GetCurrentPageId + "']", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode pageNode in pageNodeList) { XmlNodeList nodesToBeDeleted = pageNode.SelectNodes(@"./a:Element/@ID", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode nodeToBeDeleted in nodesToBeDeleted) { XmlNode idToBeDeleted = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(".//a:ID[../a:ID='" + nodeToBeDeleted.Value + "']", metaDataDocMgt.XmlNamespaceMgt); if (idToBeDeleted != null) { if (idToBeDeleted.ParentNode.Name == "Properties") { /* TODO Refactor this into XPATh */ idToBeDeleted.ParentNode.ParentNode.ParentNode.RemoveChild(idToBeDeleted.ParentNode.ParentNode); } else { idToBeDeleted.ParentNode.ParentNode.RemoveChild(idToBeDeleted.ParentNode); } } } } }
//// It seems like we don’t need this function anymore. //// /// <summary> //// /// ?abc? //// /// </summary> //// /// <param name="xmlNode">?abc?</param> //// /// <param name="xmlNamespaceMgt">?abc?</param> //// public static void CleanProperties(XmlNode xmlNode, XmlNamespaceManager xmlNamespaceMgt) //// { /////* XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:Caption", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:DataCaptionExpr", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:DataCaptionFields", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:BorderStyle", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:CaptionBar", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:Minimizable", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:Maximizable", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:Sizeable", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:LogWidth", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:LogHeight", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:Width", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:Height", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:XPos", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:YPos", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:BackColor", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:Visible", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:ActiveControlOnOpen", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:MinimizedOnOpen", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:MaximizedOnOpen", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:AutoPosition", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:TableBoxId", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:LookupMode", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:CalcFields", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:SourceTablePlacement", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:SourceTableRecord", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:SaveControlInfo", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:SaveColumnWidths", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:SavePosAndSize", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:UpdateOnActivate", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:DelayedInsert", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:PopulateAllFields", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:Horzgrid", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:VertGrid", xmlNamespaceMgt); //// XmlUtility.DeleteElements(xmlNode.SelectSingleNode(@"./a:Properties", xmlNamespaceMgt), "./a:TimerInterval", xmlNamespaceMgt);*/ //// } /// <summary> /// ?abc? /// </summary> public static void AddDefaultProperties() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; // Add PageType=Card const string PageType = "PageType"; string defaultPageType = "Card"; XmlNode properties = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Properties", metaDataDocMgt.XmlNamespaceMgt); if (properties != null) { if (properties.SelectSingleNode("./a:" + PageType, metaDataDocMgt.XmlNamespaceMgt) == null) { // Only assign default Pagetype for Page objects if (metaDataDocMgt.GetCurrentPageId > 0) { XmlElement element = XmlUtility.CreateXmlElement(PageType, defaultPageType); properties.AppendChild(element); } } } else { string logStr = string.Format( System.Globalization.CultureInfo.InvariantCulture, Resources.CanNotFindNode, "Properties", PageType); TransformationLog.GenericLogEntry(logStr, LogCategory.Error, metaDataDocMgt.GetCurrentPageId); } }
private static void ReSortActions() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode actionNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Actions/a:ActionItems", metaDataDocMgt.XmlNamespaceMgt); if (actionNode != null) { XmlNode currNode = actionNode.SelectSingleNode(@"./a:Properties", metaDataDocMgt.XmlNamespaceMgt); foreach (KeyValuePair <string, ControlType1> control in actionsSequence) { switch (control.Value) { case ControlType1.CommandButton: XmlNode controlNode = actionNode.SelectSingleNode(@"./a:Action[./a:ID='" + control.Key + "']", metaDataDocMgt.XmlNamespaceMgt); if (controlNode != null) { currNode = actionNode.InsertAfter(controlNode.ParentNode.RemoveChild(controlNode), currNode); } break; case ControlType1.MenuButton: controlNode = actionNode.SelectSingleNode(@"./a:ActionGroup[./a:Properties/a:ID='" + control.Key + "']", metaDataDocMgt.XmlNamespaceMgt); if (controlNode != null) { currNode = actionNode.InsertAfter(controlNode.ParentNode.RemoveChild(controlNode), currNode); } break; } } } }
private static Int32 Compare(XmlNode control1, XmlNode control2) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; const Int32 HorzCompareTolerance = 3500; Int32 x1 = Convert.ToInt32(control1.SelectSingleNode("./a:Properties/a:XPos", metaDataDocMgt.XmlNamespaceMgt).InnerText, CultureInfo.InvariantCulture); Int32 y1 = Convert.ToInt32(control1.SelectSingleNode("./a:Properties/a:YPos", metaDataDocMgt.XmlNamespaceMgt).InnerText, CultureInfo.InvariantCulture); Int32 x2 = Convert.ToInt32(control2.SelectSingleNode("./a:Properties/a:XPos", metaDataDocMgt.XmlNamespaceMgt).InnerText, CultureInfo.InvariantCulture); Int32 y2 = Convert.ToInt32(control2.SelectSingleNode("./a:Properties/a:YPos", metaDataDocMgt.XmlNamespaceMgt).InnerText, CultureInfo.InvariantCulture); if (Math.Abs(x1 - x2) < HorzCompareTolerance) /* same column */ { if (y1 == y2) { if (x1 < x2) { return(-1); } if (x1 > x2) { return(1); } if (x1 == x2) { return(0); } } else { if (y1 < y2) { return(-1); } else { return(1); } } } else { if (x1 < x2) { return(-1); } else { return(1); } } return(0); }
private static String GetProperty(XmlNode controlNode, String propertyName) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode propNode = controlNode.SelectSingleNode(@"./a:Properties/a:" + propertyName, metaDataDocMgt.XmlNamespaceMgt); if (propNode == null) { return(null); } return(propNode.LastChild.InnerText); }
/// <summary> /// ?abc? /// </summary> /// <param name="name">?abc?</param> /// <param name="innerText">?abc?</param> /// <returns>?abc?</returns> internal static XmlElement CreateXmlElement(String name, String innerText) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlElement element = metaDataDocMgt.XmlDocument.CreateElement(name, metaDataDocMgt.XmlNamespace); if (innerText != null) { element.InnerText = innerText; } return(element); }
private static void UpdateNewIdNodes() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNodeList nodesToBeDeleted = metaDataDocMgt.XmlCurrentFormNode.SelectNodes(@".//a:NewID", metaDataDocMgt.XmlNamespaceMgt); for (Int32 i = nodesToBeDeleted.Count - 1; i >= 0; i--) { XmlUtility.DeleteElements(nodesToBeDeleted[i].ParentNode, ".//a:ID", metaDataDocMgt.XmlNamespaceMgt); } XmlUtility.RenameNode(nodesToBeDeleted, "ID"); }
private static void ControlParentChildNesting() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNodeList parentControlList = metaDataDocMgt.XmlCurrentFormNode.SelectNodes(@".//a:ParentControl", metaDataDocMgt.XmlNamespaceMgt); for (Int32 i = 0; i < parentControlList.Count; i++) { XmlNode parentNode = parentControlList[i]; Int32 parentID = Convert.ToInt32(parentNode.InnerText, CultureInfo.InvariantCulture); AppendChild(parentNode, parentID); } }
/// <summary> /// Will update InnerText property if element exists. Otherwise will create new Element with InnerText set to "newValue" /// </summary> /// <param name="nodeToUpdate">This node will contain nodeName</param> /// <param name="nodeName">Node name</param> /// <param name="newValue">New Value</param> internal static void UpdateNodeInnerText(XmlNode nodeToUpdate, string nodeName, string newValue) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode node = nodeToUpdate.SelectSingleNode("./a:" + nodeName, metaDataDocMgt.XmlNamespaceMgt); if (node == null) { nodeToUpdate.AppendChild(XmlUtility.CreateXmlElement(nodeName, newValue)); } else { node.InnerText = newValue; } }
/// <summary> /// Should add Style and StyleExpr properties and then remove FontBold and ForeColor /// </summary> private static void AddStyleNode(XmlNodeList propertyNodes, string style) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; foreach (XmlNode node in propertyNodes) { XmlNode styleNode = XmlUtility.CreateXmlElement("Style", style); XmlNode styleExpNode = XmlUtility.CreateXmlElement("StyleExpr", "TRUE"); node.AppendChild(styleNode); node.AppendChild(styleExpNode); XmlUtility.DeleteElements(node, @"./a:FontBold", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.DeleteElements(node, @"./a:ForeColor", metaDataDocMgt.XmlNamespaceMgt); } }
public static void RemoveFormsWithMatrixControls() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNodeList nodeList = metaDataDocMgt.XmlDocument.SelectNodes(@"./a:Objects/a:Form", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode formNode in nodeList) { XmlNode ControlIDNode = formNode.SelectSingleNode(".//a:Control[.//a:Controltype='MatrixBox']", metaDataDocMgt.XmlNamespaceMgt); if (ControlIDNode != null) { RemoveIgnoredForm(formNode.Attributes.GetNamedItem("ID").FirstChild.Value); } } }
/// <summary> /// ?abc? /// </summary> /// <param name="parentNode">?abc?</param> /// <param name="newName">?abc?</param> /// <returns>?abc?</returns> internal static XmlNode InsertNodeWithPropertyChild(XmlNode parentNode, String newName) { if (parentNode == null) { throw new ArgumentNullException("parentNode"); } MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode newNode = metaDataDocMgt.XmlDocument.CreateNode(XmlNodeType.Element, newName, parentNode.NamespaceURI); newNode.AppendChild(metaDataDocMgt.XmlDocument.CreateNode(XmlNodeType.Element, "Properties", parentNode.NamespaceURI)); parentNode.AppendChild(newNode); return(newNode); }
/// <summary> /// ?abc? /// </summary> public static void RemoveIgnoredForms() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; if (metaDataDocMgt.IgnorePagesDoc == null) { return; } XmlNodeList pageIDList = metaDataDocMgt.IgnorePagesDoc.SelectNodes(@"./a:IgnorePages/a:Page/@ID", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode pageID in pageIDList) { RemoveIgnoredForm(pageID.Value); } }
/// <summary> /// ?abc? /// </summary> public static void StartMerging() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; if (metaDataDocMgt.InsertElementsDoc == null) { return; } XmlNodeList pageList = metaDataDocMgt.InsertElementsDoc.SelectNodes(@"./a:TransformPages/a:Page[@ID=" + metaDataDocMgt.GetCurrentPageId + "]", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode page in pageList) { PageSectionDelegation(page); } }
//private static void TempCodeWash(XmlNodeList nodeList, String code, Boolean isCode ) //{ // MetaDataDocumentManagement metaDataDocMgt = MetaDataDocumentManagement.Instance; // foreach (XmlNode node in nodeList) // { // if (isCode) // { // node.RemoveAll(); // XmlCDataSection data = metaDataDocMgt.XmlDocument.CreateCDataSection(code); // node.AppendChild(data); // } // else // node.InnerXml = code; // TransformationLog.GenericLogEntry(metaDataDocMgt.GetCurrentPageID + " : " + XmlUtility.GetNodePath(node) + " node is deleted.", LogCategory.TempCodeWash); // } //} private static void SetEmphasis() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNodeList propertyNodes; propertyNodes = metaDataDocMgt.XmlCurrentFormNode.SelectNodes(@".//a:Properties [./a:FontBold='Yes' and ./a:ForeColor='255']", metaDataDocMgt.XmlNamespaceMgt); AddStyleNode(propertyNodes, "Unfavorable"); propertyNodes = metaDataDocMgt.XmlCurrentFormNode.SelectNodes(@".//a:Properties [./a:FontBold='Yes' and ./a:ForeColor='65280']", metaDataDocMgt.XmlNamespaceMgt); AddStyleNode(propertyNodes, "Favorable"); propertyNodes = metaDataDocMgt.XmlCurrentFormNode.SelectNodes(@".//a:Properties [./a:FontBold='Yes']", metaDataDocMgt.XmlNamespaceMgt); AddStyleNode(propertyNodes, "Strong"); propertyNodes = metaDataDocMgt.XmlCurrentFormNode.SelectNodes(@".//a:Properties [./a:ForeColor='255']", metaDataDocMgt.XmlNamespaceMgt); AddStyleNode(propertyNodes, "Attention"); }
/// <summary> /// Function will return value of element specified in XPath query. /// Function will return default value if node can’t be found. /// You can use String.Empty as default and then validate by String.IsNullOrEmpty. /// Attention! Function will return the first found element’s value if more than one element can be found. /// </summary> /// <param name="node">Node in which search will be perform</param> /// <param name="element">XPath query</param> /// <param name="defaultValue">default value</param> /// <returns>Element value or default value if element’s node not found.</returns> internal static string GetNodeValue(System.Xml.XPath.IXPathNavigable node, String element, String defaultValue) { if (node != null) { // TODO: Throw error if more than one element can be found. MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; System.Xml.XPath.XPathNavigator position = node.CreateNavigator().SelectSingleNode(element, metaDataDocMgt.XmlNamespaceMgt); if (position == null) { return(defaultValue); } return(position.Value); } return(null); }
public static Boolean PageWillBeReplaced(String pageId) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode pageNode = metaDataDocMgt.RenumberPagesDoc.SelectSingleNode(@"./a:MovePages/a:Page[.//@destinationID='" + pageId + "']", metaDataDocMgt.XmlNamespaceMgt); // XmlNode pageNode = metaDataDocMgt.RenumberPagesDoc.SelectSingleNode(@"./a:MovePages/a:Page", metaDataDocMgt.XmlNamespaceMgt); if (pageNode == null) { return(false); } XmlNode nodeToRenumber = metaDataDocMgt.XmlDocument.SelectSingleNode(@"./a:Objects/a:Page[./@ID='" + pageNode.Attributes["ID"].Value + "']", metaDataDocMgt.XmlNamespaceMgt); if (nodeToRenumber == null) { return(false); } return(true); }
private static void InsertIDAsChildInNodeList(XmlNodeList nodeList, String where) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; foreach (XmlNode node in nodeList) { string newId = string.Empty; XmlNode fixedIdNode = node.SelectSingleNode("./a:FixedID", metaDataDocMgt.XmlNamespaceMgt); if (fixedIdNode != null) { newId = fixedIdNode.InnerText; RemoveNodeFromParent(fixedIdNode); } else { if (node.ParentNode.Name.Equals("Part")) { switch (node.SelectSingleNode("./a:PartType", metaDataDocMgt.XmlNamespaceMgt).InnerText) { case "Page": newId = metaDataDocMgt.CalcId(GetProperty(node.ParentNode, "NewID"), node.SelectSingleNode("./a:PagePartID", metaDataDocMgt.XmlNamespaceMgt).InnerText, where).ToString(CultureInfo.InvariantCulture); break; case "System": newId = metaDataDocMgt.CalcId(GetProperty(node.ParentNode, "NewID"), node.SelectSingleNode("./a:SystemPartID", metaDataDocMgt.XmlNamespaceMgt).InnerText, where).ToString(CultureInfo.InvariantCulture); break; case "Chart": newId = metaDataDocMgt.CalcId(GetProperty(node.ParentNode, "NewID"), node.SelectSingleNode("./a:ChartPartID", metaDataDocMgt.XmlNamespaceMgt).InnerText, where).ToString(CultureInfo.InvariantCulture); break; } } else { newId = newId + 0; } //XmlNode partNode = node.SelectSingleNode(@"./a:Properties/a:Visible", metaDataDocMgt.XmlNamespaceMgt); //newId = metaDataDocMgt.GetNewId.ToString(CultureInfo.InvariantCulture); } node.AppendChild(XmlUtility.CreateXmlElement("ID", newId)); } }
public static void RemoveReplacedForms() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; if (metaDataDocMgt.RenumberPagesDoc == null) { return; } XmlNodeList pageIDList = metaDataDocMgt.IgnorePagesDoc.SelectNodes(@"./a:MovePages/a:Page/@destinationID", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode pageID in pageIDList) { if (RenumberPages.PageWillBeReplaced(pageID.Value)) { RemoveIgnoredForm(pageID.Value); } } }
private static void MergeSimpleSection(XmlNode sourceNode, XmlNode destinationNode) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; foreach (XmlNode childNode in sourceNode.ChildNodes) { XmlNode propertyNode = destinationNode.SelectSingleNode("./a:" + childNode.Name, metaDataDocMgt.XmlNamespaceMgt); XmlNode newNode = metaDataDocMgt.XmlDocument.ImportNode(childNode, true); if (propertyNode == null) { destinationNode.AppendChild(newNode); } else { destinationNode.ReplaceChild(newNode, propertyNode); } } }
// private static void DeclareVariables(XmlNodeList triggerNodeList) // { // // for each trigger node // foreach (XmlNode triggerNode in triggerNodeList) // { // try // { // CodeTransformationRules.DeclareVariables(triggerNode); // } // catch (Exception e) // { // throw new CodeTransformationException(Resources.StepCodeTransformation, e); // } // } // } private static void AppendChild(XmlNode parentNode, Int32 parentID) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNodeList idList = metaDataDocMgt.XmlCurrentFormNode.SelectNodes(@".//a:ID", metaDataDocMgt.XmlNamespaceMgt); for (Int32 j = 0; j < idList.Count; j++) { XmlNode idNode = idList[j]; Int32 nodeID = Convert.ToInt32(idNode.InnerText, CultureInfo.InvariantCulture); if (parentID == nodeID) { XmlNode nodeParentProperties = idNode.ParentNode.SelectSingleNode(@"./a:Controltype", metaDataDocMgt.XmlNamespaceMgt); if (nodeParentProperties != null) { if (nodeParentProperties.InnerText == "Label") { XmlNode tmpNode = idNode.ParentNode.SelectSingleNode(@"./a:ParentControl", metaDataDocMgt.XmlNamespaceMgt); if (tmpNode != null) { Int32 labelParentID = Convert.ToInt32(tmpNode.InnerText, CultureInfo.InvariantCulture); AppendChild(parentNode, labelParentID); break; } else { tmpNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Controls", metaDataDocMgt.XmlNamespaceMgt); if (tmpNode != null) { tmpNode.AppendChild(parentNode.ParentNode.ParentNode); } break; } } } idNode.ParentNode.ParentNode.AppendChild(parentNode.ParentNode.ParentNode); break; } } }
/// <summary> /// ?abc? /// </summary> /// <param name="parentNode">?abc?</param> /// <param name="newName">?abc?</param> /// <param name="id">?abc?</param> /// <returns>?abc?</returns> internal static XmlNode InsertNodeWithPropertyChild(XmlNode parentNode, String newName, Int32 id) { if (parentNode == null) { throw new ArgumentNullException("parentNode"); } MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode newNode = metaDataDocMgt.XmlDocument.CreateNode(XmlNodeType.Element, newName, parentNode.NamespaceURI); XmlNode propertyNode = metaDataDocMgt.XmlDocument.CreateNode(XmlNodeType.Element, "Properties", parentNode.NamespaceURI); newNode.AppendChild(propertyNode); parentNode.AppendChild(newNode); XmlNode newID = metaDataDocMgt.XmlDocument.CreateNode(XmlNodeType.Element, "ID", parentNode.NamespaceURI); newID.InnerText = id.ToString(CultureInfo.InvariantCulture); propertyNode.AppendChild(newID); return(newNode); }
/// <summary> /// ?abc? /// </summary> /// <param name="node">?abc?</param> /// <param name="newName">?abc?</param> /// <returns>?abc?</returns> internal static XmlNode GetNodeWithNewName(XmlNode node, String newName) { if (node == null) { throw new ArgumentNullException("node"); } MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode renameNode = metaDataDocMgt.XmlDocument.CreateNode(node.NodeType, newName, node.NamespaceURI); renameNode.InnerXml = node.InnerXml; for (Int32 i = node.Attributes.Count - 1; i >= 0; i--) { if (node.Attributes[i].Name != "xmlns") { renameNode.Attributes.Prepend(node.Attributes[i]); } } return(renameNode); }
private static void AssignImportance(XmlNode pageElement, MetadataDocumentManagement metaDataDocMgt) { if (pageElement.Name == "PromotedField") { String elementID = pageElement.Attributes["ID"].Value; XmlNode idToBeMoved = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Controls//a:Field/a:Properties[./a:ID='" + elementID + "']", metaDataDocMgt.XmlNamespaceMgt); if (idToBeMoved != null) { XmlNode importanceNode = idToBeMoved.SelectSingleNode("./a:Importance", metaDataDocMgt.XmlNamespaceMgt); if (importanceNode != null) { importanceNode.InnerText = "Promoted"; } else { idToBeMoved.AppendChild(XmlUtility.CreateXmlElement("Importance", "Promoted")); } } } if (pageElement.Name == "AdditionalField") { String elementID = pageElement.Attributes["ID"].Value; XmlNode idToBeMoved = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Controls//a:Field/a:Properties[./a:ID='" + elementID + "']", metaDataDocMgt.XmlNamespaceMgt); if (idToBeMoved != null) { XmlNode importanceNode = idToBeMoved.SelectSingleNode("./a:Importance", metaDataDocMgt.XmlNamespaceMgt); if (importanceNode != null) { importanceNode.InnerText = "Additional"; } else { idToBeMoved.AppendChild(XmlUtility.CreateXmlElement("Importance", "Additional")); } } } }
private static void MergeStructure(XmlNode sectionNode, SectionType sectionType) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; if (sectionType == SectionType.Actions) { foreach (XmlNode childNode in sectionNode.ChildNodes) { /* TODO !!! TEMPORARY !!! we should change TransformPages.xml instead! */ XmlNode destinationNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Actions/a:" + childNode.Name, metaDataDocMgt.XmlNamespaceMgt); if (destinationNode == null) { XmlNode actionsNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Actions", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.InsertNodeWithPropertyChild(actionsNode, childNode.Name, metaDataDocMgt.CalcId(null, null, childNode.Name) /*metaDataDocMgt.GetNewId */); destinationNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Actions/a:" + childNode.Name, metaDataDocMgt.XmlNamespaceMgt); } MergeComplexStructure(childNode, destinationNode); } } if (sectionType == SectionType.Controls) { foreach (XmlNode childNode in sectionNode.ChildNodes) { XmlNode destinationNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Controls/a:" + childNode.Name, metaDataDocMgt.XmlNamespaceMgt); if (destinationNode == null) { XmlNode controlsNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Controls", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.InsertNodeWithPropertyChild(controlsNode, childNode.Name, metaDataDocMgt.CalcId(null, null, childNode.Name) /* metaDataDocMgt.GetNewId */); destinationNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode("./a:Controls/a:" + childNode.Name, metaDataDocMgt.XmlNamespaceMgt); } MergeComplexStructure(childNode, destinationNode); } } }
private static void ReSortControls() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode cntrlNode = metaDataDocMgt.XmlCurrentFormNode.SelectSingleNode(@"./a:Controls/a:ContentArea", metaDataDocMgt.XmlNamespaceMgt); XmlNode currCntrlContainer = null; if (cntrlNode != null) { XmlNode currNode = cntrlNode.SelectSingleNode(@"./a:Properties", metaDataDocMgt.XmlNamespaceMgt); foreach (KeyValuePair <string, ControlType1> control in controlsSequence) { XmlNode controlNode; switch (control.Value) { case ControlType1.OptionButton: controlNode = cntrlNode.SelectSingleNode(@"./a:Control[./a:Properties/a:ID='" + control.Key + "']", metaDataDocMgt.XmlNamespaceMgt); if (controlNode == null) { break; } String optionCaptionML = GetProperty(controlNode, "OptionCaptionML"); if (!string.IsNullOrEmpty(optionCaptionML)) { bool breakWork = false; ResortControlsForTrendscape(ref currCntrlContainer, cntrlNode, currNode, controlNode, ref breakWork, optionCaptionML); if (breakWork) { break; } } currCntrlContainer = null; currNode = cntrlNode.InsertAfter(controlNode.ParentNode.RemoveChild(controlNode), currNode); break; case ControlType1.TextBox: case ControlType1.CheckBox: controlNode = cntrlNode.SelectSingleNode(@"./a:Control[./a:Properties/a:ID='" + control.Key + "']", metaDataDocMgt.XmlNamespaceMgt); // to avoid sorting problems with new groups. if (controlNode == null) { XmlNode groupControl = cntrlNode.SelectSingleNode(@"./a:Group[./a:Control/a:Properties/a:ID='" + control.Key + "']", metaDataDocMgt.XmlNamespaceMgt); if (groupControl == null) { break; } if (currNode.Equals(groupControl)) { break; } XmlNode controlForCheck = cntrlNode.SelectSingleNode(@".//a:Control[./a:Properties/a:ID='" + control.Key + "']", metaDataDocMgt.XmlNamespaceMgt); if ((groupControl.ChildNodes.Count > 2) && (!groupControl.ChildNodes[1].Equals(controlForCheck))) // so it's the first control in the group { break; } controlNode = groupControl; } XmlNode removedTempNode = controlNode.ParentNode.RemoveChild(controlNode); currNode = cntrlNode.InsertAfter(removedTempNode, currNode); break; case ControlType1.Frame: case ControlType1.TabControl: case ControlType1.TableBox: controlNode = cntrlNode.SelectSingleNode(@"./a:Group[./a:Properties/a:ID='" + control.Key + "']", metaDataDocMgt.XmlNamespaceMgt); if (controlNode == null) { break; } currCntrlContainer = null; currNode = cntrlNode.InsertAfter(controlNode.ParentNode.RemoveChild(controlNode), currNode); break; case ControlType1.Subform: controlNode = cntrlNode.SelectSingleNode(@"./a:Control[./a:Properties/a:ID='" + control.Key + "']", metaDataDocMgt.XmlNamespaceMgt); if (controlNode == null) { break; } currCntrlContainer = null; currNode = cntrlNode.InsertAfter(controlNode.ParentNode.RemoveChild(controlNode), currNode); break; case ControlType1.Label: if (PageControls.IsObjectHasIndentation(metaDataDocMgt.GetCurrentPageId)) { goto case ControlType1.TableBox; } break; default: break; } } } }
private static void GetSortedControls() { controlsSequence.Clear(); actionsSequence.Clear(); MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNodeList controlList = metaDataDocMgt.XmlCurrentFormNode.SelectNodes(@"./a:Controls/a:Control", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode controlNode in controlList) { string controlID = controlNode.SelectSingleNode(@"./a:Properties/a:ID", metaDataDocMgt.XmlNamespaceMgt).InnerText; switch (controlNode.SelectSingleNode(@"./a:Properties/a:Controltype", metaDataDocMgt.XmlNamespaceMgt).InnerText) { case "Label": controlsSequence.Add(controlID, ControlType1.Label); break; case "TextBox": controlsSequence.Add(controlID, ControlType1.TextBox); break; case "CheckBox": controlsSequence.Add(controlID, ControlType1.CheckBox); break; case "OptionButton": controlsSequence.Add(controlID, ControlType1.OptionButton); break; case "CommandButton": actionsSequence.Add(controlID, ControlType1.CommandButton); break; case "MenuButton": actionsSequence.Add(controlID, ControlType1.MenuButton); break; case "Frame": controlsSequence.Add(controlID, ControlType1.Frame); break; case "Image": controlsSequence.Add(controlID, ControlType1.Image); break; case "PictureBox": controlsSequence.Add(controlID, ControlType1.PictureBox); break; case "Shape": controlsSequence.Add(controlID, ControlType1.Shape); break; case "Indicator": controlsSequence.Add(controlID, ControlType1.Indicator); break; case "TabControl": controlsSequence.Add(controlID, ControlType1.TabControl); break; case "SubForm": controlsSequence.Add(controlID, ControlType1.Subform); break; case "TableBox": controlsSequence.Add(controlID, ControlType1.TableBox); break; case "MatrixBox": controlsSequence.Add(controlID, ControlType1.MatrixBox); break; } } }
private static void ResortControlsForTrendscape( ref XmlNode currCntrlContainer, XmlNode cntrlNode, XmlNode currNode, XmlNode controlNode, ref bool breakWork, String optionCaptionML) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; if (metaDataDocMgt.MoveElementsDoc == null) { return; } StringBuilder queryPromoted = new StringBuilder(); queryPromoted.Append(@"./a:MovePageElements/a:Page[@ID='"); queryPromoted.Append(((int)MovePageElements.NotFormsId.TrendscapeControls).ToString(CultureInfo.InvariantCulture)); queryPromoted.Append("' and @OptionCaptionML ='"); queryPromoted.Append(optionCaptionML.Replace("'", "")); queryPromoted.Append("']"); XmlNode trend = metaDataDocMgt.MoveElementsDoc.SelectSingleNode(queryPromoted.ToString(), metaDataDocMgt.XmlNamespaceMgt); if (trend == null) { return; } if (GetProperty(controlNode, "CaptionML") == null) { XmlNode propNode = controlNode.SelectSingleNode( @"./a:Properties", metaDataDocMgt.XmlNamespaceMgt); string captionMlFromFile = GetAttribute(trend, "CaptionML"); propNode.AppendChild(XmlUtility.CreateXmlElement("CaptionML", captionMlFromFile)); propNode.AppendChild(XmlUtility.CreateXmlElement("TempProperty", "Trendscape")); XmlNode cntrlTypeNode = propNode.SelectSingleNode( @"./a:Controltype", metaDataDocMgt.XmlNamespaceMgt); if ((cntrlTypeNode != null) && (cntrlTypeNode.InnerText == "RadioButton")) { cntrlTypeNode.InnerText = "Field"; } } if (currCntrlContainer == null) { Boolean done = false; XmlNode tempCurrNode = currNode; if (tempCurrNode != null) { while (!done) { if (((tempCurrNode.Name == "Control") && (GetProperty(tempCurrNode, "Controltype") == "Part")) || ((tempCurrNode.Name == "Group") && (GetProperty(tempCurrNode, "GroupType") == "Repeater"))) { if ((tempCurrNode.PreviousSibling != null) && (tempCurrNode.PreviousSibling.Name == "Group") && (GetProperty(tempCurrNode.PreviousSibling, "CaptionML").Contains("ENU=Options"))) { currCntrlContainer = tempCurrNode.PreviousSibling; currCntrlContainer.AppendChild(controlNode.ParentNode.RemoveChild(controlNode)); } else { tempCurrNode = cntrlNode.InsertBefore( PageControls.CreateBand( /*metaDataDocMgt.GetNewId.ToString(CultureInfo.InvariantCulture)*/ metaDataDocMgt.CalcId(null, "Options", "ContentArea").ToString(CultureInfo.InvariantCulture), "ENU=Options"), tempCurrNode); currCntrlContainer = tempCurrNode; currCntrlContainer.AppendChild(controlNode.ParentNode.RemoveChild(controlNode)); } done = true; } if (tempCurrNode != null) { break; } } if (!done) { tempCurrNode = tempCurrNode.PreviousSibling; if (tempCurrNode != null) { if (tempCurrNode.Name == "Properties") { breakWork = true; } } } } if (done) { breakWork = true; } } else if ((currCntrlContainer.Name == "Group") && (GetProperty(currCntrlContainer, "CaptionML").Contains("ENU=Options"))) { currCntrlContainer.AppendChild(controlNode.ParentNode.RemoveChild(controlNode)); breakWork = true; } }