/// <summary>
        /// Delete values from TitleAssociation_TitleIdentifier by primary key(s).
        /// </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="titleAssociation_TitleIdentifierID"></param>
        /// <returns>true if successful otherwise false.</returns>
        public bool TitleAssociation_TitleIdentifierDeleteAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            string connectionKeyName,
            int titleAssociation_TitleIdentifierID)
        {
            SqlConnection  connection  = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings(connectionKeyName), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("TitleAssociation_TitleIdentifierDeleteAuto", connection, transaction,
                                                                      CustomSqlHelper.CreateInputParameter("TitleAssociation_TitleIdentifierID", SqlDbType.Int, null, false, titleAssociation_TitleIdentifierID),
                                                                      CustomSqlHelper.CreateReturnValueParameter("ReturnCode", SqlDbType.Int, null, false)))
            {
                int returnCode = CustomSqlHelper.ExecuteNonQuery(command, "ReturnCode");

                if (transaction == null)
                {
                    CustomSqlHelper.CloseConnection(connection);
                }

                if (returnCode == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #2
0
        public static void Save(SqlConnection sqlConnection, SqlTransaction sqlTransaction, PageType pageType)
        {
            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 PageTypeDAL().PageTypeManageAuto(connection, transaction, pageType);

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

                throw new Exception("Exception in Save", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
Пример #3
0
        /// <summary>
        /// Delete values from CreatorRoleType by primary key(s).
        /// </summary>
        /// <param name="sqlConnection">Sql connection or null.</param>
        /// <param name="sqlTransaction">Sql transaction or null.</param>
        /// <param name="creatorRoleTypeID">Unique identifier for each Creator Role Type.</param>
        /// <returns>true if successful otherwise false.</returns>
        public bool CreatorRoleTypeDeleteAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            int creatorRoleTypeID)
        {
            SqlConnection  connection  = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("CreatorRoleTypeDeleteAuto", connection, transaction,
                                                                      CustomSqlHelper.CreateInputParameter("CreatorRoleTypeID", SqlDbType.Int, null, false, creatorRoleTypeID),
                                                                      CustomSqlHelper.CreateReturnValueParameter("ReturnCode", SqlDbType.Int, null, false)))
            {
                int returnCode = CustomSqlHelper.ExecuteNonQuery(command, "ReturnCode");

                if (transaction == null)
                {
                    CustomSqlHelper.CloseConnection(connection);
                }

                if (returnCode == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Delete values from IndicatedPage by primary key(s).
        /// </summary>
        /// <param name="sqlConnection">Sql connection or null.</param>
        /// <param name="sqlTransaction">Sql transaction or null.</param>
        /// <param name="pageID">Unique identifier for each Page record.</param>
        /// <param name="sequence">A number to separately identify various series of Indicated Pages.</param>
        /// <returns>true if successful otherwise false.</returns>
        public bool IndicatedPageDeleteAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            int pageID,
            short sequence)
        {
            SqlConnection  connection  = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("IndicatedPageDeleteAuto", connection, transaction,
                                                                      CustomSqlHelper.CreateInputParameter("PageID", SqlDbType.Int, null, false, pageID),
                                                                      CustomSqlHelper.CreateInputParameter("Sequence", SqlDbType.SmallInt, null, false, sequence),
                                                                      CustomSqlHelper.CreateReturnValueParameter("ReturnCode", SqlDbType.Int, null, false)))
            {
                int returnCode = CustomSqlHelper.ExecuteNonQuery(command, "ReturnCode");

                if (transaction == null)
                {
                    CustomSqlHelper.CloseConnection(connection);
                }

                if (returnCode == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Delete values from Institution by primary key(s).
        /// </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="institutionCode">Code for Institution providing assistance.</param>
        /// <returns>true if successful otherwise false.</returns>
        public bool InstitutionDeleteAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            string connectionKeyName,
            string institutionCode)
        {
            SqlConnection  connection  = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings(connectionKeyName), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("InstitutionDeleteAuto", connection, transaction,
                                                                      CustomSqlHelper.CreateInputParameter("InstitutionCode", SqlDbType.NVarChar, 10, false, institutionCode),
                                                                      CustomSqlHelper.CreateReturnValueParameter("ReturnCode", SqlDbType.Int, null, false)))
            {
                int returnCode = CustomSqlHelper.ExecuteNonQuery(command, "ReturnCode");

                if (transaction == null)
                {
                    CustomSqlHelper.CloseConnection(connection);
                }

                if (returnCode == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #6
0
        public bool IndicatedPageInsertNext(SqlConnection sqlConnection, SqlTransaction sqlTransaction, int pageID,
                                            string pagePrefix, string pageNumber, bool implied, int userId)
        {
            SqlConnection connection = CustomSqlHelper.CreateConnection(
                CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("IndicatedPageInsertNext", connection, transaction,
                                                                      CustomSqlHelper.CreateInputParameter("PageID", SqlDbType.Int, null, false, pageID),
                                                                      CustomSqlHelper.CreateInputParameter("PagePrefix", SqlDbType.NVarChar, 20, true, pagePrefix),
                                                                      CustomSqlHelper.CreateInputParameter("PageNumber", SqlDbType.NVarChar, 20, true, pageNumber),
                                                                      CustomSqlHelper.CreateInputParameter("Implied", SqlDbType.Bit, null, false, implied),
                                                                      CustomSqlHelper.CreateInputParameter("CreationUserID", SqlDbType.Int, null, false, userId),
                                                                      CustomSqlHelper.CreateInputParameter("LastModifiedUserID", SqlDbType.Int, null, false, userId),
                                                                      CustomSqlHelper.CreateReturnValueParameter("ReturnCode", SqlDbType.Int, null, false)))
            {
                int returnCode = CustomSqlHelper.ExecuteNonQuery(command, "ReturnCode");

                if (transaction == null)
                {
                    CustomSqlHelper.CloseConnection(connection);
                }

                if (returnCode == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #7
0
        public bool IndicatedPageDeleteAllForPage(SqlConnection sqlConnection, SqlTransaction sqlTransaction, int pageID)
        {
            SqlConnection connection = CustomSqlHelper.CreateConnection(
                CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            try
            {
                using (SqlCommand command =
                           CustomSqlHelper.CreateCommand("IndicatedPageDeleteAllForPage", connection, sqlTransaction,
                                                         CustomSqlHelper.CreateInputParameter("PageID", SqlDbType.Int, null, false, pageID),
                                                         CustomSqlHelper.CreateReturnValueParameter("ReturnCode", SqlDbType.Int, null, false)))
                {
                    int returnCode = CustomSqlHelper.ExecuteNonQuery(command, "ReturnCode");

                    if (transaction == null)
                    {
                        CustomSqlHelper.CloseConnection(connection);
                    }

                    if (returnCode == 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Exception in IndicatedPageDeleteAllForPage", ex);
            }
        }
Пример #8
0
 public void Dispose()
 {
     if (connection != null)
     {
         CustomSqlHelper.CloseConnection(connection);
     }
 }
Пример #9
0
        public static void Save(SqlConnection sqlConnection, SqlTransaction sqlTransaction, Item item, int userId)
        {
            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 ItemDAL().ItemManageAuto(connection, transaction, item, userId);

                if (item.Pages.Count > 0)
                {
                    PageDAL pageDAL = new PageDAL();
                    foreach (Page page in item.Pages)
                    {
                        pageDAL.PageManageAuto(connection, transaction, page, userId);
                    }
                }

                if (item.TitleItems.Count > 0)
                {
                    TitleItemDAL titleItemDAL = new TitleItemDAL();
                    foreach (TitleItem titleItem in item.TitleItems)
                    {
                        titleItemDAL.TitleItemManageAuto(connection, transaction, titleItem);
                    }
                }

                if (item.ItemLanguages.Count > 0)
                {
                    ItemLanguageDAL itemLanguageDAL = new ItemLanguageDAL();
                    foreach (ItemLanguage itemLanguage in item.ItemLanguages)
                    {
                        itemLanguageDAL.ItemLanguageManageAuto(connection, transaction, itemLanguage);
                    }
                }


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

                throw new Exception("Exception in Save", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
Пример #10
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);
            }
        }
Пример #11
0
        public static void Save(SqlConnection sqlConnection, SqlTransaction sqlTransaction,
                                TitleAssociation titleAssociation)
        {
            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);

                CustomDataAccessStatus <TitleAssociation> updatedTitleAssociation =
                    new TitleAssociationDAL().TitleAssociationManageAuto(connection, transaction, titleAssociation);

                if (titleAssociation.TitleAssociationIdentifiers.Count > 0)
                {
                    TitleAssociation_TitleIdentifierDAL titleAssociationTitleIdentifierDAL = new TitleAssociation_TitleIdentifierDAL();
                    foreach (TitleAssociation_TitleIdentifier titleAssociationTitleIdentifier in titleAssociation.TitleAssociationIdentifiers)
                    {
                        if (titleAssociationTitleIdentifier.TitleAssociationID == 0)
                        {
                            titleAssociationTitleIdentifier.TitleAssociationID = updatedTitleAssociation.ReturnObject.TitleAssociationID;
                        }
                        titleAssociationTitleIdentifierDAL.TitleAssociation_TitleIdentifierManageAuto(connection, transaction, titleAssociationTitleIdentifier);
                    }
                }

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

                throw new Exception("Exception in Save", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
Пример #12
0
        public static void Save(SqlConnection sqlConnection, SqlTransaction sqlTransaction, Vault vault)
        {
            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);

                if (vault.VaultID == 0)
                {
                    using (SqlCommand command = CustomSqlHelper.CreateCommand("VaultSelectMaxID", connection, transaction))
                    {
                        using (CustomSqlHelper <int> helper = new CustomSqlHelper <int>())
                        {
                            CustomGenericList <int> list = helper.ExecuteReader(command);
                            vault.VaultID = list[0] + 1;
                        }
                    }
                }

                new VaultDAL().VaultManageAuto(connection, transaction, vault);

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

                throw new Exception("Exception in Save", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
Пример #13
0
        public static void SaveList(SqlConnection sqlConnection, SqlTransaction sqlTransaction,
                                    CustomGenericList <PageName> pageNames)
        {
            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);

                if (pageNames.Count > 0)
                {
                    PageNameDAL pageNameDAL = new PageNameDAL();
                    foreach (PageName pageName in pageNames)
                    {
                        pageNameDAL.PageNameManageAuto(connection, transaction, pageName);
                    }
                }

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

                throw new Exception("Exception in Save", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
Пример #14
0
        public static void Save(SqlConnection sqlConnection, SqlTransaction sqlTransaction, Title title, int userId)
        {
            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);

                CustomDataAccessStatus <Title> updatedTitle =
                    new TitleDAL().TitleManageAuto(connection, transaction, title, userId);

                if (title.TitleCreators.Count > 0)
                {
                    Title_CreatorDAL titleCreatorDAL = new Title_CreatorDAL();
                    foreach (Title_Creator titleCreator in title.TitleCreators)
                    {
                        if (titleCreator.TitleID == 0)
                        {
                            titleCreator.TitleID = updatedTitle.ReturnObject.TitleID;
                        }
                        titleCreatorDAL.Title_CreatorManageAuto(connection, transaction, titleCreator, userId);
                    }
                }

                if (title.TitleTags.Count > 0)
                {
                    TitleTagDAL titleTagDAL = new TitleTagDAL();
                    foreach (TitleTag titleTag in title.TitleTags)
                    {
                        if (titleTag.TitleID == 0)
                        {
                            titleTag.TitleID = updatedTitle.ReturnObject.TitleID;
                        }
                        titleTagDAL.TitleTagManageAuto(connection, transaction, titleTag);
                    }
                }

                if (title.TitleIdentifiers.Count > 0)
                {
                    Title_TitleIdentifierDAL titleTitleIdentifierDAL = new Title_TitleIdentifierDAL();
                    foreach (Title_TitleIdentifier titleTitleIdentifier in title.TitleIdentifiers)
                    {
                        if (titleTitleIdentifier.TitleID == 0)
                        {
                            titleTitleIdentifier.TitleID = updatedTitle.ReturnObject.TitleID;
                        }
                        titleTitleIdentifierDAL.Title_TitleIdentifierManageAuto(connection, transaction, titleTitleIdentifier);
                    }
                }

                if (title.TitleAssociations.Count > 0)
                {
                    TitleAssociationDAL titleAssociationDAL = new TitleAssociationDAL();
                    foreach (TitleAssociation titleAssociation in title.TitleAssociations)
                    {
                        if (titleAssociation.TitleID == 0)
                        {
                            titleAssociation.TitleID = updatedTitle.ReturnObject.TitleID;
                        }
                        TitleAssociationDAL.Save(connection, transaction, titleAssociation);
                    }
                }

                if (title.TitleLanguages.Count > 0)
                {
                    TitleLanguageDAL titleLanguageDAL = new TitleLanguageDAL();
                    foreach (TitleLanguage titleLanguage in title.TitleLanguages)
                    {
                        if (titleLanguage.TitleID == 0)
                        {
                            titleLanguage.TitleID = updatedTitle.ReturnObject.TitleID;
                        }
                        titleLanguageDAL.TitleLanguageManageAuto(connection, transaction, titleLanguage);
                    }
                }

                if (title.TitleTypes.Count > 0)
                {
                    Title_TitleTypeDAL titleTypeDAL = new Title_TitleTypeDAL();
                    foreach (Title_TitleType titleType in title.TitleTypes)
                    {
                        if (titleType.TitleID == 0)
                        {
                            titleType.TitleID = updatedTitle.ReturnObject.TitleID;
                        }
                        titleTypeDAL.Title_TitleTypeManageAuto(connection, transaction, titleType);
                    }
                }

                if (title.TitleItems.Count > 0)
                {
                    ItemDAL      itemDAL      = new ItemDAL();
                    TitleItemDAL titleItemDAL = new TitleItemDAL();
                    foreach (TitleItem titleItem in title.TitleItems)
                    {
                        // Update the item
                        if (titleItem.TitleID == 0)
                        {
                            titleItem.TitleID = updatedTitle.ReturnObject.TitleID;
                        }
                        titleItemDAL.TitleItemManageAuto(connection, transaction, titleItem);
                        // Update the primary title id (stored on the Item table)
                        itemDAL.ItemUpdatePrimaryTitleID(connection, transaction, titleItem.ItemID, titleItem.PrimaryTitleID);
                    }
                }

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

                throw new Exception("Exception in Save", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }