예제 #1
0
        private void AddResultRow(bool optimizeForSpeed, UPMResultSection resultSection, UPCRMResultRow dataRow)
        {
            if (resultSection == null)
            {
                throw new ArgumentNullException(nameof(resultSection));
            }

            if (dataRow == null)
            {
                throw new ArgumentNullException(nameof(dataRow));
            }

            if (optimizeForSpeed)
            {
                ((UPResultRowFromCRMResultRows)resultSection.ResultRowProvider).AddRow(dataRow);
            }
            else
            {
                var identifier = new RecordIdentifier(this.InfoAreaId, dataRow.RecordIdAtIndex(0));
                var resultRow  = new UPMResultRow(identifier);
                this.ResultContext.RowDictionary[resultRow.Key] = new UPCoreMappingResultRowContext(dataRow, this.ResultContext);
                resultRow.Invalid   = true;
                resultRow.DataValid = true;
                resultSection?.AddResultRow(resultRow);
            }
        }
        private void AddCategoryActionsToRow(UPMResultRow row)
        {
            var      categories      = this.Analysis.CategoryDictionary.Values;
            UPMGroup detailGroupCol1 = new UPMGroup(StringIdentifier.IdentifierWithStringId("det1"));

            foreach (AnalysisCategory category in categories)
            {
                UPMStringField field = new UPMStringField(null)
                {
                    LabelText   = category.Key,
                    StringValue = category.Label
                };

                detailGroupCol1.AddField(field);
            }

            row.AddDetailGroup(detailGroupCol1);
            UPMGroup detailGroupCol2 = new UPMGroup(StringIdentifier.IdentifierWithStringId("det2"));

            row.AddDetailGroup(detailGroupCol2);
            foreach (var analysisResultColumn in this.AnalysisSettings.ResultColumns)
            {
                UPMStringField field = new UPMStringField(null)
                {
                    LabelText   = analysisResultColumn.Key,
                    StringValue = analysisResultColumn.Label
                };
                detailGroupCol2.AddField(field);
            }
        }
        private void ProcessResultRows(
            AnalysisResult result,
            UPMGridPage searchPage,
            IReadOnlyList <object> xColumnArray,
            bool keyAsRawString,
            int columnCount,
            UPMResultSection section)
        {
            var i          = 0;
            var resultRows = CreateResultRows(result);
            var sumRow     = result.SumLine;

            foreach (AnalysisRow row in resultRows)
            {
                var identifier = StringIdentifier.IdentifierWithStringId($"row {i}");
                var listRow    = new UPMResultRow(identifier)
                {
                    Context = row
                };
                i++;
                var fieldArray = CreateFieldArray(row, xColumnArray, keyAsRawString, columnCount, i);

                listRow.Fields = fieldArray;
                if (searchPage.FixedSumRow && sumRow != null && i == resultRows.Count && resultRows.Count > 12)
                {
                    searchPage.SumResultRow = listRow;
                    searchPage.SumRowAtEnd  = false;
                }
                else
                {
                    section.AddResultRow(listRow);
                }

                if (row.HasDetails)
                {
                    var detailGroupCol1 = new UPMAnalysisResultRowGroup(StringIdentifier.IdentifierWithStringId("det1"))
                    {
                        Invalid = true,
                        Left    = true,
                        Row     = row
                    };
                    listRow.AddDetailGroup(detailGroupCol1);
                    var detailGroupCol2 = new UPMAnalysisResultRowGroup(StringIdentifier.IdentifierWithStringId("det2"))
                    {
                        Invalid = true,
                        Left    = false,
                        Row     = row
                    };
                    listRow.AddDetailGroup(detailGroupCol2);
                }

                this.AddDrilldownActionsFromRowToListRow(row, listRow);
                this.AddDetailsActionFromRowToListRow(row, listRow);
            }
        }
        /// <summary>
        /// Results the section for search result.
        /// </summary>
        /// <param name="preparedSearch">The prepared search.</param>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        public virtual UPMResultSection ResultSectionForSearchResult(UPSearchPageModelControllerPreparedSearch preparedSearch, UPCRMResult result)
        {
            var configStore   = ConfigurationUnitStore.DefaultStore;
            var resultContext = new UPCoreMappingResultContext(result, preparedSearch.CombinedControl, preparedSearch.ListFieldControl.NumberOfFields);

            this.SectionContexts.SetObjectForKey(resultContext, preparedSearch.InfoAreaId);
            var resultSection  = new UPMResultSection(StringIdentifier.IdentifierWithStringId($"Search_{preparedSearch.InfoAreaId}"));
            var infoAreaConfig = configStore.InfoAreaConfigById(preparedSearch.InfoAreaId);

            if (infoAreaConfig != null)
            {
                var colorKey = infoAreaConfig.ColorKey;
                if (!string.IsNullOrEmpty(colorKey))
                {
                    resultSection.BarColor = AureaColor.ColorWithString(colorKey);
                }

                var imageName = infoAreaConfig.ImageName;
                if (!string.IsNullOrEmpty(imageName))
                {
                    var fileResource = configStore.ResourceByName(imageName);
                    if (fileResource != null)
                    {
                        resultSection.GlobalSearchIconName = fileResource.FileName;
                    }
                }
            }

            resultSection.SectionField = new UPMField(StringIdentifier.IdentifierWithStringId("SectionLabel"));
            var sectionName = infoAreaConfig?.PluralName;

            if (string.IsNullOrEmpty(sectionName))
            {
                var tableInfo = UPCRMDataStore.DefaultStore.TableInfoForInfoArea(preparedSearch.InfoAreaId);
                sectionName = tableInfo != null ? tableInfo.Label : preparedSearch.InfoAreaId;
            }

            resultSection.SectionField.FieldValue = sectionName;
            var count = result.RowCount;

            for (var j = 0; j < count; j++)
            {
                var dataRow    = result.ResultRowAtIndex(j) as UPCRMResultRow;
                var identifier = new RecordIdentifier(preparedSearch.InfoAreaId, dataRow.RecordIdAtIndex(0));
                var resultRow  = new UPMResultRow(identifier);
                resultContext.RowDictionary.Add(resultRow.Key, new UPCoreMappingResultRowContext(dataRow, resultContext));
                resultContext.ExpandMapper = preparedSearch.ExpandSettings;
                resultRow.Invalid          = true;
                resultRow.DataValid        = true;
                resultSection.AddResultRow(resultRow);
            }

            return(resultSection);
        }
        private static UPMResultSection CreateSection(List <object> columnInfoArray, UPMGridPage searchPage)
        {
            var identifier          = StringIdentifier.IdentifierWithStringId("columnHeader");
            var section             = new UPMResultSection(identifier);
            var columnHeaderListRow = new UPMResultRow(identifier);

            var fieldArray = CreateFieldArray(searchPage, columnInfoArray);

            columnHeaderListRow.Fields = fieldArray;
            section.AddResultRow(columnHeaderListRow);

            return(section);
        }
 private void AddDetailsActionFromRowToListRow(AnalysisRow row, UPMResultRow listRow)
 {
     if (row.ResultRows.Count > 0 && row.Result.DetailsFields.Count > 0)
     {
         var action = new UPMOrganizerDrillThruAction(StringIdentifier.IdentifierWithStringId("drillThru"))
         {
             AnalysisRow = row
         };
         action.SetTargetAction(this, this.PerformDrillThru);
         action.LabelText = LocalizedString.TextAnalysesDetails;
         listRow.AddDetailAction(action);
     }
 }
