Example #1
0
        public List<Book> Select(BookFilter filter)
        {
            if (filter == null) return null;

            List<Book> list = null;

            using (var db = new DozpContext())
            {
                list = (from b in db.Books.Include(e => e.Catalogue).Include(e => e.ScanFiles)
                        where (0 == filter.BookID || b.BookID == filter.BookID) &&
                              (0 == filter.CatalogueID || b.CatalogueID == filter.CatalogueID) &&
                              (String.IsNullOrEmpty(filter.SysNo) || b.SysNo == filter.SysNo) &&
                              (String.IsNullOrEmpty(filter.ISBN) || b.Barcode == filter.ISBN) &&
                              (String.IsNullOrEmpty(filter.Barcode) || b.Barcode == filter.Barcode) &&
                              (!filter.Modified.From.HasValue || b.Modified >= filter.Modified.From.Value) &&
                              (!filter.Modified.To.HasValue || b.Modified <= filter.Modified.To.Value) &&
                              //(!filter.Modified.From.HasValue || b.ScanFiles.Count(f => f.Modified >= filter.Modified.From.Value) > 0) &&
                              //(!filter.Modified.To.HasValue || b.ScanFiles.Count(f => f.Modified <= filter.Modified.To.Value) > 0) &&
                              (!filter.PartOfBook.HasValue || b.ScanFiles.Count(f => f.PartOfBook == filter.PartOfBook.Value) > 0) &&
                              (!filter.UseOCR.HasValue || b.ScanFiles.Count(f => f.UseOCR == filter.UseOCR.Value) > 0) &&
                              (!filter.Status.HasValue || b.ScanFiles.Count(f => f.Status == filter.Status.Value) > 0)
                        select b).ToList();
            }

            return list;
        }
Example #2
0
        public List<Book> GetList(BookFilter filter)
        {
            if (filter == null) throw new ArgumentNullException("filter");
            if (filter.Modified == null) filter.Modified = new DateRange(DateRange.DateType.Modified);

            BookRepository repository = new BookRepository();
            return repository.Select(filter);
        }
Example #3
0
        public List<Book> GetByFilter(int catalogueID, DateTime modifiedFrom, DateTime modifiedTo, short? partOfBook, int? status, string sortExpression)
        {
            BookFilter filter = new BookFilter();
            filter.CatalogueID = catalogueID;
            filter.Modified = new DateRange(modifiedFrom, modifiedTo);
            filter.PartOfBook = (PartOfBook?)partOfBook;
            filter.Status = (StatusCode?)status;

            return GetList(filter).OrderBy(sortExpression).ToList();
        }
Example #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sysno"></param>
        /// <returns></returns>
        public static List<Book> GetBooks(int catalogueID, string sysno, string isbn = null)
        {
            BookFilter filter = new BookFilter();
            filter.CatalogueID = catalogueID;
            filter.SysNo = sysno;
            filter.ISBN = isbn;

            return AuthController.GetProxy().Execute(client => client.GetBooks(filter));
        }
Example #5
0
 public List<Book> GetBooks(BookFilter filter)
 {
     try
     {
         return BookComponent.Instance.GetList(filter);
     }
     catch (Exception ex)
     {
         string message = "Chyba při načtení záznamů knih podle filtru";
         throw new FaultException<DozpServiceFault>(new DozpServiceFault(message), ex.Message);
     }
 }
Example #6
0
        public int Export(int catalogueID, string userName, string computer)
        {
            //kontrola vstupnich parametru
            if (catalogueID == 0)
                throw new ArgumentNullException("Neplatný parametr identifikátor katalogu.");

            int result = 0;
            CatalogueRepository repository = new CatalogueRepository();

            //kontrola existence katalogu
            Catalogue catalogue = repository.Select(catalogueID);
            if (catalogue == null)
                throw new ApplicationException(String.Format("Katalog (ID={0}) neexistuje.", catalogueID));

            StreamWriter sw = null;

            try
            {
                BookFilter filter = new BookFilter();
                filter.CatalogueID = catalogue.CatalogueID;
                filter.Status = StatusCode.Complete;
                List<Book> books = BookComponent.Instance.GetList(filter);

                filter.UseOCR = false;
                filter.Status = StatusCode.Scanned;
                books.AddRange(BookComponent.Instance.GetList(filter));

                if (books != null && books.Count > 0)
                {
                    string logFilePath = Path.Combine(catalogue.GetDirectoryFTP(), "Export.log");

                    if (File.Exists(logFilePath))
                        throw new ApplicationException(String.Format("Soubor s exportom '{0}' již existuje.", logFilePath));

                    foreach (var book in books)
                    {
                        try
                        {
                            if (BookComponent.Instance.Export(book.BookID, userName, computer))
                            {
                                string publication = book.Title;
                                if (!String.IsNullOrEmpty(book.Author))
                                    publication = String.Format("{0}: {1}", book.Author, publication);
                                if (!String.IsNullOrEmpty(book.Year))
                                    publication = String.Format("{0}, {1}", publication, book.Year);

                                string volume = null;
                                string jpgFileName = null;
                                string pdfFileName = null;
                                string txtFileName = null;

                                if (book.FrontCover != null)
                                {
                                    jpgFileName = book.FrontCover.FileName;
                                }

                                if (book.TableOfContents != null)
                                {
                                    volume = String.Format("Obsah {0}", book.Volume).Trim();
                                    pdfFileName = book.TableOfContents.OcrFileName;

                                    if (book.TableOfContents.UseOCR)
                                    {
                                        txtFileName = book.TableOfContents.TxtFileName;
                                    }
                                }

                                string exportBook = String.Join(" | ", new string[] { book.SysNo, publication, volume, jpgFileName, pdfFileName, txtFileName });

                                if (sw == null)
                                    sw = new StreamWriter(logFilePath, false);
                                sw.WriteLine(exportBook);
                                sw.Flush();

                                result++;
                            }
                        }
                        catch
                        {
                            //zapis chyby do textoveho suboru Errors.log
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(String.Format("Nepodařilo se exportovat katalog (ID={0}) na FTP: {1}", catalogueID, ex.Message));
            }
            finally
            {
                if (sw != null)
                {
                    sw.Flush();
                    sw.Close();
                }
            }

            return result;
        }