コード例 #1
0
ファイル: PDFDAL.cs プロジェクト: hoangbktech/bhl-bits
        public PDF AddNewPdf(SqlConnection sqlConnection, SqlTransaction sqlTransaction,
            int itemID, String emailAddress, String shareWith, bool imagesOnly,
            String articleTitle, String articleCreators, String articleTags, List<int> pageIDs)
        {
            SqlConnection connection = sqlConnection;
            SqlTransaction transaction = sqlTransaction;

            if (connection == null)
            {
                connection = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"));
            }

            bool isTransactionCoordinator = CustomSqlHelper.IsTransactionCoordinator(transaction);

            try
            {
                transaction = CustomSqlHelper.BeginTransaction(connection, transaction, isTransactionCoordinator);

                // Add the new pdf record
                PDF newPdf = new PDF();
                newPdf.ItemID = itemID;
                newPdf.EmailAddress = emailAddress;
                newPdf.ShareWithEmailAddresses = shareWith;
                newPdf.ImagesOnly = imagesOnly;
                newPdf.ArticleTitle = articleTitle;
                newPdf.ArticleCreators = articleCreators;
                newPdf.ArticleTags = articleTags;
                newPdf.PdfStatusID = 10;
                PDF savedpdf = new PDFDAL().PDFInsertAuto(connection, transaction, newPdf);

                // Add records for the pdf pages
                PDFPageDAL pdfPageDal = new PDFPageDAL();
                foreach (int pageID in pageIDs)
                {
                    PDFPage newPdfPage = new PDFPage();
                    newPdfPage.PdfID = savedpdf.PdfID;
                    newPdfPage.PageID = pageID;
                    pdfPageDal.PDFPageInsertAuto(connection, transaction, newPdfPage);
                }

                CustomSqlHelper.CommitTransaction(transaction, isTransactionCoordinator);

                return savedpdf;
            }
            catch (Exception ex)
            {
                CustomSqlHelper.RollbackTransaction(transaction, isTransactionCoordinator);
                throw new Exception("Exception in AddNewPdf", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
コード例 #2
0
ファイル: PDFDAL.cs プロジェクト: gbhl/bhl-legacy
        public PDF AddNewPdf(SqlConnection sqlConnection, SqlTransaction sqlTransaction,
                             int itemID, String emailAddress, String shareWith, bool imagesOnly,
                             String articleTitle, String articleCreators, String articleTags, List <int> pageIDs)
        {
            SqlConnection  connection  = sqlConnection;
            SqlTransaction transaction = sqlTransaction;

            if (connection == null)
            {
                connection = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"));
            }

            bool isTransactionCoordinator = CustomSqlHelper.IsTransactionCoordinator(transaction);

            try
            {
                transaction = CustomSqlHelper.BeginTransaction(connection, transaction, isTransactionCoordinator);

                // Add the new pdf record
                PDF newPdf = new PDF();
                newPdf.ItemID                  = itemID;
                newPdf.EmailAddress            = emailAddress;
                newPdf.ShareWithEmailAddresses = shareWith;
                newPdf.ImagesOnly              = imagesOnly;
                newPdf.ArticleTitle            = articleTitle;
                newPdf.ArticleCreators         = articleCreators;
                newPdf.ArticleTags             = articleTags;
                newPdf.PdfStatusID             = 10;
                PDF savedpdf = new PDFDAL().PDFInsertAuto(connection, transaction, newPdf);

                // Add records for the pdf pages
                PDFPageDAL pdfPageDal = new PDFPageDAL();
                foreach (int pageID in pageIDs)
                {
                    PDFPage newPdfPage = new PDFPage();
                    newPdfPage.PdfID  = savedpdf.PdfID;
                    newPdfPage.PageID = pageID;
                    pdfPageDal.PDFPageInsertAuto(connection, transaction, newPdfPage);
                }

                CustomSqlHelper.CommitTransaction(transaction, isTransactionCoordinator);

                return(savedpdf);
            }
            catch (Exception ex)
            {
                CustomSqlHelper.RollbackTransaction(transaction, isTransactionCoordinator);
                throw new Exception("Exception in AddNewPdf", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
コード例 #3
0
 public bool PDFUpdatePdfStatus(int pdfId, int pdfStatusId)
 {
     PDFDAL dal = new PDFDAL();
     return dal.PDFUpdatePdfStatus(null, null, pdfId, pdfStatusId);
 }
コード例 #4
0
 public PDF PDFUpdateFileDeletion(int pdfId)
 {
     PDFDAL dal = new PDFDAL();
     PDF pdf = dal.PDFSelectAuto(null, null, pdfId);
     if (pdf != null)
     {
         pdf.FileDeletionDate = DateTime.Now;
         pdf = dal.PDFUpdateAuto(null, null, pdf);
     }
     else
     {
         throw new Exception("Could not find existing pdf record");
     }
     return pdf;
 }
コード例 #5
0
 public PDF PDFUpdateGenerationInfo(int pdfId, string fileLocation, string fileUrl,
     int numberImagesMissing, int numberOcrMissing)
 {
     PDFDAL dal = new PDFDAL();
     PDF pdf = dal.PDFSelectAuto(null, null, pdfId);
     if (pdf != null)
     {
         pdf.FileLocation = fileLocation;
         pdf.FileUrl = fileUrl;
         pdf.FileGenerationDate = DateTime.Now;
         pdf.NumberImagesMissing = numberImagesMissing;
         pdf.NumberOcrMissing = numberOcrMissing;
         pdf.PdfStatusID = this.PdfStatusGenerated;
         pdf = dal.PDFUpdateAuto(null, null, pdf);
     }
     else
     {
         throw new Exception("Could not find existing pdf record");
     }
     return pdf;
 }