/// <summary> /// The method creates a map of file name and a list of the pages that it contains /// and saves it in the global constants. /// </summary> public void createFilePageMap() { Dictionary <string, List <string> > filePageMap = new Dictionary <string, List <string> >(); if (CurrentDCO.ObjectType() == Constants.Batch) { for (int i = 0; i < CurrentDCO.NumOfChildren(); i++) { TDCOLib.IDCO childDCO = CurrentDCO.GetChild(i); if (childDCO.ObjectType() == Constants.Page) { SmartNav.SetRRCurrentDCO(childDCO); string imageName = SmartNav.MetaWord(Constants.SMARTP_AT + "P.ScanSrcPath"); List <string> pages = null; if (filePageMap.ContainsKey(imageName)) { pages = filePageMap[imageName]; } else { pages = new List <string>(); } pages.Add(childDCO.ID); filePageMap[imageName] = pages; ExportCore.WriteInfoLog(" file page map " + imageName + " : " + childDCO.ID + "; size : " + pages.Count); } } Globals.Instance.SetData(Constants.FILE_PAGE_MAP, filePageMap); SmartNav.SetRRCurrentDCO(CurrentDCO); } else { throw new SmartExportException("Unable to create File-Page map, since the associated level is not Batch."); } }
//This method is used to get the innertext if its child node text node or // smart parameter value its child node is under smart param node private String getNodevalue(XmlNode headerNode) { StringBuilder nodeValue = new StringBuilder(Constants.EMPTYSTRING); foreach (XmlNode node in headerNode.ChildNodes) { switch (node.Name) { case Constants.TEXT_NODE_NAME: nodeValue.Append(node.Value.Trim()); break; case Constants.SE_SMART_PARAM_NODE_NAME: nodeValue.Append(smartNav.MetaWord(Constants.SMARTP_AT + node.InnerText.Trim())); ExportCore.WriteDebugLog("smart param value for '" + node.InnerText.Trim() + "' is " + smartNav.MetaWord(Constants.SMARTP_AT + node.InnerText.Trim())); break; default: throw new SmartExportException("Internal error. " + node.Name + " node is not supported inside " + headerNode.Name + " node "); } } return(nodeValue.ToString()); }
public string CountXmlNodes(string parameter) { GenerateMasterXML(); var localSmartObj = new dcSmart.SmartNav(this); try { var xPath = parameter.StartsWith("@") ? localSmartObj.MetaWord(parameter) : parameter; var doc = new XPathDocument(new XmlNodeReader(_masterDoc)); var docNav = doc.CreateNavigator(); return(docNav.Select(xPath).Count.ToString()); } catch (Exception ex) { // It is a best practice to have a try catch in every action to prevent any unexpected errors // from being thrown back to RRS. WriteLog(string.Format(Messages.Exception, ex.Message)); } return("0"); }
public void EvaluateData(XmlNode DataNode) { Stopwatch sw = Stopwatch.StartNew(); string NodeName = ((XmlElement)DataNode).Name; if (DataNode.HasChildNodes) { StringBuilder text = new StringBuilder(Constants.EMPTYSTRING); foreach (XmlNode node in DataNode.ChildNodes) { switch (node.Name) { case Constants.TEXT_NODE_NAME: text.Append(node.Value.Trim()); break; case Constants.SE_TAB_NODE_NAME: text.Append(Constants.TAB_SPACE); break; case Constants.SE_NEW_LINE_NODE_NAME: text.Append(Constants.NEW_LINE); break; case Constants.SE_COMMA_NODE_NAME: text.Append(Constants.COMMA); break; case Constants.SE_VALUE_NODE_NAME: string value = ""; if (isTableColumn) { value = dCODataRetriever.getColumnValueForRow(node.Attributes["select"].Value); text.Append(ExportCore.getExportUtil.escapeString(value, columnSeparator)); } else { value = dCODataRetriever.getDCOValue(node.Attributes["select"].Value).Trim(); text.Append(ExportCore.getExportUtil.escapeString(value)); } break; case Constants.SE_SMART_PARAM_NODE_NAME: text.Append(SmartNav.MetaWord(Constants.SMARTP_AT + node.InnerText.Trim()).Trim()); ExportCore.WriteDebugLog("smart param value for '" + node.InnerText.Trim() + "' is " + text); break; default: ExportCore.WriteInfoLog("Node type [" + node.Name + "] is not supported inside data node. Will be ignored "); break; } } if (text.Length > 0) { if (isHeader) { Globals.Instance.SetData(Constants.CSV_HEADERS, text.ToString()); } else { ExportCore.getExportUtil.addToOutPutList(text.ToString()); } } } ExportCore.WriteDebugLog(" EvaluateData(" + DataNode + ") completed in " + sw.ElapsedMilliseconds + " ms."); sw.Stop(); }
public string SmartParameter(string parameter) { var localSmartObj = new dcSmart.SmartNav(this); return(parameter.StartsWith("@") ? localSmartObj.MetaWord(parameter) : parameter); }