Exemple #1
0
        /// <summary>Inserts a Configuration record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="configurationId">The value for the ConfigurationId column.</param>
        /// <param name="parameterId">The value for the ParameterId column.</param>
        /// <param name="columnIndex">The value for the ColumnIndex column.</param>
        public static void Insert(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, string configurationId, string parameterId, int columnIndex)
        {
            // Accessor for the Configuration Table.
            ServerDataModel.ConfigurationDataTable configurationTable = ServerDataModel.Configuration;
            // Apply Defaults
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.ConfigurationRow configurationRow = configurationTable.NewConfigurationRow();
            configurationRow[configurationTable.RowVersionColumn]      = rowVersion;
            configurationRow[configurationTable.ConfigurationIdColumn] = configurationId;
            configurationRow[configurationTable.ParameterIdColumn]     = parameterId;
            configurationRow[configurationTable.ColumnIndexColumn]     = columnIndex;
            configurationTable.AddConfigurationRow(configurationRow);
            adoTransaction.DataRows.Add(configurationRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand("insert \"Configuration\" (\"rowVersion\",\"ConfigurationId\",\"ParameterId\",\"ColumnIndex" +
                                                   "\") values (@rowVersion,@configurationId,@parameterId,@columnIndex)");

            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("@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.Parameters.Add(new SqlParameter("@columnIndex", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, columnIndex));
            sqlCommand.ExecuteNonQuery();
        }
Exemple #2
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();
        }
Exemple #3
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;
 }
Exemple #4
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);
 }
Exemple #5
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;
 }