예제 #7
0
        /// <inheritdoc/>
        public override UPMResultSection ResultSectionForSearchResult(UPSearchPageModelControllerPreparedSearch preparedSearch, UPCRMResult result)
        {
            UPCoreMappingResultContext resultContext = new UPCoreMappingResultContext(result, preparedSearch.CombinedControl, preparedSearch.ListFieldControl.NumberOfFields);

            this.SectionContexts.SetObjectForKey(resultContext, preparedSearch.InfoAreaId);
            bool newSection = this.geoSection == null;

            if (newSection)
            {
                this.geoSection = new UPMResultSection(StringIdentifier.IdentifierWithStringId($"Search_{preparedSearch.InfoAreaId}"));
            }

            var count = result.RowCount;

            for (var j = 0; j < count; j++)
            {
                UPCRMResultRow dataRow    = result.ResultRowAtIndex(j) as UPCRMResultRow;
                var            identifier = new RecordIdentifier(preparedSearch.InfoAreaId, dataRow.RecordIdAtIndex(0));
                UPMResultRow   resultRow  = new UPMResultRow(identifier);
                resultRow.DataValid = true;
                resultContext.RowDictionary.SetObjectForKey(new UPCoreMappingResultRowContext(dataRow, resultContext), resultRow.Key);
                resultContext.ExpandMapper = preparedSearch.ExpandSettings;
                resultRow = (UPMResultRow)this.UpdatedElement(resultRow);

                this.AddDistanceFieldToRow(resultRow);
                this.geoSection.AddResultRow(resultRow);
                if (resultRow.RecordImageDocument != null)
                {
                    this.AnyResultWithImageField = true;
                }
            }

            List <GeoUPMResultRow> sortedArray = this.resultRowsToSort.OrderBy(a => a.Distance).ToList();

            this.geoSection.RemoveAllChildren();
            foreach (var row in sortedArray)
            {
                if (row.ResultRow != null)
                {
                    this.geoSection.AddResultRow(row.ResultRow);
                }
                else
                {
                }
            }

            return(newSection ? this.geoSection : null);
        }
        private void AddDrilldownActionsFromRowToListRow(AnalysisRow row, UPMResultRow listRow)
        {
            string drilldownText = LocalizedString.TextAnalysesDrilldown;

            foreach (AnalysisDrilldownOption drilldownOption in row.DrilldownOptions)
            {
                var action = new UPMOrganizerDrilldownAction(StringIdentifier.IdentifierWithStringId($"action.{drilldownOption.Key}"))
                {
                    DrilldownOption = drilldownOption,
                    AnalysisRow     = row
                };
                action.SetTargetAction(this, this.PerformDrilldown);
                action.LabelText = drilldownText.Replace("%@", drilldownOption.Label);
                listRow.AddDetailAction(action);
            }
        }
        private void UpdatePageFromResultReset(AnalysisResult result, bool reset)
        {
            this.AnalysisResult = result;
            var searchPage  = (UPMGridPage)this.CreatePageInstance();
            var oldPage     = this.Page;
            var oldGridPage = (UPMGridPage)this.Page;

            if (reset)
            {
                var resetHeadOption = oldGridPage.ResetHeadOption;
                searchPage.ResetHeadOption = resetHeadOption;
            }

            searchPage.InitialSortColumn = this.AnalysisResult.SortColumn + 1;
            var columnCount         = result.Columns.Count;
            var identifier          = StringIdentifier.IdentifierWithStringId("columnHeader");
            var section             = new UPMResultSection(identifier);
            var columnHeaderListRow = new UPMResultRow(identifier);
            var fieldArray          = this.CreateFieldArray();

            var xColumnArray = new List <object>(result.Columns.Count);

            ProcessColumns(result.Columns, searchPage, fieldArray, xColumnArray);

            columnHeaderListRow.Fields = fieldArray;
            this.AddCategoryActionsToRow(columnHeaderListRow);
            section.AddResultRow(columnHeaderListRow);
            searchPage.AddResultSection(section);

            var keyAsRawString = result.Settings.Category.IsExplicitCategory;

            if (keyAsRawString)
            {
                searchPage.SetColumnInfoAtIndexDataTypeSpecialSort(0, UPMColumnDataType.String, true);
            }

            this.ProcessResultRows(result, searchPage, xColumnArray, keyAsRawString, columnCount, section);

            this.AddDrillupActionsFromResultToPage(result, searchPage);
            this.AddCategoriesFromResultToPage(result, searchPage);
            this.UpdateResetHeadOption(searchPage, reset, result);

            this.TopLevelElement = searchPage;
            this.InformAboutDidChangeTopLevelElement(oldPage, searchPage, null, oldGridPage.Reset ? UPChangeHints.ChangeHintsWithHint("ResetAnalysis") : null);
        }
