public async Task<List<ForumThreadEntity>> RefreshBookmarkedThreads() { using (var dbs = new BookmarkDataSource()) { List<ForumThreadEntity> updatedBookmarkList; var notifyThreads = await dbs.BookmarkForumRepository.Items.Where(node => node.IsNotified).ToListAsync(); var notifyThreadIds = notifyThreads.Select(thread => thread.ThreadId).ToList(); try { updatedBookmarkList = await GetBookmarkedThreadsAsync(); } catch (Exception ex) { throw new Exception("Could not get bookmarks", ex); } await RemoveBookmarkThreads(); var count = 0; foreach (ForumThreadEntity t in updatedBookmarkList) { if (notifyThreadIds.Contains(t.ThreadId)) { t.IsNotified = true; } t.Id = count; await dbs.BookmarkForumRepository.CreateWithChildren(t); count++; } _localSettings.Values["RefreshBookmarks"] = DateTime.UtcNow.ToString(); return updatedBookmarkList; } }
public async Task <List <ForumThreadEntity> > GetBookmarkedThreadsFromDb() { using (var bds = new BookmarkDataSource()) { return(await bds.BookmarkForumRepository.Items.ToListAsync()); } }
public async Task <ForumThreadEntity> GetBookmarkThreadAsync(long threadId) { using (var bds = new BookmarkDataSource()) { return(await bds.BookmarkForumRepository.Items.Where(node => node.ThreadId == threadId).FirstOrDefaultAsync()); } }
public async Task SetThreadNotified(ForumThreadEntity thread) { using (var bds = new BookmarkDataSource()) { thread.IsNotified = !thread.IsNotified; await bds.BookmarkForumRepository.Update(thread); } }
public async Task AddBookmarkThreads(List <ForumThreadEntity> bookmarkedThreads) { var dbs = new BookmarkDataSource(); foreach (ForumThreadEntity t in bookmarkedThreads) { await dbs.BookmarkForumRepository.CreateWithChildren(t); } }
public async Task <bool> IsBookmark(long threadId) { using (var bds = new BookmarkDataSource()) { var result = await bds.BookmarkForumRepository.Items.Where(node => node.ThreadId == threadId).ToListAsync(); return(result.Count > 0); } }
/// <summary> /// 単一アプリケーション オブジェクトを初期化します。これは、実行される作成したコードの ///最初の行であるため、main() または WinMain() と論理的に等価です。 /// </summary> public App() { Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(); this.InitializeComponent(); this.Suspending += OnSuspending; if (_localSettings.Values.ContainsKey(Constants.ThemeDefault)) { var themeType = (ThemeTypes)_localSettings.Values[Constants.ThemeDefault]; switch (themeType) { case ThemeTypes.Light: RequestedTheme = ApplicationTheme.Light; break; case ThemeTypes.Dark: RequestedTheme = ApplicationTheme.Dark; break; case ThemeTypes.YOSPOS: RequestedTheme = ApplicationTheme.Dark; break; } } SelectedTheme = RequestedTheme; try { DataSource ds = new DataSource(); SaclopediaDataSource sds = new SaclopediaDataSource(); BookmarkDataSource bds = new BookmarkDataSource(); ds.InitDatabase(); ds.CreateDatabase(); bds.InitDatabase(); bds.CreateDatabase(); sds.InitDatabase(); sds.CreateDatabase(); } catch { } Container = AutoFacConfiguration.Configure(); }
public async Task <List <ForumThreadEntity> > RefreshBookmarkedThreads() { using (var dbs = new BookmarkDataSource()) { List <ForumThreadEntity> updatedBookmarkList; var notifyThreads = await dbs.BookmarkForumRepository.Items.Where(node => node.IsNotified).ToListAsync(); var notifyThreadIds = notifyThreads.Select(thread => thread.ThreadId).ToList(); try { updatedBookmarkList = await GetBookmarkedThreadsAsync(); } catch (Exception ex) { throw new Exception("Could not get bookmarks", ex); } await RemoveBookmarkThreads(); var count = 0; foreach (ForumThreadEntity t in updatedBookmarkList) { if (notifyThreadIds.Contains(t.ThreadId)) { t.IsNotified = true; } t.Id = count; await dbs.BookmarkForumRepository.CreateWithChildren(t); count++; } _localSettings.Values["RefreshBookmarks"] = DateTime.UtcNow.ToString(); return(updatedBookmarkList); } }
public async Task RemoveBookmarkThreads() { var dbs = new BookmarkDataSource(); await dbs.BookmarkForumRepository.RemoveAll(); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="Common.NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } try { var threadId = (long)e.NavigationParameter; var bookmarkdata = new BookmarkDataSource(); _lastSelectedItem = await bookmarkdata.BookmarkForumRepository.Items.Where(node => node.ThreadId == threadId).FirstOrDefaultAsync(); if (_lastSelectedItem != null) { Locator.ViewModels.BookmarksPageVm.NavigateToThreadPageViaToastCommand.Execute(_lastSelectedItem); if (AdaptiveStates.CurrentState == NarrowState) { Frame.Navigate(typeof(ThreadPage), null, new DrillInNavigationTransitionInfo()); } } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to load Bookmarks page", ex); } }
public async Task AddBookmarkThreads(List<ForumThreadEntity> bookmarkedThreads) { var dbs = new BookmarkDataSource(); foreach (ForumThreadEntity t in bookmarkedThreads) { await dbs.BookmarkForumRepository.CreateWithChildren(t); } }
public async Task<List<ForumThreadEntity>> GetBookmarkedThreadsFromDb() { using (var bds = new BookmarkDataSource()) { return await bds.BookmarkForumRepository.Items.ToListAsync(); } }
public async Task<bool> IsBookmark(long threadId) { using (var bds = new BookmarkDataSource()) { var result = await bds.BookmarkForumRepository.Items.Where(node => node.ThreadId == threadId).ToListAsync(); return result.Count > 0; } }
public async Task<ForumThreadEntity> GetBookmarkThreadAsync(long threadId) { using (var bds = new BookmarkDataSource()) { return await bds.BookmarkForumRepository.Items.Where(node => node.ThreadId == threadId).FirstOrDefaultAsync(); } }