Пример #1
0
 public InpBookLoader(InpBookRecord bookRecord, AuthorLoader authorLoader, GenresLoader genresLoader, SeriesLoader seriesLoader, Entities context)
 {
     this.bookRecord = bookRecord;
     this.authorLoader = authorLoader;
     this.genresLoader = genresLoader;
     this.seriesLoader = seriesLoader;
     this.context = context;
     ProcessBook();
 }
Пример #2
0
 public InpBookLoader(InpBookRecord bookRecord, AuthorLoader authorLoader, GenresLoader genresLoader, SeriesLoader seriesLoader, Entities context)
 {
     this.bookRecord   = bookRecord;
     this.authorLoader = authorLoader;
     this.genresLoader = genresLoader;
     this.seriesLoader = seriesLoader;
     this.context      = context;
     ProcessBook();
 }
Пример #3
0
 private void LoadBookTranslators()
 {
     if (!string.IsNullOrEmpty(fb2Parser.TitleInfo.Translator.FullName))
     {
         AuthorLoader authorLoader = new AuthorLoader(fb2Parser.TitleInfo.Translator.FullName, context);
         if (authorLoader.Authors != null)
         {
             TranslatorsInBook translator = new TranslatorsInBook();
             translator.TranslatorId = Guid.NewGuid();
             translator.BookId       = book.BookId;
             translator.AuthorId     = authorLoader.Authors[0].AuthorId;
             context.TranslatorsInBooks.Add(translator);
         }
     }
 }
Пример #4
0
 private void UploadBookAndEntities()
 {
     using (Entities context = new Entities())
     {
         try
         {
             AuthorLoader authorLoader = new AuthorLoader(bookSources.BookRecord, context);
             if (authorLoader.Authors != null)
             {
                 GenresLoader genresLoader = new GenresLoader(bookSources.BookRecord, context);
                 SeriesLoader seriesLoader = new SeriesLoader(bookSources.BookRecord, context);
                 InpBookLoader bookLoader = new InpBookLoader(bookSources.BookRecord, authorLoader, genresLoader, seriesLoader, context);
                 if (bookLoader.Book != null)
                 {
                     try
                     {
                         FB2BookUploader fb2Loader = new FB2BookUploader(bookLoader.Book, bookSources.BookFileName, context);
                         try
                         {
                             LoadAuthorsDataFromWiki(context, bookLoader.Book.Authors);
                         }
                         catch { }
                         context.SaveChanges();
                         ApplicationLogger.WriteStringToLog("Book \"" + bookLoader.Book.Name + "\" has been uploaded successfully.");
                     }
                     catch (Exception ex)
                     {
                         ApplicationLogger.WriteStringToLog("Book from file: \"" + Path.GetFileName(bookSources.BookFileName) + "\" has not been uploaded because: \r\n" + ex.Message);
                     }
                 }
                 else
                 {
                     ApplicationLogger.WriteStringToLog("Book from file: \"" + Path.GetFileName(bookSources.BookFileName) + "\" has not been uploaded because exist in the database.");
                 }
             }
             else
             {
                 ApplicationLogger.WriteStringToLog("Book from file: \"" + Path.GetFileName(bookSources.BookFileName) + "\" has not been uploaded because couldn't parse authors.");
             }
         }
         catch (Exception ex)
         {
             //transaction.Rollback();
             throw new Exception("UploadBookAndEntities:\r\n" + ex.Message);
         }
     }
 }
Пример #5
0
 private void UploadBookAndEntities()
 {
     using (Entities context = new Entities())
     {
         try
         {
             AuthorLoader authorLoader = new AuthorLoader(bookSources.BookRecord, context);
             if (authorLoader.Authors != null)
             {
                 GenresLoader  genresLoader = new GenresLoader(bookSources.BookRecord, context);
                 SeriesLoader  seriesLoader = new SeriesLoader(bookSources.BookRecord, context);
                 InpBookLoader bookLoader   = new InpBookLoader(bookSources.BookRecord, authorLoader, genresLoader, seriesLoader, context);
                 if (bookLoader.Book != null)
                 {
                     try
                     {
                         FB2BookUploader fb2Loader = new FB2BookUploader(bookLoader.Book, bookSources.BookFileName, context);
                         try
                         {
                             LoadAuthorsDataFromWiki(context, bookLoader.Book.Authors);
                         }
                         catch { }
                         context.SaveChanges();
                         ApplicationLogger.WriteStringToLog("Book \"" + bookLoader.Book.Name + "\" has been uploaded successfully.");
                     }
                     catch (Exception ex)
                     {
                         ApplicationLogger.WriteStringToLog("Book from file: \"" + Path.GetFileName(bookSources.BookFileName) + "\" has not been uploaded because: \r\n" + ex.Message);
                     }
                 }
                 else
                 {
                     ApplicationLogger.WriteStringToLog("Book from file: \"" + Path.GetFileName(bookSources.BookFileName) + "\" has not been uploaded because exist in the database.");
                 }
             }
             else
             {
                 ApplicationLogger.WriteStringToLog("Book from file: \"" + Path.GetFileName(bookSources.BookFileName) + "\" has not been uploaded because couldn't parse authors.");
             }
         }
         catch (Exception ex)
         {
             //transaction.Rollback();
             throw new Exception("UploadBookAndEntities:\r\n" + ex.Message);
         }
     }
 }