Пример #1
0
        public void Setup()
        {
            SetAssemblyConfig(GetType().Assembly);
            var    configLocation = Assembly.GetEntryAssembly().Location;
            string configFile     = @"C:\Users\vgh8no\source\repos\BooksParser\NUnitTestBooksParser\testConf.json";

            configuration = Newtonsoft.Json.JsonConvert.DeserializeObject <BookParserConfig>(File.ReadAllText(configFile));

            mybooks = new BooksCollectedDataMapper(configuration.libraryContext.hostname, configuration.libraryContext.databasename);
            ImportJsonTestDatabase();
        }
Пример #2
0
        public async void ExecuteStartCollect()
        {
            if (!CanExecuteStartCollection())
            {
                MessageBox.Show("Library not properly Configured", "Libraryathome", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var configuration = new BookParserConfig
            {
                ebookdirectory = _confData.EbookFolder,
                libraryContext = new LibraryContextConfig
                {
                    hostname = _confData.RepositoryHost, databasename = _confData.DatabaseName
                }
            };

            configuration.ebookformat = _confData.BookFormatsCheckStatus.Keys.ToList();
            configuration.providerPlugin.pluginfolder       = AppDomain.CurrentDomain.BaseDirectory;
            configuration.providerPlugin.pluginassemblyname = "LibraryAtHomeProvider";


            var exceptions = new ConcurrentQueue <Exception>();

            Action <int> updateProg = i => UpdateprogressBar(i);

            _cataloger = new LibraryCataloguer(configuration, exceptions, null, updateProg);

            TotalBookCount = _cataloger.FileCount;


            try
            {
                await Task.Run(async() =>
                {
                    await _cataloger.CatalogBooksAsync().ConfigureAwait(false);
                });


                List <PocoBook>         bookCollected = _cataloger.BooksInLibrary.Read();
                List <BookToBeReviewed> booktoreview  = _cataloger.BookToReview.Read();

                TotalBookCataloged = bookCollected.Count;
                TotalBookDiscarted = booktoreview.Count;

                foreach (var book in bookCollected)
                {
                    if (!Books.Contains(book))
                    {
                        Books.Add(book);
                    }
                }
            }
            catch (AggregateException ae)
            {
                foreach (var ex in ae.Flatten().InnerExceptions)
                {
                    if (ex is ArgumentException)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }