//// 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); } }
/// <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); } }
private void PreRenameNodes() { XmlNodeList formNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@"./a:Objects/a:Form", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(formNodeList, "Page"); XmlNodeList subFormIDNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@"./a:Objects/a:Page//a:SubFormID", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(subFormIDNodeList, "PagePartID"); XmlNodeList timerIntervalNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@"./a:Objects/a:Page/a:Properties/a:TimerInterval", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(timerIntervalNodeList, "TimerUpdate"); XmlNodeList updateOnActivateNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@"./a:Objects/a:Page/a:Properties/a:UpdateOnActivate", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(updateOnActivateNodeList, "RefreshOnActivate"); XmlNodeList passwordTextList = metaDataDocMgt.XmlDocument.SelectNodes(@"./a:Objects//a:Control/a:Properties/a:PasswordText", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode passwordText in passwordTextList) { XmlNode page = passwordText.ParentNode.ParentNode.ParentNode.ParentNode; // Node parent to Controls node int pageId = (int)LogEntryObjectId.NotSpecified; while (page != null) { if (page.Name == "Page") { pageId = Convert.ToInt32(page.Attributes["ID"].Value, CultureInfo.InvariantCulture); page = null; } else { page = page.ParentNode; } } TransformationLog.GenericLogEntry(Resources.PasswordText, LogCategory.Warning, pageId, null); passwordText.ParentNode.AppendChild(XmlUtility.CreateXmlElement("ExtendedDataType", "Masked")); passwordText.ParentNode.RemoveChild(passwordText); } }
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)); } }
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 void PostProcessControlTypeNode() { XmlNodeList partNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@".//a:Control[.//a:Controltype='Part']", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(partNodeList, "Part"); XmlNodeList fieldNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@".//a:Control[.//a:Controltype='Field']", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(fieldNodeList, "Field"); XmlNodeList progressNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@".//a:Control[.//a:Controltype='ProgressControl']", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode node in progressNodeList) { node.FirstChild.AppendChild(XmlUtility.CreateXmlElement("ExtendedDataType", "Ratio")); } XmlUtility.RenameNode(progressNodeList, "Field"); XmlNodeList radioNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@".//a:Control[.//a:Controltype='RadioButton']", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(radioNodeList, "Field"); // Delete Controltype propety XmlUtility.DeleteElements(metaDataDocMgt.XmlDocument, ".//a:Controls//a:Controltype", metaDataDocMgt.XmlNamespaceMgt); // Rename OnForm Triggers to OnPage Triggers XmlNodeList onFormOpenNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@".//a:Triggers//a:OnOpenForm", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(onFormOpenNodeList, "OnOpenPage"); XmlNodeList onFormCloseNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@".//a:Triggers//a:OnCloseForm", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(onFormCloseNodeList, "OnClosePage"); XmlNodeList onFormQuCloseNodeList = metaDataDocMgt.XmlDocument.SelectNodes(@".//a:Triggers//a:OnQueryCloseForm", metaDataDocMgt.XmlNamespaceMgt); XmlUtility.RenameNode(onFormQuCloseNodeList, "OnQueryClosePage"); }
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; } }
/// <summary> /// ?abc? /// </summary> public static void Start() { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; if (metaDataDocMgt.RenumberPagesDoc != null) { XmlNodeList pageNodeList = metaDataDocMgt.RenumberPagesDoc.SelectNodes(@"./a:MovePages/a:Page", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode pageNode in pageNodeList) { String pageID = pageNode.Attributes["ID"].Value; XmlNode nodeToRenumber = metaDataDocMgt.XmlDocument.SelectSingleNode("./a:Objects/a:Page[./@ID='" + pageID + "']", metaDataDocMgt.XmlNamespaceMgt); if (nodeToRenumber != null) { String destinationID = pageNode.Attributes["destinationID"].Value; XmlNode existingNode = metaDataDocMgt.XmlDocument.SelectSingleNode("./a:Objects/a:Page[./@ID='" + destinationID + "']", metaDataDocMgt.XmlNamespaceMgt); nodeToRenumber.Attributes["ID"].Value = destinationID; nodeToRenumber.Attributes["Name"].Value = pageNode.Attributes["destinationName"].Value; if (existingNode != null) { XmlNode goodCaptionML = existingNode.SelectSingleNode("./a:Properties/a:CaptionML", metaDataDocMgt.XmlNamespaceMgt); if (goodCaptionML != null) { XmlNode originalCaptionML = nodeToRenumber.SelectSingleNode("./a:Properties/a:CaptionML", metaDataDocMgt.XmlNamespaceMgt); if (originalCaptionML != null) { originalCaptionML.InnerText = goodCaptionML.InnerText; } else { XmlNode tmpNode = nodeToRenumber.SelectSingleNode("./a:Properties", metaDataDocMgt.XmlNamespaceMgt); if (tmpNode != null) { tmpNode.AppendChild(XmlUtility.CreateXmlElement("CaptionML", goodCaptionML.InnerText)); } } } existingNode.ParentNode.RemoveChild(existingNode); } } } } if (!System.IO.File.Exists(UserSetupManagement.Instance.TranslationFile)) { return; } Console.WriteLine(Resources.ImportingLocalizedStrings); XmlNodeList nodeList = metaDataDocMgt.XmlDocument.SelectNodes(@"./a:Objects/a:Page", metaDataDocMgt.XmlNamespaceMgt); foreach (XmlNode formNode in nodeList) { AddMlCaptions(formNode); if (AddMultiLanguageSupport.FileState == AddMultiLanguageSupport.TranslationFileStates.NotReady) { return; } } }
private static void AddMlCaptions(XmlNode page) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNodeList idList = page.SelectNodes(@".//a:ID", metaDataDocMgt.XmlNamespaceMgt); int destinationID = Convert.ToInt32(page.Attributes["ID"].Value, CultureInfo.InvariantCulture); foreach (XmlNode id in idList) { if (!string.IsNullOrEmpty(id.InnerText)) { try { AddMultiLanguageSupport.PopulateMlStrings(id.ParentNode, destinationID, Convert.ToInt32(id.InnerText, CultureInfo.InvariantCulture)); } catch (Exception ex) { string log = String.Format(CultureInfo.InvariantCulture, Resources.CannotGetMlCaption, "control ", id.InnerText); TransformationLog.GenericLogEntry(log, LogCategory.Warning, destinationID, "Ignore"); TransformationLog.WriteErrorToLogFile(ex, destinationID, LogCategory.Warning); } } } XmlNode pageCaption = page.SelectSingleNode(@"./a:Properties", metaDataDocMgt.XmlNamespaceMgt); if (pageCaption != null) { try { AddMultiLanguageSupport.PopulateMlStrings(pageCaption, destinationID, 0); } catch (Exception ex) { string log = String.Format(CultureInfo.InvariantCulture, Resources.CannotGetMlCaption, "page", string.Empty); TransformationLog.GenericLogEntry(log, LogCategory.Warning, destinationID, "Ignore"); TransformationLog.WriteErrorToLogFile(ex, destinationID, LogCategory.Warning); } } XmlNode code = page.SelectSingleNode(@"./a:Code", metaDataDocMgt.XmlNamespaceMgt); if (code == null) { return; } try { System.Text.RegularExpressions.Regex textVariableExp = new System.Text.RegularExpressions.Regex(@"\@(?<varId>\d+)\s*\:\s*TextConst\s*\'", System.Text.RegularExpressions.RegexOptions.IgnoreCase); if (!textVariableExp.Match(code.InnerText).Success) { return; } string[] codeArr = code.InnerText.Split(new char[] { '\r' }); System.Text.RegularExpressions.Match textVariableMatch; int textVarId; string textVarNewCaption; for (int i = 0; i < codeArr.Length; i++) { textVariableMatch = textVariableExp.Match(codeArr[i]); if (textVariableMatch.Success) { textVarId = Convert.ToInt32(textVariableMatch.Result("${varId}"), CultureInfo.InvariantCulture); textVarNewCaption = AddMultiLanguageSupport.GetCaptionML(destinationID, textVarId, AddMultiLanguageSupport.TranslationType.TextVariable); if (!string.IsNullOrEmpty(textVarNewCaption)) { textVarNewCaption = textVarNewCaption.Replace("'", "''"); codeArr[i] = codeArr[i].Remove(textVariableMatch.Length + textVariableMatch.Index) + textVarNewCaption + "';"; } } } XmlNode codeNode = XmlUtility.CreateXmlElement("Code"); codeNode.AppendChild(XmlUtility.CreateCDataSection(string.Join("\r", codeArr))); code.ParentNode.AppendChild(codeNode); code.ParentNode.RemoveChild(code); } catch (Exception ex) { string log = String.Format(CultureInfo.InvariantCulture, Resources.CannotGetMlCaption, "code", string.Empty); TransformationLog.GenericLogEntry(log, LogCategory.Warning, destinationID, "Ignore"); TransformationLog.WriteErrorToLogFile(ex, destinationID, LogCategory.Warning); } }
private static void RemoveIgnoredForm(String pageID) { MetadataDocumentManagement metaDataDocMgt = MetadataDocumentManagement.Instance; XmlNode formToBeIgnored = metaDataDocMgt.XmlDocument.SelectSingleNode("./a:Objects/a:Form[@ID =" + pageID + "]", metaDataDocMgt.XmlNamespaceMgt); if (formToBeIgnored == null) { return; } XmlNode codeTriggerNode = formToBeIgnored.SelectSingleNode(@".//a:Code", metaDataDocMgt.XmlNamespaceMgt); Boolean restart = true; Int32 startAfter = 0; while (restart) { restart = false; Boolean inProcedure = false; Boolean inCodeBody = false; Int32 beginPosition = 0; SimpleNAVCodeParser sNAVCodeParser = new SimpleNAVCodeParser(); foreach (NormalizedCode normNAVCode in sNAVCodeParser.GenerateNormalisedCode(codeTriggerNode.InnerText)) { if (inProcedure) { if (inCodeBody) { if ((normNAVCode.xPos == 2) && (normNAVCode.Token == "END")) { inProcedure = false; inCodeBody = false; String beginningPart = codeTriggerNode.InnerText.Substring(0, beginPosition + 6); String endPart = codeTriggerNode.InnerText.Substring(normNAVCode.position - 1); codeTriggerNode.RemoveAll(); XmlCDataSection data = metaDataDocMgt.XmlDocument.CreateCDataSection( String.Format(CultureInfo.InvariantCulture, "{0}{1}", beginningPart, endPart)); codeTriggerNode.AppendChild(data); startAfter = beginPosition; beginPosition = 0; inProcedure = false; inCodeBody = false; restart = true; break; } } else { if ((normNAVCode.xPos == 2) && (normNAVCode.Token == "BEGIN")) { inCodeBody = true; beginPosition = normNAVCode.position; } } } else { if ((normNAVCode.position >= startAfter) && (normNAVCode.xPos == 2) && ((normNAVCode.Token == "LOCAL") || (normNAVCode.Token == "PROCEDURE") || (normNAVCode.Token == "EVENT"))) { inProcedure = true; } } } } XmlNode controlNode = formToBeIgnored.SelectSingleNode(@".//a:Controls", metaDataDocMgt.XmlNamespaceMgt); controlNode.ParentNode.ReplaceChild(XmlUtility.CreateXmlElement("Controls", null), controlNode); XmlNode triggerNode = formToBeIgnored.SelectSingleNode(@".//a:Triggers", metaDataDocMgt.XmlNamespaceMgt); triggerNode.ParentNode.ReplaceChild(XmlUtility.CreateXmlElement("Triggers", null), triggerNode); // TransformationLog.IgnoreFormsLog(Convert.ToInt32(pageID.Value, CultureInfo.InvariantCulture)); String logStr = Resources.FormIgnored; TransformationLog.GenericLogEntry(logStr, LogCategory.IgnoreForms, pageID, null); }