Пример #1
0
        public SendScanDialog(Book sendBook, ScanImages scannedImages)
        {
            InitializeComponent();

            this.ScannedImages = scannedImages;
            this.SendBook = sendBook;
        }
Пример #2
0
        public SendScanDialog(Book sendBook, string frontCoverFilePath, string tableOfContentsFilePath)
        {
            InitializeComponent();

            this.SendBook = sendBook;
            this.FrontCoverFilePath = frontCoverFilePath;
            this.TableOfContentsFilePath = tableOfContentsFilePath;
        }
Пример #3
0
        public bool Delete(Book book)
        {
            if (book == null) return false;

            using (var db = new DozpContext())
            {
                db.Entry(book).State = EntityState.Deleted;
                db.SaveChanges();
            }

            return true;
        }
Пример #4
0
        public Book Create(Book book)
        {
            if (book == null) return null;

            using (var db = new DozpContext())
            {
                db.Entry(book).State = EntityState.Added;
                db.SaveChanges();
            }

            return book;
        }
Пример #5
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(SearchField))
            {
                MessageBox.Show("Není vybrána položka pro vyhledání záznamu.", this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            if (String.IsNullOrWhiteSpace(SearchValue))
            {
                MessageBox.Show(String.Format("Není zadána hodnota pro {0}.", this.SearchFieldComboBox.Text), this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            try
            {
                this.Cursor = Cursors.Wait;
                this.SearchButton.IsEnabled = false;

                Report report = null;
                string barcode = null;

                switch (SearchField)
                {
                    case "barcode":
                        barcode = SearchValue;
                        report = DozpController.SearchBook(Settings.Default.SelectedCatalogueID, barcode: SearchValue);
                        break;
                    case "sysno":
                        report = DozpController.SearchBook(Settings.Default.SelectedCatalogueID, sysno: SearchValue);
                        break;
                    case "isbn":
                        report = DozpController.SearchBook(Settings.Default.SelectedCatalogueID, isbn: SearchValue);
                        break;
                    default:
                        break;
                }

                //nacteni MARC zaznamu z katalogu
                if (report != null)
                {
                    if (report.Success)
                    {
                        Marc21Records records = new Marc21Records(report.XmlData);

                        if (records == null || records.Count == 0)
                        {
                            MessageBox.Show("Publikace nebyla nalezena, zkuste vyhledat podle jiného parametru (SYSNO, ISBN).", this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }
                        else if (records.Count == 1)
                        {
                            Marc21Record record = (records[0] as Marc21Record);
                            string[] isbns = record.FindAll(Marc21Tag.TAG_DF_InternationalStandardBookNumber, Marc21Tag.CODE_InternationalStandardBookNumber);

                            //kontrola existence publikace - UPRAVA DATABAZY - UniqueKey
                            Books = DozpController.GetBooks(Settings.Default.SelectedCatalogueID, record.RecordIdentifier);

                            if (isbns != null && isbns.Count() <= 1)
                            {
                                if (isbns.Count() == 0)
                                    NewBook = GetBookByISBN(null);
                                else if (isbns.Count() == 1)
                                    NewBook = GetBookByISBN(isbns[0]);
                            }

                            if (NewBook == null)
                            {
                                NewBook = new Book();
                                NewBook.CatalogueID = Settings.Default.SelectedCatalogueID;
                                NewBook.SysNo = record.RecordIdentifier;
                                NewBook.ISBN = GetNormalizedISN(record.Find(Marc21Tag.TAG_DF_InternationalStandardBookNumber, Marc21Tag.CODE_InternationalStandardBookNumber));
                                NewBook.ISSN = GetNormalizedISN(record.Find(Marc21Tag.TAG_DF_InternationalStandardSerialNumber, Marc21Tag.CODE_InternationalStandardSerialNumber));
                                NewBook.NBN = GetFirstOrDefaultCNB(record.FindAll(Marc21Tag.TAG_DF_NationalBibliographyNumber, Marc21Tag.CODE_NationalBibliographyNumber));
                                NewBook.OCLC = GetFirstOrDefaultOCLC(record.FindAll(Marc21Tag.TAG_DF_SystemControlNumber, Marc21Tag.CODE_SystemControlNumber));
                                NewBook.Author = record.Author.TrimEnd(' ', ',');
                                NewBook.Title = record.Title.TrimEnd(' ', ',', ':', '/', '=');
                                NewBook.Year = record.DateOfPublication.TrimStart('c').TrimEnd(' ', '-');
                                NewBook.Volume = record.NumberOfPart.TrimEnd(' ', ',');
                                NewBook.Barcode = barcode;
                            }
                            else
                            {
                                if (NewBook.IsExported())
                                {
                                    MessageBox.Show(String.Format("Publikace SYSNO: {0} [ISBN {1}] byla již exportována do ALEPHu, nelze skenovat!", NewBook.SysNo, NewBook.ISBN), this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                                    return;
                                }
                                else
                                {
                                    if (MessageBox.Show(String.Format("Publikace SYSNO: {0} [ISBN {1}] byla již skenována, chcete pokračovat?", NewBook.SysNo, NewBook.ISBN), this.Title, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                                        return;
                                }
                            }

                            //vicesvazkove dila
                            if (isbns != null && isbns.Count() > 1)
                            {
                                this.SearchFieldComboBox.IsReadOnly = true;
                                this.SearchValueTextBox.IsReadOnly = true;

                                //ISBN
                                this.IsbnLabel.Visibility = Visibility.Visible;
                                this.IsbnComboBox.Visibility = Visibility.Visible;
                                foreach (var isbn in isbns)
                                {
                                    Book book = GetBookByISBN(isbn);
                                    string volume = Regex.Match(isbn, @"\(([^)]*)\)").Groups[1].Value;

                                    if (book != null)
                                        volume = book.Volume;
                                    else if (!String.IsNullOrEmpty(NewBook.Volume))
                                        volume = NewBook.Volume;

                                    ComboBoxItem item = new ComboBoxItem();
                                    item.Content = isbn;
                                    item.Foreground = (book != null ? Brushes.Red : Brushes.Black);
                                    item.Tag = volume;
                                    this.IsbnComboBox.Items.Add(item);
                                }

                                //Díl, svazek
                                this.VolumeLabel.Visibility = Visibility.Visible;
                                this.ContentsLabel.Visibility = Visibility.Visible;
                                this.VolumeTextBox.Visibility = Visibility.Visible;

                                this.IsbnComboBox.SelectedIndex = 0;
                                this.SearchButton.Visibility = Visibility.Collapsed;
                                this.OkButton.Visibility = Visibility.Visible;

                                return;
                            }

                            this.DialogResult = true;
                        }
                        else
                        {
                            MessageBox.Show(String.Format("Nalezeno bylo {0} publikací, čárový kód není jedinečný.", records.Count), this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show(String.Format("Chyba při vyhledání publikace: {0}", report.Errors), this.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        this.DialogResult = false;
                    }
                }
                else
                {
                    MessageBox.Show("Žádná odpověd při vyhledání publikace.", this.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    this.DialogResult = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                this.DialogResult = false;
            }
            finally
            {
                this.SearchButton.IsEnabled = true;
                this.Cursor = null;
            }
        }
Пример #6
0
 public MarcRecordDialog(Window parent, Book newBook)
     : this(newBook)
 {
     this.Owner = parent;
 }
Пример #7
0
        public MarcRecordDialog(Book newBook)
        {
            InitializeComponent();

            this.NewBook = newBook;
        }
Пример #8
0
        public Book Save(Book book)
        {
            if (book == null)
                throw new ArgumentNullException("book");

            if (book.CatalogueID == 0)
                throw new ArgumentException("Neplatný parametr CatalogueID");

            if (String.IsNullOrEmpty(book.SysNo))
                throw new ArgumentNullException("Neplatný parametr SysNo");

            if (book.SysNo.Length > 20)
                throw new ArgumentOutOfRangeException("Parametr SysNo je delší než 20 znaků");

            if (String.IsNullOrEmpty(book.Title))
                throw new ArgumentNullException("Neplatný parametr Title");

            BookRepository repository = new BookRepository();
            Book original = null;

            if (book.BookID == 0)
            {
                List<Book> books = repository.Select(new BookFilter(book.CatalogueID, book.SysNo));

                book.FileIndex = (short)(books != null && books.Count > 0 ? books.Max(i => i.FileIndex) + 1 : 0);
                book.ISBN = book.ISBN.Left(50); //normalize !!!
                book.ISSN = book.ISSN.Left(50);
                book.NBN = book.NBN.Left(50);
                book.OCLC = book.OCLC.Left(50);
                book.Author = book.Author.Left(200);
                book.Title = book.Title.Left(1000);
                book.Year = book.Year.Left(20);
                book.Volume = book.Volume.Left(100);
                book.Barcode = book.Barcode.Left(20);
                book.Created = DateTime.Now;
                book.Modified = book.Created;
                book.Comment = book.Comment.Left(1000);
                book = repository.Create(book);
            }
            else
            {
                original = repository.Select(book.BookID);

                if (original == null)
                    throw new ArgumentNullException(String.Format("Záznam publikace (ID={0}) neexistuje.", book.BookID));

                original.Volume = book.Volume.Left(100);
                original.Comment = book.Comment.Left(1000);
                original.Modified = DateTime.Now;
                book = repository.Update(original);
            }

            return book;
        }
Пример #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="catalogueID"></param>
        /// <param name="sysno"></param>
        /// <param name="isbn"></param>
        /// <returns></returns>
        public static string SearchCoverUrl(string zserverUrl, Book book)
        {
            if (book == null) throw new ArgumentNullException("book");

            string frontCoverUrl = null;

            ObalkyKnihRequest request = new ObalkyKnihRequest();
            request.zserverUrl = zserverUrl;

            ObalkyKnihBibInfo bibinfo = new ObalkyKnihBibInfo();
            bibinfo.sysno = book.SysNo;
            bibinfo.authors = new List<string>() { book.Author };
            bibinfo.title = book.Title;
            bibinfo.year = book.Year;
            bibinfo.isbn = book.ISBN;
            bibinfo.nbn = book.NBN;
            bibinfo.oclc = book.OCLC;
            request.bibinfo = bibinfo;

            ObalkyKnihResponse response = AuthController.GetProxy().Execute(client => client.SearchObalkyKnihCZ(request));

            if (response != null)
            {
                frontCoverUrl = response.cover_medium_url;
            }

            return frontCoverUrl;
        }
Пример #10
0
        public static bool SearchCoverOK(string zserverUrl, Book book, string fullName)
        {
            if (book == null) throw new ArgumentNullException("book");
            if (String.IsNullOrEmpty(fullName)) throw new ArgumentNullException("Nebyla zadána cesta k souboru", "fullName");

            bool result = false;

            ObalkyKnihRequest request = new ObalkyKnihRequest();
            request.zserverUrl = zserverUrl;

            ObalkyKnihBibInfo bibinfo = new ObalkyKnihBibInfo();
            bibinfo.sysno = book.SysNo;
            bibinfo.authors = new List<string>() { book.Author };
            bibinfo.title = book.Title;
            bibinfo.year = book.Year;
            bibinfo.isbn = book.ISBN;
            bibinfo.nbn = book.NBN;
            bibinfo.oclc = book.OCLC;
            request.bibinfo = bibinfo;

            ObalkyKnihResponse response = AuthController.GetProxy().Execute(client => client.SearchObalkyKnihCZ(request));

            if (response != null && response.cover_image != null && response.cover_image.Length > 0)
            {
                result = (ImageFunctions.WriteFile(fullName, response.cover_image, true) > 0);
            }

            return result;
        }
Пример #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="book"></param>
 /// <returns></returns>
 public static Book SaveBook(Book book)
 {
     return AuthController.GetProxy().Execute(client => client.SaveBook(book));
 }
Пример #12
0
        public Book SaveBook(Book book)
        {
            if (book == null) throw new ArgumentException("Request parameter Book is null.");

            try
            {
                return BookComponent.Instance.Save(book);
            }
            catch (Exception ex)
            {
                string message = String.Format("Chyba při vytváření nového záznamu knihy v katalogu (ID={0})", book.CatalogueID);
                throw new FaultException<DozpServiceFault>(new DozpServiceFault(message), ex.Message);
            }
        }
Пример #13
0
 public SendScanDialog(Window parent, Book sendBook, ScanImages scannedImages)
     : this(sendBook, scannedImages)
 {
     this.Owner = parent;
 }
Пример #14
0
 public SendScanDialog(Window parent, Book sendBook, string frontCoverFilePath, string tableOfContentsFilePath)
     : this(sendBook, frontCoverFilePath, tableOfContentsFilePath)
 {
     this.Owner = parent;
 }
Пример #15
0
        private void RecoveryLastBook()
        {
            if (Settings.Default.LastScanBook == null) return;

            if (Settings.Default.LastScanBook.BookID != 0)
                CurrentBook = DozpController.GetBook(Settings.Default.LastScanBook.BookID); //server
            else
                CurrentBook = new Book(Settings.Default.LastScanBook);  //local

            ScannedImages.ScanFileName = CurrentBook.GetFileName();
            ScanImageListView.ItemsSource = ScannedImages;

            ScannedImages.Repair();
            DownloadObalkyKnihCZ();
            //DownloadCurrentBook();
            SelectFirstScanImage();
        }
Пример #16
0
        public void Load(Book book)
        {
            this.Book = book;

            if (this.Book != null)
            {
                Settings.Default.LastScanBook = Book.GetSettings();
                Settings.Default.Save();

                this.BookInfoGrid.Visibility = Visibility.Visible;
                this.SysnoTextBox.Text = Book.SysNo;
                this.AuthorTextBox.Text = Book.Author;
                this.TitleTextBox.Text = Book.Title;
                this.YearTextBox.Text = Book.Year;
                this.VolumeTextBox.Text = Book.Volume;
                this.IsbnTextBox.Text = Book.ISBN;
                this.NbnTextBox.Text = Book.NBN;
                this.OclcTextBox.Text = Book.OCLC;
                this.BarcodeTextBox.Text = Book.Barcode;
            }
            else
            {
                Clear();
            }
        }