/// <summary>Archives a Configuration 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="configurationId">The value for the ConfigurationId column.</param> /// <param name="parameterId">The value for the ParameterId 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, string configurationId, string parameterId) { // Accessor for the Configuration Table. ServerMarketData.ConfigurationDataTable configurationTable = ServerMarketData.Configuration; // Rule #1: Make sure the record exists before updating it. ServerMarketData.ConfigurationRow configurationRow = configurationTable.FindByConfigurationIdParameterId(configurationId, parameterId); if ((configurationRow == null)) { throw new Exception(string.Format("The Configuration table does not have an element identified by {0}{0}", configurationId, parameterId)); } // Rule #2: Optimistic Concurrency Check if ((configurationRow.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. configurationRow[configurationTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(configurationRow); configurationRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Configuration\" set \"IsArchived\" = 1 where \"ConfigurationId\"=@configuratio" + "nId and \"ParameterId\"=@parameterId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@configurationId", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, configurationId)); sqlCommand.Parameters.Add(new SqlParameter("@parameterId", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, parameterId)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Loads a Configuration 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 Configuration Table. ServerMarketData.ConfigurationDataTable configurationTable = ServerMarketData.Configuration; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; int columnIndex = parameters["columnIndex"]; string configurationId = parameters["configurationId"]; string parameterId = parameters["parameterId"]; // The row versioning is largely disabled for external operations. long rowVersion = long.MinValue; // Find the record using the unique identifier. If it doesn't exist, it will be inserted, if it does exist, // it will be updated. ServerMarketData.ConfigurationRow configurationRow = configurationTable.FindByConfigurationIdParameterId(configurationId, parameterId); if ((configurationRow == null)) { // Call the internal 'Insert' method to complete the operation. MarkThree.Guardian.Core.Configuration.Insert(adoTransaction, sqlTransaction, ref rowVersion, columnIndex, configurationId, parameterId); } else { // This will bypass the optimistic concurrency checking required by the internal method. rowVersion = ((long)(configurationRow[configurationTable.RowVersionColumn])); // Call the internal 'Update' method to complete the operation. MarkThree.Guardian.Core.Configuration.Update(adoTransaction, sqlTransaction, ref rowVersion, columnIndex, configurationId, parameterId); } // Return values parameters["rowVersion"] = rowVersion; }
/// <summary>Archives a Configuration 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 Configuration Table. ServerMarketData.ConfigurationDataTable configurationTable = ServerMarketData.Configuration; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; string configurationId = parameters["configurationId"]; string parameterId = parameters["parameterId"]; // The row versioning is largely disabled for external operations. long rowVersion = long.MinValue; // 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.ConfigurationRow configurationRow = configurationTable.FindByConfigurationIdParameterId(configurationId, parameterId); rowVersion = ((long)(configurationRow[configurationTable.RowVersionColumn])); // Call the internal method to complete the operation. MarkThree.Guardian.Core.Configuration.Archive(adoTransaction, sqlTransaction, rowVersion, configurationId, parameterId); }
/// <summary>Updates a Configuration 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 Configuration Table. ServerMarketData.ConfigurationDataTable configurationTable = ServerMarketData.Configuration; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; object columnIndex = parameters["columnIndex"].Value; string configurationId = parameters["configurationId"]; string parameterId = parameters["parameterId"]; // The row versioning is largely disabled for external operations. long rowVersion = long.MinValue; // This will bypass the internal optimistic concurrency checking by providing the current rowVersion to the // internal method. ServerMarketData.ConfigurationRow configurationRow = configurationTable.FindByConfigurationIdParameterId(configurationId, parameterId); rowVersion = ((long)(configurationRow[configurationTable.RowVersionColumn])); // Call the internal method to complete the operation. MarkThree.Guardian.Core.Configuration.Update(adoTransaction, sqlTransaction, ref rowVersion, columnIndex, configurationId, parameterId); // Return values. parameters["rowVersion"] = rowVersion; }