Beispiel #1
0
        /// <summary>Inserts a BlockOrderTree record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="parentId">The value for the ParentId column.</param>
        /// <param name="childId">The value for the ChildId column.</param>
        public static void Insert(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int parentId, int childId)
        {
            // Accessor for the BlockOrderTree Table.
            ServerDataModel.BlockOrderTreeDataTable blockOrderTreeTable = ServerDataModel.BlockOrderTree;
            // Apply Defaults
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.BlockOrderTreeRow blockOrderTreeRow = blockOrderTreeTable.NewBlockOrderTreeRow();
            blockOrderTreeRow[blockOrderTreeTable.RowVersionColumn] = rowVersion;
            blockOrderTreeRow[blockOrderTreeTable.ParentIdColumn]   = parentId;
            blockOrderTreeRow[blockOrderTreeTable.ChildIdColumn]    = childId;
            blockOrderTreeTable.AddBlockOrderTreeRow(blockOrderTreeRow);
            adoTransaction.DataRows.Add(blockOrderTreeRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand("insert \"BlockOrderTree\" (\"rowVersion\",\"ParentId\",\"ChildId\") values (@rowVersion,@" +
                                                   "parentId,@childId)");

            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("@parentId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, parentId));
            sqlCommand.Parameters.Add(new SqlParameter("@childId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, childId));
            sqlCommand.ExecuteNonQuery();
        }
Beispiel #2
0
        /// <summary>Archives a BlockOrderTree 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="parentId">The value for the ParentId column.</param>
        /// <param name="childId">The value for the ChildId 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 parentId, int childId)
        {
            // Accessor for the BlockOrderTree Table.
            ServerDataModel.BlockOrderTreeDataTable blockOrderTreeTable = ServerDataModel.BlockOrderTree;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.BlockOrderTreeRow blockOrderTreeRow = blockOrderTreeTable.FindByParentIdChildId(parentId, childId);
            if ((blockOrderTreeRow == null))
            {
                throw new Exception(string.Format("The BlockOrderTree table does not have an element identified by {0}{0}", parentId, childId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((blockOrderTreeRow.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.
            blockOrderTreeRow[blockOrderTreeTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(blockOrderTreeRow);
            blockOrderTreeRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"BlockOrderTree\" set \"IsArchived\" = 1 where \"ParentId\"=@parentId and \"Chil" +
                                                   "dId\"=@childId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@parentId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, parentId));
            sqlCommand.Parameters.Add(new SqlParameter("@childId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, childId));
            sqlCommand.ExecuteNonQuery();
        }
Beispiel #3
0
 /// <summary>Archives a BlockOrder 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="blockOrderId">The value for the BlockOrderId 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 blockOrderId)
 {
     // Accessor for the BlockOrder Table.
     ServerDataModel.BlockOrderDataTable blockOrderTable = ServerDataModel.BlockOrder;
     // Rule #1: Make sure the record exists before updating it.
     ServerDataModel.BlockOrderRow blockOrderRow = blockOrderTable.FindByBlockOrderId(blockOrderId);
     if ((blockOrderRow == null))
     {
         throw new Exception(string.Format("The BlockOrder table does not have an element identified by {0}", blockOrderId));
     }
     // Rule #2: Optimistic Concurrency Check
     if ((blockOrderRow.RowVersion != rowVersion))
     {
         throw new System.Exception("This record is busy.  Please try again later.");
     }
     // Archive the child records.
     for (int index = 0; (index < blockOrderRow.GetAllocationRows().Length); index = (index + 1))
     {
         ServerDataModel.AllocationRow childAllocationRow = blockOrderRow.GetAllocationRows()[index];
         Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
     }
     for (int index = 0; (index < blockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeChildId().Length); index = (index + 1))
     {
         ServerDataModel.BlockOrderTreeRow childBlockOrderTreeRow = blockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeChildId()[index];
         BlockOrderTree.Archive(adoTransaction, sqlTransaction, childBlockOrderTreeRow.RowVersion, childBlockOrderTreeRow.ParentId, childBlockOrderTreeRow.ChildId);
     }
     for (int index = 0; (index < blockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeParentId().Length); index = (index + 1))
     {
         ServerDataModel.BlockOrderTreeRow childBlockOrderTreeRow = blockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeParentId()[index];
         BlockOrderTree.Archive(adoTransaction, sqlTransaction, childBlockOrderTreeRow.RowVersion, childBlockOrderTreeRow.ParentId, childBlockOrderTreeRow.ChildId);
     }
     for (int index = 0; (index < blockOrderRow.GetExecutionRows().Length); index = (index + 1))
     {
         ServerDataModel.ExecutionRow childExecutionRow = blockOrderRow.GetExecutionRows()[index];
         Execution.Archive(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
     }
     for (int index = 0; (index < blockOrderRow.GetOrderRows().Length); index = (index + 1))
     {
         ServerDataModel.OrderRow childOrderRow = blockOrderRow.GetOrderRows()[index];
         Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
     }
     for (int index = 0; (index < blockOrderRow.GetPlacementRows().Length); index = (index + 1))
     {
         ServerDataModel.PlacementRow childPlacementRow = blockOrderRow.GetPlacementRows()[index];
         Placement.Archive(adoTransaction, sqlTransaction, childPlacementRow.RowVersion, childPlacementRow.PlacementId);
     }
     // Increment the row version
     rowVersion = ServerDataModel.RowVersion.Increment();
     // Delete the record in the ADO database.
     blockOrderRow[blockOrderTable.RowVersionColumn] = rowVersion;
     adoTransaction.DataRows.Add(blockOrderRow);
     blockOrderRow.Delete();
     // Archive the record in the SQL database.
     SqlCommand sqlCommand = new SqlCommand("update \"BlockOrder\" set \"IsArchived\" = 1 where \"BlockOrderId\"=@blockOrderId");
     sqlCommand.Connection = sqlTransaction.Connection;
     sqlCommand.Transaction = sqlTransaction;
     sqlCommand.Parameters.Add(new SqlParameter("@blockOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blockOrderId));
     sqlCommand.ExecuteNonQuery();
 }