Example #1
0
        /// <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);
        }
Example #2
0
        /// <inheritdoc/>
        public override string TextResultForResultRow(ICrmDataSourceRow row)
        {
            if (this.CountField.QueryResultTableIndex >= 0)
            {
                return(row.RecordIdentificationAtIndex(this.CountField.QueryResultTableIndex));
            }

            return(string.Empty);
        }
        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);
            }
        }
        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);
        }
        /// <inheritdoc/>
        public override bool ApplyRowXCategoryValueArraySumLine(ICrmDataSourceRow dataSourceRow, List <object> xCategoryValueArray, bool sumLine)
        {
            var v = dataSourceRow.RawValueAtIndex(this.SourceField.QueryResultFieldIndex);
            var recordIdentification = $"{this.YCategoryValue.Key}:{dataSourceRow.RecordIdentificationAtIndex(this.queryTableIndex)}";

            if (this.appliedRecordIdentifications.ValueOrDefault(recordIdentification) != null)
            {
                return(false);
            }

            this.appliedRecordIdentifications[recordIdentification] = 1;
            double doubleValue = v.ToDouble();

            if (this.WeightField != null)
            {
                var weightValue = dataSourceRow.RawValueAtIndex(this.WeightField.QueryResultFieldIndex);
                doubleValue *= weightValue.ToDouble();
            }

            if (this.CurrencyField != null)
            {
                string currencyValue = dataSourceRow.RawValueAtIndex(this.CurrencyField.QueryResultFieldIndex);
                doubleValue = this.ProcessingResultColumn.ProcessingContext.AdjustValueForCurrency(doubleValue, currencyValue);
            }

            if (this.AggregationType.Min)
            {
                if (this.count == 0 || this.aggregatedValue > doubleValue)
                {
                    this.aggregatedValue = doubleValue;
                }
            }
            else if (this.AggregationType.Max)
            {
                if (this.aggregatedValue < doubleValue || this.count == 0)
                {
                    this.aggregatedValue = doubleValue;
                }
            }
            else
            {
                this.aggregatedValue += doubleValue;
            }

            this.count++;
            if (xCategoryValueArray != null)
            {
                foreach (AnalysisProcessingXCategoryValue xCategoryValue in xCategoryValueArray)
                {
                    AnalysisProcessingSimpleXResultColumnValue xResult = this.XResultColumnValueForCategoryValueKey(xCategoryValue.Key);
                    if (this.AggregationType.Min)
                    {
                        if (this.count == 0 || xResult.AggregatedValue > doubleValue)
                        {
                            xResult.AggregatedValue = doubleValue;
                        }
                    }
                    else if (this.AggregationType.Max)
                    {
                        if (xResult.AggregatedValue < doubleValue || this.count == 0)
                        {
                            xResult.AggregatedValue = doubleValue;
                        }
                    }
                    else
                    {
                        xResult.AggregatedValue += doubleValue;
                    }

                    xResult.Count++;
                }
            }

            return(true);
        }