Пример #1
0
        public void OnNewQueryFilter(string message)
        {
            BooksCollectedDataMapper mapper = new BooksCollectedDataMapper(ConfData.RepositoryHost, ConfData.DatabaseName);

            if (string.IsNullOrEmpty(message))
            {
                foreach (var book in mapper.Read())
                {
                    if (!Books.Contains(book))
                    {
                        Books.Add(book);
                    }
                }
                return;
            }

            PocoBook titlebook = new PocoBook("");

            titlebook.Title = message;

            var filtered = mapper.Read(titlebook);

            if (filtered.Any())
            {
                Books.Clear();
            }

            foreach (var book in filtered)
            {
                Books.Add(book);
            }
        }
Пример #2
0
        public void UpdateLibraryConfigurationData(LibraryConfigurationData message)
        {
            Books.Clear();

            ConfData    = message;
            LibraryName = message.DatabaseName;
            BookFolder  = message.EbookFolder;

            if (message.LibraryExits)
            {
                BooksCollectedDataMapper    mapper = new BooksCollectedDataMapper(message.RepositoryHost, message.DatabaseName);
                LibraryStatisticsDataMapper stat   = new LibraryStatisticsDataMapper(message.RepositoryHost, message.DatabaseName);

                BookFolder = stat?.Read().FirstOrDefault()?.LibraryDirectory;


                foreach (var book in mapper.Read())
                {
                    if (!Books.Contains(book))
                    {
                        Books.Add(book);
                    }
                }
            }

            LibraryAtHomeMain.Default.EbookFolder       = message.EbookFolder;
            LibraryAtHomeMain.Default.LastLibraryOpened = message.DatabaseName;
            LibraryAtHomeMain.Default.LibraryExists     = true;
            LibraryAtHomeMain.Default.RepositoryHost    = message.RepositoryHost;
            LibraryAtHomeMain.Default.Save();
        }