示例#1
0
        ///       <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.");
            }
        }
示例#2
0
 public bool Parse()
 {
     try
     {
         XmlDocument templateXML = new XmlDocument();
         templateXML.Load(TemplateFilePath);
         ExportCore.WriteInfoLog("template file :" + TemplateFilePath);
         this.NameSpcManager = new XmlNamespaceManager(templateXML.NameTable);
         this.NameSpcManager.AddNamespace(Constants.SE_NAMESPACE_NAME, Constants.SE_NAMESPACE_URL);
         this.TemplateRoot = templateXML.DocumentElement;
         if (this.TemplateRoot.HasChildNodes)
         {
             this.HasMoreNodes = true;
             this.CurrentNode  = TemplateRoot.FirstChild;
         }
         templateContents = System.IO.File.ReadAllLines(TemplateFilePath);
     }
     catch (Exception exp)
     {
         ExportCore.WriteErrorLog("Error while parsing the template file, terminating. Details: " + exp.Message);
         throw new SmartExportException("Error while parsing template file. Please verify the syntax and semantics of the template file.");
     }
     return(true);
 }
        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();
        }