Ejemplo n.º 1
0
        /// <summary>
        /// Update values in Page. Returns an object of type Page.
        /// </summary>
        /// <param name="sqlConnection">Sql connection or null.</param>
        /// <param name="sqlTransaction">Sql transaction or null.</param>
        /// <param name="pageID"></param>
        /// <param name="itemID"></param>
        /// <param name="fileNamePrefix"></param>
        /// <param name="sequenceOrder"></param>
        /// <param name="pageDescription"></param>
        /// <param name="illustration"></param>
        /// <param name="note"></param>
        /// <param name="fileSize_Temp"></param>
        /// <param name="fileExtension"></param>
        /// <param name="active"></param>
        /// <param name="year"></param>
        /// <param name="series"></param>
        /// <param name="volume"></param>
        /// <param name="issue"></param>
        /// <param name="externalURL"></param>
        /// <param name="altExternalURL"></param>
        /// <param name="issuePrefix"></param>
        /// <param name="lastPageNameLookupDate"></param>
        /// <param name="paginationUserID"></param>
        /// <param name="paginationDate"></param>
        /// <param name="lastModifiedUserID"></param>
        /// <returns>Object of type Page.</returns>
        public Page PageUpdateAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            int pageID,
            int itemID,
            string fileNamePrefix,
            int?sequenceOrder,
            string pageDescription,
            bool illustration,
            string note,
            int?fileSize_Temp,
            string fileExtension,
            bool active,
            string year,
            string series,
            string volume,
            string issue,
            string externalURL,
            string altExternalURL,
            string issuePrefix,
            DateTime?lastPageNameLookupDate,
            int?paginationUserID,
            DateTime?paginationDate,
            int?lastModifiedUserID)
        {
            SqlConnection  connection  = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("PageUpdateAuto", connection, transaction,
                                                                      CustomSqlHelper.CreateInputParameter("PageID", SqlDbType.Int, null, false, pageID),
                                                                      CustomSqlHelper.CreateInputParameter("ItemID", SqlDbType.Int, null, false, itemID),
                                                                      CustomSqlHelper.CreateInputParameter("FileNamePrefix", SqlDbType.NVarChar, 50, false, fileNamePrefix),
                                                                      CustomSqlHelper.CreateInputParameter("SequenceOrder", SqlDbType.Int, null, true, sequenceOrder),
                                                                      CustomSqlHelper.CreateInputParameter("PageDescription", SqlDbType.NVarChar, 255, true, pageDescription),
                                                                      CustomSqlHelper.CreateInputParameter("Illustration", SqlDbType.Bit, null, false, illustration),
                                                                      CustomSqlHelper.CreateInputParameter("Note", SqlDbType.NVarChar, 255, true, note),
                                                                      CustomSqlHelper.CreateInputParameter("FileSize_Temp", SqlDbType.Int, null, true, fileSize_Temp),
                                                                      CustomSqlHelper.CreateInputParameter("FileExtension", SqlDbType.NVarChar, 5, true, fileExtension),
                                                                      CustomSqlHelper.CreateInputParameter("Active", SqlDbType.Bit, null, false, active),
                                                                      CustomSqlHelper.CreateInputParameter("Year", SqlDbType.NVarChar, 20, true, year),
                                                                      CustomSqlHelper.CreateInputParameter("Series", SqlDbType.NVarChar, 20, true, series),
                                                                      CustomSqlHelper.CreateInputParameter("Volume", SqlDbType.NVarChar, 20, true, volume),
                                                                      CustomSqlHelper.CreateInputParameter("Issue", SqlDbType.NVarChar, 20, true, issue),
                                                                      CustomSqlHelper.CreateInputParameter("ExternalURL", SqlDbType.NVarChar, 500, true, externalURL),
                                                                      CustomSqlHelper.CreateInputParameter("AltExternalURL", SqlDbType.NVarChar, 500, true, altExternalURL),
                                                                      CustomSqlHelper.CreateInputParameter("IssuePrefix", SqlDbType.NVarChar, 20, true, issuePrefix),
                                                                      CustomSqlHelper.CreateInputParameter("LastPageNameLookupDate", SqlDbType.DateTime, null, true, lastPageNameLookupDate),
                                                                      CustomSqlHelper.CreateInputParameter("PaginationUserID", SqlDbType.Int, null, true, paginationUserID),
                                                                      CustomSqlHelper.CreateInputParameter("PaginationDate", SqlDbType.DateTime, null, true, paginationDate),
                                                                      CustomSqlHelper.CreateInputParameter("LastModifiedUserID", SqlDbType.Int, null, true, lastModifiedUserID),
                                                                      CustomSqlHelper.CreateReturnValueParameter("ReturnCode", SqlDbType.Int, null, false)))
            {
                using (CustomSqlHelper <Page> helper = new CustomSqlHelper <Page>())
                {
                    CustomGenericList <Page> list = helper.ExecuteReader(command);
                    if (list.Count > 0)
                    {
                        Page o = list[0];
                        list = null;
                        return(o);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Insert values into Title.
        /// </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="mARCBibID"></param>
        /// <param name="mARCLeader"></param>
        /// <param name="tropicosTitleID"></param>
        /// <param name="redirectTitleID"></param>
        /// <param name="fullTitle"></param>
        /// <param name="shortTitle"></param>
        /// <param name="uniformTitle"></param>
        /// <param name="sortTitle"></param>
        /// <param name="partNumber"></param>
        /// <param name="partName"></param>
        /// <param name="callNumber"></param>
        /// <param name="publicationDetails"></param>
        /// <param name="startYear"></param>
        /// <param name="endYear"></param>
        /// <param name="datafield_260_a"></param>
        /// <param name="datafield_260_b"></param>
        /// <param name="datafield_260_c"></param>
        /// <param name="institutionCode"></param>
        /// <param name="languageCode"></param>
        /// <param name="titleDescription"></param>
        /// <param name="tL2Author"></param>
        /// <param name="publishReady"></param>
        /// <param name="rareBooks"></param>
        /// <param name="note"></param>
        /// <param name="creationUserID"></param>
        /// <param name="lastModifiedUserID"></param>
        /// <param name="originalCatalogingSource"></param>
        /// <param name="editionStatement"></param>
        /// <param name="currentPublicationFrequency"></param>
        /// <returns>Object of type Title.</returns>
        public Title TitleInsertAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            string connectionKeyName,
            string mARCBibID,
            string mARCLeader,
            int?tropicosTitleID,
            int?redirectTitleID,
            string fullTitle,
            string shortTitle,
            string uniformTitle,
            string sortTitle,
            string partNumber,
            string partName,
            string callNumber,
            string publicationDetails,
            short?startYear,
            short?endYear,
            string datafield_260_a,
            string datafield_260_b,
            string datafield_260_c,
            string institutionCode,
            string languageCode,
            string titleDescription,
            string tL2Author,
            bool publishReady,
            bool rareBooks,
            string note,
            int?creationUserID,
            int?lastModifiedUserID,
            string originalCatalogingSource,
            string editionStatement,
            string currentPublicationFrequency)
        {
            SqlConnection  connection  = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings(connectionKeyName), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("TitleInsertAuto", connection, transaction,
                                                                      CustomSqlHelper.CreateOutputParameter("TitleID", SqlDbType.Int, null, false),
                                                                      CustomSqlHelper.CreateInputParameter("MARCBibID", SqlDbType.NVarChar, 50, false, mARCBibID),
                                                                      CustomSqlHelper.CreateInputParameter("MARCLeader", SqlDbType.NVarChar, 24, true, mARCLeader),
                                                                      CustomSqlHelper.CreateInputParameter("TropicosTitleID", SqlDbType.Int, null, true, tropicosTitleID),
                                                                      CustomSqlHelper.CreateInputParameter("RedirectTitleID", SqlDbType.Int, null, true, redirectTitleID),
                                                                      CustomSqlHelper.CreateInputParameter("FullTitle", SqlDbType.NVarChar, 2000, false, fullTitle),
                                                                      CustomSqlHelper.CreateInputParameter("ShortTitle", SqlDbType.NVarChar, 255, true, shortTitle),
                                                                      CustomSqlHelper.CreateInputParameter("UniformTitle", SqlDbType.NVarChar, 255, true, uniformTitle),
                                                                      CustomSqlHelper.CreateInputParameter("SortTitle", SqlDbType.NVarChar, 60, true, sortTitle),
                                                                      CustomSqlHelper.CreateInputParameter("PartNumber", SqlDbType.NVarChar, 255, true, partNumber),
                                                                      CustomSqlHelper.CreateInputParameter("PartName", SqlDbType.NVarChar, 255, true, partName),
                                                                      CustomSqlHelper.CreateInputParameter("CallNumber", SqlDbType.NVarChar, 100, true, callNumber),
                                                                      CustomSqlHelper.CreateInputParameter("PublicationDetails", SqlDbType.NVarChar, 255, true, publicationDetails),
                                                                      CustomSqlHelper.CreateInputParameter("StartYear", SqlDbType.SmallInt, null, true, startYear),
                                                                      CustomSqlHelper.CreateInputParameter("EndYear", SqlDbType.SmallInt, null, true, endYear),
                                                                      CustomSqlHelper.CreateInputParameter("Datafield_260_a", SqlDbType.NVarChar, 150, true, datafield_260_a),
                                                                      CustomSqlHelper.CreateInputParameter("Datafield_260_b", SqlDbType.NVarChar, 255, true, datafield_260_b),
                                                                      CustomSqlHelper.CreateInputParameter("Datafield_260_c", SqlDbType.NVarChar, 100, true, datafield_260_c),
                                                                      CustomSqlHelper.CreateInputParameter("InstitutionCode", SqlDbType.NVarChar, 10, true, institutionCode),
                                                                      CustomSqlHelper.CreateInputParameter("LanguageCode", SqlDbType.NVarChar, 10, true, languageCode),
                                                                      CustomSqlHelper.CreateInputParameter("TitleDescription", SqlDbType.NText, 1073741823, true, titleDescription),
                                                                      CustomSqlHelper.CreateInputParameter("TL2Author", SqlDbType.NVarChar, 100, true, tL2Author),
                                                                      CustomSqlHelper.CreateInputParameter("PublishReady", SqlDbType.Bit, null, false, publishReady),
                                                                      CustomSqlHelper.CreateInputParameter("RareBooks", SqlDbType.Bit, null, false, rareBooks),
                                                                      CustomSqlHelper.CreateInputParameter("Note", SqlDbType.NVarChar, 255, true, note),
                                                                      CustomSqlHelper.CreateInputParameter("CreationUserID", SqlDbType.Int, null, true, creationUserID),
                                                                      CustomSqlHelper.CreateInputParameter("LastModifiedUserID", SqlDbType.Int, null, true, lastModifiedUserID),
                                                                      CustomSqlHelper.CreateInputParameter("OriginalCatalogingSource", SqlDbType.NVarChar, 100, true, originalCatalogingSource),
                                                                      CustomSqlHelper.CreateInputParameter("EditionStatement", SqlDbType.NVarChar, 450, true, editionStatement),
                                                                      CustomSqlHelper.CreateInputParameter("CurrentPublicationFrequency", SqlDbType.NVarChar, 100, true, currentPublicationFrequency),
                                                                      CustomSqlHelper.CreateReturnValueParameter("ReturnCode", SqlDbType.Int, null, false)))
            {
                using (CustomSqlHelper <Title> helper = new CustomSqlHelper <Title>())
                {
                    CustomGenericList <Title> list = helper.ExecuteReader(command);
                    if (list.Count > 0)
                    {
                        Title o = list[0];
                        list = null;
                        return(o);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 3
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);
            }
        }