public override Data GetRespondents(Data filter, DataCore.Classes.StorageMethods.Database storageMethod) { if (this.Equation != null) { if (this.CompiledEquation == null) { this.CompiledEquation = new DataCore.Classes.Equation( this.Owner.Owner.Core, this.Equation, storageMethod.WeightMissingValue ); } return(storageMethod.GetRespondents( this.Identity, this.Owner.Identity, this.Owner.IsTaxonomy, this.Owner.Owner.Core.CaseDataLocation, filter, this.Owner.Owner.WeightingFilters, this.CompiledEquation )); } Data result = new Data(); // Run through all scores of the score group. foreach (LinkBiDefinitionDimensionScore score in this.Scores) { Data scoreRespondents = score.GetRespondents(filter, storageMethod); // Run through all respondent ids of the score result. foreach (Guid idRespondent in scoreRespondents.Responses.Keys) { if (result.Responses.ContainsKey(idRespondent)) { result.Responses[idRespondent][0] += scoreRespondents.Responses[idRespondent][0]; } else { result.Responses.Add(idRespondent, scoreRespondents.Responses[idRespondent]); result.Base += scoreRespondents.Responses[idRespondent][0]; if (score.Owner.VariableType == DatabaseCore.Items.VariableType.Multi) { result.Value += scoreRespondents.Responses[idRespondent][0]; } } if (score.Owner.VariableType != DatabaseCore.Items.VariableType.Multi) { result.Value += scoreRespondents.Responses[idRespondent][0]; } } } return(result); }
public virtual Data GetRespondents( Data filter, DataCore.Classes.StorageMethods.Database storageMethod ) { return(storageMethod.GetRespondents( this, filter, this.Owner.Owner.WeightingFilters )); }
public override void Render( StringBuilder result, DashboardRenderContext context, Data filter, WeightingFilterCollection weight ) { Data data = filter; DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( this.Dashboard.Core, null, this.Dashboard.Settings.ReportSettings.WeightMissingValue ); double highestValue = double.MinValue; Guid idCategory = new Guid(); foreach (string category in this.Dashboard.Cache.Categories[this.IdVariable.Value].Keys) { Data value = storageMethod.GetRespondents( (Guid)this.Dashboard.Cache.Categories[this.IdVariable.Value][category][0][2], this.IdVariable.Value, true, this.Dashboard.Core.CaseDataLocation, data, weight ); if (value.Value > highestValue) { highestValue = value.Value; idCategory = (Guid)this.Dashboard.Cache. Categories[this.IdVariable.Value][category][0][2]; } } if (this.Dashboard.Cache.CategoryLabels.ContainsKey(idCategory)) { result.Append((string)this.Dashboard.Cache.CategoryLabels[idCategory][0][1]); } }
/// <summary> /// Gets the respondents that apply on a list of categories. /// </summary> /// <param name="categories">The categories to filter on.</param> /// <param name="respondents">A previous applied filter, to filter the categories on.</param> /// <returns></returns> private Data FilterCategories( DataCore.Classes.StorageMethods.Database storageMethod, bool aggregateNonQAData, List <KeyValuePair <Guid, Guid> > categories, bool isTaxonomy, Data respondents = null ) { foreach (KeyValuePair <Guid, Guid> filterCategory in categories) { respondents = storageMethod.GetRespondents( filterCategory.Key, filterCategory.Value, isTaxonomy, this.Core.CaseDataLocation, respondents, null, null ); } return(respondents); }
private void RenderMeasure(LinkBiDefinitionDimension measure, string _selection, StringBuilder writer, int columnOffset, Data filter = null) { DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( base.Core, null ); // Check if the measure is a numeric variable. if (measure.Type == VariableType.Numeric) { string label = ""; if (measure.XmlNode.Attributes["Label" + this.Definition.Settings.IdLanguage] == null) { if (measure.IsTaxonomy) { label = (string)this.Core.TaxonomyVariableLabels.GetValue( "Label", new string[] { "IdTaxonomyVariable", "IdLanguage" }, new object[] { measure.Identity, this.Definition.Settings.IdLanguage } ); } else { label = (string)this.Core.VariableLabels.GetValue( "Label", new string[] { "IdVariable", "IdLanguage" }, new object[] { measure.Identity, this.Definition.Settings.IdLanguage } ); } measure.XmlNode.AddAttribute("Label" + this.Definition.Settings.IdLanguage, label); } label = measure.XmlNode.Attributes["Label" + this.Definition.Settings.IdLanguage].Value; string selection = _selection + string.Format( "\"{0}\",", (label) ); Data result = storageMethod.GetRespondentsNumeric( measure.Identity, measure.IsTaxonomy, this.Core.CaseDataLocation, filter, this.Definition.WeightingFilters ); writer.Append("[" + selection); //empty for responses writer.Append(string.Format( "\"{0}\",", "" )); writer.Append(string.Format( "\"{0}\",", result.Base.ToString(new CultureInfo("en-GB")) )); writer.Append(string.Format( "\"{0}\",", result.Value.ToString(new CultureInfo("en-GB")) )); //writer.Append(string.Format( // "\"{0}\"", // result.GetStdDev(1, result.GetMean(1)).ToString(new CultureInfo("en-GB")) //)); writer.Append(string.Format( "\"\"" )); writer.Append("],"); } else { // Create a new report calculator to calculate the // significant difference between categories. ReportCalculator calculator = new ReportCalculator( null, base.Core, null ); filter = storageMethod.GetRespondents(measure, filter, this.Definition.WeightingFilters); string baseValue = filter.Base.ToString(new CultureInfo("en-GB")); string uBaseValueStr = filter.Responses.Count.ToString(new CultureInfo("en-GB")); string eBaseValueStr = filter.Responses.Count.ToString(new CultureInfo("en-GB")); int rowOffset = i; Dictionary <Guid, double> categoryValues = new Dictionary <Guid, double>(); TaskCollection tasks = new TaskCollection(); tasks.Synchronously = true; // Run through all scores of the measure. /*foreach (LinkBiDefinitionDimensionScore score in measure.Scores) * { * if (score.Equation != null) * { * tasks.Synchronously = true; * break; * } * }*/ // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { tasks.Add(() => { Data scoreFilter = score.GetRespondents(filter, this.StorageMethod); categoryValues.Add(score.Identity, scoreFilter.Value); }); } tasks.WaitAll(); // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { if (measure.IsTaxonomy && score.Persistent && base.Definition.HierarchyFilter.TaxonomyCategories.ContainsKey(score.Identity) == false) { continue; } string label = ""; if (score.XmlNode.Attributes["Label" + this.Definition.Settings.IdLanguage] == null) { if (measure.IsTaxonomy) { label = (string)this.Core.TaxonomyCategoryLabels.GetValue( "Label", new string[] { "IdTaxonomyCategory", "IdLanguage" }, new object[] { score.Identity, this.Definition.Settings.IdLanguage } ); } else { label = (string)this.Core.CategoryLabels.GetValue( "Label", new string[] { "IdCategory", "IdLanguage" }, new object[] { score.Identity, this.Definition.Settings.IdLanguage } ); } score.XmlNode.AddAttribute("Label" + this.Definition.Settings.IdLanguage, label); } label = score.XmlNode.Attributes["Label" + this.Definition.Settings.IdLanguage].Value; string selection = _selection + string.Format( " \"{0}\",", measure.XmlNode.Attributes["Label" + this.Definition.Settings.IdLanguage].Value ); writer.Append("[" + selection); writer.Append(string.Format( "\"{0}\",", (label) )); if (this.Definition.Settings.DisplayUnweightedBase) { writer.Append(string.Format( "\"{0}\",", uBaseValueStr )); } if (this.Definition.Settings.DisplayEffectiveBase) { writer.Append(string.Format( "\"{0}\",", eBaseValueStr )); } writer.Append(string.Format( "\"{0}\",", baseValue )); double catgValue = categoryValues.ContainsKey(score.Identity) ? categoryValues[score.Identity] : 0; writer.Append(string.Format( "\"{0}\"", catgValue )); if (this.Definition.Settings.ExportPercentage) { double percent = 0; if (!string.IsNullOrEmpty(baseValue)) { percent = (catgValue / double.Parse(baseValue)) * 100; } writer.Append(string.Format( ",\"{0}\"", percent )); } writer.Append("],"); i++; } } }
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>"); }
private void RenderMeasure(LinkBiDefinitionDimension measure, ExcelWriter writer, int columnOffset, Data filter = null) { DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( base.Core, null ); int rowOffset = i; if (measure.Type == VariableType.Numeric) { Data result = storageMethod.GetRespondentsNumeric( measure.Identity, measure.IsTaxonomy, this.Core.CaseDataLocation, filter, this.Definition.WeightingFilters ); double baseValue = result.Base; string uBaseValueStr = result.Responses.Count.ToString(new CultureInfo("en-GB")); string eBaseValueStr = result.Responses.Count.ToString(new CultureInfo("en-GB")); string baseValueStr = baseValue.ToString(new CultureInfo("en-GB")); writer.Write( columnOffset + 2, i, baseValueStr ); writer.Write( columnOffset + 3, i, result.Responses.Values.Sum(x => x[0]).ToString(new CultureInfo("en-GB")) ); i++; if (totalToProcess != 0) { int progress = i * 100 / totalToProcess; if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } else { filter = storageMethod.GetRespondents( measure, filter, this.Definition.WeightingFilters ); double baseValue = filter.Base; string uBaseValueStr = filter.Responses.Count.ToString(new CultureInfo("en-GB")); string eBaseValueStr = filter.Responses.Count.ToString(new CultureInfo("en-GB")); string baseValueStr = baseValue.ToString(new CultureInfo("en-GB")); // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { if (score.Hidden) { continue; } if (measure.IsTaxonomy && score.Persistent && base.Definition.HierarchyFilter.TaxonomyCategories.ContainsKey(score.Identity) == false) { continue; } DefinitionObject _score = new DefinitionObject( this.Core, this.Definition.FileName, score.XmlNode ); /*writer.Write( * columnOffset + 1, * i, * score.Label * );*/ writer.Write( columnOffset + 1, i, _score.GetLabel(this.Definition.Settings.IdLanguage) ); int columnOffset2 = 0; if (this.DisplayUnweightedBase) { columnOffset2 = 1; writer.Write( columnOffset + 2, i, uBaseValueStr ); } if (this.DisplayEffectiveBase) { columnOffset2 = 1; writer.Write( columnOffset + 2, i, eBaseValueStr ); } writer.Write( columnOffset + columnOffset2 + 2, i, baseValueStr ); double value; Data scoreFilter = score.GetRespondents(filter, this.StorageMethod); value = scoreFilter.Value; writer.Write( columnOffset + columnOffset2 + 3, i, value.ToString(new CultureInfo("en-GB")) ); if (this.ExportPercentage) { double percentage = (value * 100 / baseValue); if (double.IsNaN(percentage)) { percentage = 0.0; } writer.Write( columnOffset + columnOffset2 + 4, i, percentage.ToString(new CultureInfo("en-GB")) ); } i++; if (totalToProcess != 0) { int progress = i * 100 / totalToProcess; if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } } for (int a = rowOffset; a < i; a++) { DefinitionObject _measure = new DefinitionObject( this.Core, this.Definition.FileName, measure.XmlNode ); /*writer.Write( * columnOffset, * a, * measure.Label * );*/ writer.Write( columnOffset, a, _measure.GetLabel(this.Definition.Settings.IdLanguage) ); } }
private void RenderMeasure(LinkBiDefinitionDimension measure, StringBuilder writer, int columnOffset, string selection, Data filter = null) { DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( base.Core, null ); // Check if the measure's variable is a numeric variable. if (measure.Type == VariableType.Numeric) { Data data = storageMethod.GetRespondentsNumeric( measure.Identity, measure.IsTaxonomy, this.Core.CaseDataLocation, filter, this.Definition.WeightingFilters ); writer.Append(data.Value.ToString(new CultureInfo("en-GB"))); writer.Append(","); i++; if (totalToProcess != 0) { int progress = (int)(i * 100 / totalToProcess); if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } else { filter = storageMethod.GetRespondents(measure, filter, this.Definition.WeightingFilters); string baseValue = filter.Base.ToString(new CultureInfo("en-GB")); string uBaseValue = filter.Responses.Count.ToString(new CultureInfo("en-GB")); int rowOffset = i; // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { if (score.Hidden) { continue; } if (measure.IsTaxonomy && score.Persistent && base.Definition.HierarchyFilter.TaxonomyCategories.ContainsKey(score.Identity) == false) { continue; } DefinitionObject _score = new DefinitionObject( this.Core, this.Definition.FileName, score.XmlNode.GetXPath() ); Data scoreFilter = score.GetRespondents(filter, this.StorageMethod); for (int r = 0; r < scoreFilter.Responses.Count; r++) { //writer.Append(selection); writer.Append(_score.GetLabel(this.Definition.Settings.IdLanguage).Replace(",", ",") + ","); //writer.Append(Environment.NewLine); break; } i++; if (totalToProcess != 0) { int progress = (int)(i * 100 / totalToProcess); if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } } }
private void RenderMeasure(LinkBiDefinitionDimension measure, string _selection, StringBuilder writer, int columnOffset, Data filter = null) { DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( base.Core, null ); // Check if the measure is a numeric variable. if (measure.Type == VariableType.Numeric) { string label = ""; if (measure.XmlNode.Attributes["Label" + this.Definition.Settings.IdLanguage] == null) { if (measure.IsTaxonomy) { label = (string)this.Core.TaxonomyVariableLabels.GetValue( "Label", new string[] { "IdTaxonomyVariable", "IdLanguage" }, new object[] { measure.Identity, this.Definition.Settings.IdLanguage } ); } else { label = (string)this.Core.VariableLabels.GetValue( "Label", new string[] { "IdVariable", "IdLanguage" }, new object[] { measure.Identity, this.Definition.Settings.IdLanguage } ); } measure.XmlNode.AddAttribute("Label" + this.Definition.Settings.IdLanguage, label); } label = measure.XmlNode.Attributes["Label" + this.Definition.Settings.IdLanguage].Value; string selection = _selection + string.Format( "\"Label\": \"{0}\",", label ); Data result = storageMethod.GetRespondentsNumeric( measure.Identity, measure.IsTaxonomy, this.Core.CaseDataLocation, filter, this.Definition.WeightingFilters ); writer.Append("{" + selection); writer.Append(string.Format( "\"Base\": \"{0}\",", result.Base.ToString(new CultureInfo("en-GB")) )); writer.Append(string.Format( "\"Value\": \"{0}\",", result.Value.ToString(new CultureInfo("en-GB")) )); writer.Append(string.Format( "\"StdDev\": \"{0}\"", result.GetStdDev(1, result.GetMean(1)).ToString(new CultureInfo("en-GB")) )); writer.Append("},"); } else { // Create a new report calculator to calculate the // significant difference between categories. ReportCalculator calculator = new ReportCalculator( null, base.Core, null ); filter = storageMethod.GetRespondents(measure, filter); string baseValue = filter.Base.ToString(new CultureInfo("en-GB")); int rowOffset = i; Dictionary <Guid, double> categoryValues = new Dictionary <Guid, double>(); TaskCollection tasks = new TaskCollection(); tasks.Synchronously = true; // Run through all scores of the measure. /*foreach (LinkBiDefinitionDimensionScore score in measure.Scores) * { * if (score.Equation != null) * { * tasks.Synchronously = true; * break; * } * }*/ // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { tasks.Add(() => { Data scoreFilter = score.GetRespondents(filter, this.StorageMethod); categoryValues.Add(score.Identity, scoreFilter.Value); }); } tasks.WaitAll(); // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { if (measure.IsTaxonomy && score.Persistent && base.Definition.HierarchyFilter.TaxonomyCategories.ContainsKey(score.Identity) == false) { continue; } string label = ""; if (score.XmlNode.Attributes["Label" + this.Definition.Settings.IdLanguage] == null) { if (measure.IsTaxonomy) { label = (string)this.Core.TaxonomyCategoryLabels.GetValue( "Label", new string[] { "IdTaxonomyCategory", "IdLanguage" }, new object[] { score.Identity, this.Definition.Settings.IdLanguage } ); } else { label = (string)this.Core.CategoryLabels.GetValue( "Label", new string[] { "IdCategory", "IdLanguage" }, new object[] { score.Identity, this.Definition.Settings.IdLanguage } ); } score.XmlNode.AddAttribute("Label" + this.Definition.Settings.IdLanguage, label); } label = score.XmlNode.Attributes["Label" + this.Definition.Settings.IdLanguage].Value; string selection = _selection + string.Format( "\"Label\": \"{0}\",", HttpUtility.HtmlEncode(label) ); writer.Append("{" + selection); writer.Append(string.Format( "\"Base\": \"{0}\",", baseValue )); writer.Append(string.Format( "\"Value\": \"{0}\"", categoryValues.ContainsKey(score.Identity) ? categoryValues[score.Identity] : 0 )); writer.Append("},"); i++; if (totalToProcess != 0) { int progress = i * 100 / totalToProcess; if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } } }
private void GetValue(HttpContext context) { LogRequest(context); DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( Global.Core, null ); Calculation calculation = Calculation.Total; if (context.Request.Params["Calculation"] != null) { if (!Enum.TryParse <Calculation>( context.Request.Params["Calculation"], true, out calculation )) { if (context.Request.Params["Category"] != null) { calculation = Calculation.Difference; } } } else { if (context.Request.Params["Category"] != null) { calculation = Calculation.Difference; } } Data filter = null; /*filter = storageMethod.GetRespondentsNumeric( * idVariable.Value, * true, * Global.Core.CaseDataLocation, * filter * );*/ WeightingFilterCollection weighting = null; Guid?idWeightingVariable = null; if (context.Request.Params["WeightingVariable"] != null) { idWeightingVariable = FindVariable(context.Request.Params["WeightingVariable"]); if (!idWeightingVariable.HasValue) { context.Response.Write( Global.LanguageManager.GetText("Error_VariableNotExists")); return; } weighting = new WeightingFilterCollection(null, Global.Core, null); weighting.DefaultWeighting = idWeightingVariable; weighting.LoadRespondents(filter); } if (context.Request.Params["Filter"] != null) { object[] category = FindCategory(context.Request.Params["Filter"]); if (category != null) { filter = storageMethod.GetRespondents( (Guid)category[1], (Guid)category[2], true, Global.Core.CaseDataLocation, filter, weighting ); } } if (context.Request.Params["Filter2"] != null) { object[] category = FindCategory(context.Request.Params["Filter2"]); if (category != null) { filter = storageMethod.GetRespondents( (Guid)category[1], (Guid)category[2], true, Global.Core.CaseDataLocation, filter, weighting ); } } if (context.Request.Params["Filter3"] != null) { object[] category = FindCategory(context.Request.Params["Filter3"]); if (category != null) { filter = storageMethod.GetRespondents( (Guid)category[1], (Guid)category[2], true, Global.Core.CaseDataLocation, filter, weighting ); } } double result = 0.0; if (calculation != Calculation.Difference && filter == null) { if (idWeightingVariable.HasValue) { filter = storageMethod.GetRespondentsNumeric( idWeightingVariable.Value, true, Global.Core.CaseDataLocation, filter, weighting ); } else { filter = new Data(); } } switch (calculation) { case Calculation.Average: case Calculation.Mean: result = filter.Value / filter.Responses.Count; result = Math.Round(result, 2); if (result > 1000) { result = Math.Round(result, 0); } context.Response.Write(string.Format( Global.LanguageManager.GetText("Output_Value"), calculation, result )); break; case Calculation.Total: result = filter.Value; result = Math.Round(result, 2); if (result > 1000) { result = Math.Round(result, 0); } context.Response.Write(string.Format( Global.LanguageManager.GetText("Output_Value"), calculation, result, idWeightingVariable.HasValue ? context.Request.Params["WeightingVariable"] : "" )); break; case Calculation.Difference: case Calculation.Up: case Calculation.Increased: Data data = filter; object[] category = FindCategory(context.Request.Params["Category"]); if (category != null) { data = storageMethod.GetRespondents( (Guid)category[1], (Guid)category[2], true, Global.Core.CaseDataLocation, filter, weighting ); } double value1 = data.Value; double baseValue = data.Value; category = FindCategory(context.Request.Params["CategoryCompare"]); data = storageMethod.GetRespondents( (Guid)category[1], (Guid)category[2], true, Global.Core.CaseDataLocation, filter, weighting ); value1 = data.Value - value1; result = Math.Round(result, 2); ValueChange valueChange = ValueChange.Increase; if (value1 < 10) { valueChange = ValueChange.Decrease; } if (value1 == 0) { context.Response.Write(string.Format( Global.LanguageManager.GetText("Output_Difference_NoChange"), context.Request.Params["WeightingVariable"], context.Request.Params["CategoryCompare"] )); } else { value1 = Math.Round(Math.Abs(value1 * 100 / baseValue), 0); if (value1 == 0) { value1 = Math.Round(Math.Abs(value1 * 100 / baseValue), 2); } string outputType = "Percent"; if (value1 > 200) { value1 = Math.Round(value1 / 100); outputType = "Times"; calculation = Calculation.Difference; } if (calculation == Calculation.Difference) { context.Response.Write(string.Format( Global.LanguageManager.GetText("Output_Difference"), context.Request.Params["WeightingVariable"], Global.LanguageManager.GetText("Type_ValueChange_" + valueChange), value1, context.Request.Params["CategoryCompare"], outputType )); } else { context.Response.Write(string.Format( Global.LanguageManager.GetText("Output_Difference2"), context.Request.Params["WeightingVariable"], Global.LanguageManager.GetText("Type_ValueChange_" + calculation + "_" + valueChange), value1, context.Request.Params["Category"] )); } } break; } }
public byte[] CheckTaxonomizedData() { Data2 filter = new Data2(0); // Get all respondents of the study. List <object[]> respondents = this.Core.Respondents.GetValues( new string[] { "Id" }, new string[] { "IdStudy" }, new object[] { this.IdStudy } ); // Run through all respondents of the study. foreach (object[] respondent in respondents) { filter.Responses.Add((Guid)respondent[0], new double[] { 0 }); } string fileName = Path.GetTempFileName() + ".xlsx"; // Create a new excel writer that builds the result document. ExcelWriter writer = new ExcelWriter(); DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( this.Core, null ); // Get all variable links of the study. List <object[]> variableLinks = this.Core.VariableLinks.ExecuteReader(string.Format( "SELECT IdVariable, IdTaxonomyVariable FROM VariableLinks WHERE IdVariable IN (SELECT Id FROM Variables WHERE IdStudy='{0}')", this.IdStudy ), typeof(Guid), typeof(Guid)); Dictionary <string, Dictionary <string, Dictionary <string, Dictionary <string, double[]> > > > categoryValues = new Dictionary <string, Dictionary <string, Dictionary <string, Dictionary <string, double[]> > > >(); Dictionary <string, Dictionary <string, double> > unlinkedCategories = new Dictionary <string, Dictionary <string, double> >(); writer.Write(0, "Variable"); writer.Write(1, "Taxonomy variable"); writer.Write(2, "Variable value"); writer.Write(3, "Taxonomy variable value"); writer.Write(4, "Status"); writer.ActiveSheet.Cells[writer.Position, 0, writer.Position, 4].Interior.Color = SpreadsheetGear.Color.FromArgb(54, 94, 146); writer.ActiveSheet.Cells[writer.Position, 0, writer.Position, 4].Font.Color = SpreadsheetGear.Color.FromArgb(255, 255, 255); writer.ActiveSheet.Cells[writer.Position, 0, writer.Position, 1].EntireColumn.ColumnWidth = 50; writer.ActiveSheet.Cells[writer.Position, 0, writer.Position, 1].EntireColumn.WrapText = true; writer.ActiveSheet.WindowInfo.FreezePanes = true; writer.ActiveSheet.Cells[0, 0, 0, 4].Select(); writer.NewLine(); int i = 0; // Run through all variable links of the study. foreach (object[] variableLink in variableLinks) { Variable variable = this.Core.Variables.GetSingle( "Id", variableLink[0] ); TaxonomyVariable taxonomyVariable = this.Core.TaxonomyVariables.GetSingle( "Id", variableLink[1] ); if (!categoryValues.ContainsKey(variable.Name)) { categoryValues.Add(variable.Name, new Dictionary <string, Dictionary <string, Dictionary <string, double[]> > >()); } if (!categoryValues[variable.Name].ContainsKey(taxonomyVariable.Name)) { categoryValues[variable.Name].Add(taxonomyVariable.Name, new Dictionary <string, Dictionary <string, double[]> >()); } XmlDocument test2 = new XmlDocument(); test2.LoadXml("<Report><Settings><Setting Name=\"AggregateNonQAData\">True</Setting></Settings></Report>"); ReportDefinition test = new ReportDefinition( this.Core, test2, new Crosstables.Classes.HierarchyClasses.HierarchyFilter(null) ); test.HierarchyFilter.Load(); // Create a fake report definition variable for the study variable. ReportDefinitionVariable reportDefinitionVariable = new ReportDefinitionVariable(test, variable, null); // Create a fake report definition variable for the taxonomy variable. ReportDefinitionVariable reportDefinitionTaxonomyVariable = new ReportDefinitionVariable(test, taxonomyVariable, null); Data variableData = storageMethod.GetRespondents(reportDefinitionVariable); Data taxonomyVariableData = storageMethod.GetRespondents( reportDefinitionTaxonomyVariable, filter ); writer.Write(0, variable.Name); writer.Write(1, taxonomyVariable.Name); writer.Write(2, variableData.Value.ToString()); writer.Write(3, taxonomyVariableData.Value.ToString()); if (variableData.Value != taxonomyVariableData.Value) { writer.Write(4, "FAILED"); writer.ActiveSheet.Cells[writer.Position, 4].Interior.Color = SpreadsheetGear.Drawing.Color.FromArgb(255, 0, 0); } else { writer.Write(4, "PASSED"); writer.ActiveSheet.Cells[writer.Position, 4].Interior.Color = SpreadsheetGear.Drawing.Color.FromArgb(0, 255, 0); } writer.NewLine(); // Get all category links of the variable. /*List<object[]> categoryLinks = this.Core.CategoryLinks.ExecuteReader(string.Format( * "SELECT IdCategory, IdTaxonomyCategory FROM CategoryLinks WHERE IdVariable='{0}'", * variableLink[0] * ));*/ // Get all categories of the variable. List <object[]> categories = this.Core.Categories.GetValues( new string[] { "Id", "Name" }, new string[] { "IdVariable" }, new object[] { variableLink[0] } ); // Run through all category links of the variable. foreach (object[] category in categories) { /*if ((string)category[1] == "SystemMissing") * continue;*/ // Get the category links for the category. List <object[]> categoryLinks = this.Core.CategoryLinks.ExecuteReader(string.Format( "SELECT IdCategory, IdTaxonomyCategory FROM CategoryLinks WHERE IdCategory='{0}'", category[0] )); // Create a fake report definition category for the study category. ReportDefinitionCategory reportDefinitionCategory = new ReportDefinitionCategory(reportDefinitionVariable, reportDefinitionVariable.XmlNode.SelectSingleNode(string.Format( "*[@Id=\"{0}\"]", category[0] ))); Data categoryData = storageMethod.GetRespondents( reportDefinitionCategory, reportDefinitionVariable ); if (categoryLinks.Count == 0) { if (!unlinkedCategories.ContainsKey(variable.Name)) { unlinkedCategories.Add(variable.Name, new Dictionary <string, double>()); } if (!unlinkedCategories[variable.Name].ContainsKey((string)category[1])) { unlinkedCategories[variable.Name].Add((string)category[1], categoryData.Value); } continue; } object[] categoryLink = categoryLinks.First(); XmlNode xmlNode = reportDefinitionTaxonomyVariable.XmlNode.SelectSingleNode(string.Format( "*[@Id=\"{0}\"]", categoryLink[1] )); if (xmlNode == null) { continue; } // Create a fake report definition category for the study category. ReportDefinitionTaxonomyCategory reportDefinitionTaxonomyCategory = new ReportDefinitionTaxonomyCategory(reportDefinitionTaxonomyVariable, xmlNode); if (!categoryValues[variable.Name][taxonomyVariable.Name].ContainsKey(reportDefinitionCategory.Name)) { categoryValues[variable.Name][taxonomyVariable.Name].Add(reportDefinitionCategory.Name, new Dictionary <string, double[]>()); } if (!categoryValues[variable.Name][taxonomyVariable.Name][reportDefinitionCategory.Name].ContainsKey(reportDefinitionTaxonomyCategory.Name)) { categoryValues[variable.Name][taxonomyVariable.Name][reportDefinitionCategory.Name].Add(reportDefinitionTaxonomyCategory.Name, new double[2]); } Data taxonomyCategoryData = storageMethod.GetRespondents(reportDefinitionTaxonomyCategory, reportDefinitionTaxonomyVariable, filter); categoryValues[variable.Name][taxonomyVariable.Name][reportDefinitionCategory.Name][reportDefinitionTaxonomyCategory.Name][0] = categoryData.Value; categoryValues[variable.Name][taxonomyVariable.Name][reportDefinitionCategory.Name][reportDefinitionTaxonomyCategory.Name][1] = taxonomyCategoryData.Value; } i++; } writer.NewSheet("Categories"); writer.Write(0, "Variable"); writer.Write(1, "Taxonomy variable"); writer.Write(2, "Category"); writer.Write(3, "Taxonomy category"); writer.Write(4, "Category value"); writer.Write(5, "Taxonomy category value"); writer.Write(6, "Status"); writer.ActiveSheet.Cells[writer.Position, 0, writer.Position, 6].Interior.Color = SpreadsheetGear.Color.FromArgb(54, 94, 146); writer.ActiveSheet.Cells[writer.Position, 0, writer.Position, 6].Font.Color = SpreadsheetGear.Color.FromArgb(255, 255, 255); writer.ActiveSheet.Cells[writer.Position, 0, writer.Position, 4].EntireColumn.ColumnWidth = 25; writer.ActiveSheet.Cells[writer.Position, 0, writer.Position, 4].EntireColumn.WrapText = true; writer.ActiveSheet.Cells[writer.Position, 6].EntireColumn.ColumnWidth = 12; writer.ActiveSheet.WindowInfo.FreezePanes = true; writer.ActiveSheet.Cells[0, 0, 0, 6].Select(); writer.NewLine(); // Run through all variables of the study. foreach (string variableName in categoryValues.Keys) { // Run through all taxonomy variables that are linked to the study variable. foreach (string taxonomyVariableName in categoryValues[variableName].Keys) { // Run through all categories of the variable. foreach (string categoryName in categoryValues[variableName][taxonomyVariableName].Keys) { // Run through all taxonomy categories that are linked to the study category. foreach (string taxonomyCategoryName in categoryValues[variableName][taxonomyVariableName][categoryName].Keys) { double categoryData = categoryValues[variableName][taxonomyVariableName][categoryName][taxonomyCategoryName][0]; double taxonomyCategoryData = categoryValues[variableName][taxonomyVariableName][categoryName][taxonomyCategoryName][1]; writer.Write(0, variableName); writer.Write(1, taxonomyVariableName); writer.Write(2, categoryName); writer.Write(3, taxonomyCategoryName); writer.Write(4, categoryData.ToString()); writer.Write(5, taxonomyCategoryData.ToString()); if (categoryData != taxonomyCategoryData) { writer.Write(6, "FAILED"); writer.ActiveSheet.Cells[writer.Position, 6].Interior.Color = SpreadsheetGear.Drawing.Color.FromArgb(255, 0, 0); } else { writer.Write(6, "PASSED"); writer.ActiveSheet.Cells[writer.Position, 6].Interior.Color = SpreadsheetGear.Drawing.Color.FromArgb(0, 255, 0); } writer.NewLine(); } } if (unlinkedCategories.ContainsKey(variableName)) { // Run through all unlinked categories of the variable. foreach (string categoryName in unlinkedCategories[variableName].Keys) { writer.Write(0, variableName); writer.Write(1, ""); writer.Write(2, categoryName); writer.Write(3, ""); writer.Write(4, unlinkedCategories[variableName][categoryName].ToString()); writer.Write(5, ""); writer.Write(6, "NON-LINKED"); writer.ActiveSheet.Cells[writer.Position, 6].Interior.Color = SpreadsheetGear.Drawing.Color.FromArgb(255, 192, 0); writer.NewLine(); } } } } return(writer.Save()); }
private void MeanScore(HttpContext context) { DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( Global.Core, null ); Guid?idVariable = FindVariable(context.Request.Params["Variable"]); if (!idVariable.HasValue) { context.Response.Write( Global.LanguageManager.GetText("Error_VariableNotExists")); return; } Dictionary <Guid, List <object[]> > categories = Global.Core.TaxonomyCategories.ExecuteReaderDict <Guid>( "SELECT IdTaxonomyVariable, Id, [Value] FROM TaxonomyCategories", new object[] { } ); if (categories.ContainsKey(idVariable.Value)) { double meanScore = 0; double baseValue = 0; Data data = storageMethod.GetRespondents( idVariable.Value, true, Global.Core.CaseDataLocation ); baseValue = data.Value; foreach (object[] category in categories[idVariable.Value]) { data = storageMethod.GetRespondents( (Guid)category[1], idVariable.Value, true, Global.Core.CaseDataLocation ); data.Value = data.Value * (int)category[2] / baseValue; meanScore += data.Value; } context.Response.Write(string.Format( Global.LanguageManager.GetText("Output_Value2"), context.Request.Params["Variable"], Math.Round(meanScore, 2) )); } else { Data data = storageMethod.GetRespondents( idVariable.Value, true, Global.Core.CaseDataLocation ); context.Response.Write(string.Format( Global.LanguageManager.GetText("Output_Value"), context.Request.Params["Variable"], data.Value )); } }
private void HighestValue(HttpContext context) { LogRequest(context); DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( Global.Core, null ); Guid?idVariable = FindVariable(context.Request.Params["Variable"]); if (!idVariable.HasValue) { context.Response.Write(Global.LanguageManager.GetText("Error_VariableNotExists")); return; } Dictionary <Guid, List <object[]> > categories = Global.Core.TaxonomyCategories.ExecuteReaderDict <Guid>( "SELECT IdTaxonomyVariable, Id FROM TaxonomyCategories", new object[] { } ); Data filter = null; if (context.Request.Params["Filter"] != null) { object[] category = FindCategory(context.Request.Params["Filter"]); if (category != null) { filter = storageMethod.GetRespondents( (Guid)category[1], (Guid)category[2], true, Global.Core.CaseDataLocation, filter ); } } if (context.Request.Params["Filter2"] != null) { object[] category = FindCategory(context.Request.Params["Filter2"]); if (category != null) { filter = storageMethod.GetRespondents( (Guid)category[1], (Guid)category[2], true, Global.Core.CaseDataLocation, filter ); } } if (context.Request.Params["Filter3"] != null) { object[] category = FindCategory(context.Request.Params["Filter3"]); if (category != null) { filter = storageMethod.GetRespondents( (Guid)category[1], (Guid)category[2], true, Global.Core.CaseDataLocation, filter ); } } WeightingFilterCollection weighting = null; Guid?idWeightingVariable = null; if (context.Request.Params["WeightingVariable"] != null) { idWeightingVariable = FindVariable(context.Request.Params["WeightingVariable"]); if (!idWeightingVariable.HasValue) { context.Response.Write( Global.LanguageManager.GetText("Error_VariableNotExists")); return; } weighting = new WeightingFilterCollection(null, Global.Core, null); weighting.DefaultWeighting = idWeightingVariable; weighting.LoadRespondents(null); } string highestIdentifier = "highest"; if (context.Request.Params["HighestIdentifier"] != null) { highestIdentifier = context.Request.Params["HighestIdentifier"]; if (highestIdentifier == "undefined") { highestIdentifier = "most"; } } if (categories.ContainsKey(idVariable.Value)) { double highestShare = 0; Guid? idCategoryHighestShare = null; Data data = storageMethod.GetRespondents( idVariable.Value, true, Global.Core.CaseDataLocation, filter, weighting ); double baseValue = data.Value; foreach (object[] category in categories[idVariable.Value]) { data = storageMethod.GetRespondents( (Guid)category[1], idVariable.Value, true, Global.Core.CaseDataLocation, filter, weighting ); data.Value = data.Value * 100 / baseValue; if (data.Value > highestShare) { highestShare = data.Value; idCategoryHighestShare = (Guid)category[1]; } } Dictionary <Guid, List <object[]> > categoryLabels = Global.Core.TaxonomyCategoryLabels.ExecuteReaderDict <Guid>( "SELECT IdTaxonomyCategory, Label FROM TaxonomyCategoryLabels", new object[] { } ); if (idCategoryHighestShare.HasValue) { context.Response.Write(string.Format( Global.LanguageManager.GetText("Output_HighestValue"), context.Request.Params["Variable"], categoryLabels[idCategoryHighestShare.Value][0][1], Math.Round(highestShare, 0), highestIdentifier, context.Request.Params["WeightingVariable"] == null ? "value" : context.Request.Params["WeightingVariable"] )); } else { context.Response.Write(string.Format( Global.LanguageManager.GetText("Error_ValueNotFound") )); } } else { Data data = storageMethod.GetRespondents( idVariable.Value, true, Global.Core.CaseDataLocation, filter, weighting ); context.Response.Write(string.Format( Global.LanguageManager.GetText("Output_Value"), context.Request.Params["Variable"], data.Value )); } }
private void RenderMeasure(LinkBiDefinitionDimension measure, StringBuilder writer, int columnOffset, Data filter = null) { DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( base.Core, null ); string baseValue = filter.Base.ToString(new CultureInfo("en-GB")); string uBaseValue = filter.Responses.Count.ToString(new CultureInfo("en-GB")); string eBaseValue = filter.Responses.Count.ToString(new CultureInfo("en-GB")); int rowOffset = i; writer.Append(string.Format( "<{0}", measure.XmlNode.Name )); foreach (XmlAttribute attribute in measure.XmlNode.Attributes) { writer.Append(string.Format( " {0}=\"{1}\"", attribute.Name, HttpUtility.HtmlEncode(attribute.Value) )); } writer.Append(">"); if (measure.Type == DatabaseCore.Items.VariableType.Numeric) { Data result = storageMethod.GetRespondentsNumeric( measure.Identity, measure.IsTaxonomy, this.Core.CaseDataLocation, filter, this.Definition.WeightingFilters ); writer.Append(string.Format( "<NumericValue Id=\"00000000-0000-0000-0000-000000000000\" Value=\"{0}\" Base=\"{1}\" />", result.Value, filter.Base )); i++; } else { filter = storageMethod.GetRespondents( measure, filter, this.Definition.WeightingFilters ); baseValue = filter.Base.ToString(new CultureInfo("en-GB")); uBaseValue = filter.Responses.Count.ToString(new CultureInfo("en-GB")); eBaseValue = filter.Responses.Count.ToString(new CultureInfo("en-GB")); // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { if (score.Hidden) { continue; } if (measure.IsTaxonomy && score.Persistent && base.Definition.HierarchyFilter.TaxonomyCategories.ContainsKey(score.Identity) == false) { continue; } writer.Append(string.Format( "<{0}", score.XmlNode.Name )); foreach (XmlAttribute attribute in score.XmlNode.Attributes) { if (attribute.Name == "Base" || attribute.Name == "Value") { continue; } writer.Append(string.Format( " {0}=\"{1}\"", attribute.Name, HttpUtility.HtmlEncode(attribute.Value) )); } /*Data scoreFilter = storageMethod.GetRespondents( * score.Identity, * measure.Identity, * measure.IsTaxonomy, * filter, * this.Definition.WeightingFilters * );*/ Data scoreFilter = score.GetRespondents(filter, this.StorageMethod); if (this.DisplayUnweightedBase) { writer.Append(string.Format( " UBase=\"{0}\"", uBaseValue )); } if (this.DisplayEffectiveBase) { writer.Append(string.Format( " eBase=\"{0}\"", uBaseValue )); } writer.Append(string.Format( " Base=\"{0}\"", baseValue )); //double value = scoreFilter.Responses.Values.Sum(x => x[0]); double value = scoreFilter.Value; writer.Append(string.Format( " Value=\"{0}\"", value.ToString(new CultureInfo("en-GB")) )); if (this.ExportPercentage) { writer.Append(string.Format( " Percentage=\"{0}\"", (value * 100 / filter.Base).ToString(new CultureInfo("en-GB")) )); } i++; if (totalToProcess != 0) { int progress = i * 100 / totalToProcess; if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } writer.Append(string.Format( "></{0}>", score.XmlNode.Name )); } } writer.Append(string.Format( "</{0}>", measure.XmlNode.Name )); }
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); }
private void RenderMeasure(LinkBiDefinitionDimension measure, StringBuilder writer, int columnOffset, string selection, Data filter = null) { DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( base.Core, null ); VariableType variableType = measure.VariableType; // Check if the measure's variable is a numeric variable. if (variableType == VariableType.Numeric) { Data data = storageMethod.GetRespondentsNumeric( measure.Identity, measure.IsTaxonomy, this.Core.CaseDataLocation, filter, this.Definition.WeightingFilters ); selection += HttpUtility.HtmlEncode(measure.Label).Replace(",", ",") + ","; writer.Append(selection); writer.Append(filter.Base.ToString(new CultureInfo(2057))); writer.Append(","); writer.Append(data.Value.ToString(new CultureInfo(2057))); writer.Append(Environment.NewLine); } else { filter = storageMethod.GetRespondents(measure, filter, this.Definition.WeightingFilters); string baseValue = filter.Base.ToString(new CultureInfo("en-GB")); string uBaseValue = filter.Responses.Count.ToString(new CultureInfo("en-GB")); string eBaseValue = filter.Responses.Count.ToString(new CultureInfo("en-GB")); int rowOffset = i; selection += HttpUtility.HtmlEncode(measure.Label).Replace(",", ",") + ","; // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { if (score.Hidden) { continue; } if (measure.IsTaxonomy && score.Persistent && base.Definition.HierarchyFilter.TaxonomyCategories.ContainsKey(score.Identity) == false) { continue; } DefinitionObject _score = new DefinitionObject( this.Core, this.Definition.FileName, score.XmlNode.GetXPath() ); writer.Append(selection); writer.Append(_score.GetLabel(this.Definition.Settings.IdLanguage).Replace(",", ",") + ","); /*Data scoreFilter = storageMethod.GetRespondents( * score.Identity, * measure.Identity, * measure.IsTaxonomy, * filter, * this.Definition.WeightingFilters * );*/ Data scoreFilter = score.GetRespondents(filter, this.StorageMethod); if (this.DisplayUnweightedBase) { writer.Append(uBaseValue + ","); } if (this.DisplayEffectiveBase) { writer.Append(eBaseValue + ","); } writer.Append(baseValue + ","); writer.Append(scoreFilter.Value); if (this.ExportPercentage) { writer.Append(","); if (filter.Base != 0) { writer.Append((scoreFilter.Value * 100 / filter.Base).ToString(new CultureInfo("en-GB"))); } else { writer.Append("0"); } } writer.Append(Environment.NewLine); i++; if (totalToProcess != 0) { int progress = i * 100 / totalToProcess; if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } } }
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 ) { 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 ); } }