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 void AddDrillupActionsFromResultToPage(AnalysisResult result, UPMGridPage gridPage)
        {
            if (result.DrillupOptions != null)
            {
                foreach (AnalysisDrillupOption drillupOption in result.DrillupOptions)
                {
                    string label = drillupOption.IsBack ? LocalizedString.TextBack : drillupOption.DrillupDisplayString();

                    UPMOrganizerDrillupAction action = new UPMOrganizerDrillupAction(StringIdentifier.IdentifierWithStringId($"action.{drillupOption.Key}"))
                    {
                        DrillupOption = drillupOption
                    };

                    action.SetTargetAction(this, this.PerformDrillUp);
                    gridPage.AddHeadOption(new UPMGridHeadOption(label, action));
                }
            }
        }