Ejemplo n.º 1
0
 /// <summary>Loads a Type 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 Type Table.
     ServerDataModel.TypeDataTable typeTable = ServerDataModel.Type;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string description = parameters["description"];
     object externalId0 = parameters["externalId0"].Value;
     string specification = parameters["specification"];
     string typeCode = parameters["typeCode"];
     // 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.TypeRow typeRow = typeTable.FindByTypeCode(typeCode);
     if ((typeRow == null))
     {
         // Call the internal 'Insert' method to complete the operation.
         MarkThree.Quasar.Core.Type.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, specification, typeCode);
     }
     else
     {
         // This will bypass the optimistic concurrency checking required by the internal method.
         rowVersion = ((long)(typeRow[typeTable.RowVersionColumn]));
         // Call the internal 'Update' method to complete the operation.
         MarkThree.Quasar.Core.Type.Update(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, specification, typeCode);
     }
     // Return values
     parameters["rowVersion"] = rowVersion;
 }
Ejemplo n.º 2
0
        /// <summary>Inserts a Type record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="specification">The value for the Specification column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        public static void Insert(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, string description, object externalId0, string specification, string typeCode)
        {
            // Accessor for the Type Table.
            ServerDataModel.TypeDataTable typeTable = ServerDataModel.Type;
            // Apply Defaults
            if ((externalId0 == null))
            {
                externalId0 = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.TypeRow typeRow = typeTable.NewTypeRow();
            typeRow[typeTable.RowVersionColumn]    = rowVersion;
            typeRow[typeTable.DescriptionColumn]   = description;
            typeRow[typeTable.ExternalId0Column]   = externalId0;
            typeRow[typeTable.SpecificationColumn] = specification;
            typeRow[typeTable.TypeCodeColumn]      = typeCode;
            typeTable.AddTypeRow(typeRow);
            adoTransaction.DataRows.Add(typeRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand("insert \"Type\" (\"rowVersion\",\"Description\",\"ExternalId0\",\"Specification\",\"TypeCode" +
                                                   "\") values (@rowVersion,@description,@externalId0,@specification,@typeCode)");

            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("@description", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, description));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@specification", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, specification));
            sqlCommand.Parameters.Add(new SqlParameter("@typeCode", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, typeCode));
            sqlCommand.ExecuteNonQuery();
        }
Ejemplo n.º 3
0
        /// <summary>Archives a Type 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="typeCode">The value for the TypeCode 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 typeCode)
        {
            // Accessor for the Type Table.
            ServerDataModel.TypeDataTable typeTable = ServerDataModel.Type;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.TypeRow typeRow = typeTable.FindByTypeCode(typeCode);
            if ((typeRow == null))
            {
                throw new Exception(string.Format("The Type table does not have an element identified by {0}", typeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((typeRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < typeRow.GetObjectRows().Length); index = (index + 1))
            {
                ServerDataModel.ObjectRow childObjectRow = typeRow.GetObjectRows()[index];
                Object.Archive(adoTransaction, sqlTransaction, childObjectRow.RowVersion, childObjectRow.ObjectId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            typeRow[typeTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(typeRow);
            typeRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Type\" set \"IsArchived\" = 1 where \"TypeCode\"=@typeCode");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@typeCode", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, typeCode));
            sqlCommand.ExecuteNonQuery();
        }
Ejemplo n.º 4
0
        /// <summary>Updates a Type 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="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="specification">The value for the Specification column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, object description, object externalId0, object specification, string typeCode)
        {
            // Accessor for the Type Table.
            ServerDataModel.TypeDataTable typeTable = ServerDataModel.Type;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.TypeRow typeRow = typeTable.FindByTypeCode(typeCode);
            if ((typeRow == null))
            {
                throw new Exception(string.Format("The Type table does not have an element identified by {0}", typeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((typeRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((description == null))
            {
                description = typeRow[typeTable.DescriptionColumn];
            }
            if ((externalId0 == null))
            {
                externalId0 = typeRow[typeTable.ExternalId0Column];
            }
            if ((specification == null))
            {
                specification = typeRow[typeTable.SpecificationColumn];
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Update the record in the ADO database.
            typeRow[typeTable.RowVersionColumn]    = rowVersion;
            typeRow[typeTable.DescriptionColumn]   = description;
            typeRow[typeTable.ExternalId0Column]   = externalId0;
            typeRow[typeTable.SpecificationColumn] = specification;
            adoTransaction.DataRows.Add(typeRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Type\" set \"RowVersion\"=@rowVersion,\"Description\"=@description,\"ExternalId" +
                                                   "0\"=@externalId0,\"Specification\"=@specification where \"TypeCode\"=@typeCode");

            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("@description", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, description));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@specification", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, specification));
            sqlCommand.Parameters.Add(new SqlParameter("@typeCode", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, typeCode));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Ejemplo n.º 5
0
 /// <summary>Archives a Type 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 Type Table.
     ServerDataModel.TypeDataTable typeTable = ServerDataModel.Type;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string typeCode = parameters["typeCode"];
     // 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.TypeRow typeRow = typeTable.FindByTypeCode(typeCode);
     rowVersion = ((long)(typeRow[typeTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.Type.Archive(adoTransaction, sqlTransaction, rowVersion, typeCode);
 }
Ejemplo n.º 6
0
 /// <summary>Updates a Type 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 Type Table.
     ServerDataModel.TypeDataTable typeTable = ServerDataModel.Type;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object specification = parameters["specification"].Value;
     string externalTypeCode = parameters["typeCode"];
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     string typeCode = Type.FindRequiredKey(configurationId, "typeCode", externalTypeCode);
     // This will bypass the internal optimistic concurrency checking by providing the current rowVersion to the 
     // internal method.
     ServerDataModel.TypeRow typeRow = typeTable.FindByTypeCode(typeCode);
     rowVersion = ((long)(typeRow[typeTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.Type.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, specification, typeCode);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }