Example #1
0
        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 bool FormattedDataOutput(string TemplateFilePath)
        {
            bool returnValue = true;

            try
            {
                Stopwatch sw = Stopwatch.StartNew();
                smartNav = new dcSmart.SmartNav(this);

                //set thread locals
                SetGlobals();
                //TODO: Validate template
                //Initialize the parser
                TemplateParser templateParser = new TemplateParser(TemplateFilePath);
                templateParser.Parse();

                exportUtil.setContext(templateParser);

                if (templateParser.AppendToFile() && !singleOutputFileNameMap.ContainsKey(templateParser.GetOutputFileName()))
                {
                    singleOutputFileNameMap.Add(templateParser.GetOutputFileName(), templateParser.GetOutputFileName() + "_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-fffffff"));
                }
                string locale = templateParser.GetLocale();
                Globals.Instance.SetData(Constants.LOCALE, locale);
                bool projectHasDocument = doesProjectHaveDocument();
                Globals.Instance.SetData(Constants.PROJECT_HAS_DOC, projectHasDocument);
                if (projectHasDocument)
                {
                    ContentProcessorWithDoc ContentProcessor = new ContentProcessorWithDoc(templateParser);
                    DCOPatterns.AddRange(ContentProcessor.createDCOPatternList(getDCODefinitionFile()));
                    ValidateExpressions(TemplateFilePath, Constants.DCO_REF_PATTERN);
                    ContentProcessor.processNodes();
                }
                else
                {
                    ContentProcessorWithoutDoc ContentProcessor = new ContentProcessorWithoutDoc(templateParser);
                    DCOPatterns.AddRange(ContentProcessor.createDCOPatternList(getDCODefinitionFile()));
                    ValidateExpressions(TemplateFilePath, Constants.DCO_REF_PATTERN_NO_DOC);
                    ContentProcessor.processNodes();
                }
                //if project has document
                //or when project doesn't have document and action is attached at page/field level
                //or when collate batch output flag is true when action is attached at batch level and project doesn't have
                //document
                if (projectHasDocument ||
                    (CurrentDCO.ObjectType() != Constants.Batch && !projectHasDocument) ||
                    (CurrentDCO.ObjectType() == Constants.Batch && !projectHasDocument &&
                     templateParser.CollateBatchOutput()))
                {
                    exportUtil.writeToFile(singleOutputFileNameMap);
                }

                WriteInfoLog(" Smart export WriteLog completed in " + sw.ElapsedMilliseconds + " ms.");

                sw.Stop();
            }
            catch (System.Exception exp)
            {
                returnValue = false;
                WriteErrorLog("Error while processing the template file: " + exp.Message);
                WriteErrorLog(exp.StackTrace);
            }

            // TODO: Catch the important exceptions here...
            return(returnValue);
        }
Example #3
0
        public string SmartParameter(string parameter)
        {
            var localSmartObj = new dcSmart.SmartNav(this);

            return(parameter.StartsWith("@") ? localSmartObj.MetaWord(parameter) : parameter);
        }