Пример #1
0
        private async Task CountAndSearchAsync()
        {
            var selectedRepository = Navigator.SelectedRepository;

            if (selectedRepository is null)
            {
                return;
            }

            try
            {
                _dispatcherService.BeginInvoke(() => SearchResult.PackageList.Clear());

                using (ScopeManager <AuthenticationScope> .GetScopeManager(selectedRepository.Source.GetSafeScopeName(), () => new AuthenticationScope()))
                {
                    using (_pleaseWaitService.WaitingScope())
                    {
                        var searchSettings = SearchSettings;

                        SearchResult.TotalPackagesCount = await TaskHelper.Run(() => _packageQueryService.CountPackages(selectedRepository, searchSettings.SearchFilter, IsPrereleaseAllowed ?? true), true);

                        var packageDetails = await TaskHelper.Run(() => _packageQueryService.GetPackages(selectedRepository, IsPrereleaseAllowed ?? true, searchSettings.SearchFilter, searchSettings.PackagesToSkip), true);

                        var packages = packageDetails;

                        _dispatcherService.BeginInvoke(() =>
                        {
                            using (SearchResult.PackageList.SuspendChangeNotifications())
                            {
                                CollectionExtensions.AddRange(((ICollection <IPackageDetails>)SearchResult.PackageList), packages);
                            }
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to search packages");
            }
            finally
            {
                // Note: this is hack
                Navigator.SelectedRepository = selectedRepository;
            }
        }
Пример #2
0
        private async Task CountAndSearchAsync()
        {
            var selectedRepository = Navigator.SelectedRepository;

            try
            {
                _dispatcherService.BeginInvoke(() => SearchResult.PackageList.Clear());

                using (_pleaseWaitService.WaitingScope())
                {
                    var searchSettings = SearchSettings;
                    searchSettings.PackagesToSkip = 0;

                    SearchResult.TotalPackagesCount = await TaskHelper.Run(() => _packageQueryService.CountPackages(selectedRepository, searchSettings.SearchFilter, IsPrereleaseAllowed ?? true), true);

                    var packageDetails = await TaskHelper.Run(() => _packageQueryService.GetPackages(selectedRepository, IsPrereleaseAllowed ?? true, searchSettings.SearchFilter, searchSettings.PackagesToSkip), true);

                    var packages = packageDetails;

                    _dispatcherService.BeginInvoke(() =>
                    {
                        using (SearchResult.PackageList.SuspendChangeNotifications())
                        {
                            SearchResult.PackageList.AddRange(packages);
                        }
                    });
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Failed to search packages.");
            }
            finally
            {
                // TODO: this is hack. Need to fix it.
                Navigator.SelectedRepository = selectedRepository;
            }
        }