Esempio n. 1
0
        public static void Save(SqlConnection sqlConnection, SqlTransaction sqlTransaction, PDF pdf)
        {
            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);

                new PDFDAL().PDFManageAuto(connection, transaction, pdf);

                CustomSqlHelper.CommitTransaction(transaction, isTransactionCoordinator);
            }
            catch (Exception ex)
            {
                CustomSqlHelper.RollbackTransaction(transaction, isTransactionCoordinator);

                throw new Exception("Exception in Save", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
Esempio n. 2
0
        protected void btnDone_Click(object sender, EventArgs e)
        {
            // Get the item to which this PDF is related
            int        itemID;
            String     itemIDString = Request.QueryString["ItemID"] as String;
            List <int> pageIDs      = new List <int>();

            // Get the page numbers being requested
            foreach (DataListItem dlItem in dlPages.Items)
            {
                HtmlInputCheckBox pageCheckbox = (HtmlInputCheckBox)dlItem.FindControl("chkPage");
                if (pageCheckbox.Checked)
                {
                    pageIDs.Add(Int32.Parse(pageCheckbox.Value));
                }
            }

            String shareWith       = txtShareWith.Text;
            String articleTitle    = txtArticleTitle.Text;
            String articleCreators = txtAuthors.Text;
            String articleTags     = txtSubjects.Text;
            String emailAddress    = txtEmail.Text;
            bool   imagesOnly      = rdoImages.Checked;

            if (shareWith.StartsWith("Enter email addresses"))
            {
                shareWith = String.Empty;
            }
            if (articleCreators.StartsWith("Enter names"))
            {
                articleCreators = String.Empty;
            }
            if (articleTags.StartsWith("Enter subjects"))
            {
                articleTags = String.Empty;
            }

            // Validate submitted data
            if (this.ValidatePage(itemIDString, pageIDs, emailAddress, shareWith, out itemID))
            {
                litError.Text = this._errMsg;

                // Save submitted data
                BHLProvider provider          = new BHLProvider();
                MOBOT.BHL.DataObjects.PDF pdf = provider.AddNewPdf(itemID, emailAddress, shareWith,
                                                                   imagesOnly, articleTitle, articleCreators, articleTags, pageIDs);

                this.SendEmail(emailAddress, pdf.PdfID);

                Response.Cookies["pdf"]["id"]   = pdf.PdfID.ToString();
                Response.Cookies["pdf"].Expires = DateTime.Now.AddDays(1);
                Response.Redirect("/PdfGenDone.aspx");
            }
            else
            {
                // Return and give error message to user
                litError.Text = this._errMsg;
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Update values in PDF. Returns an object of type PDF.
 /// </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 PDF.</param>
 /// <returns>Object of type PDF.</returns>
 public PDF PDFUpdateAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     string connectionKeyName,
     PDF value)
 {
     return PDFUpdateAuto(sqlConnection, sqlTransaction, connectionKeyName,
         value.PdfID,
         value.ItemID,
         value.EmailAddress,
         value.ShareWithEmailAddresses,
         value.ImagesOnly,
         value.ArticleTitle,
         value.ArticleCreators,
         value.ArticleTags,
         value.FileLocation,
         value.FileUrl,
         value.FileGenerationDate,
         value.FileDeletionDate,
         value.PdfStatusID,
         value.NumberImagesMissing,
         value.NumberOcrMissing,
         value.Comment);
 }
Esempio n. 5
0
 /// <summary>
 /// Update values in PDF. Returns an object of type PDF.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="value">Object of type PDF.</param>
 /// <returns>Object of type PDF.</returns>
 public PDF PDFUpdateAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     PDF value)
 {
     return PDFUpdateAuto(sqlConnection, sqlTransaction, "BHL", value );
 }
Esempio n. 6
0
        /// <summary>
        /// Manage PDF object.
        /// If the object is of type CustomObjectBase, 
        /// then either insert values into, delete values from, or update values in PDF.
        /// </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 PDF.</param>
        /// <returns>Object of type CustomDataAccessStatus<PDF>.</returns>
        public CustomDataAccessStatus<PDF> PDFManageAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            string connectionKeyName,
            PDF value)
        {
            if (value.IsNew && !value.IsDeleted)
            {

                PDF returnValue = PDFInsertAuto(sqlConnection, sqlTransaction, connectionKeyName,
                    value.ItemID,
                        value.EmailAddress,
                        value.ShareWithEmailAddresses,
                        value.ImagesOnly,
                        value.ArticleTitle,
                        value.ArticleCreators,
                        value.ArticleTags,
                        value.FileLocation,
                        value.FileUrl,
                        value.FileGenerationDate,
                        value.FileDeletionDate,
                        value.PdfStatusID,
                        value.NumberImagesMissing,
                        value.NumberOcrMissing,
                        value.Comment);

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

                PDF returnValue = PDFUpdateAuto(sqlConnection, sqlTransaction, connectionKeyName,
                    value.PdfID,
                        value.ItemID,
                        value.EmailAddress,
                        value.ShareWithEmailAddresses,
                        value.ImagesOnly,
                        value.ArticleTitle,
                        value.ArticleCreators,
                        value.ArticleTags,
                        value.FileLocation,
                        value.FileUrl,
                        value.FileGenerationDate,
                        value.FileDeletionDate,
                        value.PdfStatusID,
                        value.NumberImagesMissing,
                        value.NumberOcrMissing,
                        value.Comment);

                return new CustomDataAccessStatus<PDF>(
                    CustomDataAccessContext.Update,
                    true, returnValue);
            }
            else
            {
                return new CustomDataAccessStatus<PDF>(
                    CustomDataAccessContext.NA,
                    false, value);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Manage PDF object.
 /// If the object is of type CustomObjectBase, 
 /// then either insert values into, delete values from, or update values in PDF.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="value">Object of type PDF.</param>
 /// <returns>Object of type CustomDataAccessStatus<PDF>.</returns>
 public CustomDataAccessStatus<PDF> PDFManageAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     PDF value)
 {
     return PDFManageAuto( sqlConnection, sqlTransaction, "BHL", value  );
 }
Esempio n. 8
0
 public void PDFSave(PDF pdf)
 {
     PDFDAL.Save(null, null, pdf);
 }