Esempio n. 1
0
        /// <summary>
        /// Updateds the element for page.
        /// </summary>
        /// <param name="origSearchPage">The original search page.</param>
        /// <returns></returns>
        public override Page UpdatedElementForPage(UPMSearchPage origSearchPage)
        {
            if (this.ModelControllerDelegate == null)
            {
                return(origSearchPage);
            }

            if (this.CalendarPage.IncludeSystemCalendar && !ResultRowCalendarItem.EventStoreInitialized)
            {
                //ResultRowCalendarItem.initializeEventStore(delegate (bool granted, NSError error)
                //{
                //    if (!granted)
                //    {
                //        this.CalendarPage.IncludeSystemCalendar = false;
                //    }
                //    else
                //    {
                //        NSNotificationCenter.DefaultCenter().RemoveObserverNameTheObject(this, EKEventStoreChangedNotification, null);
                //        NSNotificationCenter.DefaultCenter().AddObserverSelectorNameTheObject(this, @selector(eventStoreUpdated:), EKEventStoreChangedNotification, null);
                //        ResultRowCalendarItem.RefreshEventStore();
                //    }

                //    this.Search((UPMSearchPage)this.Page);
                //});
                //return this.Page;
            }

            this.Search(origSearchPage);
            return(this.Page);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
 private void BuildPageDetails(UPMSearchPage searchPage)
 {
     searchPage.HideSearchBar = true;
     searchPage.ViewType      = SearchPageViewType.List;
     searchPage.RowAction     = new UPMAction(StringIdentifier.IdentifierWithStringId("UPHistoryListViewRowAction"));
     searchPage.RowAction.SetTargetAction(this, this.SwitchToDetail);
 }
Esempio n. 4
0
        /// <summary>
        /// Internal method to create a Page Instance
        /// </summary>
        /// <param name="configStore">
        /// IConfigurationUnitStore
        /// </param>
        /// <param name="searchType">
        /// SearchPageSearchType
        /// </param>
        /// <returns>
        /// UPMSearchPage
        /// </returns>
        private UPMSearchPage CreatePageInstanceWorker(IConfigurationUnitStore configStore, SearchPageSearchType searchType)
        {
            var defaultRadiusMeter = 100;
            var defaultRadius      = ViewReference.ContextValueForKey("DefaultRadius");

            if (!string.IsNullOrWhiteSpace(defaultRadius))
            {
                defaultRadiusMeter = defaultRadius.ToInt();
            }

            usedFilters = new Dictionary <string, UPMFilter>();
            var identifiers = new List <IIdentifier>();
            var filters     = new List <UPMFilter>();

            PopulatePageFilterAndIdentifierLists(configStore, filters, identifiers, defaultRadiusMeter);

            var multipleIdentifier = new MultipleIdentifier(identifiers);
            var page = new UPMSearchPage(multipleIdentifier)
            {
                SearchType            = searchType,
                AvailableFilters      = filters,
                Style                 = UPMTableStyle.UPMStandardTableStyle,
                AvailableOnlineSearch = !ViewReference.ContextValueIsSet("hideOnlineOfflineButton")
            };

            return(page);
        }
Esempio n. 5
0
        /// <summary>
        /// Loads the source record record identifier.
        /// </summary>
        /// <param name="_fieldControl">The field control.</param>
        /// <param name="recordId">The record identifier.</param>
        public void LoadSourceRecordRecordId(FieldControl _fieldControl, string recordId)
        {
            UPContainerMetaInfo query      = new UPContainerMetaInfo(_fieldControl);
            UPMSearchPage       searchPage = this.searchPageModelController.SearchPage;

            query.ReadRecord(recordId, searchPage.SearchType == SearchPageSearchType.OfflineSearch
                    ? UPRequestOption.Offline
                    : UPRequestOption.Online, this);
        }
Esempio n. 6
0
        /// <summary>
        /// Builds the page.
        /// </summary>
        public override void BuildPage()
        {
            UPMSearchPage page = this.CreatePageInstance();

            page.Invalid         = true;
            this.TopLevelElement = page;
            this.rows            = new List <UPMElement>();
            this.pendingRecords  = new List <string>();
            this.BuildPageDetails(page);
        }
        /// <summary>
        /// Creates the page instance.
        /// </summary>
        /// <returns></returns>
        public override UPMSearchPage CreatePageInstance()
        {
            this.InfoAreaId = this.ViewReference.ContextValueForKey("InfoArea");
            this.ConfigName = this.ViewReference.ContextValueForKey("ConfigName");
            string searchTypeString         = this.ViewReference.ContextValueForKey("InitialSearchType");
            SearchPageSearchType searchType = SearchPageSearchType.OfflineSearch;
            string fullTextSearchString     = this.ViewReference.ContextValueForKey("FullTextSearch");

            this.FullTextSearch = !(string.IsNullOrEmpty(fullTextSearchString) || fullTextSearchString == "false");

            this.MinSearchTextLength = Convert.ToInt32(this.ViewReference.ContextValueForKey("MinSearchTextLength"));

            if (this.MinSearchTextLength == 0)
            {
                this.MinSearchTextLength = 1;
            }

            if (!string.IsNullOrEmpty(searchTypeString))
            {
                searchType = (SearchPageSearchType)Convert.ToInt32(searchTypeString);
            }

            if (string.IsNullOrEmpty(this.InfoAreaId) && this.ViewReference.ContextValueForKey("Modus") == "GlobalSearch")
            {
                if (string.IsNullOrEmpty(this.ConfigName))
                {
                    this.ConfigName = "default";
                }
            }

            List <IIdentifier>      identifiers = new List <IIdentifier>();
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            QuickSearch             quickSearch = configStore.QuickSearchByName(this.ConfigName);
            int infoAreaCount = quickSearch?.NumberOfInfoAreas ?? 0;

            for (int i = 0; i < infoAreaCount; i++)
            {
                string currentInfoAreaId = quickSearch.InfoAreaIdAtIndex(i);
                identifiers.Add(new RecordIdentifier(currentInfoAreaId, null));
            }

            MultipleIdentifier multipleIdentifier = new MultipleIdentifier(identifiers);
            UPMSearchPage      page = new UPMSearchPage(multipleIdentifier);

            page.SearchType            = searchType;
            page.AvailableOnlineSearch = !this.ViewReference.ContextValueIsSet("hideOnlineOfflineButton");
            page.Style = UPMTableStyle.UPMGlobalSearchTableStyle;
            if (searchType == SearchPageSearchType.OnlineSearch)
            {
                page.InitiallyOnline = true;
            }

            return(page);
        }
        /// <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);
        }
