Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
 public SeriesImporter(LibationContext context) : base(context)
 {
 }
Exemplo n.º 5
0
 public ContributorImporter(LibationContext context) : base(context)
 {
 }
Exemplo n.º 6
0
 protected ItemsImporterBase(LibationContext context) : base(context)
 {
 }
Exemplo n.º 7
0
 protected ImporterBase(LibationContext context)
 {
     ArgumentValidator.EnsureNotNull(context, nameof(context));
     DbContext = context;
 }
Exemplo n.º 8
0
        //// idea for future command/query separation
        // public static LibationContext GetCommandContext() { }
        // public static LibationContext GetQueryContext() { }

        public static LibationContext GetContext()
        => LibationContext.Create(SqliteStorage.ConnectionString);
Exemplo n.º 9
0
 public SearchEngine(LibationContext context) => this.context = context;
Exemplo n.º 10
0
 public BookImporter(LibationContext context) : base(context)
 {
 }
Exemplo n.º 11
0
 public CategoryImporter(LibationContext context) : base(context)
 {
 }
Exemplo n.º 12
0
 public LibraryImporter(LibationContext context) : base(context)
 {
 }