///       <summary>
        ///       The method returns true if the project contains a document and false otherwise.
        ///       </summary>
        private bool doesProjectHaveDocument()
        {
            List <bool> docStatus     = new List <bool>();
            bool        projectHasDoc = false;

            // if there is a document type in the DCO hierarchy
            if (CurrentDCO.ObjectType() == Constants.Document ||
                (CurrentDCO.ObjectType() == Constants.Page && CurrentDCO.Parent().ObjectType() == Constants.Document) ||
                (CurrentDCO.ObjectType() == Constants.Field && CurrentDCO.Parent().ObjectType() == Constants.Page &&
                 CurrentDCO.Parent().Parent().ObjectType() == Constants.Document)
                )
            {
                projectHasDoc = true;
            }
            //check if the children of batch are not  document
            else if (CurrentDCO.ObjectType() == Constants.Batch)
            {
                for (int i = 0; i < CurrentDCO.NumOfChildren(); i++)
                {
                    TDCOLib.IDCO childDCO = CurrentDCO.GetChild(i);
                    if (childDCO.ObjectType() != Constants.Document)
                    {
                        docStatus.Add(false);
                    }
                    else
                    {
                        docStatus.Add(true);
                    }
                }
                projectHasDoc = docStatus.Contains(true);
            }
            return(projectHasDoc);
        }
Exemple #2
0
 ///       <summary>
 ///       The method Evaluates for loop.
 ///       <param name="loopNode">XML node of Foreach</param>
 ///       </summary>
 public void EvaluateLoop(XmlNode loopNode)
 {
     TDCOLib.IDCO DCO = null;
     if (Globals.Instance.ContainsKey(Constants.forLoopString.CURRENTITERATIONDCO) &&
         Globals.Instance.GetData(Constants.forLoopString.CURRENTITERATIONDCO) is TDCOLib.IDCO)
     {
         DCO = (TDCOLib.IDCO)Globals.Instance.GetData(Constants.forLoopString.CURRENTITERATIONDCO);
     }
     if (DCO == null)
     {
         DCO = CurrentDCO;
     }
     EvaluateLoop(loopNode, DCO);
 }
Exemple #3
0
 ///       <summary>
 ///       The method validates for loop expression.
 ///       <param name="forEachlevel">integer value of the level</param>
 ///       </summary>
 protected void validateForLoop(int forEachlevel, TDCOLib.IDCO DCO)
 {
     if (DCO == null)
     {
         throw new SmartExportException(" DCO associated with the for-each loop cannot be determined.");
     }
     if (forEachlevel == 4 || forEachlevel == Constants.Batch)
     {
         throw new SmartExportException(" Assigned level of ForEach loop is wrong");
     }
     if (forEachlevel == DCO.ObjectType())
     {
         throw new SmartExportException(" ForEach loop level must not be same to the Datacap assigned level");
     }
     if (!(forEachlevel == (DCO.ObjectType() + 1)))
     {
         throw new SmartExportException(" ForEach loop must be one level lower from the Datacap assigned level ");
     }
 }
Exemple #4
0
        public void EvaluateLoopForPagesOfFile(XmlNode loopNode)
        {
            Stopwatch   sw                 = Stopwatch.StartNew();
            DataElement dataElement        = new DataElement();
            Conditions  conditionEvaluator = new Conditions();
            Tables      table              = new Tables();

            try
            {
                Dictionary <string, List <string> > filePageMap =
                    (Dictionary <string, List <string> >)Globals.Instance.GetData(Constants.FILE_PAGE_MAP);
                string        file  = (string)Globals.Instance.GetData(Constants.forLoopString.CURRENTFILE);
                List <string> pages = filePageMap[file];
                foreach (string page in pages)
                {
                    TDCOLib.IDCO DCO = CurrentDCO.FindChild(page);
                    Globals.Instance.SetData(Constants.GE_CURRENT_DCO, DCO);
                    processNodes(loopNode, false);
                    Globals.Instance.SetData(Constants.GE_CURRENT_DCO, CurrentDCO);
                }
            }
            catch (System.Exception exp)
            {
                string message = exp.Message;
                //if the problem was already caught at the child node level the line number
                // information would be already present in the exception message
                if (!message.Contains("Problem found at line number"))
                {
                    TemplateParser templateParser =
                        (TemplateParser)Globals.Instance.GetData(Constants.GE_TEMPLATE_PARSER);
                    message = "Problem found at line number : "
                              + templateParser.GetLineNumberForNode(loopNode) + "\n" + exp.Message;
                }
                //setting it to empty after every iteration.
                Globals.Instance.SetData(Constants.GE_CURRENT_DCO, CurrentDCO);
                throw new SmartExportException(message);
            }
            ExportCore.WriteDebugLog(" EvaluateLoopForPagesOfFile " + loopNode
                                     + "  completed in " + sw.ElapsedMilliseconds + " ms.");
            sw.Stop();
        }
Exemple #5
0
        ///       <summary>
        ///       The method Evaluates for loop.
        ///       <param name="loopNode">XML node of Foreach</param>
        ///       <param name="DCO">Current iteration DCO of the parent for-each loop</param>
        ///       </summary>
        public void EvaluateLoop(XmlNode loopNode, TDCOLib.IDCO DCO)
        {
            Stopwatch sw = Stopwatch.StartNew();


            DataElement dataElement        = new DataElement();
            Conditions  conditionEvaluator = new Conditions();
            Tables      table = new Tables();

            try
            {
                int forEachlevel = getIntValueForEachObjectType(loopNode.Attributes["select"].Value);
                nestingLevel = setAndValidateNestingLevel(loopNode);
                validateForLoop(forEachlevel, DCO);

                for (int i = 0; i < DCO.NumOfChildren(); i++)
                {
                    //setting the currentIterationDCO , so that it can be used in DCODataRetreiver to get the data.
                    Globals.Instance.SetData(Constants.forLoopString.CURRENTITERATIONDCO, DCO.GetChild(i));

                    foreach (XmlNode node in loopNode.ChildNodes)
                    {
                        switch (node.Name)
                        {
                        case Constants.NodeTypeString.SE_IF:
                            conditionEvaluator.EvaluateCondition(node);
                            break;

                        case Constants.NodeTypeString.SE_FOREACH:
                            Loops loopEvaluator = new Loops();
                            loopEvaluator.EvaluateLoop(node, DCO.GetChild(i));
                            break;

                        case Constants.NodeTypeString.SE_ROWS:
                            if (node.Attributes == null || node.Attributes.Count > 0 ||
                                string.IsNullOrEmpty(node.Attributes["tablename"].Value))
                            {
                                new SmartExportException("Its mandatory to specify the table name when the for-each-rows tag " +
                                                         "is used within se:for-each tag for tables.");
                            }
                            if (node.Attributes["tablename"].Value == DCO.GetChild(i).ID)
                            {
                                table.FetchTable(node);
                            }
                            break;

                        case Constants.NodeTypeString.SE_DATA:
                            dataElement.EvaluateData(node);
                            break;

                        default:
                            if (node.NodeType == XmlNodeType.Element)
                            {
                                ExportCore.WriteLog("Node type [" + ((XmlElement)node).Name + "] not supported. Will be ignored");
                            }
                            break;
                        }
                    }
                    //setting it to empty after every iteration.
                    Globals.Instance.SetData(Constants.forLoopString.CURRENTITERATIONDCO, Constants.EMPTYSTRING);
                }
            }
            catch (System.Exception exp)
            {
                string message = exp.Message;
                //if the problem was already caught at the child node level the line number
                // information would be already present in the exception message
                if (!message.Contains("Problem found at line number"))
                {
                    TemplateParser templateParser = (TemplateParser)Globals.Instance.GetData(Constants.GE_TEMPLATE_PARSER);
                    message = "Problem found at line number : " + templateParser.GetLineNumberForNode(loopNode) + "\n" + exp.Message;
                }
                //setting it to empty after every iteration.
                Globals.Instance.SetData(Constants.forLoopString.CURRENTITERATIONDCO, Constants.EMPTYSTRING);
                throw new SmartExportException(message);
            }

            ExportCore.WriteDebugLog(" EvaluateLoop " + loopNode + "  completed in " + sw.ElapsedMilliseconds + " ms.");

            sw.Stop();
        }