Esempio n. 9
0
        private void DisplayPage(List <UPMElement> _rows)
        {
            UPMSearchPage newPage = this.CreatePageInstance();

            this.BuildPageDetails(newPage);
            this.ResortRowListAddToPage(_rows, newPage);
            newPage.Invalid = false;
            Page oldPage = this.Page;

            this.TopLevelElement = newPage;
            this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null);
        }
        /// <inheritdoc/>
        public override Page UpdatedElementForPage(UPMSearchPage page)
        {
            if (this.AnalysisLinkRecordIdentification?.Length > 0)
            {
                this.ContinueWithAnalysisLinkRecord(this.AnalysisLinkRecordIdentification);
            }
            else if (this.ParentLink?.Length > 0 && this.RecordIdentification?.Length > 0)
            {
                this.linkReader = new UPCRMLinkReader(this.RecordIdentification, this.ParentLink, this.RequestOption, this);
                this.linkReader.Start();
            }
            else
            {
                this.ContinueWithAnalysisLinkRecord(this.RecordIdentification);
            }

            return(this.Page);
        }
Esempio n. 11
0
        /// <summary>
        /// Builds standard search page with search page and result
        /// </summary>
        /// <param name="searchPage">Search page</param>
        /// <param name="result">Result</param>
        private void BuildStandardSearchPage(UPMSearchPage searchPage, UPCRMResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            var count = result.RowCount;

            this.ResultContext = new UPCoreMappingResultContext(
                result,
                this.PreparedSearch.CombinedControl,
                this.PreparedSearch.ListFieldControl.NumberOfFields)
            {
                ExpandMapper = this.PreparedSearch.ExpandChecker
            };
            this.SectionContexts[this.InfoAreaId] = this.ResultContext;

            var hasSections = !string.IsNullOrWhiteSpace(this.Sections);

            if (!hasSections && this.ResultContext.SectionField != null)
            {
                hasSections = true;
            }

            if (this.Sections == @"false")
            {
                hasSections = false;
            }

            var optimizeForSpeed = false;

            if (result.RowCount < 200)
            {
                // optimizeForSpeed can handle multipleRows with the same id. (PVCS 80132)
                optimizeForSpeed = this.SearchPageMode == SearchPageMode.ForceOptimizeForSpeed;
            }

            this.BuildStandardSearchPage(searchPage, result, count, hasSections, optimizeForSpeed);
        }
