public async Task Rebuild() { lock (this) { if (IsLoading) { return; } IsLoading = true; } MatchTable.Items = null; StringResources stx = StringResources.Load("LoadingMessage"); Message = stx.Str("BuildingIndexes"); Database.ContextManager.CreateFTSContext(); await Task.Run(() => { using (var FTSD = new FTSDataContext()) { FTSD.FTSChapters.AddRange( Shared.BooksDb.ChapterContents .Select(x => new FTSChapter() { ChapterId = x.ChapterId, Text = x.Data.StringValue }) ); FTSD.SaveChanges(); } }); IsLoading = false; try { Reload(); } catch (EmptySearchQueryException) { } }
public override void Reload() { if (string.IsNullOrEmpty(Search)) { throw new EmptySearchQueryException(); } if (!IsBuilt) { return; } lock (this) { if (IsLoading) { return; } IsLoading = true; } StringResources stx = StringResources.Load("LoadingMessage", "AppResources"); Message = stx.Str("ProgressIndicator_Message"); using (var FTSD = new FTSDataContext()) { MatchTable.Items = FTSD.Search(Search).Select(x => new GRRow <FTSResult>(MatchTable) { Source = new FTSResult(x.ChapterId, x.Text) }).ToArray(); } TableHeaderSource.Result = string.Format(stx.Text("Search_N_Result", "AppResources"), MatchTable.Items.Count()); IsLoading = false; }
private async void ExecQuery(string Command) { ResultDisplayData ResultDD = null; string Mesg = null; switch (Command.ToLower().Trim()) { case "quit": case "q": ResponseCommand("Quit."); OpenedDb = null; PS1.Text = ""; return; } await IntensiveCommand(() => { switch (OpenedDb) { case "Books": using (var Context = new BooksContext()) (ResultDD, Mesg) = GR.Database.DirectSQL.Command.Exec(Context, Command); break; case "Caches": using (var Context = new ZCacheContext()) (ResultDD, Mesg) = GR.Database.DirectSQL.Command.Exec(Context, Command); break; case "Settings": using (var Context = new SettingsContext()) (ResultDD, Mesg) = GR.Database.DirectSQL.Command.Exec(Context, Command); break; case "FTSData": using (var Context = new FTSDataContext()) (ResultDD, Mesg) = GR.Database.DirectSQL.Command.Exec(Context, Command); break; default: Mesg = $"\"{OpenedDb}\" is currently unavailable"; break; } }); if (ResultDD != null) { if (ResultDD.HasData) { Border B = new Border { Margin = new Thickness(5), Background = new SolidColorBrush(GR.Resources.LayoutSettings.MajorBackgroundColor), MinHeight = 400, Height = GR.Resources.LayoutSettings.ScreenHeight * 0.7 }; Explorer.GRTableView TableView = new Explorer.GRTableView(); TableView.ViewMode = Explorer.ViewMode.Table; var j = TableView.View(new ResultViewSource(ResultDD)); B.Child = TableView; AddElement(B); } else { ResponseCommand("(Empty set)"); } } if (!string.IsNullOrEmpty(Mesg)) { ResponseCommand(Mesg); } }