/// <inheritdoc/> public override List <object> RawValueArrayForRow(ICrmDataSourceRow row) { string parentValue = this.SourceField.RawValueForRow(row); if (parentValue?.Length > 0) { List <object> values = this.ExplicitCategory.CategoryValueArrayForValue(parentValue); if (values.Count == 0) { return(null); } List <object> keyArray = new List <object> { values.Count }; foreach (AnalysisExplicitCategoryValue explicitValue in values) { keyArray.Add(explicitValue.Key); } return(keyArray); } return(null); }
private AnalysisProcessingXCategoryValue XCategoryForRow(ICrmDataSourceRow row) { AnalysisCategoryValue categoryValue = this.Settings.XCategory?.CategoryValueForRow(row); if (categoryValue == null) { return(null); } else { var xcategory = this.xCategories.ValueOrDefault(categoryValue.Key); if (xcategory == null) { xcategory = new AnalysisProcessingXCategoryValue(this, categoryValue); if (this.xCategories == null) { this.xCategories = new Dictionary <string, AnalysisProcessingXCategoryValue> { { xcategory.Key, xcategory } }; this.xCategoryArray = new List <AnalysisProcessingXCategoryValue> { xcategory }; } else { this.xCategories.SetObjectForKey(xcategory, xcategory.Key); this.xCategoryArray.Add(xcategory); } } return(xcategory); } }
/// <inheritdoc/> public override string StringValueForRow(ICrmDataSourceRow row) { string rawValue = this.RawValueForRow(row); AnalysisExplicitCategoryValue categoryValue = this.ExplicitCategory.CategoryValueForValue(rawValue); return(categoryValue.Label); }
/// <summary> /// String values for result row /// </summary> /// <param name="dataSourceRow">Data source row</param> /// <returns>List of string values for result row</returns> public List <string> StringValuesForResultRow(ICrmDataSourceRow dataSourceRow) { List <object> sourceFields = this.Result.DetailsFields; int sourceFieldCount = sourceFields.Count; List <string> stringArray = null; if (sourceFieldCount > 0) { stringArray = new List <string>(); foreach (object field in sourceFields) { if (field == null) { stringArray.Add(string.Empty); } else { AnalysisSourceField sourceField = (AnalysisSourceField)field; stringArray.Add(dataSourceRow.ValueAtIndex(sourceField.QueryResultFieldIndex)); } } } return(stringArray); }
/// <summary> /// Add row x category /// </summary> /// <param name="row">Row</param> /// <param name="xCategoryValue">X category value</param> /// <returns>Returns add row x category</returns> public bool AddRowXCategory(ICrmDataSourceRow row, AnalysisProcessingXCategoryValue xCategoryValue) { bool complete = true; foreach (AnalysisProcessingResultColumnValue processingResultColumnValue in this.resultColumns) { if (!processingResultColumnValue.ApplyRowXCategoryValueSumLine(row, xCategoryValue, this.IsSumLine)) { complete = false; } } if (this.resultRows == null) { this.resultRows = new List <object> { row }; } else { this.resultRows.Add(row); } return(complete); }
/// <summary> /// Initializes a new instance of the <see cref="AnalysisProcessingQueryResultRowExecutionContext"/> class. /// </summary> /// <param name="dataSource">Data source</param> /// <param name="yCategoryValue">Y category value</param> /// <param name="xCategoryValue">X category value</param> /// <param name="processingContext">Processing context</param> public AnalysisProcessingQueryResultRowExecutionContext(ICrmDataSourceRow dataSource, AnalysisProcessingYCategoryValue yCategoryValue, AnalysisProcessingXCategoryValue xCategoryValue, AnalysisProcessing processingContext) { this.Row = dataSource; this.YCategoryValue = yCategoryValue; this.XCategoryValue = xCategoryValue; this.ProcessingContext = processingContext; }
/// <inheritdoc/> public override AnalysisValueIntermediateResult ObjectResultForResultRow(ICrmDataSourceRow row) { var objectResultArray = new List <JsValue>(); foreach (AnalysisValueFunction func in this.Arguments) { AnalysisValueIntermediateResult res = func.ObjectResultForResultRow(row); if (res == null || !res.Complete) { objectResultArray.Add(new JsValue(0)); } else { objectResultArray.Add(res.JavascriptResult); } } JsValue resultValue = this.JavascriptFunction.Invoke(objectResultArray.ToArray()); if (resultValue.IsString()) { return(new AnalysisValueIntermediateResult(resultValue.ToString())); } else if (resultValue.IsNumber()) { return(new AnalysisValueIntermediateResult(resultValue.ToDouble())); } else { return(new AnalysisValueIntermediateResult(resultValue)); } }
/// <inheritdoc/> public override bool ApplyRowXCategoryValueArraySumLine(ICrmDataSourceRow dataSourceRow, List <object> xCategoryValueArray, bool sumLine) { string rid = $"{this.YCategoryValue.Key}:{dataSourceRow.RecordIdentificationAtIndex(this.queryTableIndex)}"; if (string.IsNullOrEmpty(rid)) { return(false); } if (this.OccurrenceCountForKey(rid) == 1) { ++this.count; } foreach (AnalysisProcessingXCategoryValue xCategoryValue in xCategoryValueArray) { if (this.OccurrenceCountForKey($"{xCategoryValue.Key}:{rid}") == 1) { AnalysisProcessingTableXResultColumnValue num = this.XResultColumnValueForCategoryValueKey(xCategoryValue.Key); num.Count++; } } return(true); }
/// <inheritdoc/> public override List <object> RawValueArrayForRow(ICrmDataSourceRow row) { string v = this.RawValueForRow(row); return(v.Length == 0 ? null : new List <object> { v }); }
/// <inheritdoc/> public override string TextResultForResultRow(ICrmDataSourceRow row) { if (this.CountField.QueryResultTableIndex >= 0) { return(row.RecordIdentificationAtIndex(this.CountField.QueryResultTableIndex)); } return(string.Empty); }
/// <summary> /// Text result for result row /// </summary> /// <param name="row">Row</param> /// <returns>Text result</returns> public virtual string TextResultForResultRow(ICrmDataSourceRow row) { AnalysisValueIntermediateResult res = this.ObjectResultForResultRow(row); if (res != null) { return(res.TextResult); } return(string.Empty); }
/// <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); }
/// <summary> /// Categories for row /// </summary> /// <param name="row">Row</param> /// <returns>Returns categories for row</returns> public virtual List <object> CategoriesForRow(ICrmDataSourceRow row) { AnalysisCategoryValue v = this.CategoryValueForRow(row); if (v == null || v.IsEmptyValue) { return(new List <object>()); } return(new List <object> { v }); }
/// <summary> /// Raw value array for row /// </summary> /// <param name="row">Row</param> /// <returns>Returns raw value array for row</returns> public virtual List <object> RawValueArrayForRow(ICrmDataSourceRow row) { string v = this.RawValueForRow(row); if (v.Length == 0) { return(null); } return(new List <object> { v }); }
private bool RowMatchesFilters(ICrmDataSourceRow row) { if (this.Settings.Conditions != null) { foreach (AnalysisFilter condition in this.Settings.Conditions) { if (!condition.MatchesRow(row)) { return(false); } } } return(true); }
/// <inheritdoc/> public override AnalysisValueIntermediateResult ObjectResultForResultRow(ICrmDataSourceRow row) { AnalysisValueIntermediateResult argumentResult = this.ArgumentFunction.ObjectResultForResultRow(row); if (argumentResult.Complete) { AnalysisValueIntermediateResult res = this.AnalysisFunction.ResultWithArgumentRowContextValueContext(argumentResult.JavascriptResult, null, null); if (res.Complete) { return(res); } } return(new AnalysisValueIntermediateResult("configError: incomplete")); }
/// <inheritdoc/> public override List <object> CategoriesForRow(ICrmDataSourceRow row) { var resultArray = new List <object>(); AnalysisCategoryValue v = this.CategoryValueForRow(row); if (v != null && !v.IsEmptyValue) { resultArray.Add(v); } foreach (var subIndices in this.AnalysisField.SubFieldQueryResultFieldIndices) { string rawValue = row.RawValueAtIndex(subIndices.ToInt()); if (rawValue != null) { v = this.ValueDictionary.ValueOrDefault(rawValue) as AnalysisCategoryValue; if (v == null) { if (!this.AnalysisField.CrmFieldInfo.IsEmptyValue(rawValue)) { v = new AnalysisCategoryValue(this, rawValue, row.ValueAtIndex(subIndices.ToInt())); if (v != null) { this.AddToValueDictionary(v); } } } if (v != null) { resultArray.Add(v); } } } if (resultArray.Count > 0) { return(resultArray); } return(new List <object> { this.EmptyValue() }); }
/// <inheritdoc/> public override AnalysisCategoryValue CategoryValueForRow(ICrmDataSourceRow row) { string rawValue = this.valueFunction == null ? "invalid" : this.valueFunction.TextResultForResultRow(row); if (!string.IsNullOrEmpty(rawValue)) { AnalysisCategoryValue categoryValue = this.ValueDictionary.ValueOrDefault(rawValue) as AnalysisCategoryValue; if (categoryValue == null) { categoryValue = new AnalysisCategoryValue(this, rawValue, rawValue); if (categoryValue != null) { this.AddToValueDictionary(categoryValue); } } return(categoryValue); } return(null); }
/// <inheritdoc/> public override AnalysisCategoryValue CategoryValueForRow(ICrmDataSourceRow row) { string rawValue = this.AnalysisField.RawValueForRow(row); if (rawValue != null) { AnalysisCategoryValue v = this.ValueDictionary.ValueOrDefault(rawValue) as AnalysisCategoryValue; if (v == null) { v = this.AnalysisField.CrmFieldInfo.IsEmptyValue(rawValue) ? this.EmptyValue() : new AnalysisCategoryValue(this, rawValue, this.AnalysisField.StringValueForRow(row)); this.AddToValueDictionary(v); } return(v); } 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); }
private string SignificantRowIdentifierForRow(ICrmDataSourceRow dataSourceRow) { string sig = null; var builder = new System.Text.StringBuilder(); builder.Append(sig); foreach (int?num in this.SignificantQueryResultTableIndices) { var rid = dataSourceRow.RecordIdentificationAtIndex(num.Value); if (sig == null) { sig = rid ?? "empty_"; } else { builder.Append($"_{rid}"); } } sig = builder.ToString(); return(sig); }
private AnalysisProcessingYCategoryValue YCategoryForRow(ICrmDataSourceRow row) { AnalysisCategoryValue categoryValue = this.Settings.Category.CategoryValueForRow(row); if (categoryValue == null || categoryValue.Key.Length == 0) { if (this.Settings.ShowEmpty) { categoryValue = this.Settings.Category.EmptyValue(); } else { return(null); } } var ycategory = this.yCategories.ValueOrDefault(categoryValue.Key); if (ycategory == null) { ycategory = new AnalysisProcessingYCategoryValue(this, categoryValue); if (this.yCategories == null) { this.yCategories = new Dictionary <string, AnalysisProcessingYCategoryValue> { { ycategory.Key, ycategory } }; this.yCategoryArray = new List <AnalysisProcessingYCategoryValue> { ycategory }; } else { this.yCategories.SetObjectForKey(ycategory, ycategory.Key); this.yCategoryArray.Add(ycategory); } } return(ycategory); }
private List <object> XCategoriesForRow(ICrmDataSourceRow row) { List <object> categoryValues = this.Settings.XCategory.CategoriesForRow(row); if (categoryValues.Count == 0) { return(null); } List <object> apCategoryValues = new List <object>(); foreach (AnalysisCategoryValue categoryValue in categoryValues) { var xcategory = this.xCategories.ValueOrDefault(categoryValue.Key); if (xcategory == null) { xcategory = new AnalysisProcessingXCategoryValue(this, categoryValue); if (this.xCategories == null) { this.xCategories = new Dictionary <string, AnalysisProcessingXCategoryValue> { { xcategory.Key, xcategory } }; this.xCategoryArray = new List <AnalysisProcessingXCategoryValue> { xcategory }; } else { this.xCategories.SetObjectForKey(xcategory, xcategory.Key); this.xCategoryArray.Add(xcategory); } } apCategoryValues.Add(xcategory); } return(apCategoryValues); }
/// <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); }
private void ProcessSearchPage(UPMGridPage searchPage, IReadOnlyList <string> contextMenuOptions, ICrmDataSourceRow crmRow, UPMResultRow listRow, AnalysisResult analysisResult, Page oldPage, int i) { var dataSource = analysisResult.DataSource; for (var j = 0; j < dataSource.NumberOfResultTables; j++) { var label = contextMenuOptions[j]; if (string.IsNullOrEmpty(label)) { continue; } var recordIdentification = crmRow.RecordIdentificationAtIndex(j); if (recordIdentification?.Length > 0) { var showRecordAction = new UPMOrganizerAnalysisShowRecordAction(StringIdentifier.IdentifierWithStringId($"action.row {i} record {j}")) { RecordIdentification = recordIdentification }; showRecordAction.SetTargetAction(this, this.PerformShowRecordAction); showRecordAction.LabelText = label; listRow.AddDetailAction(showRecordAction); } var backAction = new UPMOrganizerAnalysisBackAction(StringIdentifier.IdentifierWithStringId("action.back")) { AnalysisResult = analysisResult }; backAction.SetTargetAction(this, this.PerformBackToAnalysis); backAction.LabelText = LocalizedString.TextAnalysesBackToAnalysis; searchPage.AddHeadOption(new UPMGridHeadOption(backAction.LabelText, backAction)); searchPage.FixedFirstColumn = false; searchPage.SumRowAtEnd = false; var hasOnlyEmptyLabels = true; foreach (var lbl in contextMenuOptions) { if (lbl.Length > 0) { hasOnlyEmptyLabels = false; break; } } searchPage.ShowMenu = !hasOnlyEmptyLabels; this.TopLevelElement = searchPage; this.InformAboutDidChangeTopLevelElement(oldPage, searchPage, null, null); } }
/// <inheritdoc/> public override List <object> CategoriesForRow(ICrmDataSourceRow row) { List <object> stringValueArray; if (this.valueFunction == null) { stringValueArray = new List <object> { "invalid" }; } else { AnalysisValueIntermediateResult result = this.valueFunction.ObjectResultForResultRow(row); if (result.IsTextResult) { stringValueArray = new List <object> { result.TextResult }; } else if (result.IsObject) { stringValueArray = result.ArrayResult; var arr = new List <object>(); foreach (object v in stringValueArray) { if (v is string) { arr.Add((string)v); } } stringValueArray = arr; } else { stringValueArray = new List <object> { result.TextResult }; } } List <object> categoryValueArray = null; foreach (string rawValue in stringValueArray) { AnalysisCategoryValue categoryValue = this.ValueDictionary.ValueOrDefault(rawValue) as AnalysisCategoryValue; if (categoryValue == null) { categoryValue = new AnalysisCategoryValue(this, rawValue, rawValue); if (categoryValue != null) { this.AddToValueDictionary(categoryValue); } } if (categoryValue != null) { if (categoryValueArray == null) { categoryValueArray = new List <object> { categoryValue }; } else { categoryValueArray.Add(categoryValue); } } } return(categoryValueArray); }
/// <inheritdoc/> public override string KeyForRow(ICrmDataSourceRow row) { return(this.valueFunction == null ? "invalid" : this.valueFunction.TextResultForResultRow(row)); }
/// <summary> /// Initializes a new instance of the <see cref="AnalysisRowDetails"/> class. /// </summary> /// <param name="resultRow">Result row</param> /// <param name="dataSourceRow">Data source row</param> public AnalysisRowDetails(AnalysisRow resultRow, ICrmDataSourceRow dataSourceRow) { this.DataSourceRow = dataSourceRow; this.AnalysisResultRow = resultRow; }
/// <summary> /// Applies row x category value array /// </summary> /// <param name="dataSourceRow">Data source row</param> /// <param name="xCategoryValue">X Category value array</param> /// <param name="sumLine">Sum line</param> /// <returns>Boolean value for result</returns> public bool ApplyRowXCategoryValueSumLine(ICrmDataSourceRow dataSourceRow, AnalysisProcessingXCategoryValue xCategoryValue, bool sumLine) { return(this.ApplyRowXCategoryValueArraySumLine(dataSourceRow, xCategoryValue != null ? new List <object> { xCategoryValue } : null, sumLine)); }
/// <summary> /// Applies row x category value array /// </summary> /// <param name="dataSourceRow">Data source row</param> /// <param name="xCategoryValueArray">X category value array</param> /// <param name="sumLine">Sum line</param> /// <returns>Boolean value for result</returns> public virtual bool ApplyRowXCategoryValueArraySumLine(ICrmDataSourceRow dataSourceRow, List <object> xCategoryValueArray, bool sumLine) { return(true); }