Esempio n. 12
0
        private UPMResultSection GetResultSection(
            UPMSearchPage searchPage,
            UPCRMResult result,
            bool hasSections,
            bool optimizeForSpeed,
            out bool doContinue)
        {
            if (searchPage == null)
            {
                throw new ArgumentNullException(nameof(searchPage));
            }

            doContinue = true;

            UPMResultSection resultSection = null;

            if (!hasSections)
            {
                if (optimizeForSpeed)
                {
                    resultSection = new UPMResultSection(
                        StringIdentifier.IdentifierWithStringId(@"Result_Section_1"),
                        new UPResultRowProviderForCRMResult(result, this));
                    this.SearchPage.AddResultSection(resultSection);
                    doContinue = false;
                }

                resultSection = new UPMResultSection(StringIdentifier.IdentifierWithStringId(@"Result_Section_1"));
                this.SearchPage.AddResultSection(resultSection);
            }
            else
            {
                // Date or Catalog Field --> Kein Section Index
                searchPage.HideSectionIndex = this.ResultContext.SectionFieldComplete;
            }

            return(resultSection);
        }
        /// <summary>
        /// Creates the page instance.
        /// </summary>
        /// <returns></returns>
        public override UPMSearchPage CreatePageInstance()
        {
            this.InfoAreaId = this.ViewReference.ContextValueForKey("InfoArea");
            this.ConfigName = this.ViewReference.ContextValueForKey("Config1Name");
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            string searchTypeString             = this.ViewReference.ContextValueForKey("InitialSearchType");
            SearchPageSearchType searchType     = Convert.ToInt32(searchTypeString) == 2 ? SearchPageSearchType.OnlineSearch : SearchPageSearchType.OfflineSearch;

            if (string.IsNullOrEmpty(this.InfoAreaId) && this.ViewReference.ContextValueForKey("Modus") == "MultiSearch")
            {
                if (string.IsNullOrEmpty(this.ConfigName))
                {
                    this.ConfigName = "default";
                }
            }

            List <IIdentifier> identifiers = new List <IIdentifier>();

            this.usedFilters = new Dictionary <string, UPMFilter>();
            List <UPMFilter> filters             = new List <UPMFilter>();
            string           geoFilter1          = this.ViewReference.ContextValueForKey("Config1Filter");
            UPMFilter        filter              = UPMFilter.FilterForName(geoFilter1);
            SearchAndList    searchConfiguration = configStore.SearchAndListByName(this.ConfigName);
            var infoAreaId = searchConfiguration != null ? searchConfiguration.InfoAreaId : this.ConfigName;

            if (filter != null)
            {
                filter.Active = true;
                this.usedFilters[this.ConfigName] = filter;
                filters.Add(filter);
            }

            identifiers.Add(new RecordIdentifier(infoAreaId, null));
            for (int i = 2; i < 99; i++)
            {
                string configNameKey = $"Config{i}Name";
                string configName2   = this.ViewReference.ContextValueForKey(configNameKey);
                if (!string.IsNullOrEmpty(configName2))
                {
                    string        configFilterKey      = $"Config{i}Filter";
                    string        geoFilter2           = this.ViewReference.ContextValueForKey(configFilterKey);
                    UPMFilter     filter2              = UPMFilter.FilterForName(geoFilter2);
                    SearchAndList searchConfiguration2 = configStore.SearchAndListByName(configName2);
                    if (filter2 != null)
                    {
                        filter2.Active = true;
                        this.usedFilters[configName2] = filter2;
                        filters.Add(filter2);
                    }

                    infoAreaId = (searchConfiguration2 != null) ? searchConfiguration2.InfoAreaId : configName2;
                    identifiers.Add(new RecordIdentifier(infoAreaId, null));
                }
                else
                {
                    break;
                }
            }

            MultipleIdentifier multipleIdentifier = new MultipleIdentifier(identifiers);
            UPMSearchPage      page = new UPMSearchPage(multipleIdentifier)
            {
                SearchType            = searchType,
                AvailableFilters      = filters,
                Style                 = UPMTableStyle.UPMStandardTableStyle,
                AvailableOnlineSearch = !this.ViewReference.ContextValueIsSet("hideOnlineOfflineButton"),
                InitiallyOnline       = searchType == SearchPageSearchType.OnlineSearch,
                HideSearchBar         = true,
                ViewType              = SearchPageViewType.List
            };

            return(page);
        }
Esempio n. 14
0
 /// <summary>
 /// Starts test search
 /// </summary>
 /// <param name="searchPage">Search page</param>
 public void StartTestSearch(UPMSearchPage searchPage)
 {
     this.Search(searchPage);
 }
Esempio n. 15
0
 /// <summary>
 /// Retrieves active filters for given search page
 /// </summary>
 /// <param name="searchPage">Search page</param>
 /// <returns><see cref="List{UPConfigFilter}"/></returns>
 protected virtual List <UPConfigFilter> ActiveFiltersForSearchPage(UPMSearchPage searchPage)
 {
     return(UPMFilter.ActiveFiltersForFilters(searchPage.AvailableFilters));
 }
Esempio n. 16
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);
        }
Esempio n. 17
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);
            }
        }