private async void DeleteDownloads_OnClick(object sender, RoutedEventArgs e)
        {
            deleteDownloads.IsEnabled = false;

            var ctx = new RisDbContext();
            await ctx.DeleteDownloads();

            MessengerHelper.Notify(MessengerHelper.DownloadsDeleted);
        }
        private async void DeleteHistory_OnClick(object sender, RoutedEventArgs e)
        {
            deleteHistory.IsEnabled = false;

            var ctx = new RisDbContext();
            await ctx.DeleteSearchHistory();

            MessengerHelper.Notify(MessengerHelper.SearchHistoryDeleted);
        }
Пример #3
0
        //
        // http://blog.falafel.com/Blogs/john-waters/2012/10/10/doing-an-asynchronous-search-in-windows-8
        //
        async void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            string query = args.QueryText.ToLower();

            var deferral = args.Request.GetDeferral();

            try
            {
                var ctx = new RisDbContext();
                var matches = await ctx.GetHistoryEntriesStartingWith(query);

                args.Request.SearchSuggestionCollection.AppendQuerySuggestions(matches);
            }
            finally
            {
                deferral.Complete();
            }
        }
        public async Task SearchRisAsync()
        {
            UpdateInProgress = true;

            DocumentReferences = null;
            UpdateSearchResultInfo();

            var localQueryParam = QueryParameter;

            var result = await RisQueryWithIncrementalLoading.LoadPage(localQueryParam, 1);

            UpdateInProgress = false;

            if (result.Succeeded)
            {
                DocumentReferences = new RisQueryWithIncrementalLoading(localQueryParam, result,
                    IncrementalLoadingStarted, IncrementalLoadingCompleted, IncrementalLoadingFailed);
                UpdateSearchResultInfo();

                var ctx = new RisDbContext();
                ctx.InsertSearchHistoryEntry(new DbRisQueryParameter(localQueryParam, DocumentReferences.Hits));
            }
            else
            {
                UpdateSearchResultInfo("Abfrage fehlgeschlagen");
            }
        }
Пример #5
0
        public async Task LoadDownloadsAsync()
        {
            var ctx = new RisDbContext();
            var localCopies = await ctx.GetDownloads();

            SelectedDownload = null;
            DownloadedDocuments = localCopies;

            if (null != _selectedDownloadFromState && localCopies != null)
            {
                SelectedDownload = localCopies.FirstOrDefault(h => h.Id == _selectedDownloadFromState.Value);
            }

            if (localCopies.Any())
            {
                MessengerHelper.Notify(MessengerHelper.DbLoadCompleted);
            }
        }
Пример #6
0
        public async Task DeleteSelectedSearchHistoryItemAsync()
        {
            var ctx = new RisDbContext();

            await ctx.DeleteSearchHistoryEntry(SelectedSearchHistory);
            await LoadSearchHistoryAsync();
        }
Пример #7
0
        public async Task LoadSearchHistoryAsync()
        {
            var ctx = new RisDbContext();
            var history = await ctx.GetSearchHistoryEntries();

            SelectedSearchHistory = null;
            SearchHistory = history;

            if (null != _selectedSearchHistoryItemFromState && history != null)
            {
                SelectedSearchHistory = history.FirstOrDefault(h => h.Id == _selectedSearchHistoryItemFromState.Value);
            }

            if (history.Any())
            {
                MessengerHelper.Notify(MessengerHelper.DbLoadCompleted);
            }
        }
Пример #8
0
        public async Task DeleteSelectedDownloadAsync()
        {
            var ctx = new RisDbContext();

            await ctx.DeleteDownload(SelectedDownload);
            await LoadDownloadsAsync();
        }
        private async Task RefreshCachedDocumentAsync()
        {
            try
            {
                UpdateInProgress = true;

                // #1: Refresh the data
                string dokumentNummer = CurrentDocument.Document.Dokumentnummer;
                var result = await Task.Run(() => ParallelLoadSynced(dokumentNummer));

                if (null != result)
                {
                    CurrentDocument = result.Item1;
                    SourceHtml = result.Item2;

                    // #2: Delete old row and Insert new one
                    var ctx = new RisDbContext();
                    var dl = DbDownloadedDocumentFromViewModel(dokumentNummer);
                    await ctx.RefreshDownload(dl, CachedDocumentDatabaseId.Value);

                    CachedDocumentDatabaseId = dl.Id;

                    ToastService.Display("Aktualisierung erfolgreich", CurrentDocument.Document.Kurztitel);

                    return;
                }
            }
            catch (Exception ex)
            {
                Log.Error("RefreshCachedDocumentAsync", ex);
            }
            finally
            {
                UpdateInProgress = false;
            }

            ToastService.Display("Fehler",
                String.Format("Aktualisierung von \"{0}\" konnte nicht durchgeführt werden", CurrentDocument.Document.Kurztitel));
        }
        private async Task AddDownloadAsync()
        {
            try
            {
                var ctx = new RisDbContext();
                var dl = DbDownloadedDocumentFromViewModel(NavigationParameter.Command);
                await ctx.InsertDownload(dl);

                _addOperationHasBeenExecuted = true;
                CachedDocumentDatabaseId = dl.Id;

                RaisePropertyChanged(CanAddDownloadPropertyName);
            }
            catch (Exception ex)
            {
                Log.Error("AddDownloadAsync", ex);
            }
        }
        private async Task<bool> LoadFromCacheAsync()
        {
            int id = 0;
            if (!Int32.TryParse(NavigationParameter.Command, out id)) return false;

            var ctx = new RisDbContext();
            var doc = await ctx.GetDownload(id);

            if (null == doc) return false;

            try
            {
                // Rehydrate document from storage
                var documentResult = MessageSerializationHelper.DeserializeFromString<Ris.Client.Messages.Document.DocumentResult>(doc.OriginalDocumentResultXml);
                CurrentDocument = Mapper.MapDocumentResult(documentResult);

                CurrentDocument.OriginalDocumentResultXml = doc.OriginalDocumentResultXml;
                SourceHtml = doc.HtmlFromRisServer;
                CachedDocumentDatabaseId = doc.Id;

                return CurrentDocument.Succeeded;
            }
            catch (Exception ex)
            {
                Log.Error("LoadFromCacheAsync", ex);
            }

            return false;
        }