コード例 #1
0
        private string RenderMeanEquation(
            string source,
            DefinitionObject variable,
            XmlNode xmlNodeVariable,
            object idStudy
            )
        {
            StringBuilder meanEquation = new StringBuilder();

            // Run through all category ids of the variable.
            foreach (XmlNode xmlNodeCategory in xmlNodeVariable.ChildNodes)
            {
                if (xmlNodeCategory.Name == "ScoreGroup")
                {
                    continue;
                }

                DefinitionObject category = new DefinitionObject(Global.Core, source, xmlNodeCategory);

                meanEquation.Append(string.Format(
                                        "([{3}{0}.{1}] * {2} / [{3}{0}]) + ",
                                        variable.GetValue("Name"),
                                        category.GetValue("Name"),
                                        category.GetValue("Value"),
                                        idStudy != null ? "/" + idStudy + "\\" : ""
                                        ));
            }

            if (xmlNodeVariable.ChildNodes.Count != 0)
            {
                meanEquation = meanEquation.Remove(meanEquation.Length - 3, 3);
            }

            return(meanEquation.ToString());
        }
コード例 #2
0
        private string RenderSampleVarianceEquation(
            string source,
            DefinitionObject variable,
            XmlNode xmlNodeVariable,
            object idStudy
            )
        {
            StringBuilder result = new StringBuilder();

            result.Append(RenderStdDevEquation(
                              source,
                              variable,
                              xmlNodeVariable,
                              idStudy
                              ).Replace("return", "var_result = "));

            result.Append(Environment.NewLine);
            result.Append(Environment.NewLine);

            result.Append(string.Format(
                              "return Math.Sqrt(var_result / Math.Pow([{1}{0}] - 1, 0.5));",
                              variable.GetValue("Name"),
                              idStudy != null ? "/" + idStudy + "\\" : ""
                              ));

            return(result.ToString());
        }
コード例 #3
0
        private void RemoveScoreFromGroup(HttpContext context)
        {
            string path      = context.Request.Params["Path"];
            string groupPath = context.Request.Params["GroupPath"];

            // Get the source string from the http request's parameters.
            string source      = context.Request.Params["Source"];
            string groupSource = context.Request.Params["GroupSource"];

            DefinitionObject score = new DefinitionObject(Global.Core, source, path);
            DefinitionObject group = new DefinitionObject(Global.Core, groupSource, groupPath);

            if (score.StorageType == DatabaseCore.StorageMethodType.Database)
            {
                // Delete the score group link.
                Global.Core.TaxonomyCategoryLinks.Delete((Guid)Global.Core.TaxonomyCategoryLinks.GetValue(
                                                             "Id",
                                                             new string[] { "IdScoreGroup", "IdTaxonomyCategory" },
                                                             new object[] { group.GetValue("Id"), score.GetValue("Id") }
                                                             ));
            }
            else
            {
                score.Delete();
            }
        }
コード例 #4
0
        private void DeleteScoreGroup(HttpContext context)
        {
            string xPath = context.Request.Params["XPath"];

            // Get the source string from the http request's parameters.
            string source = context.Request.Params["Source"];

            DefinitionObject scoreGroup = new DefinitionObject(Global.Core, source, xPath);

            if (scoreGroup.StorageType == DatabaseCore.StorageMethodType.Database)
            {
                // Get all categories of the score group.
                List <object[]> scoreGroupCategories = Global.Core.TaxonomyCategoryLinks.GetValues(
                    new string[] { "Id" },
                    new string[] { "IdScoreGroup" },
                    new object[] { scoreGroup.GetValue("Id") }
                    );

                // Run through all categories of the scrore group.
                foreach (object[] scoreGroupCategory in scoreGroupCategories)
                {
                    // Remove the category from the score group.
                    Global.Core.TaxonomyCategoryLinks.Delete((Guid)scoreGroupCategory[0]);
                }
            }

            scoreGroup.Delete();
        }
