コード例 #1
0
ファイル: InpBookLoader.cs プロジェクト: avgx/knigoskop
 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
ファイル: InpBookLoader.cs プロジェクト: avgx/knigoskop
 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
ファイル: BookUploader.cs プロジェクト: avgx/knigoskop
 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);
         }
     }
 }
コード例 #4
0
ファイル: BookUploader.cs プロジェクト: avgx/knigoskop
 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);
         }
     }
 }