/// <summary> Store the relationship between the EAL ( Engine Agnostic Level ) parameter and the database parameter. </summary>
        /// <param name="EalParam"></param>
        /// <param name="DbParam"></param>
        /// <remarks> This is only used for parameters that include an output direction, so the returned parameter value
        /// can be copied bac from the database parameter to the EAL parameter. </remarks>
        public void Add_Parameter_Copy_Pair(EalDbParameter EalParam, DbParameter DbParam)
        {
            if (parameterCopy == null)
                parameterCopy = new List<Tuple<EalDbParameter, DbParameter>>();

            parameterCopy.Add(new Tuple<EalDbParameter, DbParameter>(EalParam, DbParam));
        }
        /// <summary> Store the relationship between the EAL ( Engine Agnostic Level ) parameter and the database parameter. </summary>
        /// <param name="EalParam"></param>
        /// <param name="DbParam"></param>
        /// <remarks> This is only used for parameters that include an output direction, so the returned parameter value
        /// can be copied bac from the database parameter to the EAL parameter. </remarks>
        public void Add_Parameter_Copy_Pair(EalDbParameter EalParam, DbParameter DbParam)
        {
            if (parameterCopy == null)
            {
                parameterCopy = new List <Tuple <EalDbParameter, DbParameter> >();
            }

            parameterCopy.Add(new Tuple <EalDbParameter, DbParameter>(EalParam, DbParam));
        }
        /// <summary> Execute an asynchronous non-query SQL statement or stored procedure </summary>
        /// <param name="DbType"> Type of database ( i.e., MSSQL, PostgreSQL ) </param>
        /// <param name="DbConnectionString"> Database connection string </param>
        /// <param name="DbCommandType"> Database command type </param>
        /// <param name="DbCommandText"> Text of the database command, or name of the stored procedure to run </param>
        /// <param name="DbParameters"> Parameters for the SQL statement </param>
        public static void BeginExecuteNonQuery(EalDbTypeEnum DbType, string DbConnectionString, CommandType DbCommandType, string DbCommandText, EalDbParameter[] DbParameters)
        {
            if (DbType == EalDbTypeEnum.MSSQL)
            {
                // Create the SQL connection
                SqlConnection sqlConnect = new SqlConnection(DbConnectionString);

                try
                {
                    sqlConnect.Open();
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Unable to open connection to the database." + Environment.NewLine + ex.Message, ex);
                }

                // Create the SQL command
                SqlCommand sqlCommand = new SqlCommand(DbCommandText, sqlConnect)
                {
                    CommandType = DbCommandType
                };

                // Copy all the parameters to this adapter
                sql_add_params_to_command(sqlCommand, DbParameters);

                // Run the command itself
                try
                {
                    sqlCommand.BeginExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Error executing non-query command." + Environment.NewLine + ex.Message, ex);
                }

                // Return
                return;
            }

            if (DbType == EalDbTypeEnum.PostgreSQL)
            {
                throw new ApplicationException("Support for PostgreSQL with SobekCM is targeted for early 2016");
            }

            throw new ApplicationException("Unknown database type not supported");
        }
        /// <summary> Stores information about a single digital resource ( existing or new ) </summary>
        /// <param name="GroupID"> Primary key for the item group / title / bib id</param>
        /// <param name="VID"> Volume identifier for this item </param>
        /// <param name="PageCount"> Number of pages present in this item </param>
        /// <param name="FileCount"> Number of files present in this item </param>
        /// <param name="Title"> Main title for this volume </param>
        /// <param name="SortTitle"> Sort title for this volume ( all caps, and without the leading articles like 'The', 'A', 'Le', etc.. )</param>
        /// <param name="Link"> Link to this item, if this is not loaded into this digital library </param>
        /// <param name="CreateDate"> Create date for this item </param>
        /// <param name="PubDate"> Publication date string </param>
        /// <param name="SortDate"> Sort date is used to sort all items by publication date </param>
        /// <param name="Holding_Code"> Code for the holding location related to this item </param>
        /// <param name="Source_Code"> Code for the source institution related to this item </param>
        /// <param name="Author"> Display field includes all authors' names </param>
        /// <param name="Spatial_KML"> List of main coordinate points in the main display for this item</param>
        /// <param name="Spatial_KML_Distance"> Distance of the hypotenuse of the bounding box made up by the coordinates in this item </param>
        /// <param name="DiskSizeMb"> Total size (in MB) of this entire package on the digital library </param>
        /// <param name="Donor">Donor string to display for this item within any search or browse results</param>
        /// <param name="Publisher">Publishers string to display for this item within any search or browse results ( multiple publishers are seperated by a '|' character )</param>
        /// <param name="Edition"> Edition/state string to display for this item within any search or browse results</param>
        /// <param name="Institution_Display"> Institution statement to display for this item within any search or browse results</param>
        /// <param name="Material_Display"> Materials (i.e. type of materials used to create object) to display for this item within any search or browse results </param>
        /// <param name="Measurement_Display"> Measurement information to display for this item within any search or browse results</param>
        /// <param name="Spatial_Display"> Spatial information string to display for this item within any search or browse results ( multiple compound spatials are seperated by a '|' character )</param>
        /// <param name="StylePeriod_Display"> Style/Period string to display for this item within any search or browse results</param>
        /// <param name="Subjects_Display"> Subjects information string to display for this item within any search or browse results ( multiple compound subjects are seperated by a '|' character )</param>
        /// <param name="Technique_Display">Techniques information string to display for this item within any search or browse results </param>
        /// <returns> Arguments which indicate the item id for this item and whether a new volume was added or not </returns>
        /// <remarks> This calls the 'SobekCM_Save_Item' stored procedure in the SobekCM database </remarks>
        protected static Save_Item_Args Save_Item(int GroupID, string VID, int PageCount, int FileCount,
            string Title, string SortTitle, string Link, DateTime CreateDate, string PubDate, int SortDate,
            string Holding_Code, string Source_Code, string Author, string Spatial_KML, double Spatial_KML_Distance,
            double DiskSizeMb, string Donor, string Publisher, string Spatial_Display, string Institution_Display,
            string Edition, string Material_Display, string Measurement_Display, string StylePeriod_Display, string Technique_Display,
            string Subjects_Display)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[30];
                param_list[0] = new EalDbParameter("@GroupID", GroupID);
                param_list[1] = new EalDbParameter("@VID", VID);
                param_list[2] = new EalDbParameter("@PageCount", PageCount);
                param_list[3] = new EalDbParameter("@FileCount", FileCount);
                param_list[4] = new EalDbParameter("@Title", Title);
                param_list[5] = new EalDbParameter("@SortTitle", SortTitle);
                param_list[6] = new EalDbParameter("@AccessMethod", 1);
                param_list[7] = new EalDbParameter("@Link", Link);
                param_list[8] = new EalDbParameter("@CreateDate", CreateDate);
                param_list[9] = new EalDbParameter("@PubDate", PubDate);
                param_list[10] = new EalDbParameter("@SortDate", SortDate);
                param_list[11] = new EalDbParameter("@HoldingCode", Holding_Code);
                param_list[12] = new EalDbParameter("@SourceCode", Source_Code);
                param_list[13] = new EalDbParameter("@Author", Author);
                param_list[14] = new EalDbParameter("@Spatial_KML", Spatial_KML);
                param_list[15] = new EalDbParameter("@Spatial_KML_Distance", Spatial_KML_Distance);
                param_list[16] = new EalDbParameter("@DiskSize_KB", DiskSizeMb);
                param_list[17] = new EalDbParameter("@Spatial_Display", Spatial_Display);
                param_list[18] = new EalDbParameter("@Institution_Display", Institution_Display);
                param_list[19] = new EalDbParameter("@Edition_Display", Edition);
                param_list[20] = new EalDbParameter("@Material_Display", Material_Display);
                param_list[21] = new EalDbParameter("@Measurement_Display", Measurement_Display);
                param_list[22] = new EalDbParameter("@StylePeriod_Display", StylePeriod_Display);
                param_list[23] = new EalDbParameter("@Technique_Display", Technique_Display);
                param_list[24] = new EalDbParameter("@Subjects_Display", Subjects_Display);
                param_list[25] = new EalDbParameter("@Donor", Donor);
                param_list[26] = new EalDbParameter("@Publisher", Publisher);
                param_list[27] = new EalDbParameter("@ItemID", -1) { Direction = ParameterDirection.InputOutput };
                param_list[28] = new EalDbParameter("@Existing", false) { Direction = ParameterDirection.InputOutput };
                param_list[29] = new EalDbParameter("@New_VID", "00000") { Direction = ParameterDirection.InputOutput };

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Item", param_list);

                // Return the value
                int itemID = (int)param_list[27].Value;
                bool existing = (bool)param_list[28].Value;
                string new_vid = param_list[29].Value.ToString();
                return new Save_Item_Args(itemID, existing, new_vid);
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Item", ee);
                return new Save_Item_Args(-1, false, String.Empty);
            }
        }
        /// <summary> Chance for this metadata module to perform any additional database work
        /// such as saving digital resource data into custom tables </summary>
        /// <param name="ItemID"> Primary key for this item within the SobekCM database </param>
        /// <param name="DB_ConnectionString"> Connection string for the current database </param>
        /// <param name="BibObject"> Entire resource, in case there are dependencies between this module and somethingt in the full resource </param>
        /// <param name="Error_Message"> In the case of an error, this contains text of the error </param>
        /// <returns> TRUE if no error occurred, otherwise FALSE </returns>
        /// <remarks> This module currently  does no additional processing in this method </remarks>
        public bool Save_Additional_Info_To_Database(int ItemID, string DB_ConnectionString, SobekCM_Item BibObject, out string Error_Message)
        {
            // Set the default error mesasge
            Error_Message = String.Empty;

            // Get the UMI flag from the organizational notes
            string umi = String.Empty; //BibObject.Tracking.UMI_Flag
            if ( BibObject.METS_Header.Creator_Org_Notes_Count > 0 )
            {
                foreach (string thisNote in BibObject.METS_Header.Creator_Org_Notes)
                {
                    int umi_index = thisNote.ToUpper().IndexOf("UMI=");
                    if ((umi_index >= 0) && (umi_index + 4 < thisNote.Length))
                    {
                        umi = thisNote.Substring(umi_index + 4).Trim();
                        break;
                    }
                }
            }

            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[4];
                param_list[0] = new EalDbParameter("@ItemID", ItemID);
                param_list[1] = new EalDbParameter("@Original_AccessCode", Access_Code_String);

                if ( Has_Embargo_End )
                    param_list[2] = new EalDbParameter("@EmbargoEnd", Embargo_End);
                else
                    param_list[2] = new EalDbParameter("@EmbargoEnd", DBNull.Value);
                param_list[3] = new EalDbParameter("@UMI", umi);

                // Execute this query stored procedure
                EalDbAccess.ExecuteNonQuery(SobekCM_Database.DatabaseType, DB_ConnectionString, CommandType.StoredProcedure, "SobekCM_RightsMD_Save_Access_Embargo_UMI", param_list);

                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                Error_Message = "Error encountered in RightsMD_Info.Save_Additional_Info_To_Database: " + ee.Message;
                return false;
            }
        }
 // Copy any output values back to the parameters
 private static void sql_copy_returned_values_back_to_params(EalDbReaderWrapper Wrapper, SqlParameterCollection SqlParams, EalDbParameter[] EalParams)
 {
     // Copy over any values as necessary
     int i = 0;
     foreach (EalDbParameter thisParameter in EalParams)
     {
         if ((thisParameter.Direction == ParameterDirection.Output) || (thisParameter.Direction == ParameterDirection.InputOutput))
         {
             Wrapper.Add_Parameter_Copy_Pair(thisParameter, SqlParams[i]);
         }
         i++;
     }
 }
        private static void sql_add_params_to_command(SqlCommand SqlCommand, EalDbParameter[] DbParameters)
        {
            // Copy all the parameters to this adapter
            if ((DbParameters != null) && (DbParameters.Length > 0))
            {
                // Step through each parameter
                foreach (EalDbParameter thisParam in DbParameters)
                {
                    // Determine the appropriate SQL TYPE
                    SqlDbType sqlType = SqlDbType.NVarChar;
                    switch (thisParam.DbType)
                    {
                        case DbType.AnsiString:
                            sqlType = SqlDbType.VarChar;
                            break;

                        case DbType.String:
                            sqlType = SqlDbType.NVarChar;
                            break;

                        case DbType.DateTime:
                            sqlType = SqlDbType.DateTime;
                            break;

                        case DbType.Int16:
                            sqlType = SqlDbType.SmallInt;
                            break;

                        case DbType.Int32:
                            sqlType = SqlDbType.Int;
                            break;

                        case DbType.Int64:
                            sqlType = SqlDbType.BigInt;
                            break;

                        case DbType.Boolean:
                            sqlType = SqlDbType.Bit;
                            break;
                    }

                    // Create the sql parameter
                    SqlParameter sqlParam = new SqlParameter(thisParam.ParameterName, sqlType)
                    {
                        Direction = thisParam.Direction,
                        Value = thisParam.Value
                    };

                    // If this was null, use DBNull.Value
                    if (sqlParam.Value == null)
                        sqlParam.Value = DBNull.Value;

                    // Add this to the select command
                    SqlCommand.Parameters.Add(sqlParam);
                }
            }
        }
        /// <summary> Execute a SQL statement or stored procedure and return a DataSet </summary>
        /// <param name="DbType"> Type of database ( i.e., MSSQL, PostgreSQL ) </param>
        /// <param name="DbConnectionString"> Database connection string </param>
        /// <param name="DbCommandType"> Database command type </param>
        /// <param name="DbCommandText"> Text of the database command, or name of the stored procedure to run </param>
        /// <param name="DbParameters"> Parameters for the SQL statement </param>
        public static DataSet ExecuteDataset( EalDbTypeEnum DbType, string DbConnectionString, CommandType DbCommandType, string DbCommandText, EalDbParameter[] DbParameters)
        {
            if (DbType == EalDbTypeEnum.MSSQL)
            {
                DataSet returnedSet = new DataSet();

                // Create the SQL connection
                using (SqlConnection sqlConnect = new SqlConnection(DbConnectionString))
                {
                    try
                    {
                        sqlConnect.Open();
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Unable to open connection to the database." + Environment.NewLine + ex.Message, ex);
                    }

                    // Create the data adapter
                    SqlDataAdapter sqlAdapter = new SqlDataAdapter(DbCommandText, sqlConnect)
                    {
                        SelectCommand = { CommandType = DbCommandType }
                    };

                    // Copy all the parameters to this adapter
                    sql_add_params_to_command(sqlAdapter.SelectCommand, DbParameters);

                    // Fill the dataset to return
                    sqlAdapter.Fill(returnedSet);

                    // Copy any output values back to the parameters
                    sql_copy_returned_values_back_to_params(sqlAdapter.SelectCommand.Parameters, DbParameters);
                }

                // Return the dataset
                return returnedSet;
            }

            if (DbType == EalDbTypeEnum.PostgreSQL)
            {
                throw new ApplicationException("Support for PostgreSQL with SobekCM is targeted for early 2016");
            }

            throw new ApplicationException("Unknown database type not supported");
        }
        /// <summary>
        /// Updates the relevant item info in the database after QC (main thumbnail info, pagecount, filecount, disksize)
        /// </summary>
        /// <param name="BibID"></param>BibID for the item
        /// <param name="VID"></param>VID for this item
        /// <param name="MainThumbnailFileName"></param>Filename of the main thumbnail image (.thm extension)
        /// <param name="MainJpgFileName"></param>Filename of the main thumbnail JPEG image (.jpg extension)
        /// <param name="PageCount"></param>Updated count of the pages for this item
        /// <param name="FileCount"></param>Total count of all the files for the pages of this item
        /// <param name="DisksizeMb"></param>Total disk space occupied by all the files of this item
        /// <param name="Notes"></param>Notes/Comments entered by the user through the QC interface
        /// <param name="User"></param>Logged in user info
        /// <returns></returns>
        public static bool QC_Update_Item_Info(string BibID, string VID, string User, string MainThumbnailFileName, string MainJpgFileName, int PageCount, int FileCount, double DisksizeMb, string Notes)
        {
            try
            {
                int itemID = Get_ItemID(BibID, VID);
                //Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[8];
                param_list[0] = new EalDbParameter("@itemid", itemID);
                param_list[1] = new EalDbParameter("@notes", Notes);
                param_list[2] = new EalDbParameter("@onlineuser", User);
                param_list[3] = new EalDbParameter("@mainthumbnail", MainThumbnailFileName);
                param_list[4] = new EalDbParameter("@mainjpeg", MainJpgFileName);
                param_list[5] = new EalDbParameter("@pagecount", PageCount);
                param_list[6] = new EalDbParameter("@filecount", FileCount);
                param_list[7] = new EalDbParameter("@disksize_kb", DisksizeMb);

                //Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "Tracking_Submit_Online_Page_Division", param_list);

                return true;

            }
            catch (Exception e)
            {
                //Pass this exception onto the method to handle it
                exception_caught("Tracking_Submit_Online_Page_Division", e);
                return false;
            }
        }
        /// <summary> Gets the item id for an resource in a SobekCM library, by BibID and VID </summary>
        /// <param name="BibID"> Bibliographic identifier to check </param>
        /// <param name="VID"> Volume identifier to check </param>
        /// <returns> ItemID for this item from the database, or -1 </returns>
        /// <remarks> This calls the 'SobekCM_Get_ItemID' stored procedure </remarks> 
        public static int Get_ItemID(string BibID, string VID)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[2];
                param_list[0] = new EalDbParameter("@bibid", BibID);
                param_list[1] = new EalDbParameter("@vid", VID);

                // Execute this query stored procedure
                DataSet resultSet = EalDbAccess.ExecuteDataset(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Get_ItemID", param_list);

                if ((resultSet != null) && (resultSet.Tables[0].Rows.Count > 0))
                    return Convert.ToInt32(resultSet.Tables[0].Rows[0][0]);

                return -1;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Get_ItemID", ee);
                return -1;
            }
        }
        /// <summary> Saves up to five ticklers for a single item in a SobekCM digital library </summary>
        /// <param name="ItemID"> Item ID to associate these ticklers with </param>
        /// <param name="Tickler1"> Tickler to save for this item </param>
        /// <param name="Tickler2"> Tickler to save for this item </param>
        /// <param name="Tickler3"> Tickler to save for this item </param>
        /// <param name="Tickler4"> Tickler to save for this item </param>
        /// <param name="Tickler5"> Tickler to save for this item </param>
        /// <remarks> This method calls the stored procedure 'SobekCM_Save_Item_Ticklers'. </remarks>
        /// <exception cref="SobekCM_Database_Exception"> Exception is thrown if an error is caught during 
        /// the database work and the THROW_EXCEPTIONS internal flag is set to true. </exception>
        protected static bool Save_Item_Ticklers(int ItemID, string Tickler1, string Tickler2, string Tickler3, string Tickler4, string Tickler5)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[6];
                param_list[0] = new EalDbParameter("@ItemID", ItemID);
                param_list[1] = new EalDbParameter("@Tickler1", Tickler1);
                param_list[2] = new EalDbParameter("@Tickler2", Tickler2);
                param_list[3] = new EalDbParameter("@Tickler3", Tickler3);
                param_list[4] = new EalDbParameter("@Tickler4", Tickler4);
                param_list[5] = new EalDbParameter("@Tickler5", Tickler5);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Item_Ticklers", param_list);

                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Item_Ticklers", ee);
                return false;
            }
        }
        /// <summary> Saves metadata from an item into the tables for searching metadata </summary>
        /// <param name="ItemID"> Primary key for the item to which to tag this metadata </param>
        /// <param name="Metadata_Type1"> Type string for the first metadata value </param>
        /// <param name="Metadata_Value1"> Value of the first piece of metadata </param>
        /// <param name="Metadata_Type2">Type string for the second metadata value</param>
        /// <param name="Metadata_Value2"> Value of the second piece of metadata</param>
        /// <param name="Metadata_Type3">Type string for the third metadata value</param>
        /// <param name="Metadata_Value3"> Value of the third piece of metadata</param>
        /// <param name="Metadata_Type4">Type string for the fourth metadata value</param>
        /// <param name="Metadata_Value4"> Value of the fourth piece of metadata</param>
        /// <param name="Metadata_Type5">Type string for the fifth metadata value</param>
        /// <param name="Metadata_Value5"> Value of the fifth piece of metadata</param>
        /// <param name="Metadata_Type6">Type string for the sixth metadata value</param>
        /// <param name="Metadata_Value6"> Value of the sixth piece of metadata</param>
        /// <param name="Metadata_Type7">Type string for the seventh metadata value</param>
        /// <param name="Metadata_Value7"> Value of the seventh piece of metadata</param>
        /// <param name="Metadata_Type8">Type string for the eight metadata value</param>
        /// <param name="Metadata_Value8"> Value of the eight piece of metadata</param>
        /// <param name="Metadata_Type9">Type string for the ninth metadata value</param>
        /// <param name="Metadata_Value9"> Value of the ninth piece of metadata</param>
        /// <param name="Metadata_Type10">Type string for the tenth metadata value</param>
        /// <param name="Metadata_Value10"> Value of the tenth piece of metadata</param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> This calls the 'SobekCM_Metadata_Save' stored procedure in the SobekCM database </remarks>
        protected static bool Save_Item_Metadata(int ItemID, string Metadata_Type1, string Metadata_Value1,
            string Metadata_Type2, string Metadata_Value2, string Metadata_Type3, string Metadata_Value3,
            string Metadata_Type4, string Metadata_Value4, string Metadata_Type5, string Metadata_Value5,
            string Metadata_Type6, string Metadata_Value6, string Metadata_Type7, string Metadata_Value7,
            string Metadata_Type8, string Metadata_Value8, string Metadata_Type9, string Metadata_Value9,
            string Metadata_Type10, string Metadata_Value10)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[21];
                param_list[0] = new EalDbParameter("@itemid", ItemID);
                param_list[1] = new EalDbParameter("@metadata_type1", Metadata_Type1);
                param_list[2] = new EalDbParameter("@metadata_value1", Metadata_Value1.Trim());
                param_list[3] = new EalDbParameter("@metadata_type2", Metadata_Type2);
                param_list[4] = new EalDbParameter("@metadata_value2", Metadata_Value2.Trim());
                param_list[5] = new EalDbParameter("@metadata_type3", Metadata_Type3);
                param_list[6] = new EalDbParameter("@metadata_value3", Metadata_Value3.Trim());
                param_list[7] = new EalDbParameter("@metadata_type4", Metadata_Type4);
                param_list[8] = new EalDbParameter("@metadata_value4", Metadata_Value4.Trim());
                param_list[9] = new EalDbParameter("@metadata_type5", Metadata_Type5);
                param_list[10] = new EalDbParameter("@metadata_value5", Metadata_Value5.Trim());
                param_list[11] = new EalDbParameter("@metadata_type6", Metadata_Type6);
                param_list[12] = new EalDbParameter("@metadata_value6", Metadata_Value6.Trim());
                param_list[13] = new EalDbParameter("@metadata_type7", Metadata_Type7);
                param_list[14] = new EalDbParameter("@metadata_value7", Metadata_Value7.Trim());
                param_list[15] = new EalDbParameter("@metadata_type8", Metadata_Type8);
                param_list[16] = new EalDbParameter("@metadata_value8", Metadata_Value8.Trim());
                param_list[17] = new EalDbParameter("@metadata_type9", Metadata_Type9);
                param_list[18] = new EalDbParameter("@metadata_value9", Metadata_Value9.Trim());
                param_list[19] = new EalDbParameter("@metadata_type10", Metadata_Type10);
                param_list[20] = new EalDbParameter("@metadata_value10", Metadata_Value10.Trim());

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Metadata_Save", param_list);
                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Metadata_Save", ee);
                return false;
            }
        }
        /// <summary> Saves the main information about an item group in SobekCM </summary>
        /// <param name="BibID">Bib ID for this group</param>
        /// <param name="GroupTitle">Title for this group</param>
        /// <param name="SortTitle">Sort title for this item group</param>
        /// <param name="CreateDate"> Day this item was created </param>
        /// <param name="File_Root"> File root for this item group's files </param>
        /// <param name="Update_Existing"> Flag indicates to update this bib id if it exists</param>
        /// <param name="Type">Resource type for this group</param>
        /// <param name="ALEPH_Number"> ALEPH record number for this item group</param>
        /// <param name="OCLC_Number"> OCLC record number for this item group</param>
        /// <param name="Group_Thumbnail"> Thumbnail to use for this item group </param>
        /// <param name="Large_Format"> Flag indicates if this a large format item, which will affect size of service image files </param>
        /// <param name="Never_Overlay_Record"> Flag indicates to never overlay this record from the original ALEPH or OCLC record </param>
        /// <param name="Track_By_Month"> Flag indicates this material should be tracked by month, along with other items within the same title </param>
        /// <param name="Primary_Identifier_Type"> Primary identifier type for this item group </param>
        /// <param name="Primary_Identifier"> Primary identifier for this item group </param>
        /// <returns> Arguments which include the group id and bibid for this item group / title </returns>
        /// <remarks> This method calls the stored procedure 'SobekCM_Save_Item_Group'. </remarks>
        /// <exception cref="ApplicationException"> Exception is thrown if an error is caught during 
        /// the database work and the THROW_EXCEPTIONS internal flag is set to true. </exception>
        protected static Save_Item_Group_Args Save_Item_Group(string BibID, string GroupTitle, string SortTitle, string Type, string File_Root, string Group_Thumbnail, bool Update_Existing, DateTime CreateDate, long OCLC_Number, int ALEPH_Number, bool Large_Format, bool Track_By_Month, bool Never_Overlay_Record, string Primary_Identifier_Type, string Primary_Identifier)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[17];
                param_list[0] = new EalDbParameter("@BibID", BibID);
                param_list[1] = new EalDbParameter("@GroupTitle", GroupTitle);
                param_list[2] = new EalDbParameter("@SortTitle", SortTitle);
                param_list[3] = new EalDbParameter("@Type", Type);
                param_list[4] = new EalDbParameter("@File_Location", File_Root);
                if (OCLC_Number < 0)
                    param_list[5] = new EalDbParameter("@OCLC_Number", 1);
                else
                    param_list[5] = new EalDbParameter("@OCLC_Number", OCLC_Number);
                if (ALEPH_Number < 0)
                    param_list[6] = new EalDbParameter("@ALEPH_Number", 1);
                else
                    param_list[6] = new EalDbParameter("@ALEPH_Number", ALEPH_Number);
                param_list[7] = new EalDbParameter("@Group_Thumbnail", Group_Thumbnail);
                param_list[8] = new EalDbParameter("@Large_Format", Large_Format);
                param_list[9] = new EalDbParameter("@Track_By_Month", Track_By_Month);
                param_list[10] = new EalDbParameter("@Never_Overlay_Record", Never_Overlay_Record);
                param_list[11] = new EalDbParameter("@Update_Existing", Update_Existing);
                param_list[12] = new EalDbParameter("@PrimaryIdentifierType", Primary_Identifier_Type);
                param_list[13] = new EalDbParameter("@PrimaryIdentifier", Primary_Identifier);
                param_list[14] = new EalDbParameter("@GroupID", -1) { Direction = ParameterDirection.InputOutput };
                param_list[15] = new EalDbParameter("@New_BibID", "0000000000") { Direction = ParameterDirection.InputOutput };
                param_list[16] = new EalDbParameter("@New_Group", false) { Direction = ParameterDirection.InputOutput };

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Item_Group", param_list);

                // Get the values to return
                int groupid = (int)param_list[14].Value;
                string bibid = param_list[15].Value.ToString();
                bool is_new = Convert.ToBoolean(param_list[16].Value);

                // Return the value
                return new Save_Item_Group_Args(groupid, bibid, is_new);
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Item_Group", ee);
                return new Save_Item_Group_Args(-1, String.Empty, false);
            }
        }
        /// <summary> Saves the behaviors for a single item in a SobekCM digital library </summary>
        /// <param name="ItemID">Item ID to associate these icons and downlaods with</param>
        /// <param name="TextSearchable"> Flag indicates if this item is text searchable </param>
        /// <param name="Viewer1_Type"> Primary key for the first viewer type in the SobekCM database </param>
        /// <param name="Viewer1_Label"> Label to be displayed for the first viewer of this item </param>
        /// <param name="Viewer1_Attributes"> Optional attributes for the first viewer of this item </param>
        /// <param name="Viewer2_Type"> Primary key for the second viewer type in the SobekCM database </param>
        /// <param name="Viewer2_Label"> Label to be displayed for the second viewer of this item </param>
        /// <param name="Viewer2_Attributes"> Optional attributes for the second viewer of this item </param>
        /// <param name="Viewer3_Type"> Primary key for the third viewer type in the SobekCM database </param>
        /// <param name="Viewer3_Label"> Label to be displayed for the third viewer of this item </param>
        /// <param name="Viewer3_Attributes"> Optional attributes for the third viewer of this item </param>
        /// <param name="Viewer4_Type"> Primary key for the fourth viewer type in the SobekCM database </param>
        /// <param name="Viewer4_Label"> Label to be displayed for the fourth viewer of this item </param>
        /// <param name="Viewer4_Attributes"> Optional attributes for the fourth viewer of this item </param>
        /// <param name="Viewer5_Type"> Primary key for the fifth viewer type in the SobekCM database </param>
        /// <param name="Viewer5_Label"> Label to be displayed for the fifth viewer of this item </param>
        /// <param name="Viewer5_Attributes"> Optional attributes for the fifth viewer of this item </param>
        /// <param name="Viewer6_Type"> Primary key for the sixth viewer type in the SobekCM database </param>
        /// <param name="Viewer6_Label"> Label to be displayed for the sixth viewer of this item </param>
        /// <param name="Viewer6_Attributes"> Optional attributes for the sixth viewer of this item </param>
        /// <remarks> This method calls the stored procedure 'SobekCM_Save_Item_Behaviors'. </remarks>
        /// <exception cref="SobekCM_Database_Exception"> Exception is thrown if an error is caught during 
        /// the database work and the THROW_EXCEPTIONS internal flag is set to true. </exception>
        protected static bool Save_Item_Behaviors_Minimal(int ItemID, bool TextSearchable, 
            int Viewer1_Type, string Viewer1_Label, string Viewer1_Attributes, int Viewer2_Type, string Viewer2_Label, string Viewer2_Attributes,
            int Viewer3_Type, string Viewer3_Label, string Viewer3_Attributes, int Viewer4_Type, string Viewer4_Label, string Viewer4_Attributes,
            int Viewer5_Type, string Viewer5_Label, string Viewer5_Attributes, int Viewer6_Type, string Viewer6_Label, string Viewer6_Attributes)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[20];
                param_list[0] = new EalDbParameter("@ItemID", ItemID);
                param_list[1] = new EalDbParameter("@TextSearchable", TextSearchable);
                param_list[2] = new EalDbParameter("@Viewer1_TypeID", Viewer1_Type);
                param_list[3] = new EalDbParameter("@Viewer1_Label", Viewer1_Label);
                param_list[4] = new EalDbParameter("@Viewer1_Attribute", Viewer1_Attributes);
                param_list[5] = new EalDbParameter("@Viewer2_TypeID", Viewer2_Type);
                param_list[6] = new EalDbParameter("@Viewer2_Label", Viewer2_Label);
                param_list[7] = new EalDbParameter("@Viewer2_Attribute", Viewer2_Attributes);
                param_list[8] = new EalDbParameter("@Viewer3_TypeID", Viewer3_Type);
                param_list[9] = new EalDbParameter("@Viewer3_Label", Viewer3_Label);
                param_list[10] = new EalDbParameter("@Viewer3_Attribute", Viewer3_Attributes);
                param_list[11] = new EalDbParameter("@Viewer4_TypeID", Viewer4_Type);
                param_list[12] = new EalDbParameter("@Viewer4_Label", Viewer4_Label);
                param_list[13] = new EalDbParameter("@Viewer4_Attribute", Viewer4_Attributes);
                param_list[14] = new EalDbParameter("@Viewer5_TypeID", Viewer5_Type);
                param_list[15] = new EalDbParameter("@Viewer5_Label", Viewer5_Label);
                param_list[16] = new EalDbParameter("@Viewer5_Attribute", Viewer5_Attributes);
                param_list[17] = new EalDbParameter("@Viewer6_TypeID", Viewer6_Type);
                param_list[18] = new EalDbParameter("@Viewer6_Label", Viewer6_Label);
                param_list[19] = new EalDbParameter("@Viewer6_Attribute", Viewer6_Attributes);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Item_Behaviors_Minimal", param_list);

                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Item_Behaviors", ee);
                return false;
            }
        }
        /// <summary> Add a worklog entry for a current event </summary>
        /// <param name="ItemID"> ItemID for which to add a workflow history entry </param>
        /// <param name="Workflow_Type"> Name of the workflow to add to this item  </param>
        /// <param name="Notes"> Any notes associated with the workflow </param>
        /// <param name="UserName"> User who added this worklog enty </param>
        /// <param name="StorageLocation"> Location this work occured on the network or detached drives </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> This method calls the stored procedure 'Tracking_Add_Workflow_By_ItemID'. </remarks>
        /// <exception cref="SobekCM_Database_Exception"> Exception is thrown if an error is caught during 
        /// the database work and the THROW_EXCEPTIONS internal flag is set to true. </exception>
        public static bool Add_Workflow(int ItemID, string Workflow_Type, string Notes, string UserName, string StorageLocation)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[5];
                param_list[0] = new EalDbParameter("@itemid", ItemID);
                param_list[1] = new EalDbParameter("@user", UserName);
                param_list[2] = new EalDbParameter("@progressnote", Notes);
                param_list[3] = new EalDbParameter("@workflow", Workflow_Type);
                param_list[4] = new EalDbParameter("@storagelocation", StorageLocation);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "Tracking_Add_Workflow_By_ItemID", param_list);

                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("Tracking_Add_Past_Workflow_By_ItemID", ee);
                return false;
            }
        }
        /// <summary> Saves the behaviors for a single item in a SobekCM digital library </summary>
        /// <param name="ItemID">Item ID to associate these icons and downlaods with</param>
        /// <param name="TextSearchable"> Flag indicates if this item is text searchable </param>
        /// <param name="MainThumbnail"> Main thumbnail file name </param>
        /// <param name="MainJPEG"> Main page jpeg image (for full results view) </param>
        /// <param name="IP_Restriction_Mask">IP Restriction mask for this item </param>
        /// <param name="CheckoutRequired"> Flag indicates if this is a single-use item which requires checkout</param>
        /// <param name="Dark_Flag"> Flag indicates if this item is DARK and should not be made public or restricted (i.e., remains private)</param>
        /// <param name="Born_Digital"> Flag indicates if this material was born digitally, rather than digitized </param>
        /// <param name="DispositionAdvice"> Key to how this item will be disposed of once complete, or -1 for no advice </param>
        /// <param name="DispositionAdviceNotes"> Notes to further explain how this item should be disposed of (i.e., return to whom, etc.)</param>
        /// <param name="Material_Received_Date"> Day the material was received into the digitization office </param>
        /// <param name="Material_Recd_Date_Estimated"> Flag indicates if the date above is an estimate </param>
        /// <param name="Tracking_Box"> Tracking box this item currently resides in or is tracked with </param>
        /// <param name="AggregationCode1"> Code for the first aggregation this item belongs to </param>
        /// <param name="AggregationCode2"> Code for the second aggregation this item belongs to </param>
        /// <param name="AggregationCode3"> Code for the third aggregation this item belongs to </param>
        /// <param name="AggregationCode4"> Code for the fourth aggregation this item belongs to </param>
        /// <param name="AggregationCode5"> Code for the fifth aggregation this item belongs to </param>
        /// <param name="AggregationCode6"> Code for the sixth aggregation this item belongs to </param>
        /// <param name="AggregationCode7"> Code for the seventh aggregation this item belongs to </param>
        /// <param name="AggregationCode8"> Code for the eighth aggregation this item belongs to </param>
        /// <param name="HoldingCode"> Holding code for this item's holding location aggregation </param>
        /// <param name="SourceCode"> Source location code for this item's source location </param>
        /// <param name="Icon1_Name">Name of the first icon</param>
        /// <param name="Icon2_Name">Name of the second icon</param>
        /// <param name="Icon3_Name">Name of the third icon</param>
        /// <param name="Icon4_Name">Name of the fourth icon</param>
        /// <param name="Icon5_Name">Name of the fifth icon</param>
        /// <param name="Viewer1_Type"> Primary key for the first viewer type in the SobekCM database </param>
        /// <param name="Viewer1_Label"> Label to be displayed for the first viewer of this item </param>
        /// <param name="Viewer1_Attributes"> Optional attributes for the first viewer of this item </param>
        /// <param name="Viewer2_Type"> Primary key for the second viewer type in the SobekCM database </param>
        /// <param name="Viewer2_Label"> Label to be displayed for the second viewer of this item </param>
        /// <param name="Viewer2_Attributes"> Optional attributes for the second viewer of this item </param>
        /// <param name="Viewer3_Type"> Primary key for the third viewer type in the SobekCM database </param>
        /// <param name="Viewer3_Label"> Label to be displayed for the third viewer of this item </param>
        /// <param name="Viewer3_Attributes"> Optional attributes for the third viewer of this item </param>
        /// <param name="Viewer4_Type"> Primary key for the fourth viewer type in the SobekCM database </param>
        /// <param name="Viewer4_Label"> Label to be displayed for the fourth viewer of this item </param>
        /// <param name="Viewer4_Attributes"> Optional attributes for the fourth viewer of this item </param>
        /// <param name="Viewer5_Type"> Primary key for the fifth viewer type in the SobekCM database </param>
        /// <param name="Viewer5_Label"> Label to be displayed for the fifth viewer of this item </param>
        /// <param name="Viewer5_Attributes"> Optional attributes for the fifth viewer of this item </param>
        /// <param name="Viewer6_Type"> Primary key for the sixth viewer type in the SobekCM database </param>
        /// <param name="Viewer6_Label"> Label to be displayed for the sixth viewer of this item </param>
        /// <param name="Viewer6_Attributes"> Optional attributes for the sixth viewer of this item </param>
        /// <param name="Left_To_Right"> Flag indicates this item is read from Left-to-Right, rather than standard Right-to-Left</param>
        /// <remarks> This method calls the stored procedure 'SobekCM_Save_Item_Behaviors'. </remarks>
        /// <exception cref="SobekCM_Database_Exception"> Exception is thrown if an error is caught during 
        /// the database work and the THROW_EXCEPTIONS internal flag is set to true. </exception>
        protected static bool Save_Item_Behaviors(int ItemID, bool TextSearchable, string MainThumbnail,
            string MainJPEG, short IP_Restriction_Mask, bool CheckoutRequired, bool Dark_Flag, bool Born_Digital,
            short DispositionAdvice, string DispositionAdviceNotes, Nullable<DateTime> Material_Received_Date, bool Material_Recd_Date_Estimated,
            string Tracking_Box, string AggregationCode1, string AggregationCode2,
            string AggregationCode3, string AggregationCode4, string AggregationCode5, string AggregationCode6,
            string AggregationCode7, string AggregationCode8, string HoldingCode, string SourceCode,
            string Icon1_Name, string Icon2_Name, string Icon3_Name, string Icon4_Name, string Icon5_Name,
            int Viewer1_Type, string Viewer1_Label, string Viewer1_Attributes, int Viewer2_Type, string Viewer2_Label, string Viewer2_Attributes,
            int Viewer3_Type, string Viewer3_Label, string Viewer3_Attributes, int Viewer4_Type, string Viewer4_Label, string Viewer4_Attributes,
            int Viewer5_Type, string Viewer5_Label, string Viewer5_Attributes, int Viewer6_Type, string Viewer6_Label, string Viewer6_Attributes, bool Left_To_Right)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[47];
                param_list[0] = new EalDbParameter("@ItemID", ItemID);
                param_list[1] = new EalDbParameter("@TextSearchable", TextSearchable);
                param_list[2] = new EalDbParameter("@MainThumbnail", MainThumbnail);
                param_list[3] = new EalDbParameter("@MainJPEG", MainJPEG);
                param_list[4] = new EalDbParameter("@IP_Restriction_Mask", IP_Restriction_Mask);
                param_list[5] = new EalDbParameter("@CheckoutRequired", CheckoutRequired);
                param_list[6] = new EalDbParameter("@Dark_Flag", Dark_Flag);
                param_list[7] = new EalDbParameter("@Born_Digital", Born_Digital);
                if (DispositionAdvice <= 0)
                    param_list[8] = new EalDbParameter("@Disposition_Advice", DBNull.Value);
                else
                    param_list[8] = new EalDbParameter("@Disposition_Advice", DispositionAdvice);
                param_list[9] = new EalDbParameter("@Disposition_Advice_Notes", DispositionAdviceNotes);

                if (Material_Received_Date.HasValue)
                    param_list[10] = new EalDbParameter("@Material_Received_Date", Material_Received_Date.Value);
                else
                    param_list[10] = new EalDbParameter("@Material_Received_Date", DBNull.Value);
                param_list[11] = new EalDbParameter("@Material_Recd_Date_Estimated", Material_Recd_Date_Estimated);
                param_list[12] = new EalDbParameter("@Tracking_Box", Tracking_Box);
                param_list[13] = new EalDbParameter("@AggregationCode1", AggregationCode1);
                param_list[14] = new EalDbParameter("@AggregationCode2", AggregationCode2);
                param_list[15] = new EalDbParameter("@AggregationCode3", AggregationCode3);
                param_list[16] = new EalDbParameter("@AggregationCode4", AggregationCode4);
                param_list[17] = new EalDbParameter("@AggregationCode5", AggregationCode5);
                param_list[18] = new EalDbParameter("@AggregationCode6", AggregationCode6);
                param_list[19] = new EalDbParameter("@AggregationCode7", AggregationCode7);
                param_list[20] = new EalDbParameter("@AggregationCode8", AggregationCode8);
                param_list[21] = new EalDbParameter("@HoldingCode", HoldingCode);
                param_list[22] = new EalDbParameter("@SourceCode", SourceCode);
                param_list[23] = new EalDbParameter("@Icon1_Name", Icon1_Name);
                param_list[24] = new EalDbParameter("@Icon2_Name", Icon2_Name);
                param_list[25] = new EalDbParameter("@Icon3_Name", Icon3_Name);
                param_list[26] = new EalDbParameter("@Icon4_Name", Icon4_Name);
                param_list[27] = new EalDbParameter("@Icon5_Name", Icon5_Name);
                param_list[28] = new EalDbParameter("@Viewer1_TypeID", Viewer1_Type);
                param_list[29] = new EalDbParameter("@Viewer1_Label", Viewer1_Label);
                param_list[30] = new EalDbParameter("@Viewer1_Attribute", Viewer1_Attributes);
                param_list[31] = new EalDbParameter("@Viewer2_TypeID", Viewer2_Type);
                param_list[32] = new EalDbParameter("@Viewer2_Label", Viewer2_Label);
                param_list[33] = new EalDbParameter("@Viewer2_Attribute", Viewer2_Attributes);
                param_list[34] = new EalDbParameter("@Viewer3_TypeID", Viewer3_Type);
                param_list[35] = new EalDbParameter("@Viewer3_Label", Viewer3_Label);
                param_list[36] = new EalDbParameter("@Viewer3_Attribute", Viewer3_Attributes);
                param_list[37] = new EalDbParameter("@Viewer4_TypeID", Viewer4_Type);
                param_list[38] = new EalDbParameter("@Viewer4_Label", Viewer4_Label);
                param_list[39] = new EalDbParameter("@Viewer4_Attribute", Viewer4_Attributes);
                param_list[40] = new EalDbParameter("@Viewer5_TypeID", Viewer5_Type);
                param_list[41] = new EalDbParameter("@Viewer5_Label", Viewer5_Label);
                param_list[42] = new EalDbParameter("@Viewer5_Attribute", Viewer5_Attributes);
                param_list[43] = new EalDbParameter("@Viewer6_TypeID", Viewer6_Type);
                param_list[44] = new EalDbParameter("@Viewer6_Label", Viewer6_Label);
                param_list[45] = new EalDbParameter("@Viewer6_Attribute", Viewer6_Attributes);
                param_list[46] = new EalDbParameter("@Left_To_Right", Left_To_Right);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Item_Behaviors", param_list);

                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Item_Behaviors", ee);
                return false;
            }
        }
        /// <summary> Delete the QC error for a single page of an item from the database </summary>
        /// <param name="itemID"></param>
        /// <param name="filename"></param>
        public static void Delete_QC_Error(int itemID, string filename)
        {
            try
            {
                //Add the parameters to this command
                EalDbParameter[] parameters = new EalDbParameter[2];
                parameters[0] = new EalDbParameter("@itemID", itemID);
                parameters[1] = new EalDbParameter("@filename", filename);

                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_QC_Delete_Error", parameters);
            }

            catch (Exception ee)
            {
                throw new ApplicationException("Error deleting QC error from the database." + ee.Message);
            }
        }
        /// <summary> Update the disposition advice on what to do when the physical material leaves the digitization location </summary>
        /// <param name="ItemID"> ItemID for which to update the disposition advice </param>
        /// <param name="DispositionTypeID"> Primary key to the disposition type from the database </param>
        /// <param name="Notes"> Any associated notes included about the disposition advice </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> This method calls the stored procedure 'Tracking_Update_Disposition_Advice'. </remarks>
        /// <exception cref="SobekCM_Database_Exception"> Exception is thrown if an error is caught during 
        /// the database work and the THROW_EXCEPTIONS internal flag is set to true. </exception>
        public static bool Edit_Disposition_Advice(int ItemID, int DispositionTypeID, string Notes)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[3];
                param_list[0] = new EalDbParameter("@Disposition_Advice", DispositionTypeID);
                param_list[1] = new EalDbParameter("@Disposition_Advice_Notes", Notes);
                param_list[2] = new EalDbParameter("@ItemID", ItemID);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "Tracking_Update_Disposition_Advice", param_list);

                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("Tracking_Update_Disposition_Advice", ee);
                return false;
            }
        }
        /// <summary> Saves the serial hierarchy and link between an item and an item group </summary>
        /// <param name="GroupID">Group ID this item belongs to</param>
        /// <param name="ItemID">Item id for the individual item</param>
        /// <param name="Level1_Text">Text to display for the first hierarchy</param>
        /// <param name="Level1_Index">Order for this item within other first hierarchy items</param>
        /// <param name="Level2_Text">Text to display for the second hierarchy</param>
        /// <param name="Level2_Index">Order for this item within other second hierarchy items</param>
        /// <param name="Level3_Text">Text to display for the third hierarchy</param>
        /// <param name="Level3_Index">Order for this item within other third hierarchy items</param>
        /// <param name="Level4_Text">Text to display for the fourth hierarchy</param>
        /// <param name="Level4_Index">Order for this item within other fourth hierarchy items</param>
        /// <param name="Level5_Text">Text to display for the fifth hierarchy</param>
        /// <param name="Level5_Index">Order for this item within other fifth hierarchy items</param>
        /// <param name="SerialHierarchy"> Serial hierarchy as a single</param>
        /// <remarks> This method calls the stored procedure 'SobekCM_Save_Serial_Hierarchy'. </remarks>
        /// <exception cref="SobekCM_Database_Exception"> Exception is thrown if an error is caught during 
        /// the database work and the THROW_EXCEPTIONS internal flag is set to true. </exception>
        protected static void Save_Serial_Hierarchy(int GroupID, int ItemID, string Level1_Text, int Level1_Index, string Level2_Text, int Level2_Index, string Level3_Text, int Level3_Index, string Level4_Text, int Level4_Index, string Level5_Text, int Level5_Index, string SerialHierarchy)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[13];
                param_list[0] = new EalDbParameter("@GroupID", GroupID);
                param_list[1] = new EalDbParameter("@ItemID", ItemID);
                if (Level1_Index >= 0)
                {
                    param_list[2] = new EalDbParameter("@Level1_Text", Level1_Text);
                    param_list[3] = new EalDbParameter("@Level1_Index", Level1_Index);
                }
                else
                {
                    param_list[2] = new EalDbParameter("@Level1_Text", DBNull.Value);
                    param_list[3] = new EalDbParameter("@Level1_Index", DBNull.Value);
                }

                if (Level2_Index >= 0)
                {
                    param_list[4] = new EalDbParameter("@Level2_Text", Level2_Text);
                    param_list[5] = new EalDbParameter("@Level2_Index", Level2_Index);
                }
                else
                {
                    param_list[4] = new EalDbParameter("@Level2_Text", DBNull.Value);
                    param_list[5] = new EalDbParameter("@Level2_Index", DBNull.Value);
                }

                if (Level3_Index >= 0)
                {
                    param_list[6] = new EalDbParameter("@Level3_Text", Level3_Text);
                    param_list[7] = new EalDbParameter("@Level3_Index", Level3_Index);
                }
                else
                {
                    param_list[6] = new EalDbParameter("@Level3_Text", DBNull.Value);
                    param_list[7] = new EalDbParameter("@Level3_Index", DBNull.Value);
                }

                if (Level4_Index >= 0)
                {
                    param_list[8] = new EalDbParameter("@Level4_Text", Level4_Text);
                    param_list[9] = new EalDbParameter("@Level4_Index", Level4_Index);
                }
                else
                {
                    param_list[8] = new EalDbParameter("@Level4_Text", DBNull.Value);
                    param_list[9] = new EalDbParameter("@Level4_Index", DBNull.Value);
                }

                if (Level5_Index >= 0)
                {
                    param_list[10] = new EalDbParameter("@Level5_Text", Level5_Text);
                    param_list[11] = new EalDbParameter("@Level5_Index", Level5_Index);
                }
                else
                {
                    param_list[10] = new EalDbParameter("@Level5_Text", DBNull.Value);
                    param_list[11] = new EalDbParameter("@Level5_Index", DBNull.Value);
                }

                param_list[12] = new EalDbParameter("@SerialHierarchy", SerialHierarchy);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Serial_Hierarchy", param_list);
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Serial_Hierarchy", ee);
            }
        }
        /// <summary> Get the list of all the QC Page errors for a single item </summary>
        /// <param name="ItemID">ItemID</param>
        /// <returns></returns>
        public static DataTable Get_QC_Errors_For_Item(int ItemID)
        {
            try
            {
                //Add the parameters to this command
                EalDbParameter[] parameters = new EalDbParameter[1];
                parameters[0] = new EalDbParameter("@itemID", ItemID);

                DataSet returnSet = EalDbAccess.ExecuteDataset(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_QC_Get_Errors", parameters);
                if ((returnSet != null) && (returnSet.Tables.Count > 0))
                {
                    return returnSet.Tables[0];
                }

                return null;
            }
            catch (Exception ee)
            {
                throw new ApplicationException("Error getting the QC errors for this item." + ee.Message);
            }
        }
        /// <summary> Checks for similar records within the database </summary>
        /// <param name="BibID"> Bibliographic identifier to check </param>
        /// <param name="VID"> Volume identifier to check </param>
        /// <param name="OCLC"> OCLC Record number to look for existence </param>
        /// <param name="Local_Catalog_ID"> Local catalog record number to look for existence </param>
        /// <returns> DataTable with any matching results </returns>
        /// <remarks> This calls the 'SobekCM_Check_For_Record_Existence' stored procedure </remarks> 
        public static DataTable Check_For_Record_Existence(string BibID, string VID, string OCLC, string Local_Catalog_ID)
        {
            // Get oclc and/or aleph number
            long oclc = -999;
            int aleph = -999;
            if (OCLC.Length > 0)
            {
                long oclc_temp;
                if (Int64.TryParse(OCLC, out oclc_temp))
                    oclc = oclc_temp;
            }
            if (Local_Catalog_ID.Length > 0)
            {
                int catalog_temp;
                if (Int32.TryParse(Local_Catalog_ID, out catalog_temp))
                    aleph = catalog_temp;
            }

            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[4];
                param_list[0] = new EalDbParameter("@bibid", BibID);
                param_list[1] = new EalDbParameter("@vid", VID);
                param_list[2] = new EalDbParameter("@OCLC_Number", oclc);
                param_list[3] = new EalDbParameter("@Local_Cat_Number", aleph);

                // Execute this query stored procedure
                DataSet resultSet = EalDbAccess.ExecuteDataset(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Check_For_Record_Existence", param_list);

                if (resultSet != null)
                    return resultSet.Tables[0];
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Check_For_Record_Existence", ee);
            }

            return null;
        }
        /// <summary> Execute a SQL statement or stored procedure and return a data reader </summary>
        /// <param name="DbType"> Type of database ( i.e., MSSQL, PostgreSQL ) </param>
        /// <param name="DbConnectionString"> Database connection string </param>
        /// <param name="DbCommandType"> Database command type </param>
        /// <param name="DbCommandText"> Text of the database command, or name of the stored procedure to run </param>
        /// <param name="DbParameters"> Parameters for the SQL statement </param>
        public static EalDbReaderWrapper ExecuteDataReader(EalDbTypeEnum DbType, string DbConnectionString, CommandType DbCommandType, string DbCommandText, EalDbParameter[] DbParameters)
        {
            if (DbType == EalDbTypeEnum.MSSQL)
            {
                // Create the SQL connection
                SqlConnection sqlConnect = new SqlConnection(DbConnectionString);

                try
                {
                    sqlConnect.Open();
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Unable to open connection to the database." + Environment.NewLine + ex.Message, ex);
                }

                // Create the SQL command
                SqlCommand sqlCommand = new SqlCommand(DbCommandText, sqlConnect)
                {
                    CommandType = DbCommandType
                };

                // Copy all the parameters to this adapter
                sql_add_params_to_command(sqlCommand, DbParameters);

                // Fill the dataset to return
                SqlDataReader reader;

                // Try to open the reader.. if there was an error, close the database connection
                // before passing out the exception
                try
                {
                    reader = sqlCommand.ExecuteReader();
                }
                catch (Exception)
                {
                    sqlConnect.Close();
                    throw;
                }

                // Create the reader wrapper
                EalDbReaderWrapper returnValue = new EalDbReaderWrapper(sqlConnect, reader);

                // Copy any output values back to the parameters
                sql_copy_returned_values_back_to_params(returnValue, sqlCommand.Parameters, DbParameters);

                // Return the dataset
                return returnValue;
            }

            if (DbType == EalDbTypeEnum.PostgreSQL)
            {
                throw new ApplicationException("Support for PostgreSQL with SobekCM is targeted for early 2016");
            }

            throw new ApplicationException("Unknown database type not supported");
        }
        private static bool Save_Corporation(string CorpAuthCode, string CorporateName)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[2];
                param_list[0] = new EalDbParameter("@CorpAuthCode", CorpAuthCode);
                param_list[1] = new EalDbParameter("@CorporateName", CorporateName);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Corporation", param_list);

                // Return the value
                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Corporation", ee);
                return false;
            }
        }
        /// <summary> Execute a non-query SQL statement or stored procedure </summary>
        /// <param name="DbType"> Type of database ( i.e., MSSQL, PostgreSQL ) </param>
        /// <param name="DbConnectionString"> Database connection string </param>
        /// <param name="DbCommandType"> Database command type </param>
        /// <param name="DbCommandText"> Text of the database command, or name of the stored procedure to run </param>
        /// <param name="DbParameters"> Parameters for the SQL statement </param>
        public static void ExecuteNonQuery(EalDbTypeEnum DbType, string DbConnectionString, CommandType DbCommandType, string DbCommandText, EalDbParameter[] DbParameters)
        {
            if (DbType == EalDbTypeEnum.MSSQL)
            {
                // Create the SQL connection
                using (SqlConnection sqlConnect = new SqlConnection(DbConnectionString))
                {
                    try
                    {
                        sqlConnect.Open();
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Unable to open connection to the database." + Environment.NewLine + ex.Message, ex);
                    }

                    // Create the SQL command
                    SqlCommand sqlCommand = new SqlCommand(DbCommandText, sqlConnect)
                    {
                        CommandType = DbCommandType
                    };

                    // Copy all the parameters to this adapter
                    sql_add_params_to_command(sqlCommand, DbParameters);

                    // Run the command itself
                    try
                    {
                        sqlCommand.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Error executing non-query command." + Environment.NewLine + ex.Message, ex);
                    }

                    // Copy any output values back to the parameters
                    sql_copy_returned_values_back_to_params(sqlCommand.Parameters, DbParameters);

                    // Close the connection (not technical necessary since we put the connection in the
                    // scope of the using brackets.. it would dispose itself anyway)
                    try
                    {
                        sqlConnect.Close();
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Unable to close connection to the database." + Environment.NewLine + ex.Message, ex);
                    }
                }

                // Return
                return;
            }

            if (DbType == EalDbTypeEnum.PostgreSQL)
            {
                throw new ApplicationException("Support for PostgreSQL with SobekCM is targeted for early 2016");
            }

            throw new ApplicationException("Unknown database type not supported");
        }
        private static bool Save_Feature(string FeatAuthCode, string FeatureName, string LocationDesc, string CorpAuthCode, bool AA_Indicated,
            string Albers_X, string Albers_Y, string Latitude, string Longitude, string FeatureType, int FeatureTypeYear, int PageID1,
            int PageID2, int PageID3, int PageID4, int PageID5)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[16];
                param_list[0] = new EalDbParameter("@FeatAuthCode", FeatAuthCode);
                param_list[1] = new EalDbParameter("@FeatureName", FeatureName);
                param_list[2] = new EalDbParameter("@LocationDesc", LocationDesc);
                param_list[3] = new EalDbParameter("@CorpAuthCode", CorpAuthCode);
                param_list[4] = new EalDbParameter("@AA_Indicated", AA_Indicated);
                param_list[5] = new EalDbParameter("@Albers_X", Albers_X);
                param_list[6] = new EalDbParameter("@Albers_Y", Albers_Y);
                param_list[7] = new EalDbParameter("@Latitude", Latitude);
                param_list[8] = new EalDbParameter("@Longitude", Longitude);
                param_list[9] = new EalDbParameter("@FeatureType", FeatureType);
                param_list[10] = new EalDbParameter("@FeatureTypeYear", FeatureTypeYear);
                param_list[11] = new EalDbParameter("@PageID1", PageID1);
                param_list[12] = new EalDbParameter("@PageID2", PageID2);
                param_list[13] = new EalDbParameter("@PageID3", PageID3);
                param_list[14] = new EalDbParameter("@PageID4", PageID4);
                param_list[15] = new EalDbParameter("@PageID5", PageID5);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Feature", param_list);

                // Return the value
                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Feature", ee);
                return false;
            }
        }
 // Copy any output values back to the parameters
 private static void sql_copy_returned_values_back_to_params(SqlParameterCollection SqlParams, EalDbParameter[] EalParams)
 {
     // Copy over any values as necessary
     int i = 0;
     foreach (EalDbParameter thisParameter in EalParams)
     {
         if ((thisParameter.Direction == ParameterDirection.Output) || (thisParameter.Direction == ParameterDirection.InputOutput))
         {
             thisParameter.Value = SqlParams[i].Value;
         }
         i++;
     }
 }
        /// <summary> Causes the database to build the searchable full citation cell for basic searching from
        /// all of the discrete metadata elements stored for this item </summary>
        /// <param name="ItemID">Item ID of the item </param>
        /// <remarks> This method calls the stored procedure 'SobekCM_Create_Full_Citation_Value'. </remarks>
        /// <exception cref="SobekCM_Database_Exception"> Exception is thrown if an error is caught during 
        /// the database work and the THROW_EXCEPTIONS internal flag is set to true. </exception>
        public static bool Create_Full_Citation_Value(int ItemID)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[1];
                param_list[0] = new EalDbParameter("@ItemID", ItemID);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Create_Full_Citation_Value", param_list);

                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Create_Full_Citation_Value", ee);
                return false;
            }
        }
        /// <summary> Clears all the metadata associated with a particular item in the database </summary>
        /// <param name="ItemID"> Primary key for the item to clear the searchable metadata values</param>
        /// <param name="Clear_Non_Metadata_Values">Flag indicates if the values which are not derived from the metadata file should be cleared as well </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> This calls the 'SobekCM_Metadata_Clear2' stored procedure in the SobekCM database </remarks>
        protected static bool Clear_Item_Metadata(int ItemID, bool Clear_Non_Metadata_Values)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[2];
                param_list[0] = new EalDbParameter("@itemid", ItemID);
                param_list[1] = new EalDbParameter("@clear_non_mets_values", Clear_Non_Metadata_Values);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Metadata_Clear2", param_list);
                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Metadata_Clear2", ee);
                return false;
            }
        }
        private static bool Save_Street(string StreetAuthCode, string StreetName, long StartAddress, long EndAddress,
            string StreetDirection, string StreetSide, string SegmentDesc, int PageID)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[8];
                param_list[0] = new EalDbParameter("@StreetAuthCode", StreetAuthCode);
                param_list[1] = new EalDbParameter("@StreetName", StreetName);
                param_list[2] = new EalDbParameter("@StartAddress", StartAddress);
                param_list[3] = new EalDbParameter("@EndAddress", EndAddress);
                param_list[4] = new EalDbParameter("@StreetDirection", StreetDirection);
                param_list[5] = new EalDbParameter("@StreetSide", StreetSide);
                param_list[6] = new EalDbParameter("@SegmentDesc", SegmentDesc);
                param_list[7] = new EalDbParameter("@PageID", PageID);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Street_Page_Link", param_list);

                // Return the value
                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Street_Page_Link", ee);
                return false;
            }
        }
        private static bool Save_Region_Item_Link(int ItemID, string GeoAuthCode, string Name, string Type, string P_Code, string P_Name, string P_Type, string P2_Code, string P2_Name, string P2_Type, string P3_Code, string P3_Name, string P3_Type, string P4_Code, string P4_Name, string P4_Type, string P5_Code, string P5_Name, string P5_Type)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[19];
                param_list[0] = new EalDbParameter("@GeoAuthCode", GeoAuthCode);
                param_list[1] = new EalDbParameter("@ItemID", ItemID);
                param_list[2] = new EalDbParameter("@RegionName", Name);
                param_list[3] = new EalDbParameter("@RegionType", Type);
                param_list[4] = new EalDbParameter("@P_RegionAuthCode", P_Code);
                param_list[5] = new EalDbParameter("@P_RegionName", P_Name);
                param_list[6] = new EalDbParameter("@P_RegionType", P_Type);
                param_list[7] = new EalDbParameter("@P2_RegionAuthCode", P2_Code);
                param_list[8] = new EalDbParameter("@P2_RegionName", P2_Name);
                param_list[9] = new EalDbParameter("@P2_RegionType", P2_Type);
                param_list[10] = new EalDbParameter("@P3_RegionAuthCode", P3_Code);
                param_list[11] = new EalDbParameter("@P3_RegionName", P3_Name);
                param_list[12] = new EalDbParameter("@P3_RegionType", P3_Type);
                param_list[13] = new EalDbParameter("@P4_RegionAuthCode", P4_Code);
                param_list[14] = new EalDbParameter("@P4_RegionName", P4_Name);
                param_list[15] = new EalDbParameter("@P4_RegionType", P4_Type);
                param_list[16] = new EalDbParameter("@P5_RegionAuthCode", P5_Code);
                param_list[17] = new EalDbParameter("@P5_RegionName", P5_Name);
                param_list[18] = new EalDbParameter("@P5_RegionType", P5_Type);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Save_Region_Item_Link", param_list);

                // Return the value
                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Save_Region_Item_Link", ee);
                return false;
            }
        }
        /// <summary> Mass updates the behaviors for all items within a single item group </summary>
        /// <param name="GroupID">GroupID for the item group to mass update all item behaviors for </param>
        /// <param name="IP_Restriction_Mask">IP Restriction mask for this item </param>
        /// <param name="CheckoutRequired"> Flag indicates if this is a single-use item which requires checkout</param>
        /// <param name="AggregationCode1"> Code for the first aggregation this item belongs to </param>
        /// <param name="AggregationCode2"> Code for the second aggregation this item belongs to </param>
        /// <param name="AggregationCode3"> Code for the third aggregation this item belongs to </param>
        /// <param name="AggregationCode4"> Code for the fourth aggregation this item belongs to </param>
        /// <param name="AggregationCode5"> Code for the fifth aggregation this item belongs to </param>
        /// <param name="AggregationCode6"> Code for the sixth aggregation this item belongs to </param>
        /// <param name="AggregationCode7"> Code for the seventh aggregation this item belongs to </param>
        /// <param name="AggregationCode8"> Code for the eighth aggregation this item belongs to </param>
        /// <param name="HoldingCode"> Holding code for this item's holding location aggregation </param>
        /// <param name="SourceCode"> Source location code for this item's source location </param>
        /// <param name="Icon1_Name">Name of the first icon</param>
        /// <param name="Icon2_Name">Name of the second icon</param>
        /// <param name="Icon3_Name">Name of the third icon</param>
        /// <param name="Icon4_Name">Name of the fourth icon</param>
        /// <param name="Icon5_Name">Name of the fifth icon</param>
        /// <param name="Viewer1_Type"> Primary key for the first viewer type in the SobekCM database </param>
        /// <param name="Viewer1_Label"> Label to be displayed for the first viewer of this item </param>
        /// <param name="Viewer1_Attributes"> Optional attributes for the first viewer of this item </param>
        /// <param name="Viewer2_Type"> Primary key for the second viewer type in the SobekCM database </param>
        /// <param name="Viewer2_Label"> Label to be displayed for the second viewer of this item </param>
        /// <param name="Viewer2_Attributes"> Optional attributes for the second viewer of this item </param>
        /// <param name="Viewer3_Type"> Primary key for the third viewer type in the SobekCM database </param>
        /// <param name="Viewer3_Label"> Label to be displayed for the third viewer of this item </param>
        /// <param name="Viewer3_Attributes"> Optional attributes for the third viewer of this item </param>
        /// <param name="Viewer4_Type"> Primary key for the fourth viewer type in the SobekCM database </param>
        /// <param name="Viewer4_Label"> Label to be displayed for the fourth viewer of this item </param>
        /// <param name="Viewer4_Attributes"> Optional attributes for the fourth viewer of this item </param>
        /// <param name="Viewer5_Type"> Primary key for the fifth viewer type in the SobekCM database </param>
        /// <param name="Viewer5_Label"> Label to be displayed for the fifth viewer of this item </param>
        /// <param name="Viewer5_Attributes"> Optional attributes for the fifth viewer of this item </param>
        /// <param name="Viewer6_Type"> Primary key for the sixth viewer type in the SobekCM database </param>
        /// <param name="Viewer6_Label"> Label to be displayed for the sixth viewer of this item </param>
        /// <param name="Viewer6_Attributes"> Optional attributes for the sixth viewer of this item </param>
        /// <param name="Born_Digital"> Flag indicates this item was born digitally, rather than scanned in-house</param>
        /// <param name="Dark_Flag"> Flag indicates this item is permanently DARK and can not be made public without first un-darking the item </param>
        /// <param name="Set_Born_Digital"> Flag indicates whether the born digital flag should be set for all items in this title </param>
        /// <param name="Set_CheckoutRequired"> Flag indicates whether the checkout required flag should be set for all items in this title </param>
        /// <param name="Set_Dark_Flag"> Flag indicates if the dark flag should be set for all items in this title </param>
        /// <param name="Set_IP_Restriction_Mask"> Flag indicates if the IP restriction mask should be set for all items in this title </param>
        /// <remarks> This method calls the stored procedure 'SobekCM_Mass_Update_Item_Behaviors2'. </remarks>
        /// <exception cref="SobekCM_Database_Exception"> Exception is thrown if an error is caught during 
        /// the database work and the THROW_EXCEPTIONS internal flag is set to true. </exception>
        protected static bool Mass_Update_Item_Behaviors(int GroupID, bool Set_IP_Restriction_Mask, short IP_Restriction_Mask,
            bool Set_CheckoutRequired, bool CheckoutRequired, bool Set_Dark_Flag, bool Dark_Flag,
            bool Set_Born_Digital, bool Born_Digital, string AggregationCode1, string AggregationCode2,
            string AggregationCode3, string AggregationCode4, string AggregationCode5, string AggregationCode6,
            string AggregationCode7, string AggregationCode8, string HoldingCode, string SourceCode,
            string Icon1_Name, string Icon2_Name, string Icon3_Name, string Icon4_Name, string Icon5_Name,
            int Viewer1_Type, string Viewer1_Label, string Viewer1_Attributes, int Viewer2_Type, string Viewer2_Label, string Viewer2_Attributes,
            int Viewer3_Type, string Viewer3_Label, string Viewer3_Attributes, int Viewer4_Type, string Viewer4_Label, string Viewer4_Attributes,
            int Viewer5_Type, string Viewer5_Label, string Viewer5_Attributes, int Viewer6_Type, string Viewer6_Label, string Viewer6_Attributes)
        {
            try
            {
                // Build the parameter list
                EalDbParameter[] param_list = new EalDbParameter[38];
                param_list[0] = new EalDbParameter("@GroupID", GroupID);

                if (Set_IP_Restriction_Mask)
                    param_list[1] = new EalDbParameter("@IP_Restriction_Mask", IP_Restriction_Mask);
                else
                    param_list[1] = new EalDbParameter("@IP_Restriction_Mask", DBNull.Value);

                if (Set_CheckoutRequired)
                    param_list[2] = new EalDbParameter("@CheckoutRequired", CheckoutRequired);
                else
                    param_list[2] = new EalDbParameter("@CheckoutRequired", DBNull.Value);

                if (Set_Dark_Flag)
                    param_list[3] = new EalDbParameter("@Dark_Flag", Dark_Flag);
                else
                    param_list[3] = new EalDbParameter("@Dark_Flag", DBNull.Value);

                if (Set_Born_Digital)
                    param_list[4] = new EalDbParameter("@Born_Digital", Born_Digital);
                else
                    param_list[4] = new EalDbParameter("@Born_Digital", DBNull.Value);

                param_list[5] = new EalDbParameter("@AggregationCode1", AggregationCode1);
                param_list[6] = new EalDbParameter("@AggregationCode2", AggregationCode2);
                param_list[7] = new EalDbParameter("@AggregationCode3", AggregationCode3);
                param_list[8] = new EalDbParameter("@AggregationCode4", AggregationCode4);
                param_list[9] = new EalDbParameter("@AggregationCode5", AggregationCode5);
                param_list[10] = new EalDbParameter("@AggregationCode6", AggregationCode6);
                param_list[11] = new EalDbParameter("@AggregationCode7", AggregationCode7);
                param_list[12] = new EalDbParameter("@AggregationCode8", AggregationCode8);
                param_list[13] = new EalDbParameter("@HoldingCode", HoldingCode);
                param_list[14] = new EalDbParameter("@SourceCode", SourceCode);
                param_list[15] = new EalDbParameter("@Icon1_Name", Icon1_Name);
                param_list[16] = new EalDbParameter("@Icon2_Name", Icon2_Name);
                param_list[17] = new EalDbParameter("@Icon3_Name", Icon3_Name);
                param_list[18] = new EalDbParameter("@Icon4_Name", Icon4_Name);
                param_list[19] = new EalDbParameter("@Icon5_Name", Icon5_Name);
                param_list[20] = new EalDbParameter("@Viewer1_TypeID", Viewer1_Type);
                param_list[21] = new EalDbParameter("@Viewer1_Label", Viewer1_Label);
                param_list[22] = new EalDbParameter("@Viewer1_Attribute", Viewer1_Attributes);
                param_list[23] = new EalDbParameter("@Viewer2_TypeID", Viewer2_Type);
                param_list[24] = new EalDbParameter("@Viewer2_Label", Viewer2_Label);
                param_list[25] = new EalDbParameter("@Viewer2_Attribute", Viewer2_Attributes);
                param_list[26] = new EalDbParameter("@Viewer3_TypeID", Viewer3_Type);
                param_list[27] = new EalDbParameter("@Viewer3_Label", Viewer3_Label);
                param_list[28] = new EalDbParameter("@Viewer3_Attribute", Viewer3_Attributes);
                param_list[29] = new EalDbParameter("@Viewer4_TypeID", Viewer4_Type);
                param_list[30] = new EalDbParameter("@Viewer4_Label", Viewer4_Label);
                param_list[31] = new EalDbParameter("@Viewer4_Attribute", Viewer4_Attributes);
                param_list[32] = new EalDbParameter("@Viewer5_TypeID", Viewer5_Type);
                param_list[33] = new EalDbParameter("@Viewer5_Label", Viewer5_Label);
                param_list[34] = new EalDbParameter("@Viewer5_Attribute", Viewer5_Attributes);
                param_list[35] = new EalDbParameter("@Viewer6_TypeID", Viewer6_Type);
                param_list[36] = new EalDbParameter("@Viewer6_Label", Viewer6_Label);
                param_list[37] = new EalDbParameter("@Viewer6_Attribute", Viewer6_Attributes);

                // Execute this non-query stored procedure
                EalDbAccess.ExecuteNonQuery(DatabaseType, connectionString, CommandType.StoredProcedure, "SobekCM_Mass_Update_Item_Behaviors", param_list);

                return true;
            }
            catch (Exception ee)
            {
                // Pass this exception onto the method to handle it
                exception_caught("SobekCM_Mass_Update_Item_Behaviors2", ee);
                return false;
            }
        }