コード例 #5
0
        private void ReorderScale(HttpContext context)
        {
            string xPath = context.Request.Params["XPath"];

            // Get the source string from the http request's parameters.
            string source = context.Request.Params["Source"];

            DefinitionObject score = new DefinitionObject(Global.Core, source, xPath);

            int order = int.Parse(context.Request.Params["Order"]);

            int oldOrder = int.Parse(score.GetValue("Order").ToString());

            score.SetValue("Order", order);
            score.Save();

            DefinitionObject[] scores = score.GetParent().GetChilds();
            foreach (DefinitionObject _score in scores)
            {
                int _order = int.Parse(_score.GetValue("Order").ToString());

                if (_order < order)
                {
                    continue;
                }

                if (_order >= oldOrder)
                {
                    continue;
                }

                if (_score.GetValue("Id") == score.GetValue("Id"))
                {
                    continue;
                }

                _score.SetValue(
                    "Order",
                    (_order + 1)
                    );

                _score.Save();
            }

            ReOrderScores(scores.OrderBy(x => int.Parse(x.GetValue("Order").ToString())).ToArray());
        }
コード例 #6
0
        private void GetEquation(HttpContext context)
        {
            string path = context.Request.Params["Path"];

            // Get the source string from the http request's parameters.
            string source = context.Request.Params["Source"];

            DefinitionObject item = new DefinitionObject(Global.Core, source, path);

            context.Response.Write(HttpUtility.HtmlDecode((string)item.GetValue("Equation")));
        }
        public override void Render(StringBuilder writer, HierarchyFilter hierarchyFilter)
        {
            string[] chartingColors = LoadChartingColors();
            int      i = 0;
            // Select the xml node that contains the chart's data.
            XmlNodeList xmlNodes = this.Document.SelectNodes(this.PathDimension + "/*[not(self::Variable)][not(self::MeanScore)]");

            // Open an array for the values.
            writer.Append("[");

            // FOR TEST ONLY:
            foreach (XmlNode xmlNodeCategory in xmlNodes)
            {
                if (xmlNodeCategory.ParentNode.Attributes["IsNestedBase"] != null &&
                    bool.Parse(xmlNodeCategory.ParentNode.Attributes["IsNestedBase"].Value) == true)
                {
                    continue;
                }

                if (xmlNodeCategory.Attributes["ShowInChart"] != null && bool.Parse(xmlNodeCategory.Attributes["ShowInChart"].Value) == false)
                {
                    continue;
                }

                DefinitionObject test = new DefinitionObject(
                    base.Core,
                    this.Source,
                    string.Format(
                        "//Variable/{0}[@Id=\"{1}\"]",
                        xmlNodeCategory.Name,
                        xmlNodeCategory.Attributes["Id"].Value
                        )
                    );

                object enabled = test.GetValue("Enabled");

                if (enabled != null && bool.Parse((string)enabled) == false)
                {
                    continue;
                }

                writer.Append("{");

                Guid idCategory = Guid.Parse(xmlNodeCategory.Attributes["Id"].Value);

                string categoryName  = (string)test.GetValue("Name");
                string categoryLabel = (string)test.GetLabel(base.IdLanguage);

                XmlNode xmlNode = xmlNodeCategory.SelectSingleNode("Variable[@IsNestedBase=\"True\"]");

                if (xmlNode == null)
                {
                    xmlNode = xmlNodeCategory.SelectSingleNode("Variable");
                }

                if (xmlNode == null)
                {
                    xmlNode = xmlNodeCategory;
                }

                double value     = 0.0;
                double baseValue = 0;
                if (xmlNode.Attributes["Value"] != null)
                {
                    if (xmlNode.Attributes["Value"] != null)
                    {
                        value = double.Parse(xmlNode.Attributes["Value"].Value);
                    }

                    if (xmlNode.ParentNode.Attributes["Position"].Value == "Top")
                    {
                        if (xmlNode.ParentNode.Attributes["Base"] != null)
                        {
                            baseValue = double.Parse(xmlNode.ParentNode.Attributes["Base"].Value);
                        }
                    }
                    else
                    {
                        if (xmlNode.Attributes["Base"] != null)
                        {
                            baseValue = double.Parse(xmlNode.Attributes["Base"].Value);
                        }
                    }
                }
                else
                {
                    if (xmlNode.Attributes["Base"] != null)
                    {
                        value = double.Parse(xmlNode.Attributes["Base"].Value);
                    }
                    if (xmlNode.Attributes["VariableBase"] != null)
                    {
                        baseValue = double.Parse(xmlNode.Attributes["VariableBase"].Value);
                    }
                    else if (xmlNodeCategory.ParentNode.Attributes["Base"] != null)
                    {
                        baseValue = double.Parse(xmlNodeCategory.ParentNode.Attributes["Base"].Value);
                    }
                }

                /*if (xmlNodeCategory.Attributes["Base"] != null)
                 *  value = double.Parse(xmlNodeCategory.Attributes["Base"].Value);
                 * else if (xmlNodeCategory.ParentNode.Attributes["Base"] != null)
                 *  value = double.Parse(xmlNodeCategory.ParentNode.Attributes["Base"].Value);
                 *
                 * if (xmlNode.Attributes["Value"] != null)
                 * {
                 *  baseValue = value;
                 *  value = double.Parse(xmlNode.Attributes["Value"].Value);
                 * }
                 * else
                 * {
                 *  if (xmlNodeCategory.ParentNode.Attributes["Base"] != null)
                 *      baseValue = double.Parse(xmlNodeCategory.ParentNode.Attributes["Base"].Value);
                 * }*/

                if (baseValue != 0)
                {
                    value = value * 100 / baseValue;
                }
                else
                {
                    value = 0;
                }

                if (chartingColors.Length == i)
                {
                    i = 0;
                }

                writer.Append(string.Format(
                                  "\"dimension\": \"{0}\", \"value\": \"{1}\", \"Label\": \"{2}\",\"Color_{0}\": \"{3}\"",
                                  categoryName,
                                  value.ToString(new CultureInfo(2057)),
                                  HttpUtility.HtmlEncode(categoryLabel),
                                  chartingColors[i++]
                                  ));

                if (xmlNodeCategory.ChildNodes.Count > 0 && xmlNodeCategory.FirstChild.Attributes["Id"].Value != "00000000-0000-0000-0000-000000000000")
                {
                    writer.Append(string.Format(
                                      ", \"XPATH\": \"{0}\"",
                                      HttpUtility.UrlEncode(xmlNodeCategory.GetXPath(true) + "/Variable")
                                      ));
                }

                writer.Append("},");
            }

            if (xmlNodes.Count > 0)
            {
                writer = writer.Remove(writer.Length - 1, 1);
            }

            // Close the values array.
            writer.Append("]");
        }
