Example #1
0
        public Data InitFilter()
        {
            Data result = null;

            if (!File.Exists(this.Source))
            {
                return(result);
            }

            // Create a new xml document that contains the report
            // definition which contains the filter definitions.
            XmlDocument xmlDocument = new System.Xml.XmlDocument();

            xmlDocument.Load(this.Source);

            // Select the xml node that contains the workflow definition.
            XmlNode xmlNodeWorkflow = xmlDocument.DocumentElement.SelectSingleNode("Workflow");

            // Select the xml node that contains the filter definition.
            XmlNode xmlNodeFilter = xmlDocument.DocumentElement.SelectSingleNode("Filters/Operator");

            bool aggregateNonQAData = false;

            XmlNode xmlNodeSetting = xmlDocument.DocumentElement.SelectSingleNode("Settings/Setting[@Name=\"AggregateNonQAData\"]");

            if (xmlNodeSetting != null)
            {
                bool.TryParse(xmlNodeSetting.InnerXml, out aggregateNonQAData);
            }

            this.AggregateNonQAData = aggregateNonQAData;

            DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database(
                this.Calculator.Core,
                this.Calculator
                );

            // Check if a workflow is defined.
            if (xmlNodeWorkflow != null)
            {
                WorkflowClasses.Workflow workflow = new WorkflowClasses.Workflow(
                    this.Calculator.Core,
                    this.Source,
                    xmlNodeWorkflow,
                    "",
                    new HierarchyClasses.HierarchyFilter(null)
                    );

                try
                {
                    result = workflow.GetWorkflowFilter(storageMethod, aggregateNonQAData);
                }
                catch { }
            }

            // Check if a filter is defined.
            if (xmlNodeFilter != null)
            {
                FilterCategoryOperator filterOperator = new FilterCategoryOperator(
                    null,
                    xmlNodeFilter,
                    0,
                    this.Source
                    );

                try
                {
                    result = filterOperator.GetRespondents(
                        storageMethod,
                        result
                        );
                }
                catch { }
            }

            return(result);
        }