예제 #1
0
        /// <summary>Inserts a ProposedOrderTree record using Metadata Parameters.</summary>
        /// <param name="parameters">Contains the metadata parameters.</param>
        public static void Archive(ParameterList parameters)
        {
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction = parameters["adoTransaction"];
            SqlTransaction sqlTransaction = parameters["sqlTransaction"];
            long           rowVersion     = parameters["rowVersion"];
            int            parentId       = parameters["parentId"];
            int            childId        = parameters["childId"];

            // Call the internal method to complete the operation.
            ProposedOrderTree.Archive(adoTransaction, sqlTransaction, rowVersion, parentId, childId);
        }
예제 #2
0
        /// <summary>Inserts a ProposedOrderTree record using Metadata Parameters.</summary>
        /// <param name="parameters">Contains the metadata parameters.</param>
        public static void Insert(ParameterList parameters)
        {
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction = parameters["adoTransaction"];
            SqlTransaction sqlTransaction = parameters["sqlTransaction"];
            int            parentId       = parameters["parentId"];
            int            childId        = parameters["childId"];
            // The rowVersion is passed back to the caller in the event it's needed for additional commands in the batch.
            long rowVersion = long.MinValue;

            // Call the internal method to complete the operation.
            ProposedOrderTree.Insert(adoTransaction, sqlTransaction, ref rowVersion, parentId, childId);
            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
예제 #3
0
        /// <summary>Archives a ProposedOrder 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="proposedOrderId">The value for the ProposedOrderId 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 proposedOrderId)
        {
            // Accessor for the ProposedOrder Table.
            ServerDataModel.ProposedOrderDataTable proposedOrderTable = ServerDataModel.ProposedOrder;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.ProposedOrderRow proposedOrderRow = proposedOrderTable.FindByProposedOrderId(proposedOrderId);
            if ((proposedOrderRow == null))
            {
                throw new Exception(string.Format("The ProposedOrder table does not have an element identified by {0}", proposedOrderId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((proposedOrderRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < proposedOrderRow.GetProposedOrderTreeRowsByFKProposedOrderProposedOrderTreeChildId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderTreeRow childProposedOrderTreeRow = proposedOrderRow.GetProposedOrderTreeRowsByFKProposedOrderProposedOrderTreeChildId()[index];
                ProposedOrderTree.Archive(adoTransaction, sqlTransaction, childProposedOrderTreeRow.RowVersion, childProposedOrderTreeRow.ParentId, childProposedOrderTreeRow.ChildId);
            }
            for (int index = 0; (index < proposedOrderRow.GetProposedOrderTreeRowsByFKProposedOrderProposedOrderTreeParentId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderTreeRow childProposedOrderTreeRow = proposedOrderRow.GetProposedOrderTreeRowsByFKProposedOrderProposedOrderTreeParentId()[index];
                ProposedOrderTree.Archive(adoTransaction, sqlTransaction, childProposedOrderTreeRow.RowVersion, childProposedOrderTreeRow.ParentId, childProposedOrderTreeRow.ChildId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            proposedOrderRow[proposedOrderTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(proposedOrderRow);
            proposedOrderRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"ProposedOrder\" set \"IsArchived\" = 1 where \"ProposedOrderId\"=@proposedOrde" +
                                                   "rId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@proposedOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, proposedOrderId));
            sqlCommand.ExecuteNonQuery();
        }
예제 #4
0
 /// <summary>Collects the table lock request(s) for an Update operation</summary>
 /// <param name="adoTransaction">A list of locks required for this operation.</param>
 public static void Archive(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Archive' operation.
     adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.ProposedOrder));
     ProposedOrderTree.Archive(adoTransaction);
 }