/// <summary>Long running. Use await Task.Run(() => UpdateBook(productId))</summary> public void UpdateBook(LibationContext context, string productId) { var libraryBook = context.GetLibraryBook_Flat_NoTracking(productId); var term = new Term(_ID_, productId); var document = createBookIndexDocument(libraryBook); var createNewIndex = false; using var index = getIndex(); using var analyzer = new StandardAnalyzer(Version); using var ixWriter = new IndexWriter(index, analyzer, createNewIndex, IndexWriter.MaxFieldLength.UNLIMITED); ixWriter.DeleteDocuments(term); ixWriter.AddDocument(document); }
public void Display() { if (hasBeenDisplayed) { return; } hasBeenDisplayed = true; // // transform into sorted GridEntry.s BEFORE binding // context = DbContexts.GetContext(); var lib = context.GetLibrary_Flat_WithTracking(); // if no data. hide all columns. return if (!lib.Any()) { for (var i = dataGridView.ColumnCount - 1; i >= 0; i--) { dataGridView.Columns.RemoveAt(i); } return; } var orderedGridEntries = lib .Select(lb => new GridEntry(lb)).ToList() // default load order .OrderByDescending(ge => ge.Purchase_Date) //// more advanced example: sort by author, then series, then title //.OrderBy(ge => ge.Authors) // .ThenBy(ge => ge.Series) // .ThenBy(ge => ge.Title) .ToList(); // // BIND // gridEntryBindingSource.DataSource = orderedGridEntries.ToSortableBindingList(); // // FILTER // filter(); BackupCountsChanged?.Invoke(this, EventArgs.Empty); }
public static int UpdateTags(this LibationContext context, Book book, string newTags) { try { book.UserDefinedItem.Tags = newTags; var qtyChanges = context.SaveChanges(); if (qtyChanges > 0) { SearchEngineCommands.UpdateBookTags(book); } return(qtyChanges); } catch (Exception ex) { Log.Logger.Error(ex, "Error updating tags"); throw; } }
public SeriesImporter(LibationContext context) : base(context) { }
public ContributorImporter(LibationContext context) : base(context) { }
protected ItemsImporterBase(LibationContext context) : base(context) { }
protected ImporterBase(LibationContext context) { ArgumentValidator.EnsureNotNull(context, nameof(context)); DbContext = context; }
//// idea for future command/query separation // public static LibationContext GetCommandContext() { } // public static LibationContext GetQueryContext() { } public static LibationContext GetContext() => LibationContext.Create(SqliteStorage.ConnectionString);
public SearchEngine(LibationContext context) => this.context = context;
public BookImporter(LibationContext context) : base(context) { }
public CategoryImporter(LibationContext context) : base(context) { }
public LibraryImporter(LibationContext context) : base(context) { }