コード例 #8
0
        private string RenderStdDevEquation(
            string source,
            DefinitionObject variable,
            XmlNode xmlNodeVariable,
            object idStudy
            )
        {
            StringBuilder meanEquation = new StringBuilder();

            // Run through all category ids of the variable.
            foreach (XmlNode xmlNodeCategory in xmlNodeVariable.ChildNodes)
            {
                if (xmlNodeCategory.Name == "ScoreGroup")
                {
                    continue;
                }

                DefinitionObject category = new DefinitionObject(Global.Core, source, xmlNodeCategory);

                meanEquation.Append(string.Format(
                                        "([{3}{0}.{1}] * {2}) + ",
                                        variable.GetValue("Name"),
                                        category.GetValue("Name"),
                                        category.GetValue("Value"),
                                        idStudy != null ? "/" + idStudy + "\\" : ""
                                        ));
            }

            if (xmlNodeVariable.ChildNodes.Count != 0)
            {
                meanEquation = meanEquation.Remove(meanEquation.Length - 3, 3);
            }

            StringBuilder equation = new StringBuilder();

            equation.Append("double var_mean = Math.Pow(");
            equation.Append(meanEquation.ToString());
            equation.Append(string.Format(
                                ", 2) / [{1}{0}];",
                                variable.GetValue("Name"),
                                idStudy != null ? "/" + idStudy + "\\" : ""
                                ));

            equation.Append(Environment.NewLine);
            equation.Append("double var_result = ");

            // Run through all category ids of the variable.
            foreach (XmlNode xmlNodeCategory in xmlNodeVariable.ChildNodes)
            {
                if (xmlNodeCategory.Name == "ScoreGroup")
                {
                    continue;
                }

                DefinitionObject category = new DefinitionObject(Global.Core, source, xmlNodeCategory);

                equation.Append(string.Format(
                                    "([{3}{0}.{1}] * Math.Pow({3}{2}, 2)) + ",
                                    variable.GetValue("Name"),
                                    category.GetValue("Name"),
                                    category.GetValue("Value"),
                                    idStudy != null ? "/" + idStudy + "\\" : ""
                                    ));
            }

            if (xmlNodeVariable.ChildNodes.Count != 0)
            {
                equation = equation.Remove(equation.Length - 3, 3);
            }

            equation.Append(" - var_mean");

            equation.Append(";");
            equation.Append(Environment.NewLine);
            equation.Append(Environment.NewLine);

            equation.Append(string.Format(
                                "var_result = var_result / ([{1}{0}] - 1);",
                                variable.GetValue("Name"),
                                idStudy != null ? "/" + idStudy + "\\" : ""
                                ));

            equation.Append(Environment.NewLine);
            equation.Append("return Math.Pow(var_result, 0.5);");

            return(equation.ToString());
        }
