Exemplo n.º 1
0
        /// <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.
            ServerDataModel.ConfigurationDataTable configurationTable = ServerDataModel.Configuration;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.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 = ServerDataModel.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();
        }
Exemplo n.º 2
0
 /// <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.
     ServerDataModel.ConfigurationDataTable configurationTable = ServerDataModel.Configuration;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     string configurationId = parameters["configurationId"];
     string parameterId = parameters["parameterId"];
     int columnIndex = parameters["columnIndex"];
     // 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.
     ServerDataModel.ConfigurationRow configurationRow = configurationTable.FindByConfigurationIdParameterId(configurationId, parameterId);
     if ((configurationRow == null))
     {
         // Call the internal 'Insert' method to complete the operation.
         MarkThree.Quasar.Core.Configuration.Insert(adoTransaction, sqlTransaction, ref rowVersion, configurationId, parameterId, columnIndex);
     }
     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.Quasar.Core.Configuration.Update(adoTransaction, sqlTransaction, ref rowVersion, configurationId, parameterId, columnIndex);
     }
     // Return values
     parameters["rowVersion"] = rowVersion;
 }
Exemplo n.º 3
0
 /// <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.
     ServerDataModel.ConfigurationDataTable configurationTable = ServerDataModel.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.
     ServerDataModel.ConfigurationRow configurationRow = configurationTable.FindByConfigurationIdParameterId(configurationId, parameterId);
     rowVersion = ((long)(configurationRow[configurationTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.Configuration.Archive(adoTransaction, sqlTransaction, rowVersion, configurationId, parameterId);
 }
Exemplo n.º 4
0
 /// <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.
     ServerDataModel.ConfigurationDataTable configurationTable = ServerDataModel.Configuration;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     string configurationId = parameters["configurationId"];
     string parameterId = parameters["parameterId"];
     object columnIndex = parameters["columnIndex"].Value;
     // 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.
     ServerDataModel.ConfigurationRow configurationRow = configurationTable.FindByConfigurationIdParameterId(configurationId, parameterId);
     rowVersion = ((long)(configurationRow[configurationTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.Configuration.Update(adoTransaction, sqlTransaction, ref rowVersion, configurationId, parameterId, columnIndex);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }