예제 #1
0
        public void RenderMeasure(
            StringBuilder sbFieldNames,
            StringBuilder sbFieldTypes,
            ReportDefinitionVariable measure
            )
        {
            foreach (ReportDefinitionScore category in measure.Scores)
            {
                if (category.Hidden)
                {
                    continue;
                }

                string categoryLabel = category.Label.Trim();

                if (categoryLabel == "")
                {
                    categoryLabel = "Value";
                }

                sbFieldNames.Append("\"" + categoryLabel + "\",");
                sbFieldTypes.Append("\"float\",");

                if (category.Variable.IsFake)
                {
                    this.RenderPercentage = true;

                    sbFieldNames.Append("\"Percentage\",");
                    sbFieldTypes.Append("\"float\",");
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Creates a new instance of the report definition variable.
        /// </summary>
        /// <param name="owner">The owning report definition.</param>
        /// <param name="variable">The variable to create a report variable from.</param>
        public ReportDefinitionVariable(
            ReportDefinition owner,
            Variable variable,
            ReportDefinitionVariable parent
            )
        {
            this.Owner           = owner;
            this.NestedVariables = new List <ReportDefinitionVariable>();
            this.Scores          = new ReportDefinitionScoreCollection();

            this.XmlNode = this.Owner.XmlDocument.CreateElement("Variable");

            this.XmlNode.AddAttribute("Id", variable.Id.ToString());
            this.XmlNode.AddAttribute("Scale", variable.Scale.ToString());

            if (parent != null)
            {
                parent.XmlNode.AppendChild(this.XmlNode);
            }

            this.VariableType = GetVariableType();

            RenderCategories();
            ParseCategories();
        }
        public ReportDefinitionScoreGroup(ReportDefinitionVariable variable, XmlNode xmlNode)
            : base(variable, xmlNode)
        {
            this.Scores = new List <ReportDefinitionScore>();

            // Run through all child nodes of the xml node.
            foreach (XmlNode xmlNodeScore in this.XmlNode.ChildNodes)
            {
                ReportDefinitionScore score = null;

                switch (xmlNodeScore.Name)
                {
                case "Category":
                    score = new ReportDefinitionCategory(this.Variable, xmlNodeScore);
                    break;

                case "TaxonomyCategory":
                    score = new ReportDefinitionTaxonomyCategory(this.Variable, xmlNodeScore);
                    break;

                case "ScoreGroup":
                    score = new ReportDefinitionScoreGroup(this.Variable, xmlNodeScore);
                    break;
                }

                if (score != null)
                {
                    this.Scores.Add(score);
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Creates a new instance of the report definition variable.
 /// </summary>
 /// <param name="owner">The owning report definition.</param>
 /// <param name="xmlNode">The xml node that contains the variable definition.</param>
 /// <param name="parent">The parent report definition variable.</param>
 public ReportDefinitionVariable(
     ReportDefinition owner,
     XmlNode xmlNode,
     ReportDefinitionVariable parent
     )
     : this(owner, xmlNode)
 {
     this.ParentVariable = parent;
 }
        private void LoadCombinations(ReportDefinitionVariable variable, List <string> filters, string path)
        {
            List <ReportDefinitionVariable> next = variable.NestedVariables;

            if (next.Count == 0 && variable.Position == "Left")
            {
                next = this.ReportDefinition.TopVariables;
            }

            if (next.Count > 0)
            {
                foreach (ReportDefinitionScore category in variable.Scores)
                {
                    if (category.Hidden)
                    {
                        continue;
                    }

                    List <string> _filters = new List <string>();
                    _filters.AddRange(filters);
                    _filters.Add(category.Label);

                    string _path = path + string.Format(
                        "/Variable[@Id=\"{0}\"]/*[@Id=\"{1}\"]",
                        variable.IdVariable,
                        category.Identity
                        );

                    foreach (ReportDefinitionVariable nestedVariable in next)
                    {
                        LoadCombinations(nestedVariable, _filters, _path);
                    }
                }
            }
            else
            {
                foreach (ReportDefinitionScore category in variable.Scores)
                {
                    if (category.Hidden)
                    {
                        continue;
                    }

                    ReportDefinitionRenderJSONCombination combination = new ReportDefinitionRenderJSONCombination();
                    combination.Filters = filters;
                    combination.Label   = category.Label;
                    combination.Path    = path + string.Format(
                        "/Variable[@Id=\"{0}\"]/*[@Id=\"{1}\"]",
                        variable.IdVariable,
                        category.Identity
                        );

                    this.Combinations.Add(combination);
                }
            }
        }
예제 #6
0
        public void ParseNestedVariables()
        {
            // Run through all child variable xml nodes.
            foreach (XmlNode xmlNodeVariable in this.XmlNode.SelectNodes("Variable"))
            {
                ReportDefinitionVariable variable = new ReportDefinitionVariable(this.Owner, xmlNodeVariable, this);

                this.NestedVariables.Add(variable);

                string position = variable.Position;
            }
        }
예제 #7
0
        public void RenderDimension(
            StringBuilder sbFieldNames,
            StringBuilder sbFieldTypes,
            ReportDefinitionVariable dimension
            )
        {
            sbFieldNames.Append("\"" + dimension.Label + "\",");
            sbFieldTypes.Append("\"string\",");

            foreach (ReportDefinitionVariable nestedDimension in dimension.NestedVariables)
            {
                RenderDimension(
                    sbFieldNames,
                    sbFieldTypes,
                    nestedDimension
                    );
            }
        }
        private ReportDefinitionVariable ResolvePath(List <ReportDefinitionVariable> collection, string path)
        {
            foreach (ReportDefinitionVariable variable in collection)
            {
                if (variable.XmlNode.GetXPath() == path)
                {
                    return(variable);
                }

                ReportDefinitionVariable nested = ResolvePath(variable.NestedVariables, path);

                if (nested != null)
                {
                    return(nested);
                }
            }

            return(null);
        }
        private List <Dictionary <string, object> > GetCategories(ReportDefinitionVariable variable)
        {
            List <Dictionary <string, object> > result = new List <Dictionary <string, object> >();

            foreach (ReportDefinitionScore score in variable.Scores)
            {
                if (score.Hidden)
                {
                    continue;
                }

                Dictionary <string, object> value = new Dictionary <string, object>();

                value.Add("name", score.XmlNode.Attributes["Name"].Value);
                value.Add("kind", "EntitySet");
                value.Add("url", this.RequestString + "&Query=Category_" + score.Identity);

                result.Add(value);
            }

            return(result);
        }
 public ReportDefinitionTaxonomyCategory(ReportDefinitionVariable variable, XmlNode xmlNode)
     : base(variable, xmlNode)
 {
 }
        public override void Parse()
        {
            this.LeftVariables = new List <ReportDefinitionVariable>();
            this.TopVariables  = new List <ReportDefinitionVariable>();

            // Select all left variable xml nodes.
            XmlNodeList xmlNodesLeftVariables = this.XmlDocument.DocumentElement.
                                                SelectNodes("Variables[@Position=\"Left\"]/Variable");

            // Select all top variable xml nodes.
            XmlNodeList xmlNodesTopVariables = this.XmlDocument.DocumentElement.
                                               SelectNodes("Variables[@Position=\"Top\"]/Variable");

            // Run through all left variable xml nodes.
            foreach (XmlNode xmlNodeLeftVariable in xmlNodesLeftVariables)
            {
                // Create a new report definition variable by the left variable xml node.
                ReportDefinitionVariable variable = new ReportDefinitionVariable(this, xmlNodeLeftVariable);

                // Check if the variable still exists.
                if (variable.IsFake == false && variable.IsTaxonomy == false && this.Core.Variables.GetSingle(variable.IdVariable) == null)
                {
                    // Remove the variable's xml node from the report definition.
                    xmlNodeLeftVariable.ParentNode.RemoveChild(xmlNodeLeftVariable);

                    // Continue with the next item.
                    continue;
                }

                // Add the report definition variable to the left variables collection.
                this.LeftVariables.Add(variable);

                string position = variable.Position;
            }

            // Run through all top variable xml nodes.
            foreach (XmlNode xmlNodeTopVariable in xmlNodesTopVariables)
            {
                // Create a new report definition variable by the top variable xml node.
                ReportDefinitionVariable variable = new ReportDefinitionVariable(this, xmlNodeTopVariable);

                // Check if the variable still exists.
                if (variable.IsFake == false && variable.IsTaxonomy == false && this.Core.Variables.GetSingle(variable.IdVariable) == null)
                {
                    // Remove the variable's xml node from the report definition.
                    xmlNodeTopVariable.ParentNode.RemoveChild(xmlNodeTopVariable);

                    // Continue with the next item.
                    continue;
                }

                // Add the report definition variable to the top variables collection.
                this.TopVariables.Add(variable);

                string position = variable.Position;
            }

            // Select the settings xml node.
            XmlNode xmlNodeSettings = this.XmlDocument.DocumentElement.SelectSingleNode("Settings");

            if (xmlNodeSettings != null)
            {
                this.Settings = new CrosstableSettings(this, xmlNodeSettings);
            }
        }
 public ReportDefinitionScore(ReportDefinitionVariable variable, XmlNode xmlNode)
 {
     this.Properties = new ReportDefinitionScoreProperties(this);
     this.Variable   = variable;
     this.XmlNode    = xmlNode;
 }