/// <summary> /// Initializes a new instance of the <see cref="AnalysisExplicitCategory"/> class. /// </summary> /// <param name="analysis">Analysis</param> /// <param name="configCategory">Config category</param> public AnalysisExplicitCategory(Analysis analysis, UPConfigAnalysisCategory configCategory) { this.Analysis = analysis; this.ConfigCategory = configCategory; this.valueDictionary = new Dictionary <string, object>(); this.sourceValueArray = new List <object>(); foreach (UPConfigAnalysisCategoryValue configValue in configCategory.Values) { AnalysisExplicitCategoryValue value = new AnalysisExplicitCategoryValue(this, configValue); this.valueDictionary.SetObjectForKey(value, value.Key); this.sourceValueArray.Add(value); } if (this.ConfigCategory?.OtherLabel?.Length > 0) { this.otherValue = new AnalysisExplicitCategoryValue(this, this.ConfigCategory.OtherLabel); if (this.otherValue != null) { this.valueDictionary.SetObjectForKey(this.otherValue, this.otherValue.Key); this.sourceValueArray.Add(this.otherValue); } } else { this.otherValue = null; } }
/// <inheritdoc/> public override string StringValueForRow(ICrmDataSourceRow row) { string rawValue = this.RawValueForRow(row); AnalysisExplicitCategoryValue categoryValue = this.ExplicitCategory.CategoryValueForValue(rawValue); return(categoryValue.Label); }
private List <object> ValuesForYear(string year) { var values = this.categoriesPerYear[year] as List <object>; if (values != null) { return(values); } List <object> parameters = DateParameterSetForYear(year); List <object> arr = new List <object>(); foreach (UPConfigAnalysisCategoryValue configValue in this.ConfigCategory.Values) { AnalysisExplicitCategoryValue categoryValue = new AnalysisExplicitCategoryValue(this, configValue, parameters); arr.Add(categoryValue); this.ValueDictionary.SetObjectForKey(categoryValue, categoryValue.Key); } if (this.categoriesPerYear == null) { this.categoriesPerYear = new Dictionary <string, object> { { year, arr } }; } else { this.categoriesPerYear.SetObjectForKey(arr, year); } return(arr); }
/// <inheritdoc/> public override List <object> CategoryValueArrayForValue(string value) { AnalysisExplicitCategoryValue catVal = this.CategoryValueForValue(value); return(catVal != null ? new List <object> { catVal } : null); }
/// <inheritdoc/> public override string RawValueForRow(ICrmDataSourceRow row) { string parentValue = this.SourceField.RawValueForRow(row); if (parentValue?.Length > 0) { AnalysisExplicitCategoryValue value = this.ExplicitCategory.CategoryValueForValue(parentValue); return(value.Key); } return(null); }
/// <inheritdoc/> public override AnalysisCategoryValue CategoryValueForRow(ICrmDataSourceRow row) { string rawValue = this.AnalysisField.RawValueForRow(row); if (!string.IsNullOrEmpty(rawValue)) { AnalysisCategoryValue v = this.ValueDictionary.ValueOrDefault(rawValue) as AnalysisCategoryValue; if (v == null) { AnalysisExplicitCategoryValue explicitCategoryValue = this.AnalysisField.ExplicitCategory.CategoryValueForKey(rawValue); if (explicitCategoryValue != null) { v = new AnalysisCategoryValue(this, explicitCategoryValue); this.AddToValueDictionary(v); } } return(v); } return(null); }
/// <inheritdoc/> public override List <object> CategoriesForRow(ICrmDataSourceRow row) { List <object> rawValues = this.AnalysisField?.RawValueArrayForRow(row); if (rawValues == null || rawValues.Count == 0) { return(null); } List <object> valueArray = new List <object>(); foreach (string rawValue in rawValues) { AnalysisCategoryValue v = this.ValueDictionary.ValueOrDefault(rawValue) as AnalysisCategoryValue; if (v == null) { AnalysisExplicitCategoryValue explicitCategoryValue = this.AnalysisField.ExplicitCategory.CategoryValueForKey(rawValue); if (explicitCategoryValue != null) { v = new AnalysisCategoryValue(this, explicitCategoryValue); this.AddToValueDictionary(v); } } if (v != null) { valueArray.Add(v); } } if (valueArray.Count == 0) { valueArray = null; } return(valueArray); }
/// <inheritdoc/> public override string ValueForRawValue(string rawValue) { AnalysisExplicitCategoryValue explicitCategoryValue = this.AnalysisField?.ExplicitCategory.CategoryValueForKey(rawValue); return(explicitCategoryValue != null ? explicitCategoryValue.Label : base.ValueForRawValue(rawValue)); }