예제 #10
0
        /// <summary>
        /// Details the organizer for result row.
        /// </summary>
        /// <param name="resultRow">The result row.</param>
        /// <returns></returns>
        public override UPOrganizerModelController DetailOrganizerForResultRow(UPMResultRow resultRow)
        {
            RecordIdentifier           identifier          = (RecordIdentifier)resultRow.Identifier;
            ViewReference              viewReference       = HistoryManager.DefaultHistoryManager.ViewReferenceForRecordIdentifier(identifier.RecordIdentification);
            UPOrganizerModelController organizerController = UPOrganizerModelController.OrganizerFromViewReference(viewReference);

            if (resultRow.OnlineData)
            {
                organizerController.OnlineData = resultRow.OnlineData;
            }

            resultRow.DataValid = true;
            resultRow.Invalid   = true;
            UPChangeManager.CurrentChangeManager.RegisterChanges(new List <IIdentifier> {
                resultRow.Identifier
            });
            return(organizerController);
        }
예제 #11
0
        private void AddDistanceFieldToRow(UPMResultRow resultRow)
        {
            UPMGpsXField gpsXField = null;
            UPMGpsYField gpsYField = null;

            foreach (UPMField field in resultRow.Fields)
            {
                if (field is UPMGpsXField)
                {
                    gpsXField = (UPMGpsXField)field;
                }
                else if (field is UPMGpsYField)
                {
                    gpsYField = (UPMGpsYField)field;
                }
            }

            var target   = new Location(gpsXField.StringValue.ToDouble(), gpsYField.StringValue.ToDouble());
            var locA     = new Location(target.Longitude, target.Latitude);
            var locB     = new Location(this.currentUserLocation.Longitude, this.currentUserLocation.Latitude);
            var distance = locA.DistanceFromLocation(locB);

            this.resultRowsToSort.Add(new GeoUPMResultRow(resultRow, distance));
            uint fieldCount = 0;

            foreach (UPMField field in resultRow.Fields)
            {
                if (field.Hidden == false)
                {
                    fieldCount++;
                }
            }

            var            rowIdentifier = (RecordIdentifier)resultRow.Identifier;
            UPMStringField distanceField = new UPMStringField(rowIdentifier.IdentifierWithFieldId("Distance"));

            // TODO: Localization not working and will be handled in CRM-5629
            // distanceField.FieldValue = $"{(distance / 1000).ToString("0.##")} {LocalizationKeys.upTextDistanceFilterKmValue}";
            distanceField.FieldValue = $"{(distance / 1000).ToString("0.##")} km";

            resultRow.Fields.Add(distanceField);
        }
