Example #1
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.AddWriterLock(ServerMarketData.VolumeCategoryLock);
     Security.ArchiveChildren(adoTransaction);
     TraderVolumeSetting.Archive(adoTransaction);
 }
Example #2
0
        /// <summary>Inserts a TraderVolumeSetting 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            traderVolumeSettingId = parameters["traderVolumeSettingId"];

            // Call the internal method to complete the operation.
            TraderVolumeSetting.Archive(adoTransaction, sqlTransaction, rowVersion, traderVolumeSettingId);
        }
Example #3
0
        /// <summary>Inserts a TraderVolumeSetting record using Metadata Parameters.</summary>
        /// <param name="parameters">Contains the metadata parameters.</param>
        public static void Update(ParameterList parameters)
        {
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction        = parameters["adoTransaction"];
            SqlTransaction sqlTransaction        = parameters["sqlTransaction"];
            long           rowVersion            = parameters["rowVersion"];
            object         externalId0           = parameters["externalId0"].Value;
            object         autoExecuteQuantity   = parameters["autoExecuteQuantity"].Value;
            object         thresholdQuantity     = parameters["thresholdQuantity"].Value;
            int            traderVolumeSettingId = parameters["traderVolumeSettingId"];
            object         traderId         = parameters["traderId"].Value;
            object         volumeCategoryId = parameters["volumeCategoryId"].Value;

            // Call the internal method to complete the operation.
            TraderVolumeSetting.Update(adoTransaction, sqlTransaction, ref rowVersion, externalId0, autoExecuteQuantity, thresholdQuantity, traderVolumeSettingId, traderId, volumeCategoryId);
            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
Example #4
0
        /// <summary>Inserts a TraderVolumeSetting 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"];
            object         externalId0         = parameters["externalId0"].Value;
            decimal        autoExecuteQuantity = parameters["autoExecuteQuantity"];
            decimal        thresholdQuantity   = parameters["thresholdQuantity"];
            int            traderId            = parameters["traderId"];
            int            volumeCategoryId    = parameters["volumeCategoryId"];
            // 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.
            int traderVolumeSettingId = TraderVolumeSetting.Insert(adoTransaction, sqlTransaction, ref rowVersion, externalId0, autoExecuteQuantity, thresholdQuantity, traderId, volumeCategoryId);

            // Return values.
            parameters["rowVersion"] = rowVersion;
            parameters.Return        = traderVolumeSettingId;
        }
Example #5
0
        /// <summary>Archives a VolumeCategory 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="volumeCategoryId">The value for the VolumeCategoryId 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 volumeCategoryId)
        {
            // Accessor for the VolumeCategory Table.
            ServerMarketData.VolumeCategoryDataTable volumeCategoryTable = ServerMarketData.VolumeCategory;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.VolumeCategoryRow volumeCategoryRow = volumeCategoryTable.FindByVolumeCategoryId(volumeCategoryId);
            if ((volumeCategoryRow == null))
            {
                throw new Exception(string.Format("The VolumeCategory table does not have an element identified by {0}", volumeCategoryId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((volumeCategoryRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < volumeCategoryRow.GetSecurityRows().Length); index = (index + 1))
            {
                ServerMarketData.SecurityRow childSecurityRow = volumeCategoryRow.GetSecurityRows()[index];
                Security.ArchiveChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId);
            }
            for (int index = 0; (index < volumeCategoryRow.GetTraderVolumeSettingRows().Length); index = (index + 1))
            {
                ServerMarketData.TraderVolumeSettingRow childTraderVolumeSettingRow = volumeCategoryRow.GetTraderVolumeSettingRows()[index];
                TraderVolumeSetting.Archive(adoTransaction, sqlTransaction, childTraderVolumeSettingRow.RowVersion, childTraderVolumeSettingRow.TraderVolumeSettingId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            volumeCategoryRow[volumeCategoryTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(volumeCategoryRow);
            volumeCategoryRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"VolumeCategory\" set \"IsArchived\" = 1 where \"VolumeCategoryId\"=@volumeCate" +
                                                   "goryId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@volumeCategoryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, volumeCategoryId));
            sqlCommand.ExecuteNonQuery();
        }