/// <summary>Collects the table lock request(s) for an Insert operation</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit</param> public static void Insert(Transaction transaction) { // These methods are called during the processing of this operation. Shadows.WebService.Core.Order.Insert(transaction); BlockOrder.Open(transaction); // Additionally, these tables are required to look up the default blotter. transaction.Locks.AddReaderLock(ServerMarketData.BlotterMapLock); transaction.Locks.AddReaderLock(ServerMarketData.SecurityLock); }
/// <summary>Opens a BlockOrder record using Metadata Parameters.</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit.</param> /// <param name="remoteMethod">Contains the metadata parameters and exceptions for this command.</param> public static void Open(Transaction transaction, RemoteMethod remoteMethod) { try { // Extract the parameters from the command batch. int blotterId = remoteMethod.Parameters.GetRequiredInt32("blotterId"); object accountId = remoteMethod.Parameters.GetOptionalInt32("accountId"); int securityId = remoteMethod.Parameters.GetRequiredInt32("securityId"); int settlementId = remoteMethod.Parameters.GetRequiredInt32("settlementId"); object brokerId = remoteMethod.Parameters.GetOptionalInt32("brokerId"); int transactionTypeCode = remoteMethod.Parameters.GetRequiredInt32("transactionTypeCode"); object timeInForceCode = remoteMethod.Parameters.GetOptionalInt32("timeInForceCode"); object orderTypeCode = remoteMethod.Parameters.GetOptionalInt32("orderTypeCode"); object conditionCode = remoteMethod.Parameters.GetOptionalInt32("conditionCode"); object isAgency = remoteMethod.Parameters.GetOptionalBoolean("isAgency"); object price1 = remoteMethod.Parameters.GetOptionalDecimal("price1"); object price2 = remoteMethod.Parameters.GetOptionalDecimal("price2"); // Make sure the parameters were parsed correctly before calling the internal method. This will prevent the method // from being called with bad data, but provides for error checking on all the parameters. if ((remoteMethod.HasExceptions == false)) { // 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 blockOrderId = BlockOrder.Open(transaction, blotterId, accountId, securityId, settlementId, brokerId, transactionTypeCode, timeInForceCode, orderTypeCode, conditionCode, ref rowVersion, isAgency, price1, price2); // Return values. remoteMethod.Parameters.ReturnValue("rowVersion", rowVersion); remoteMethod.Parameters.ReturnValue(blockOrderId); } } catch (SqlException sqlException) { // Every exception from the SQL server call is packed into the 'RemoteMethod' structure and returned to the caller. for (IEnumerator iEnumerator = sqlException.Errors.GetEnumerator(); iEnumerator.MoveNext(); remoteMethod.Exceptions.Add(((SqlError)(iEnumerator.Current)).Message)) { } } catch (Exception exception) { // This will pass the general exception back to the caller. remoteMethod.Exceptions.Add(exception); } }