Пример #1
0
        /// <summary>Inserts a Image record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="image">The value for the Image column.</param>
        public static int Insert(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, object externalId0, string image)
        {
            // Accessor for the Image Table.
            ServerMarketData.ImageDataTable imageTable = ServerMarketData.Image;
            // Apply Defaults
            if ((externalId0 == null))
            {
                externalId0 = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.ImageRow imageRow = imageTable.NewImageRow();
            imageRow[imageTable.RowVersionColumn]  = rowVersion;
            imageRow[imageTable.ExternalId0Column] = externalId0;
            imageRow[imageTable.ImageColumn]       = image;
            imageTable.AddImageRow(imageRow);
            adoTransaction.DataRows.Add(imageRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand("insert \"Image\" (\"rowVersion\",\"ExternalId0\",\"ImageId\",\"Image\") values (@rowVersion" +
                                                   ",@externalId0,@imageId,@image)");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@imageId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, imageRow[imageTable.ImageIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@image", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, image));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(imageRow.ImageId);
        }
Пример #2
0
        /// <summary>Archives a Image record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="RowVersion">The version number of this row.</param>
        /// <param name="imageId">The value for the ImageId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int imageId)
        {
            // Accessor for the Image Table.
            ServerMarketData.ImageDataTable imageTable = ServerMarketData.Image;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.ImageRow imageRow = imageTable.FindByImageId(imageId);
            if ((imageRow == null))
            {
                throw new Exception(string.Format("The Image table does not have an element identified by {0}", imageId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((imageRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            imageRow[imageTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(imageRow);
            imageRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Image\" set \"IsArchived\" = 1 where \"ImageId\"=@imageId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@imageId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, imageId));
            sqlCommand.ExecuteNonQuery();
        }
Пример #3
0
        /// <summary>Updates a Image record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of the row</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="imageId">The value for the ImageId column.</param>
        /// <param name="image">The value for the Image column.</param>
        public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, object externalId0, int imageId, object image)
        {
            // Accessor for the Image Table.
            ServerMarketData.ImageDataTable imageTable = ServerMarketData.Image;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.ImageRow imageRow = imageTable.FindByImageId(imageId);
            if ((imageRow == null))
            {
                throw new Exception(string.Format("The Image table does not have an element identified by {0}", imageId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((imageRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((externalId0 == null))
            {
                externalId0 = imageRow[imageTable.ExternalId0Column];
            }
            if ((image == null))
            {
                image = imageRow[imageTable.ImageColumn];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            imageRow[imageTable.RowVersionColumn]  = rowVersion;
            imageRow[imageTable.ExternalId0Column] = externalId0;
            imageRow[imageTable.ImageColumn]       = image;
            adoTransaction.DataRows.Add(imageRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Image\" set \"RowVersion\"=@rowVersion,\"ExternalId0\"=@externalId0,\"Image\"=@i" +
                                                   "mage where \"ImageId\"=@imageId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@imageId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, imageId));
            sqlCommand.Parameters.Add(new SqlParameter("@image", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, image));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Пример #4
0
 /// <summary>Loads a Image record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Load(ParameterList parameters)
 {
     // Accessor for the Image Table.
     ServerMarketData.ImageDataTable imageTable = ServerMarketData.Image;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object externalId0 = parameters["externalId0"].Value;
     object externalImageId = parameters["imageId"].Value;
     string image = parameters["image"];
     // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
     // event it's needed for operations within the batch.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     int imageId = Image.FindKey(configurationId, "imageId", externalImageId);
     // The load operation will create a record if it doesn't exist, or update an existing record.  The external
     // identifier is used to determine if a record exists with the same key.
     if ((imageId == int.MinValue))
     {
         // Populate the 'externalId' varaibles so that the external identifier can be used to find the row when an
         // external method is called with the same 'configurationId' parameter.
         int externalKeyIndex = Image.GetExternalKeyIndex(configurationId, "imageId");
         object[] externalIdArray = new object[1];
         externalIdArray[externalKeyIndex] = externalImageId;
         externalId0 = externalIdArray[0];
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Image.Insert(adoTransaction, sqlTransaction, ref rowVersion, externalId0, image);
     }
     else
     {
         // While the optimistic concurrency checking is disabled for the external methods, the internal methods
         // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
         // will bypass the coused when the internal method is called.
         ServerMarketData.ImageRow imageRow = imageTable.FindByImageId(imageId);
         rowVersion = ((long)(imageRow[imageTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Image.Update(adoTransaction, sqlTransaction, ref rowVersion, externalId0, imageId, image);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Пример #5
0
 /// <summary>Archives a Image record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Archive(ParameterList parameters)
 {
     // Accessor for the Image Table.
     ServerMarketData.ImageDataTable imageTable = ServerMarketData.Image;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalImageId = parameters["imageId"];
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Find the internal identifier using the primar key elements.
     // identifier is used to determine if a record exists with the same key.
     int imageId = Image.FindRequiredKey(configurationId, "imageId", externalImageId);
     // While the optimistic concurrency checking is disabled for the external methods, the internal methods
     // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
     // will bypass the coused when the internal method is called.
     ServerMarketData.ImageRow imageRow = imageTable.FindByImageId(imageId);
     rowVersion = ((long)(imageRow[imageTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Image.Archive(adoTransaction, sqlTransaction, rowVersion, imageId);
 }
Пример #6
0
 /// <summary>Updates a Image record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Update(ParameterList parameters)
 {
     // Accessor for the Image Table.
     ServerMarketData.ImageDataTable imageTable = ServerMarketData.Image;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalImageId = ((string)(parameters["imageId"]));
     object image = parameters["image"].Value;
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     int imageId = Image.FindRequiredKey(configurationId, "imageId", externalImageId);
     // While the optimistic concurrency checking is disabled for the external methods, the internal methods
     // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
     // will bypass the coused when the internal method is called.
     ServerMarketData.ImageRow imageRow = imageTable.FindByImageId(imageId);
     rowVersion = ((long)(imageRow[imageTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Image.Update(adoTransaction, sqlTransaction, ref rowVersion, null, imageId, image);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }