public override void RenderDataUpdate(
            StringBuilder result,
            DashboardRenderContext context,
            Data filter,
            WeightingFilterCollection weight,
            string path
            )
        {
            if (!context.Categories.ContainsKey(this.Variable))
            {
                context.Categories.Add(this.Variable, new Guid());
            }

            DataCore.Classes.Data data = null;
            DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database(
                this.Dashboard.Core,
                null,
                this.Dashboard.Settings.ReportSettings.WeightMissingValue
                );

            if (this.XmlNode.Attributes["DefaultWeighting"] != null)
            {
                if (this.Dashboard.Cache.Variables.ContainsKey(this.XmlNode.Attributes["DefaultWeighting"].Value))
                {
                    XmlNode xmlNode = this.XmlNode.Clone();
                    xmlNode.InnerXml = "";

                    xmlNode.Attributes["DefaultWeighting"].Value =
                        ((Guid)this.Dashboard.Cache.Variables
                         [this.XmlNode.Attributes["DefaultWeighting"].Value][0][1]).ToString();

                    weight = new WeightingFilterCollection(
                        null,
                        this.Dashboard.Core,
                        xmlNode
                        );
                    weight.LoadRespondents(filter);
                }
            }

            foreach (Guid idCategory in this.Categories.Keys)
            {
                data = storageMethod.GetRespondents(
                    idCategory,
                    this.IdVariable,
                    true,
                    this.Dashboard.Core.CaseDataLocation,
                    filter,
                    weight
                    );

                context.Categories[this.Variable] = idCategory;

                foreach (DashboardNode node in this.Children)
                {
                    node.RenderDataUpdate(
                        result,
                        context,
                        data,
                        weight,
                        path
                        );
                }
            }
        }
        public override void Render(
            StringBuilder result,
            DashboardRenderContext context,
            Data filter,
            WeightingFilterCollection weight
            )
        {
            result.Append("<select");

            if (this.XmlNode.Attributes["class"] != null)
            {
                this.XmlNode.Attributes["class"].Value += " DimensionSelector";
            }
            else
            {
                this.XmlNode.AddAttribute("class", "DimensionSelector");
            }

            DataCore.Classes.Data data = null;
            DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database(
                this.Dashboard.Core,
                null,
                this.Dashboard.Settings.ReportSettings.WeightMissingValue
                );

            if (this.XmlNode.Attributes["DefaultWeighting"] != null)
            {
                if (this.Dashboard.Cache.Variables.ContainsKey(this.XmlNode.Attributes["DefaultWeighting"].Value))
                {
                    XmlNode xmlNode = this.XmlNode.Clone();
                    xmlNode.InnerXml = "";

                    xmlNode.Attributes["DefaultWeighting"].Value =
                        ((Guid)this.Dashboard.Cache.Variables
                         [this.XmlNode.Attributes["DefaultWeighting"].Value][0][1]).ToString();

                    weight = new WeightingFilterCollection(
                        null,
                        this.Dashboard.Core,
                        xmlNode
                        );
                    weight.LoadRespondents(filter);
                }
            }

            if (this.XmlNode.Attributes["selected"] == null)
            {
                // Render the html attribute.
                result.Append(string.Format(
                                  " {0}=\"{1}\"",
                                  "selected",
                                  string.Join(",", this.Selected)
                                  ));
            }

            // Run through all attributes of the html node.
            foreach (XmlAttribute xmlAttribute in this.XmlNode.Attributes)
            {
                // Render the html attribute.
                result.Append(string.Format(
                                  " {0}=\"{1}\"",
                                  xmlAttribute.Name,
                                  ReplacePlaceholder(xmlAttribute.Value, context)
                                  ));
            }

            result.Append(">");

            foreach (Guid idCategory in this.Categories.Keys)
            {
                if (this.HideEmpty)
                {
                    data = storageMethod.GetRespondents(
                        idCategory,
                        this.IdVariable,
                        true,
                        this.Dashboard.Core.CaseDataLocation,
                        null,//filter,
                        weight
                        );

                    //if(data.Responses.Count == 0)
                    if (data.Base == 0)
                    {
                        continue;
                    }
                }
                result.Append(string.Format(
                                  "<option value=\"{0}\">{1}</option>",
                                  this.Dashboard.Cache.Categories2[idCategory][0][1],
                                  this.Dashboard.Cache.CategoryLabels[idCategory][0][1]
                                  ));
            }

            result.Append("</select>");
        }
        public override void Render(
            StringBuilder result,
            DashboardRenderContext context,
            Data filter,
            WeightingFilterCollection weight
            )
        {
            if (!context.Categories.ContainsKey(this.Variable))
            {
                context.Categories.Add(this.Variable, new Guid());
            }

            DataCore.Classes.Data data       = null;
            DataCore.Classes.Data datafilter = null;
            DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database(
                this.Dashboard.Core,
                null,
                this.Dashboard.Settings.ReportSettings.WeightMissingValue
                );

            if (this.XmlNode.Attributes["DefaultWeighting"] != null)
            {
                if (this.Dashboard.Cache.Variables.ContainsKey(this.XmlNode.Attributes["DefaultWeighting"].Value))
                {
                    XmlNode xmlNode = this.XmlNode.Clone();
                    xmlNode.InnerXml = "";

                    xmlNode.Attributes["DefaultWeighting"].Value =
                        ((Guid)this.Dashboard.Cache.Variables
                         [this.XmlNode.Attributes["DefaultWeighting"].Value][0][1]).ToString();

                    weight = new WeightingFilterCollection(
                        null,
                        this.Dashboard.Core,
                        xmlNode
                        );
                    weight.LoadRespondents(filter);
                }
            }

            int count = 0;

            foreach (Guid idCategory in this.Categories.Keys)
            {
                //if (this.Aggregate)
                {
                    data = storageMethod.GetRespondents(
                        idCategory,
                        this.IdVariable,
                        true,
                        this.Dashboard.Core.CaseDataLocation,
                        filter,
                        weight
                        );
                }

                if (this.HideEmpty)
                {
                    /*bool exists = true;
                     * Data hasValueFilter = null;
                     * DashboardCacheHasValue hasValue = null;
                     *
                     * if (!this.Dashboard.Cache.HasValue.ContainsKey(idCategory))
                     * {
                     *  this.Dashboard.Cache.HasValue.Add(idCategory, new DashboardCacheHasValue());
                     *
                     *  if(this.Aggregate)
                     *      this.Dashboard.Cache.HasValue[idCategory].Filter = data;
                     *  else
                     *  {
                     *      this.Dashboard.Cache.HasValue[idCategory].Filter = storageMethod.GetRespondents(
                     *          idCategory,
                     *          this.IdVariable,
                     *          true,
                     *          this.Dashboard.Core.CaseDataLocation,
                     *          filter,
                     *          weight
                     *      );
                     *  }
                     *  hasValueFilter = filter;
                     *  exists = false;
                     * }
                     *
                     * hasValue = this.Dashboard.Cache.HasValue[idCategory];
                     *
                     * foreach (string variable in context.Categories.Keys)
                     * {
                     *  if (variable == this.Variable)
                     *      continue;
                     *
                     *  if (!hasValue.Values.ContainsKey(context.Categories[variable]))
                     *  {
                     *      hasValue.Values.Add(context.Categories[variable], new DashboardCore.DashboardCacheHasValue());
                     *
                     *      exists = false;
                     *      break;
                     *  }
                     *  else
                     *  {
                     *      hasValueFilter = hasValue.Filter;
                     *  }
                     *
                     *  hasValue = hasValue.Values[context.Categories[variable]];
                     *  hasValue.Filter = hasValueFilter;
                     * }
                     *
                     * if (!exists)
                     * {
                     *  if (!this.Aggregate)
                     *  {
                     *      data = storageMethod.GetRespondents(
                     *          idCategory,
                     *          this.IdVariable,
                     *          true,
                     *          this.Dashboard.Core.CaseDataLocation,
                     *          hasValueFilter,
                     *          weight
                     *      );
                     *
                     *      hasValue.Filter = data;
                     *  }
                     *
                     *  hasValue.HasValue = data.Base != 0;
                     * }
                     *
                     * //if(data.Responses.Count == 0)
                     * if (!hasValue.HasValue)
                     *  continue;*/
                    /*if (data.Base == 0)
                     *  continue;*/
                    if (data.Base == 0)
                    {
                        continue;
                    }
                }

                context.Categories[this.Variable] = idCategory;

                // Run through all child dashboard nodes.
                foreach (DashboardNode children in base.Children)
                {
                    children.Render(
                        result,
                        context,
                        data,
                        weight
                        );
                }

                count++;

                if (this.Count != -1 && count == this.Count)
                {
                    break;
                }
            }

            context.Categories.Remove(this.Variable);
        }
        public override void Render(
            StringBuilder result,
            DashboardRenderContext context,
            Data filter,
            WeightingFilterCollection weight
            )
        {
            DataCore.Classes.Data data = filter;
            DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database(
                this.Dashboard.Core,
                null,
                this.Dashboard.Settings.ReportSettings.WeightMissingValue
                );

            if (this.Categories.Count == 0)
            {
                data = storageMethod.GetRespondents(
                    this.IdVariable,
                    true,
                    base.Dashboard.Core.CaseDataLocation,
                    data,
                    weight
                    );
            }
            else
            {
                if (this.Operator == DashboardFilterOperator.AND)
                {
                    foreach (Guid idCategory in this.Categories.Keys)
                    {
                        data = storageMethod.GetRespondents(
                            idCategory,
                            this.IdVariable,
                            true,
                            base.Dashboard.Core.CaseDataLocation,
                            data,
                            weight
                            );
                    }
                }
                else
                {
                    if (data == null)
                    {
                        data = new Data();
                    }

                    foreach (Guid idCategory in this.Categories.Keys)
                    {
                        Data d = storageMethod.GetRespondents(
                            idCategory,
                            this.IdVariable,
                            true,
                            base.Dashboard.Core.CaseDataLocation,
                            data,
                            weight
                            );

                        foreach (Guid idRespondent in d.Responses.Keys)
                        {
                            if (!data.Responses.ContainsKey(idRespondent))
                            {
                                data.Responses.Add(idRespondent, d.Responses[idRespondent]);
                            }
                        }
                    }
                }
            }

            // Run through all child dashboard nodes.
            foreach (DashboardNode children in base.Children)
            {
                children.Render(
                    result,
                    context,
                    data,
                    weight
                    );
            }
        }