Exemple #1
0
        public void Should_load_the_messages_from_the_endpoint()
        {
            var endpoint = new Endpoint {
                Host = "localhost", Name = "Service"
            };

            serviceControl.GetAuditMessages(Arg.Is(endpoint), Arg.Any <string>(), Arg.Any <int>(), Arg.Any <string>(), Arg.Any <bool>())
            .Returns(x => new PagedResult <StoredMessage>
            {
                CurrentPage = 1,
                TotalCount  = 100,
                Result      = new List <StoredMessage>
                {
                    new StoredMessage(),
                    new StoredMessage()
                }
            });

            var messageList = messageListFunc();

            messageList.Handle(new SelectedExplorerItemChanged(new AuditEndpointExplorerItem(endpoint)));

            messageList.Rows.Count.ShouldBe(2);
            searchBar.IsVisible.ShouldBe(true);
        }
Exemple #2
0
        public void should_load_the_messages_from_the_endpoint()
        {
            var endpoint = new Endpoint {
                HostDisplayName = "localhost", Name = "Service"
            };

            ServiceControl.GetAuditMessages(Arg.Is(endpoint), Arg.Any <string>(), Arg.Any <int>(), Arg.Any <string>(), Arg.Any <bool>())
            .Returns(x => Task.FromResult(new PagedResult <StoredMessage>
            {
                CurrentPage = 1,
                TotalCount  = 100,
                Result      = new List <StoredMessage>
                {
                    new StoredMessage(),
                    new StoredMessage()
                }
            }));

            AsyncHelper.Run(() => MessageList.Handle(new SelectedExplorerItemChanged(new AuditEndpointExplorerItem(endpoint))));

            EventAggregator.Received(1).Publish(Arg.Any <WorkStarted>());
            EventAggregator.Received(1).Publish(Arg.Any <WorkFinished>());
            MessageList.Rows.Count.ShouldBe(2);
            SearchBar.IsVisible.ShouldBe(true);
        }
        public async Task RefreshEndpoint(Endpoint endpoint, int pageIndex = 1, string searchQuery = null, string orderBy = null, bool ascending = false)
        {
            _eventAggregator.Publish(new WorkStarted(string.Format("Loading {0} messages...", endpoint)));

            if (orderBy != null)
            {
                _lastSortColumn         = orderBy;
                _lastSortOrderAscending = ascending;
            }

            var pagedResult = await _serviceControl.GetAuditMessages(endpoint,
                                                                     pageIndex : pageIndex,
                                                                     searchQuery : searchQuery,
                                                                     orderBy : _lastSortColumn,
                                                                     ascending : _lastSortOrderAscending);

            using (new GridSelectionPreserver(_view))
            {
                Messages.Clear();
                Messages.AddRange(pagedResult.Result);
            }

            SearchBar.IsVisible = true;
            SearchBar.SetupPaging(new PagedResult <MessageInfo>
            {
                CurrentPage = pagedResult.CurrentPage,
                TotalCount  = pagedResult.TotalCount,
                Result      = pagedResult.Result.Cast <MessageInfo>().ToList(),
            });

            _eventAggregator.Publish(new WorkFinished());
        }
        public async Task RefreshMessages(string link)
        {
            using (workNotifier.NotifyOfWork("Loading messages..."))
            {
                var pagedResult = await serviceControl.GetAuditMessages(link);

                if (pagedResult == null)
                {
                    return;
                }

                TryRebindMessageList(pagedResult);

                SearchBar.IsVisible = true;
                SearchBar.SetupPaging(pagedResult);
            }
        }
Exemple #5
0
        public void RefreshMessages(Endpoint endpoint, int pageIndex = 1, string searchQuery = null, string orderBy = null, bool ascending = false)
        {
            try
            {
                eventAggregator.PublishOnUIThread(new WorkStarted("Loading {0} messages...", endpoint == null ? "all" : endpoint.Address));

                if (orderBy != null)
                {
                    lastSortColumn         = orderBy;
                    lastSortOrderAscending = ascending;
                }

                PagedResult <StoredMessage> pagedResult;

                if (endpoint != null)
                {
                    pagedResult = serviceControl.GetAuditMessages(endpoint,
                                                                  pageIndex: pageIndex,
                                                                  searchQuery: searchQuery,
                                                                  orderBy: lastSortColumn,
                                                                  ascending: lastSortOrderAscending);
                }
                else if (!searchQuery.IsEmpty())
                {
                    pagedResult = serviceControl.Search(pageIndex: pageIndex,
                                                        searchQuery: searchQuery,
                                                        orderBy: lastSortColumn,
                                                        ascending: lastSortOrderAscending);
                }
                else
                {
                    pagedResult = serviceControl.Search(pageIndex: pageIndex,
                                                        searchQuery: null,
                                                        orderBy: lastSortColumn,
                                                        ascending: lastSortOrderAscending);
                }

                if (pagedResult == null)
                {
                    return;
                }

                TryRebindMessageList(pagedResult);

                SearchBar.IsVisible = true;
                SearchBar.SetupPaging(new PagedResult <StoredMessage>
                {
                    CurrentPage = pagedResult.CurrentPage,
                    TotalCount  = pagedResult.TotalCount,
                    Result      = pagedResult.Result,
                });
            }
            finally
            {
                eventAggregator.PublishOnUIThread(new WorkFinished());
            }
        }
        public void RefreshMessages(Endpoint endpoint, int pageIndex = 1, string searchQuery = null, string orderBy = null, bool ascending = false)
        {
            using (workNotifier.NotifyOfWork($"Loading {(endpoint == null ? "all" : endpoint.Address)} messages..."))
            {
                if (orderBy != null)
                {
                    lastSortColumn         = orderBy;
                    lastSortOrderAscending = ascending;
                }

                PagedResult <StoredMessage> pagedResult;

                if (endpoint != null)
                {
                    pagedResult = serviceControl.GetAuditMessages(endpoint,
                                                                  pageIndex: pageIndex,
                                                                  searchQuery: searchQuery,
                                                                  orderBy: lastSortColumn,
                                                                  ascending: lastSortOrderAscending);
                }
                else if (!searchQuery.IsEmpty())
                {
                    pagedResult = serviceControl.Search(pageIndex: pageIndex,
                                                        searchQuery: searchQuery,
                                                        orderBy: lastSortColumn,
                                                        ascending: lastSortOrderAscending);
                }
                else
                {
                    pagedResult = serviceControl.Search(pageIndex: pageIndex,
                                                        searchQuery: null,
                                                        orderBy: lastSortColumn,
                                                        ascending: lastSortOrderAscending);
                }

                if (pagedResult == null)
                {
                    return;
                }

                TryRebindMessageList(pagedResult);

                SearchBar.IsVisible = true;
                SearchBar.SetupPaging(new PagedResult <StoredMessage>
                {
                    CurrentPage = pagedResult.CurrentPage,
                    TotalCount  = pagedResult.TotalCount,
                    Result      = pagedResult.Result,
                });
            }
        }