예제 #12
0
        /// <summary>
        /// Adds the dropdown groups for result row.
        /// </summary>
        /// <param name="resultRow">The result row.</param>
        /// <param name="rowContext">The row context.</param>
        /// <param name="expand">The expand.</param>
        public override void AddDropdownGroupsForResultRow(UPMResultRow resultRow, UPCoreMappingResultRowContext rowContext, UPConfigExpand expand)
        {
            UPCoreMappingResultContext resultContext = rowContext.Context;

            if (resultContext.DropdownFields.Any())
            {
                int detailFieldCount = resultContext.DropdownFields.Count;
                if (detailFieldCount > 0)
                {
                    UPCRMResultRow row             = rowContext.Row;
                    string         recordId        = row.RecordIdentificationAtIndex(0);
                    var            detailGroupCol1 =
                        new UPMTimelineDetailsGroup(FieldIdentifier.IdentifierWithInfoAreaIdRecordIdFieldId(this.InfoAreaId, recordId, "DetailField_Left"))
                    {
                        Invalid       = true,
                        ResultContext = resultContext
                    };
                    resultRow.AddDetailGroup(detailGroupCol1);
                }
            }
        }
예제 #13
0
        /// <summary>
        /// The sender needs calendar item details.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="item">The item.</param>
        public void SenderNeedsCalendarItemDetails(/*UPCalendarViewController*/ object sender, ICalendarItem item)
        {
            if (item.CrmResultRow == null && item.ResultRow != null)
            {
                return;
            }

            UPMResultRow resultRow = new UPMResultRow(new RecordIdentifier(item.CrmResultRow.RootRecordIdentification));

            item.ResultRow      = resultRow;
            resultRow.Invalid   = true;
            resultRow.DataValid = true;

            UPMCalendarPopoverGroup popoverGroup = new UPMCalendarPopoverGroup(item.ResultRow.Identifier)
            {
                Invalid = true,
                Context = item
            };

            resultRow.AddDetailGroup(popoverGroup);
        }