コード例 #9
0
        private string RenderScoreToJson(DefinitionObject score, int idLanguage)
        {
            StringBuilder result = new StringBuilder();

            if (score.IsScoreGroup())
            {
                object _enabled = score.GetValue("Enabled");

                result.Append("{");
                result.Append(string.Format(
                                  " \"Type\": \"ScoreGroup\", \"Id\": \"{0}\", \"Name\": \"{1}\", \"Order\": \"{2}\", \"Path\": \"{3}\", \"Source\": \"{4}\", \"Value\": \"{5}\", \"Enabled\": {6}, \"Color\":\"{7}\", \"Scores\": [",
                                  score.GetValue("Id"),
                                  HttpUtility.HtmlEncode(score.GetLabel(idLanguage)),
                                  score.GetValue("Order"),
                                  score.Path.Replace("\"", "\\\""),
                                  score.Source,
                                  score.GetValue("Value"),
                                  _enabled != null ? _enabled.ToString().ToLower() : true.ToString().ToLower(),
                                  score.GetValue("Color")
                                  ));

                /*foreach (XmlNode xmlNodeScore in xmlNode.ChildNodes)
                 * {
                 *  result.Append(RenderScoreToJson(xmlNodeScore, idLanguage));
                 *  result.Append(",");
                 * }*/
                DefinitionObject[] childScores = score.GetChilds();
                foreach (DefinitionObject childScore in childScores)
                {
                    result.Append(RenderScoreToJson(childScore, idLanguage));
                    result.Append(",");
                }

                if (childScores.Length > 0)
                {
                    result = result.Remove(result.Length - 1, 1);
                }

                result.Append("] }");
            }
            else
            {
                object _enabled = score.GetValue("Enabled");

                result.Append("{");
                result.Append(string.Format(
                                  " \"Type\": \"{0}\", \"Id\": \"{1}\", \"Label\": \"{2}\", \"Order\": \"{3}\", \"Path\": \"{4}\", \"Enabled\": {5}, \"Source\": \"{6}\", \"Name\": \"{7}\", \"Value\": \"{8}\" ",
                                  score.TypeName,
                                  score.GetValue("Id"),
                                  HttpUtility.HtmlEncode(score.GetLabel(idLanguage)),
                                  score.GetValue("Order"),
                                  score.Path.Replace("\"", "\\\""),
                                  _enabled != null ? _enabled.ToString().ToLower() : true.ToString().ToLower(),
                                  score.Source,
                                  HttpUtility.HtmlEncode(score.GetValue("Name")),
                                  score.GetValue("Value")
                                  ));
                result.Append("}");
            }

            return(result.ToString());
        }
