/// <summary>Updates a TraderVolumeSetting 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 TraderVolumeSetting Table. ServerMarketData.TraderVolumeSettingDataTable traderVolumeSettingTable = ServerMarketData.TraderVolumeSetting; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; object configurationId = parameters["configurationId"].Value; object autoExecuteQuantity = parameters["autoExecuteQuantity"].Value; object thresholdQuantity = parameters["thresholdQuantity"].Value; string externalTraderVolumeSettingId = ((string)(parameters["traderVolumeSettingId"])); object externalTraderId = parameters["traderId"].Value; object externalVolumeCategoryId = parameters["volumeCategoryId"].Value; // The row versioning is largely disabled for external operations. long rowVersion = long.MinValue; // Resolve External Identifiers int traderVolumeSettingId = TraderVolumeSetting.FindRequiredKey(configurationId, "traderVolumeSettingId", externalTraderVolumeSettingId); object traderId = Trader.FindOptionalKey(configurationId, "traderId", externalTraderId); object volumeCategoryId = VolumeCategory.FindOptionalKey(configurationId, "volumeCategoryId", externalVolumeCategoryId); // 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. ServerMarketData.TraderVolumeSettingRow traderVolumeSettingRow = traderVolumeSettingTable.FindByTraderVolumeSettingId(traderVolumeSettingId); rowVersion = ((long)(traderVolumeSettingRow[traderVolumeSettingTable.RowVersionColumn])); // Call the internal method to complete the operation. MarkThree.Guardian.Core.TraderVolumeSetting.Update(adoTransaction, sqlTransaction, ref rowVersion, null, autoExecuteQuantity, thresholdQuantity, traderVolumeSettingId, traderId, volumeCategoryId); // Return values. parameters["rowVersion"] = rowVersion; }
/// <summary>Archives a TraderVolumeSetting 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="traderVolumeSettingId">The value for the TraderVolumeSettingId 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 traderVolumeSettingId) { // Accessor for the TraderVolumeSetting Table. ServerMarketData.TraderVolumeSettingDataTable traderVolumeSettingTable = ServerMarketData.TraderVolumeSetting; // Rule #1: Make sure the record exists before updating it. ServerMarketData.TraderVolumeSettingRow traderVolumeSettingRow = traderVolumeSettingTable.FindByTraderVolumeSettingId(traderVolumeSettingId); if ((traderVolumeSettingRow == null)) { throw new Exception(string.Format("The TraderVolumeSetting table does not have an element identified by {0}", traderVolumeSettingId)); } // Rule #2: Optimistic Concurrency Check if ((traderVolumeSettingRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Archive the child records. // Increment the row version rowVersion = ServerMarketData.RowVersion.Increment(); // Delete the record in the ADO database. traderVolumeSettingRow[traderVolumeSettingTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(traderVolumeSettingRow); traderVolumeSettingRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"TraderVolumeSetting\" set \"IsArchived\" = 1 where \"TraderVolumeSettingId\"=@" + "traderVolumeSettingId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@traderVolumeSettingId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, traderVolumeSettingId)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Loads a TraderVolumeSetting 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 TraderVolumeSetting Table. ServerMarketData.TraderVolumeSettingDataTable traderVolumeSettingTable = ServerMarketData.TraderVolumeSetting; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; object configurationId = parameters["configurationId"].Value; object externalId0 = parameters["externalId0"].Value; decimal autoExecuteQuantity = parameters["autoExecuteQuantity"]; decimal thresholdQuantity = parameters["thresholdQuantity"]; object externalTraderVolumeSettingId = parameters["traderVolumeSettingId"].Value; string externalTraderId = parameters["traderId"]; string externalVolumeCategoryId = parameters["volumeCategoryId"]; // The row versioning is largely disabled for external operations. The value is returned to the caller in the // event it's needed for operations within the batch. long rowVersion = long.MinValue; // Resolve External Identifiers int traderVolumeSettingId = TraderVolumeSetting.FindKey(configurationId, "traderVolumeSettingId", externalTraderVolumeSettingId); int traderId = Trader.FindRequiredKey(configurationId, "traderId", externalTraderId); int volumeCategoryId = VolumeCategory.FindRequiredKey(configurationId, "volumeCategoryId", externalVolumeCategoryId); // The load operation will create a record if it doesn't exist, or update an existing record. The external // identifier is used to determine if a record exists with the same key. if ((traderVolumeSettingId == int.MinValue)) { // Populate the 'externalId' varaibles so that the external identifier can be used to find the row when an // external method is called with the same 'configurationId' parameter. int externalKeyIndex = TraderVolumeSetting.GetExternalKeyIndex(configurationId, "traderVolumeSettingId"); object[] externalIdArray = new object[1]; externalIdArray[externalKeyIndex] = externalTraderVolumeSettingId; externalId0 = externalIdArray[0]; // Call the internal method to complete the operation. MarkThree.Guardian.Core.TraderVolumeSetting.Insert(adoTransaction, sqlTransaction, ref rowVersion, externalId0, autoExecuteQuantity, thresholdQuantity, traderId, volumeCategoryId); } else { // 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. ServerMarketData.TraderVolumeSettingRow traderVolumeSettingRow = traderVolumeSettingTable.FindByTraderVolumeSettingId(traderVolumeSettingId); rowVersion = ((long)(traderVolumeSettingRow[traderVolumeSettingTable.RowVersionColumn])); // Call the internal method to complete the operation. MarkThree.Guardian.Core.TraderVolumeSetting.Update(adoTransaction, sqlTransaction, ref rowVersion, externalId0, autoExecuteQuantity, thresholdQuantity, traderVolumeSettingId, traderId, volumeCategoryId); } // Return values. parameters["rowVersion"] = rowVersion; }
/// <summary>Archives a TraderVolumeSetting 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 TraderVolumeSetting Table. ServerMarketData.TraderVolumeSettingDataTable traderVolumeSettingTable = ServerMarketData.TraderVolumeSetting; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; object configurationId = parameters["configurationId"].Value; string externalTraderVolumeSettingId = parameters["traderVolumeSettingId"]; // The row versioning is largely disabled for external operations. long rowVersion = long.MinValue; // Find the internal identifier using the primar key elements. // identifier is used to determine if a record exists with the same key. int traderVolumeSettingId = TraderVolumeSetting.FindRequiredKey(configurationId, "traderVolumeSettingId", externalTraderVolumeSettingId); // 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. ServerMarketData.TraderVolumeSettingRow traderVolumeSettingRow = traderVolumeSettingTable.FindByTraderVolumeSettingId(traderVolumeSettingId); rowVersion = ((long)(traderVolumeSettingRow[traderVolumeSettingTable.RowVersionColumn])); // Call the internal method to complete the operation. MarkThree.Guardian.Core.TraderVolumeSetting.Archive(adoTransaction, sqlTransaction, rowVersion, traderVolumeSettingId); }
/// <summary>Updates a TraderVolumeSetting 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="externalId0">The value for the ExternalId0 column.</param> /// <param name="autoExecuteQuantity">The value for the AutoExecuteQuantity column.</param> /// <param name="thresholdQuantity">The value for the ThresholdQuantity column.</param> /// <param name="traderVolumeSettingId">The value for the TraderVolumeSettingId column.</param> /// <param name="traderId">The value for the TraderId column.</param> /// <param name="volumeCategoryId">The value for the VolumeCategoryId column.</param> public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, object externalId0, object autoExecuteQuantity, object thresholdQuantity, int traderVolumeSettingId, object traderId, object volumeCategoryId) { // Accessor for the TraderVolumeSetting Table. ServerMarketData.TraderVolumeSettingDataTable traderVolumeSettingTable = ServerMarketData.TraderVolumeSetting; // Rule #1: Make sure the record exists before updating it. ServerMarketData.TraderVolumeSettingRow traderVolumeSettingRow = traderVolumeSettingTable.FindByTraderVolumeSettingId(traderVolumeSettingId); if ((traderVolumeSettingRow == null)) { throw new Exception(string.Format("The TraderVolumeSetting table does not have an element identified by {0}", traderVolumeSettingId)); } // Rule #2: Optimistic Concurrency Check if ((traderVolumeSettingRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Apply Defaults if ((externalId0 == null)) { externalId0 = traderVolumeSettingRow[traderVolumeSettingTable.ExternalId0Column]; } if ((autoExecuteQuantity == null)) { autoExecuteQuantity = traderVolumeSettingRow[traderVolumeSettingTable.AutoExecuteQuantityColumn]; } if ((thresholdQuantity == null)) { thresholdQuantity = traderVolumeSettingRow[traderVolumeSettingTable.ThresholdQuantityColumn]; } if ((traderId == null)) { traderId = traderVolumeSettingRow[traderVolumeSettingTable.TraderIdColumn]; } if ((volumeCategoryId == null)) { volumeCategoryId = traderVolumeSettingRow[traderVolumeSettingTable.VolumeCategoryIdColumn]; } // Increment the row version rowVersion = ServerMarketData.RowVersion.Increment(); // Update the record in the ADO database. traderVolumeSettingRow[traderVolumeSettingTable.RowVersionColumn] = rowVersion; traderVolumeSettingRow[traderVolumeSettingTable.ExternalId0Column] = externalId0; traderVolumeSettingRow[traderVolumeSettingTable.AutoExecuteQuantityColumn] = autoExecuteQuantity; traderVolumeSettingRow[traderVolumeSettingTable.ThresholdQuantityColumn] = thresholdQuantity; traderVolumeSettingRow[traderVolumeSettingTable.TraderIdColumn] = traderId; traderVolumeSettingRow[traderVolumeSettingTable.VolumeCategoryIdColumn] = volumeCategoryId; adoTransaction.DataRows.Add(traderVolumeSettingRow); // Update the record in the SQL database. SqlCommand sqlCommand = new SqlCommand(@"update ""TraderVolumeSetting"" set ""RowVersion""=@rowVersion,""ExternalId0""=@externalId0,""AutoExecuteQuantity""=@autoExecuteQuantity,""ThresholdQuantity""=@thresholdQuantity,""TraderId""=@traderId,""VolumeCategoryId""=@volumeCategoryId where ""TraderVolumeSettingId""=@traderVolumeSettingId"); 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("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0)); sqlCommand.Parameters.Add(new SqlParameter("@autoExecuteQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, autoExecuteQuantity)); sqlCommand.Parameters.Add(new SqlParameter("@thresholdQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, thresholdQuantity)); sqlCommand.Parameters.Add(new SqlParameter("@traderVolumeSettingId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, traderVolumeSettingId)); sqlCommand.Parameters.Add(new SqlParameter("@traderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, traderId)); sqlCommand.Parameters.Add(new SqlParameter("@volumeCategoryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, volumeCategoryId)); // Update the record in the SQL database. sqlCommand.ExecuteNonQuery(); }