예제 #14
0
        /// <summary>
        /// Adds row actions
        /// </summary>
        /// <param name="expand">Expand</param>
        /// <param name="resultRow">Result row</param>
        /// <param name="recordId">Record id</param>
        public override void AddRowActions(UPConfigExpand expand, UPMResultRow resultRow, string recordId)
        {
            base.AddRowActions(expand, resultRow, recordId);

            if (this.PreparedSearch.FilterBasedDecision != null)
            {
                var rowContext    = this.ResultContext.RowDictionary[resultRow.Key];
                var actionButtons = this.PreparedSearch.FilterBasedDecision.ButtonsForResultRow(rowContext.Row);

                if (actionButtons.Count > 0)
                {
                    foreach (UPConfigButton buttonDef in actionButtons)
                    {
                        string iconName   = string.Empty;
                        string buttonName = buttonDef.UnitName;

                        if (buttonDef.ViewReference != null)
                        {
                            var action = new UPMOrganizerAction(StringIdentifier.IdentifierWithStringId($"action.{buttonName}"));

                            var viewReference = buttonDef.ViewReference.ViewReferenceWith(recordId);
                            viewReference = viewReference.ViewReferenceWith(new Dictionary <string, object> {
                                { ".fromPopup", 1 }
                            });
                            action.ViewReference = viewReference;

                            if (!string.IsNullOrEmpty(iconName))
                            {
                                action.IconName = iconName;
                            }

                            action.LabelText = buttonDef.Label;
                            resultRow.AddDetailAction(action);
                        }
                    }
                }
            }
        }
        private void ProcessResultRows(
            AnalysisRow row,
            List <object> columnInfoArray,
            UPMResultSection section,
            UPMGridPage searchPage,
            AnalysisResult analysisResult,
            Page oldPage)
        {
            var dataSource         = analysisResult.DataSource;
            var contextMenuOptions = GetContextMenuOptions(dataSource);
            var i = 0;

            foreach (ICrmDataSourceRow crmRow in row.ResultRows)
            {
                var identifier = StringIdentifier.IdentifierWithStringId($"row {i}");
                var listRow    = new UPMResultRow(identifier)
                {
                    Context = row
                };
                var fieldArray = new List <UPMField>();
                foreach (AnalysisDrillThruColumn col in columnInfoArray)
                {
                    var field = new UPMStringField(StringIdentifier.IdentifierWithStringId($"row {++i}"))
                    {
                        StringValue    = crmRow.ValueAtIndex(col.SourceField.QueryResultFieldIndex),
                        RawStringValue = crmRow.RawValueAtIndex(col.SourceField.QueryResultFieldIndex)
                    };
                    fieldArray.Add(field);
                }

                listRow.Fields = fieldArray;
                section.AddResultRow(listRow);
                ++i;
                this.ProcessSearchPage(searchPage, contextMenuOptions, crmRow, listRow, analysisResult, oldPage, i);
            }
        }
        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);
            }
        }
예제 #17
0
 /// <summary>
 /// Gets called when result row provider created row from data row
 /// </summary>
 /// <param name="resultRowProvider">Result row provider</param>
 /// <param name="resultRow">Result row</param>
 /// <param name="dataRow">Data row</param>
 public virtual void ResultRowProviderDidCreateRowFromDataRow(UPResultRowProvider resultRowProvider, UPMResultRow resultRow, UPCRMResultRow dataRow)
 {
     this.ResultContext.RowDictionary[resultRow.Key] = new UPCoreMappingResultRowContext(dataRow, this.ResultContext);
 }
 /// <inheritdoc/>
 public override List <UPMAction> FindQuickActionsForRowCheckDetails(UPMResultRow resultRow, bool checkDetails)
 {
     return(resultRow.DetailActions);
 }
예제 #19
0
        private UPMSearchPage UpdatePage(UPMSearchPage searchPage)
        {
            UPMSearchPage newPage = this.CreatePageInstance();

            this.BuildPageDetails(newPage);
            if (searchPage.Invalid)
            {
                this.pendingRecords.Clear();
                this.rows.Clear();
                this.historyManager = HistoryManager.DefaultHistoryManager;
                this.configStore    = ConfigurationUnitStore.DefaultStore;
                if (this.historyManager.HistoryEntries.Count == 0)
                {
                    return(newPage);
                }

                foreach (HistoryEntry entry in this.historyManager.HistoryEntries)
                {
                    string              recordIdent         = entry.RecordIdentification;
                    SearchAndList       searchConfiguration = this.configStore.SearchAndListByName(recordIdent.InfoAreaId());
                    FieldControl        listFieldControl    = this.configStore.FieldControlByNameFromGroup("List", searchConfiguration.FieldGroupName);
                    UPContainerMetaInfo containerMetaInfo   = new UPContainerMetaInfo(listFieldControl);
                    if (entry.OnlineData)
                    {
                        if (ServerSession.CurrentSession.ConnectedToServer)
                        {
                            this.pendingRecords.Add(recordIdent);
                            this.resCount++;
                            containerMetaInfo.ReadRecord(recordIdent, UPRequestOption.Online, this);
                        }
                        else
                        {
                            UPMResultRow   row         = new UPMResultRow(new RecordIdentifier(recordIdent));
                            UPMStringField stringField = new UPMStringField(StringIdentifier.IdentifierWithStringId(recordIdent));
                            stringField.FieldValue = LocalizedString.TextOfflineNotAvailable;
                            row.Fields             = new List <UPMField> {
                                stringField
                            };
                            row.OnlineData = true;
                            //row.StatusIndicatorIcon = UIImage.UpXXImageNamed("crmpad-List-Cloud");    // CRM-5007
                            InfoArea infoAreaConfig = this.configStore.InfoAreaConfigById(recordIdent.InfoAreaId());
                            string   imageName      = infoAreaConfig.ImageName;
                            if (!string.IsNullOrEmpty(imageName))
                            {
                                //row.Icon = UIImage.UpImageWithFileName(imageName);    // CRM-5007
                            }

                            this.rows.Add(row);
                        }
                    }
                    else
                    {
                        this.resCount++;
                        this.pendingRecords.Add(recordIdent);
                        containerMetaInfo.ReadRecord(recordIdent, UPRequestOption.Offline, this);
                    }
                }

                newPage.Invalid      = false;
                this.TopLevelElement = newPage;
                this.ApplyLoadingStatusOnPage(newPage);
                return(newPage);
            }

            UPMResultSection section = (UPMResultSection)this.Page.Children[0];

            this.ResortRowListAddToPage(section.Children, newPage);
            this.TopLevelElement = newPage;
            return(newPage);
        }
        private void UpdatePageFromQueryResult(UPCRMResult result)
        {
            this.QueryResult = result;
            UPMGridPage      searchPage = (UPMGridPage)this.CreatePageInstance();
            Page             oldPage = this.Page;
            int              i, j;
            int              columnCount         = result.ColumnCount;
            StringIdentifier identifier          = StringIdentifier.IdentifierWithStringId("columnHeader");
            UPMResultSection section             = new UPMResultSection(identifier);
            UPMResultRow     columnHeaderListRow = new UPMResultRow(identifier);
            var              fieldArray          = new List <UPMField>();

            searchPage.FixedFirstColumn = false;
            searchPage.ShowMenu         = true;
            searchPage.SumRowAtEnd      = false;
            for (i = 0; i < columnCount; i++)
            {
                UPContainerFieldMetaInfo fieldMetaInfo = result.ColumnFieldMetaInfoAtIndex(i);
                string fieldType = fieldMetaInfo.CrmFieldInfo.FieldType;
                if (fieldType == "F" || fieldType == "L" || fieldType == "S")
                {
                    searchPage.SetColumnInfoAtIndexDataTypeSpecialSort(i, UPMColumnDataType.Numeric, false);
                }
                else if (fieldType == "D")
                {
                    searchPage.SetColumnInfoAtIndexDataTypeSpecialSort(i, UPMColumnDataType.Date, true);
                }

                UPMGridColumnHeaderStringField field = new UPMGridColumnHeaderStringField(StringIdentifier.IdentifierWithStringId($"col {i}"))
                {
                    StringValue = result.ColumnNameAtIndex(i)
                };
                fieldArray.Add(field);
            }

            columnHeaderListRow.Fields = fieldArray;
            section.AddResultRow(columnHeaderListRow);
            searchPage.AddResultSection(section);
            int           numberOfResultTables = result.NumberOfResultTables;
            List <object> contextMenuOptions   = new List <object>(numberOfResultTables);
            var           configStore          = ConfigurationUnitStore.DefaultStore;

            for (j = 0; j < numberOfResultTables; j++)
            {
                string infoAreaId    = result.ResultTableAtIndex(j).InfoAreaId;
                string infoAreaLabel = string.Empty;
                if (infoAreaId?.Length > 0)
                {
                    InfoArea       configInfoArea = configStore.InfoAreaConfigById(infoAreaId);
                    UPConfigExpand expand         = configStore.ExpandByName(infoAreaId);
                    FieldControl   fieldControl   = configStore.FieldControlByNameFromGroup("Details", expand.FieldGroupName);
                    if (configInfoArea != null && expand != null && fieldControl != null)
                    {
                        infoAreaLabel = LocalizedString.TextAnalysesShowParam.Replace("%@", configInfoArea.SingularName);
                    }
                }

                contextMenuOptions.Add(infoAreaLabel);
            }

            for (i = 0; i < result.RowCount; i++)
            {
                identifier = StringIdentifier.IdentifierWithStringId($"row {i}");
                var listRow = new UPMResultRow(identifier);
                var crmRow  = result.ResultRowAtIndex(i) as UPCRMResultRow;
                fieldArray = new List <UPMField>();
                var v = crmRow.Values();
                for (j = 0; j < v.Count; j++)
                {
                    UPMStringField field2 = new UPMStringField(StringIdentifier.IdentifierWithStringId($"cell{i}_{j}"))
                    {
                        StringValue    = v[j],
                        RawStringValue = crmRow.RawValueAtIndex(j)
                    };
                    fieldArray.Add(field2);
                }

                listRow.Fields = fieldArray;
                section.AddResultRow(listRow);
                for (j = 0; j < numberOfResultTables; j++)
                {
                    var label = contextMenuOptions[j] as string;
                    if (label.Length == 0)
                    {
                        continue;
                    }

                    string recordIdentification = crmRow.RecordIdentificationAtIndex(j);
                    if (recordIdentification?.Length > 0)
                    {
                        UPMOrganizerAnalysisShowRecordAction showRecordAction = new UPMOrganizerAnalysisShowRecordAction(StringIdentifier.IdentifierWithStringId($"action.row {i} record {j}"))
                        {
                            RecordIdentification = recordIdentification
                        };
                        showRecordAction.SetTargetAction(this, this.PerformShowRecordAction);
                        showRecordAction.LabelText = label;
                        listRow.AddDetailAction(showRecordAction);
                    }
                }
            }

            this.TopLevelElement = searchPage;
            this.InformAboutDidChangeTopLevelElement(oldPage, searchPage, null, null);
        }
        /// <summary>
        /// Results the context for row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <returns></returns>
        public override UPCoreMappingResultContext ResultContextForRow(UPMResultRow row)
        {
            var identifier = (RecordIdentifier)row.Identifier;

            return(this.SectionContexts[identifier.InfoAreaId]);
        }
예제 #22
0
        /// <summary>
        /// Search operation did finish with result
        /// </summary>
        /// <param name="operation">Operation</param>
        /// <param name="result">Result</param>
        public override void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            UPCRMResultRow resultRow = (UPCRMResultRow)result.ResultRowAtIndex(0);

            this.resCount--;
            if (resultRow != null)
            {
                string           recordIdent      = resultRow.RootRecordIdentification;
                RecordIdentifier recordIdentifier = new RecordIdentifier(recordIdent.InfoAreaId(), recordIdent.RecordId());
                UPMResultRow     row = new UPMResultRow(new RecordIdentifier(recordIdent));
                SearchAndList    searchConfiguration = this.configStore.SearchAndListByName(recordIdent.InfoAreaId());
                FieldControl     listFieldControl    = this.configStore.FieldControlByNameFromGroup("List", searchConfiguration.FieldGroupName);
                InfoArea         configInfoArea      = this.configStore.InfoAreaConfigById(recordIdent.InfoAreaId());
                row.RowColor = AureaColor.ColorWithString(configInfoArea.ColorKey);
                UPCRMListFormatter listFormatter = new UPCRMListFormatter(listFieldControl);
                int             fieldCount       = listFormatter.PositionCount;
                List <UPMField> listFields       = new List <UPMField>(fieldCount);
                for (int i = 0; i < fieldCount; i++)
                {
                    UPConfigFieldControlField configField = listFormatter.FirstFieldForPosition(i);
                    if (configField == null)
                    {
                        continue;
                    }

                    FieldAttributes attributes = configField.Attributes;
                    if (attributes.Hide)
                    {
                        continue;
                    }

                    UPMStringField stringField = new UPMStringField(StringIdentifier.IdentifierWithStringId($"{recordIdent}-{i}"));
                    string         stringValue = listFormatter.StringFromRowForPosition(resultRow, i);
                    if (attributes.Image)
                    {
                        DocumentManager documentManager = new DocumentManager();
                        string          documentKey     = stringValue;
                        DocumentData    documentData    = documentManager.DocumentForKey(documentKey);
                        if (documentData != null)
                        {
                            row.RecordImageDocument = new UPMDocument(documentData);
                        }
                        else
                        {
                            //row.RecordImageDocument = new UPMDocument(recordIdentifier, ServerSession.DocumentRequestUrlForDocumentKey(documentKey));
                        }

                        continue;
                    }

                    if (!string.IsNullOrEmpty(stringValue))
                    {
                        if (attributes.NoLabel && !string.IsNullOrEmpty(configField.Label))
                        {
                            stringValue = $"{configField.Label} {stringValue}";
                        }

                        stringField.StringValue = stringValue;
                        stringField.SetAttributes(attributes);
                    }

                    listFields.Add(stringField);
                }

                row.OnlineData = resultRow.IsServerResponse;
                if (row.OnlineData)
                {
                    //row.StatusIndicatorIcon = UIImage.UpXXImageNamed("crmpad-List-Cloud");    // CRM-5007
                }

                foreach (HistoryEntry entry in this.historyManager.HistoryEntries)
                {
                    if (entry.RecordIdentification == recordIdent)
                    {
                        this.rows.Add(row);
                        if (this.pendingRecords.Contains(recordIdent))
                        {
                            this.pendingRecords.Remove(recordIdent);
                        }

                        break;
                    }
                }

                row.Fields = listFields;
            }

            if (this.resCount == 0)
            {
                this.DisplayPage(this.rows);
            }
        }