コード例 #10
0
        private void GetScores(HttpContext context)
        {
            string xPath = context.Request.Params["XPath"];

            // Get the source string from the http request's parameters.
            string source = context.Request.Params["Source"];

            DefinitionObject variable = new DefinitionObject(
                Global.Core,
                source,
                xPath
                );

            StringBuilder result = new StringBuilder();

            result.Append("{ \"Scores\" : [");

            // Set the default for the language to english GB.
            int idLanguage = 2057;

            // Check if a specific language is defined.
            if (context.Request.Params["IdLanguage"] != null)
            {
                idLanguage = int.Parse(context.Request.Params["IdLanguage"]);
            }

            DefinitionObject[] scores = variable.GetChilds();

            HierarchyFilter hierarchyFilter;

            if (context.Request.UrlReferrer.ToString().EndsWith("LinkBi.aspx"))
            {
                hierarchyFilter = Global.HierarchyFilters[(string)HttpContext.Current.Session["LinkBiDefinition"]];
            }
            else if (HttpContext.Current.Session["ReportDefinition"] != null)
            {
                hierarchyFilter = Global.HierarchyFilters[(string)HttpContext.Current.Session["ReportDefinition"]];
            }
            else
            {
                string fileName = System.IO.Path.Combine(
                    HttpContext.Current.Request.PhysicalApplicationPath,
                    "Fileadmin",
                    "ExportDefinitions",
                    Global.User.Id + ".xml"
                    );
                hierarchyFilter = Global.HierarchyFilters[fileName];
            }

            if (!hierarchyFilter.IsLoaded)
            {
                hierarchyFilter.Load();
            }

            bool isTaxonomy = false;

            if (context.Request.UrlReferrer.ToString().EndsWith("Exports.aspx") || context.Request.UrlReferrer.ToString().EndsWith("TaxonomyManager.aspx"))
            {
                if (variable.GetValue("Id").ToString() != "")
                {
                    isTaxonomy = true;
                }
            }
            else
            {
                isTaxonomy = bool.Parse((string)variable.GetValue("IsTaxonomy"));
            }

            foreach (DefinitionObject score in scores)
            {
                object persistant = score.GetValue("Persistent", false, false);

                if (isTaxonomy && persistant != null)
                {
                    if (!hierarchyFilter.TaxonomyCategories.ContainsKey(Guid.Parse(score.GetValue("Id").ToString())))
                    {
                        continue;
                    }
                }

                result.Append(RenderScoreToJson(score, idLanguage));
                result.Append(",");
            }

            if (scores.Length > 0)
            {
                result = result.Remove(result.Length - 1, 1);
            }

            result.Append("]}");

            context.Response.Write(result.ToString());
        }
