Пример #1
0
        private void ResortRowListAddToPage(List <UPMElement> _rows, UPMSearchPage newPage)
        {
            var validRows = _rows.Where(x => x != null).ToList();

            validRows.Sort((object1, object2) =>
            {
                RecordIdentifier id1 = (RecordIdentifier)((UPMResultRow)object1).Identifier;
                RecordIdentifier id2 = (RecordIdentifier)((UPMResultRow)object2).Identifier;
                HistoryEntry entry1  = HistoryManager.DefaultHistoryManager.EntryForRecordIdentifier(id1.RecordIdentification);
                HistoryEntry entry2  = HistoryManager.DefaultHistoryManager.EntryForRecordIdentifier(id2.RecordIdentification);
                return(DateTime.Compare(entry2.LastCall, entry1.LastCall));
            });

            UPMResultSection section = new UPMResultSection(StringIdentifier.IdentifierWithStringId("UPHistoryDefaultSection"));

            foreach (UPMElement element in validRows)
            {
                if (element != null)
                {
                    element.Invalid = false;
                    section.AddChild(element);
                }
            }

            newPage.AddResultSection(section);
        }
        /// <summary>
        /// Creates the new search page with result.
        /// </summary>
        /// <param name="results">The results.</param>
        public virtual void CreateNewSearchPageWithResult(List <UPCRMResult> results)
        {
            UPMSearchPage newPage = new UPMSearchPage(this.Page.Identifier);

            newPage.CopyDataFrom(this.SearchPage);
            newPage.Invalid = false;
            int searchCount = this.PreparedSearches?.Count ?? 0;

            for (int i = 0; i < searchCount && i < results.Count; i++)
            {
                UPSearchPageModelControllerPreparedSearch preparedSearch = this.PreparedSearches[i];
                if (results[i] != null)
                {
                    UPCRMResult result = results[i];
                    if (result.RowCount > 0)
                    {
                        UPMResultSection section = this.ResultSectionForSearchResult(preparedSearch, result);
                        if (section != null)
                        {
                            newPage.AddResultSection(section);
                        }
                    }
                }
            }

            // Hardcoded Detail Action
            UPMAction switchToDetailAction = new UPMAction(null);

            switchToDetailAction.IconName = "arrow.png";
            switchToDetailAction.SetTargetAction(this, this.SwitchToDetail);
            newPage.RowAction = switchToDetailAction;

            UPMAction searchAction = new UPMAction(null);

            searchAction.SetTargetAction(this, this.Search);
            newPage.SearchAction = searchAction;

            UPMSearchPage oldSearchPage = this.SearchPage;

            this.TopLevelElement = newPage;
            SearchPageResultState state = SearchPageResultState.OfflineNoLokalData;

            foreach (UPCRMResult result in results)
            {
                if (result != null && result.RowCount > 0)
                {
                    state = SearchPageResultState.Ok;
                }
            }

            newPage.ResultState = state;
            this.InformAboutDidChangeTopLevelElement(oldSearchPage, newPage, null, null);
        }
Пример #3
0
        private void BuildStandardSearchPage(
            UPMSearchPage searchPage,
            UPCRMResult result,
            int count,
            bool hasSections,
            bool optimizeForSpeed)
        {
            if (searchPage == null)
            {
                throw new ArgumentNullException(nameof(searchPage));
            }

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

            var sectionDictionary = new Dictionary <string, UPMResultSection>();
            var resultSection     = this.GetResultSection(searchPage, result, hasSections, optimizeForSpeed, out bool doContinue);

            if (!doContinue)
            {
                return;
            }

            // Section with # which groups the uncommon characters
            UPMResultSection lastSection = null;

            for (var i = 0; i < count; i++)
            {
                var dataRow = (UPCRMResultRow)result.ResultRowAtIndex(i);

                if (hasSections)
                {
                    var currentSectionKey = this.SectionKeyRawValueForRow(dataRow, this.ResultContext);
                    var isLastSection     = currentSectionKey == @"?";
                    if (isLastSection)
                    {
                        lastSection = resultSection;
                    }
                    else
                    {
                        resultSection = sectionDictionary.ValueOrDefault(currentSectionKey);
                    }

                    if (resultSection == null)
                    {
                        resultSection = this.CreateResultSection(optimizeForSpeed, currentSectionKey, dataRow);

                        if (isLastSection)
                        {
                            lastSection = resultSection;
                        }
                        else
                        {
                            this.SearchPage.AddResultSection(resultSection);
                            sectionDictionary[currentSectionKey] = resultSection;
                        }
                    }
                }

                this.AddResultRow(optimizeForSpeed, resultSection, dataRow);
            }

            if (lastSection != null)
            {
                searchPage.AddResultSection(lastSection);
            }
        }