예제 #1
0
        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
 /// <summary>
 /// Update values in PDFPage. Returns an object of type PDFPage.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="connectionKeyName">Connection key name located in config file.</param>
 /// <param name="value">Object of type PDFPage.</param>
 /// <returns>Object of type PDFPage.</returns>
 public PDFPage PDFPageUpdateAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     string connectionKeyName,
     PDFPage value)
 {
     return PDFPageUpdateAuto(sqlConnection, sqlTransaction, connectionKeyName,
         value.PdfPageID,
         value.PdfID,
         value.PageID);
 }
예제 #3
0
 /// <summary>
 /// Update values in PDFPage. Returns an object of type PDFPage.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="value">Object of type PDFPage.</param>
 /// <returns>Object of type PDFPage.</returns>
 public PDFPage PDFPageUpdateAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     PDFPage value)
 {
     return PDFPageUpdateAuto(sqlConnection, sqlTransaction, "BHL", value );
 }
예제 #4
0
        /// <summary>
        /// Manage PDFPage object.
        /// If the object is of type CustomObjectBase, 
        /// then either insert values into, delete values from, or update values in PDFPage.
        /// </summary>
        /// <param name="sqlConnection">Sql connection or null.</param>
        /// <param name="sqlTransaction">Sql transaction or null.</param>
        /// <param name="connectionKeyName">Connection key name located in config file.</param>
        /// <param name="value">Object of type PDFPage.</param>
        /// <returns>Object of type CustomDataAccessStatus<PDFPage>.</returns>
        public CustomDataAccessStatus<PDFPage> PDFPageManageAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            string connectionKeyName,
            PDFPage value)
        {
            if (value.IsNew && !value.IsDeleted)
            {

                PDFPage returnValue = PDFPageInsertAuto(sqlConnection, sqlTransaction, connectionKeyName,
                    value.PdfID,
                        value.PageID);

                return new CustomDataAccessStatus<PDFPage>(
                    CustomDataAccessContext.Insert,
                    true, returnValue);
            }
            else if (!value.IsNew && value.IsDeleted)
            {
                if (PDFPageDeleteAuto(sqlConnection, sqlTransaction, connectionKeyName,
                    value.PdfPageID))
                {
                return new CustomDataAccessStatus<PDFPage>(
                    CustomDataAccessContext.Delete,
                    true, value);
                }
                else
                {
                return new CustomDataAccessStatus<PDFPage>(
                    CustomDataAccessContext.Delete,
                    false, value);
                }
            }
            else if (value.IsDirty && !value.IsDeleted)
            {

                PDFPage returnValue = PDFPageUpdateAuto(sqlConnection, sqlTransaction, connectionKeyName,
                    value.PdfPageID,
                        value.PdfID,
                        value.PageID);

                return new CustomDataAccessStatus<PDFPage>(
                    CustomDataAccessContext.Update,
                    true, returnValue);
            }
            else
            {
                return new CustomDataAccessStatus<PDFPage>(
                    CustomDataAccessContext.NA,
                    false, value);
            }
        }
예제 #5
0
 /// <summary>
 /// Manage PDFPage object.
 /// If the object is of type CustomObjectBase, 
 /// then either insert values into, delete values from, or update values in PDFPage.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="value">Object of type PDFPage.</param>
 /// <returns>Object of type CustomDataAccessStatus<PDFPage>.</returns>
 public CustomDataAccessStatus<PDFPage> PDFPageManageAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     PDFPage value)
 {
     return PDFPageManageAuto( sqlConnection, sqlTransaction, "BHL", value  );
 }