コード例 #11
0
        public override void Render(StringBuilder writer, HierarchyFilter hierarchyFilter)
        {
            string[] chartingColors = LoadChartingColors();
            //Random rnd = new Random();
            //List<string> usedColors = new List<string>();
            int i = 0;

            // Select the xml node that contains the chart's data.
            XmlNodeList xmlNodes = this.Document.SelectNodes(this.PathDimension + "/*[not(self::Variable)][not(self::MeanScore)]");


            // Open an array for the values.
            writer.Append("[");

            foreach (XmlNode xmlNodeCategory in xmlNodes)
            {
                if (xmlNodeCategory.Attributes["ShowInChart"] != null && bool.Parse(xmlNodeCategory.Attributes["ShowInChart"].Value) == false)
                {
                    continue;
                }

                // if (xmlNodeCategory.Name == "MeanScore") continue;
                if (xmlNodeCategory.ParentNode.Attributes["IsNestedBase"] != null && bool.Parse(xmlNodeCategory.ParentNode.Attributes["IsNestedBase"].Value) == true)
                {
                    continue;
                }

                DefinitionObject variable = new DefinitionObject(
                    base.Core,
                    this.Source,
                    string.Format(
                        "//Variable[@Id=\"{0}\"]",
                        xmlNodeCategory.ParentNode.Attributes["Id"].Value
                        )
                    );
                DefinitionObject category = new DefinitionObject(
                    base.Core,
                    this.Source,
                    string.Format(
                        "//Variable[@Id=\"{2}\"]/{0}[@Id=\"{1}\"]",
                        xmlNodeCategory.Name,
                        xmlNodeCategory.Attributes["Id"].Value,
                        xmlNodeCategory.ParentNode.Attributes["Id"].Value
                        )
                    );

                object enabled   = category.GetValue("Enabled");
                object _hasValue = category.GetValue("HasValues");

                ReportDefinition reportDefinition = new ReportDefinition(
                    base.Core,
                    this.Source,
                    hierarchyFilter
                    );

                //if (enabled != null && bool.Parse((string)enabled) == false)
                //    continue;
                bool hasValue = true;

                bool.TryParse(_hasValue != null ? _hasValue.ToString() : "true", out hasValue);

                if ((enabled != null && bool.Parse((string)enabled) == false) || (hasValue == false && reportDefinition.Settings.HideEmptyRowsAndColumns))
                {
                    continue;
                }

                string variableName  = (string)variable.GetValue("Name");
                string categoryName  = (string)category.GetValue("Name");
                string categoryLabel = (string)category.GetLabel(base.IdLanguage);
                if (String.IsNullOrEmpty(categoryName))
                {
                    categoryName = categoryLabel;
                }
                writer.Append("{");

                writer.Append(string.Format(
                                  "\"dimension\": \"{0}\", \"Label\": \"{1}\",",
                                  variableName + "_" + categoryName,
                                  categoryLabel
                                  ));

                //XmlNodeList xmlNodesMeasures = xmlNodeCategory.SelectNodes("Variable/TaxonomyCategory");
                XmlNodeList xmlNodesMeasures = xmlNodeCategory.SelectNodes(this.PathMeasure + "/*[not(self::Variable)]");

                foreach (XmlNode measure in xmlNodesMeasures)
                {
                    if (measure.Attributes["ShowInChart"] != null && bool.Parse(measure.Attributes["ShowInChart"].Value) == false)
                    {
                        continue;
                    }

                    if (measure.ParentNode.Attributes["IsNestedBase"] != null &&
                        bool.Parse(measure.ParentNode.Attributes["IsNestedBase"].Value) == true)
                    {
                        continue;
                    }

                    //usedColors.Add(measure.Attributes["Color"].Value);

                    DefinitionObject category2 = new DefinitionObject(
                        base.Core,
                        this.Source,
                        //xmlNodeCategory.GetXPath(true)
                        string.Format(
                            "//{2}[@Id=\"{3}\"]/{0}[@Id=\"{1}\"]",
                            measure.Name,
                            measure.Attributes["Id"].Value,
                            measure.ParentNode.Name,
                            measure.ParentNode.Attributes["Id"].Value
                            )
                        );

                    double value     = 0.0;
                    double baseValue = 0;

                    // Nested on the left.
                    if ((category2.XmlNode.ParentNode.Name != "ScoreGroup" && category2.XmlNode.ParentNode.Attributes["Position"] != null && category2.XmlNode.ParentNode.Attributes["Position"].Value == "Left") ||
                        (category2.XmlNode.ParentNode.Name == "ScoreGroup" && category2.XmlNode.ParentNode.ParentNode.Attributes["Position"] != null && category2.XmlNode.ParentNode.ParentNode.Attributes["Position"].Value == "Left"))
                    {
                        value     = double.Parse(measure.ParentNode.ParentNode.Attributes["Base"].Value);
                        baseValue = double.Parse(measure.ParentNode.ParentNode.ParentNode.Attributes["Base"].Value);

                        writer.Append(string.Format(
                                          "\"_{0}\": \"{1}\",",
                                          "",
                                          (value * 100 / baseValue).ToString(new CultureInfo(2057))
                                          ));

                        if (measure.ChildNodes.Count > 0)
                        {
                            writer.Append(string.Format(
                                              "\"XPATH_{0}\": \"{1}\", \"IsDimensionPath_{0}\": \"true\", \"Color_{0}\": \"{2}\"",
                                              "",
                                              HttpUtility.UrlEncode(measure.ParentNode.ParentNode.GetXPath(true) + "/Variable"),
                                              measure.Attributes["Color"].Value

                                              /*HttpUtility.UrlEncode(string.Format(
                                               *  "Variable[@Id='{0}']/{2}[@Id='{1}']/Variable",
                                               *  measure.ParentNode.Attributes["Id"].Value,
                                               *  measure.Attributes["Id"].Value,
                                               *  measure.Name
                                               * ))*/
                                              ));
                        }

                        break;
                    }

                    enabled = category2.GetValue("Enabled");
                    bool _enabled;
                    _hasValue = category2.GetValue("HasValues", false);

                    hasValue = true;

                    bool.TryParse(_hasValue != null ? _hasValue.ToString() : "true", out hasValue);

                    if (enabled != null && bool.TryParse(enabled.ToString(), out _enabled))
                    {
                        if ((_enabled == false) || (hasValue == false && reportDefinition.Settings.HideEmptyRowsAndColumns))
                        {
                            continue;
                        }
                    }

                    //if (enabled != null && bool.TryParse(enabled.ToString(), out _enabled))
                    //{
                    //    if (_enabled == false)
                    //        continue;
                    //}

                    string measureLabel = new DefinitionObject(
                        this.Core,
                        category2.Source,
                        category2.ParentPath
                        ).GetLabel(base.IdLanguage) +
                                          "###SPLIT###" + category2.GetLabel(base.IdLanguage);

                    if (category2.TypeName != "NumericValue")
                    {
                        if (measure.Attributes["Base"] != null)
                        {
                            value = double.Parse(measure.Attributes["Base"].Value);
                        }
                        else if (measure.ParentNode.Attributes["Base"] != null)
                        {
                            value = double.Parse(measure.ParentNode.Attributes["Base"].Value);
                        }

                        if (measure.Attributes["Value"] != null)
                        {
                            baseValue = value;
                            value     = double.Parse(measure.Attributes["Value"].Value);
                        }
                        else if (measure.ChildNodes.Count > 0)
                        {
                            if (measure.ChildNodes[0].Attributes["Base"] != null)
                            {
                                baseValue = double.Parse(measure.ChildNodes[0].Attributes["Base"].Value);
                            }
                        }
                        bool isFake = Guid.Parse(measure.Attributes["Id"].Value) == new Guid();

                        if (isFake)
                        {
                            baseValue = double.Parse(measure.ParentNode.Attributes["VariableBase"].Value);
                        }
                    }
                    else
                    {
                        value     = double.Parse(measure.ParentNode.ParentNode.Attributes["Base"].Value);
                        baseValue = double.Parse(measure.ParentNode.ParentNode.ParentNode.Attributes["Base"].Value);
                    }

                    if (chartingColors.Length == i)
                    {
                        i = 0;
                    }

                    writer.Append(string.Format(
                                      "\"_{0}\": \"{1}\", \"Color_{0}\": \"{2}\",",
                                      measureLabel,
                                      (value * 100 / baseValue).ToString(new CultureInfo(2057)),
                                      chartingColors[i++]//measure.Attributes["Color"].Value
                                      ));

                    if (measure.ChildNodes.Count > 0)
                    {
                        writer.Append(string.Format(
                                          "\"XPATH_{0}\": \"{1}\",",
                                          measureLabel,
                                          HttpUtility.UrlEncode(string.Format(
                                                                    "Variable[@Id='{0}']/{2}[@Id='{1}']/Variable",
                                                                    measure.ParentNode.Attributes["Id"].Value,
                                                                    measure.Attributes["Id"].Value,
                                                                    measure.Name
                                                                    ))
                                          ));
                    }
                }

                writer = writer.Remove(writer.Length - 1, 1);

                writer.Append("},");
            }

            if (xmlNodes.Count > 0)
            {
                writer = writer.Remove(writer.Length - 1, 1);
            }

            // Close the values array.
            writer.Append("]");
        }