Exemplo n.º 1
0
 /// <summary>Updates a BrokerAccount 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 BrokerAccount Table.
     ServerMarketData.BrokerAccountDataTable brokerAccountTable = ServerMarketData.BrokerAccount;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalBrokerAccountId = ((string)(parameters["brokerAccountId"]));
     object externalBrokerId = parameters["brokerId"].Value;
     object description = parameters["description"].Value;
     object mnemonic = parameters["mnemonic"].Value;
     object externalTraderId = parameters["traderId"].Value;
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     int brokerAccountId = BrokerAccount.FindRequiredKey(configurationId, "brokerAccountId", externalBrokerAccountId);
     object brokerId = Broker.FindOptionalKey(configurationId, "brokerId", externalBrokerId);
     object traderId = Trader.FindOptionalKey(configurationId, "traderId", externalTraderId);
     // 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.BrokerAccountRow brokerAccountRow = brokerAccountTable.FindByBrokerAccountId(brokerAccountId);
     rowVersion = ((long)(brokerAccountRow[brokerAccountTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.BrokerAccount.Update(adoTransaction, sqlTransaction, ref rowVersion, brokerAccountId, brokerId, description, null, null, null, null, mnemonic, traderId);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemplo n.º 2
0
        /// <summary>Inserts a BrokerAccount record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        /// <param name="externalId2">The value for the ExternalId2 column.</param>
        /// <param name="externalId3">The value for the ExternalId3 column.</param>
        /// <param name="mnemonic">The value for the Mnemonic column.</param>
        /// <param name="traderId">The value for the TraderId column.</param>
        public static int Insert(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int brokerId, string description, object externalId0, object externalId1, object externalId2, object externalId3, string mnemonic, int traderId)
        {
            // Accessor for the BrokerAccount Table.
            ServerMarketData.BrokerAccountDataTable brokerAccountTable = ServerMarketData.BrokerAccount;
            // Apply Defaults
            if ((externalId0 == null))
            {
                externalId0 = System.DBNull.Value;
            }
            if ((externalId1 == null))
            {
                externalId1 = System.DBNull.Value;
            }
            if ((externalId2 == null))
            {
                externalId2 = System.DBNull.Value;
            }
            if ((externalId3 == null))
            {
                externalId3 = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.BrokerAccountRow brokerAccountRow = brokerAccountTable.NewBrokerAccountRow();
            brokerAccountRow[brokerAccountTable.RowVersionColumn]  = rowVersion;
            brokerAccountRow[brokerAccountTable.BrokerIdColumn]    = brokerId;
            brokerAccountRow[brokerAccountTable.DescriptionColumn] = description;
            brokerAccountRow[brokerAccountTable.ExternalId0Column] = externalId0;
            brokerAccountRow[brokerAccountTable.ExternalId1Column] = externalId1;
            brokerAccountRow[brokerAccountTable.ExternalId2Column] = externalId2;
            brokerAccountRow[brokerAccountTable.ExternalId3Column] = externalId3;
            brokerAccountRow[brokerAccountTable.MnemonicColumn]    = mnemonic;
            brokerAccountRow[brokerAccountTable.TraderIdColumn]    = traderId;
            brokerAccountTable.AddBrokerAccountRow(brokerAccountRow);
            adoTransaction.DataRows.Add(brokerAccountRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""BrokerAccount"" (""rowVersion"",""BrokerAccountId"",""BrokerId"",""Description"",""ExternalId0"",""ExternalId1"",""ExternalId2"",""ExternalId3"",""Mnemonic"",""TraderId"") values (@rowVersion,@brokerAccountId,@brokerId,@description,@externalId0,@externalId1,@externalId2,@externalId3,@mnemonic,@traderId)");

            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("@brokerAccountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerAccountRow[brokerAccountTable.BrokerAccountIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@description", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, description));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId1", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId1));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId2", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId2));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId3", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId3));
            sqlCommand.Parameters.Add(new SqlParameter("@mnemonic", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, mnemonic));
            sqlCommand.Parameters.Add(new SqlParameter("@traderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, traderId));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(brokerAccountRow.BrokerAccountId);
        }
Exemplo n.º 3
0
 /// <summary>Loads a BrokerAccount 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 BrokerAccount Table.
     ServerMarketData.BrokerAccountDataTable brokerAccountTable = ServerMarketData.BrokerAccount;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object externalBrokerAccountId = parameters["brokerAccountId"].Value;
     string externalBrokerId = parameters["brokerId"];
     string description = parameters["description"];
     object externalId0 = parameters["externalId0"].Value;
     object externalId1 = parameters["externalId1"].Value;
     object externalId2 = parameters["externalId2"].Value;
     object externalId3 = parameters["externalId3"].Value;
     string mnemonic = parameters["mnemonic"];
     string externalTraderId = parameters["traderId"];
     // 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 brokerAccountId = BrokerAccount.FindKey(configurationId, "brokerAccountId", externalBrokerAccountId);
     int brokerId = Broker.FindRequiredKey(configurationId, "brokerId", externalBrokerId);
     int traderId = Trader.FindRequiredKey(configurationId, "traderId", externalTraderId);
     // 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 ((brokerAccountId == 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 = BrokerAccount.GetExternalKeyIndex(configurationId, "brokerAccountId");
         object[] externalIdArray = new object[4];
         externalIdArray[externalKeyIndex] = externalBrokerAccountId;
         externalId0 = externalIdArray[0];
         externalId1 = externalIdArray[1];
         externalId2 = externalIdArray[2];
         externalId3 = externalIdArray[3];
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.BrokerAccount.Insert(adoTransaction, sqlTransaction, ref rowVersion, brokerId, description, externalId0, externalId1, externalId2, externalId3, mnemonic, traderId);
     }
     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.BrokerAccountRow brokerAccountRow = brokerAccountTable.FindByBrokerAccountId(brokerAccountId);
         rowVersion = ((long)(brokerAccountRow[brokerAccountTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.BrokerAccount.Update(adoTransaction, sqlTransaction, ref rowVersion, brokerAccountId, brokerId, description, externalId0, externalId1, externalId2, externalId3, mnemonic, traderId);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemplo n.º 4
0
 /// <summary>Archives a BrokerAccount 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 BrokerAccount Table.
     ServerMarketData.BrokerAccountDataTable brokerAccountTable = ServerMarketData.BrokerAccount;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalBrokerAccountId = parameters["brokerAccountId"];
     // 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 brokerAccountId = BrokerAccount.FindRequiredKey(configurationId, "brokerAccountId", externalBrokerAccountId);
     // 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.BrokerAccountRow brokerAccountRow = brokerAccountTable.FindByBrokerAccountId(brokerAccountId);
     rowVersion = ((long)(brokerAccountRow[brokerAccountTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.BrokerAccount.Archive(adoTransaction, sqlTransaction, rowVersion, brokerAccountId);
 }
Exemplo n.º 5
0
        /// <summary>ArchiveChildrens a Broker 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="brokerId">The value for the BrokerId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal new static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int brokerId)
        {
            // Accessor for the Broker Table.
            ServerMarketData.BrokerDataTable brokerTable = ServerMarketData.Broker;
            // This record can be used to iterate through all the children.
            ServerMarketData.BrokerRow brokerRow = brokerTable.FindByBrokerId(brokerId);
            // Archive the child records.
            for (int index = 0; (index < brokerRow.GetExecutionRows().Length); index = (index + 1))
            {
                ServerMarketData.ExecutionRow childExecutionRow = brokerRow.GetExecutionRows()[index];
                Execution.Archive(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
            }
            for (int index = 0; (index < brokerRow.GetBrokerAccountRows().Length); index = (index + 1))
            {
                ServerMarketData.BrokerAccountRow childBrokerAccountRow = brokerRow.GetBrokerAccountRows()[index];
                BrokerAccount.Archive(adoTransaction, sqlTransaction, childBrokerAccountRow.RowVersion, childBrokerAccountRow.BrokerAccountId);
            }
            for (int index = 0; (index < brokerRow.GetClearingBrokerRows().Length); index = (index + 1))
            {
                ServerMarketData.ClearingBrokerRow childClearingBrokerRow = brokerRow.GetClearingBrokerRows()[index];
                ClearingBroker.ArchiveChildren(adoTransaction, sqlTransaction, childClearingBrokerRow.RowVersion, childClearingBrokerRow.ClearingBrokerId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            brokerRow[brokerTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(brokerRow);
            brokerRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Broker\" set \"IsArchived\" = 1 where \"BrokerId\"=@brokerId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.ExecuteNonQuery();
        }
Exemplo n.º 6
0
        /// <summary>Archives a BrokerAccount 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="brokerAccountId">The value for the BrokerAccountId 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 brokerAccountId)
        {
            // Accessor for the BrokerAccount Table.
            ServerMarketData.BrokerAccountDataTable brokerAccountTable = ServerMarketData.BrokerAccount;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.BrokerAccountRow brokerAccountRow = brokerAccountTable.FindByBrokerAccountId(brokerAccountId);
            if ((brokerAccountRow == null))
            {
                throw new Exception(string.Format("The BrokerAccount table does not have an element identified by {0}", brokerAccountId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((brokerAccountRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < brokerAccountRow.GetExecutionRows().Length); index = (index + 1))
            {
                ServerMarketData.ExecutionRow childExecutionRow = brokerAccountRow.GetExecutionRows()[index];
                Execution.Archive(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            brokerAccountRow[brokerAccountTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(brokerAccountRow);
            brokerAccountRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"BrokerAccount\" set \"IsArchived\" = 1 where \"BrokerAccountId\"=@brokerAccoun" +
                                                   "tId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@brokerAccountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerAccountId));
            sqlCommand.ExecuteNonQuery();
        }
Exemplo n.º 7
0
        /// <summary>Updates a BrokerAccount 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="brokerAccountId">The value for the BrokerAccountId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        /// <param name="externalId2">The value for the ExternalId2 column.</param>
        /// <param name="externalId3">The value for the ExternalId3 column.</param>
        /// <param name="mnemonic">The value for the Mnemonic column.</param>
        /// <param name="traderId">The value for the TraderId column.</param>
        public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int brokerAccountId, object brokerId, object description, object externalId0, object externalId1, object externalId2, object externalId3, object mnemonic, object traderId)
        {
            // Accessor for the BrokerAccount Table.
            ServerMarketData.BrokerAccountDataTable brokerAccountTable = ServerMarketData.BrokerAccount;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.BrokerAccountRow brokerAccountRow = brokerAccountTable.FindByBrokerAccountId(brokerAccountId);
            if ((brokerAccountRow == null))
            {
                throw new Exception(string.Format("The BrokerAccount table does not have an element identified by {0}", brokerAccountId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((brokerAccountRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((brokerId == null))
            {
                brokerId = brokerAccountRow[brokerAccountTable.BrokerIdColumn];
            }
            if ((description == null))
            {
                description = brokerAccountRow[brokerAccountTable.DescriptionColumn];
            }
            if ((externalId0 == null))
            {
                externalId0 = brokerAccountRow[brokerAccountTable.ExternalId0Column];
            }
            if ((externalId1 == null))
            {
                externalId1 = brokerAccountRow[brokerAccountTable.ExternalId1Column];
            }
            if ((externalId2 == null))
            {
                externalId2 = brokerAccountRow[brokerAccountTable.ExternalId2Column];
            }
            if ((externalId3 == null))
            {
                externalId3 = brokerAccountRow[brokerAccountTable.ExternalId3Column];
            }
            if ((mnemonic == null))
            {
                mnemonic = brokerAccountRow[brokerAccountTable.MnemonicColumn];
            }
            if ((traderId == null))
            {
                traderId = brokerAccountRow[brokerAccountTable.TraderIdColumn];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            brokerAccountRow[brokerAccountTable.RowVersionColumn]  = rowVersion;
            brokerAccountRow[brokerAccountTable.BrokerIdColumn]    = brokerId;
            brokerAccountRow[brokerAccountTable.DescriptionColumn] = description;
            brokerAccountRow[brokerAccountTable.ExternalId0Column] = externalId0;
            brokerAccountRow[brokerAccountTable.ExternalId1Column] = externalId1;
            brokerAccountRow[brokerAccountTable.ExternalId2Column] = externalId2;
            brokerAccountRow[brokerAccountTable.ExternalId3Column] = externalId3;
            brokerAccountRow[brokerAccountTable.MnemonicColumn]    = mnemonic;
            brokerAccountRow[brokerAccountTable.TraderIdColumn]    = traderId;
            adoTransaction.DataRows.Add(brokerAccountRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""BrokerAccount"" set ""RowVersion""=@rowVersion,""BrokerId""=@brokerId,""Description""=@description,""ExternalId0""=@externalId0,""ExternalId1""=@externalId1,""ExternalId2""=@externalId2,""ExternalId3""=@externalId3,""Mnemonic""=@mnemonic,""TraderId""=@traderId where ""BrokerAccountId""=@brokerAccountId");

            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("@brokerAccountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerAccountId));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@description", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, description));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId1", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId1));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId2", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId2));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId3", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId3));
            sqlCommand.Parameters.Add(new SqlParameter("@mnemonic", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, mnemonic));
            sqlCommand.Parameters.Add(new SqlParameter("@traderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, traderId));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }