コード例 #1
0
        /// <summary>Archives a Position 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="accountId">The value for the AccountId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="securityId">The value for the SecurityId 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 accountId, int positionTypeCode, int securityId)
        {
            // Accessor for the Position Table.
            ServerMarketData.PositionDataTable positionTable = ServerMarketData.Position;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.PositionRow positionRow = positionTable.FindByAccountIdSecurityIdPositionTypeCode(accountId, securityId, positionTypeCode);
            if ((positionRow == null))
            {
                throw new Exception(string.Format("The Position table does not have an element identified by {0}{0}{0}", accountId, securityId, positionTypeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((positionRow.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.
            positionRow[positionTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(positionRow);
            positionRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Position\" set \"IsArchived\" = 1 where \"AccountId\"=@accountId and \"Position" +
                                                   "TypeCode\"=@positionTypeCode and \"SecurityId\"=@securityId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@accountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accountId));
            sqlCommand.Parameters.Add(new SqlParameter("@positionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, positionTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #2
0
 /// <summary>Archives a Position 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 Position Table.
     ServerMarketData.PositionDataTable positionTable = ServerMarketData.Position;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalAccountId = parameters["accountId"];
     string externalPositionTypeCode = parameters["positionTypeCode"];
     string externalSecurityId = parameters["securityId"];
     // Resolve External Identifiers
     int accountId = Account.FindRequiredKey(configurationId, "accountId", externalAccountId);
     int positionTypeCode = PositionType.FindRequiredKey(configurationId, "positionTypeCode", externalPositionTypeCode);
     int securityId = Security.FindRequiredKey(configurationId, "securityId", externalSecurityId);
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // 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.PositionRow positionRow = positionTable.FindByAccountIdSecurityIdPositionTypeCode(accountId, securityId, positionTypeCode);
     rowVersion = ((long)(positionRow[positionTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Position.Archive(adoTransaction, sqlTransaction, rowVersion, accountId, positionTypeCode, securityId);
 }
コード例 #3
0
 /// <summary>Updates a Position 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 Position Table.
     ServerMarketData.PositionDataTable positionTable = ServerMarketData.Position;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalAccountId = parameters["accountId"];
     string externalPositionTypeCode = parameters["positionTypeCode"];
     string externalSecurityId = parameters["securityId"];
     object userData0 = parameters["userData0"].Value;
     object userData1 = parameters["userData1"].Value;
     object userData2 = parameters["userData2"].Value;
     object userData3 = parameters["userData3"].Value;
     object userData4 = parameters["userData4"].Value;
     object userData5 = parameters["userData5"].Value;
     object userData6 = parameters["userData6"].Value;
     object userData7 = parameters["userData7"].Value;
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     int accountId = Account.FindRequiredKey(configurationId, "accountId", externalAccountId);
     int positionTypeCode = PositionType.FindRequiredKey(configurationId, "positionTypeCode", externalPositionTypeCode);
     int securityId = Security.FindRequiredKey(configurationId, "securityId", externalSecurityId);
     // This will bypass the internal optimistic concurrency checking by providing the current rowVersion to the 
     // internal method.
     ServerMarketData.PositionRow positionRow = positionTable.FindByAccountIdSecurityIdPositionTypeCode(accountId, securityId, positionTypeCode);
     rowVersion = ((long)(positionRow[positionTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Position.Update(adoTransaction, sqlTransaction, ref rowVersion, accountId, positionTypeCode, securityId, userData0, userData1, userData2, userData3, userData4, userData5, userData6, userData7);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
コード例 #4
0
        /// <summary>Inserts a Position record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="accountId">The value for the AccountId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="userData0">The value for the UserData0 column.</param>
        /// <param name="userData1">The value for the UserData1 column.</param>
        /// <param name="userData2">The value for the UserData2 column.</param>
        /// <param name="userData3">The value for the UserData3 column.</param>
        /// <param name="userData4">The value for the UserData4 column.</param>
        /// <param name="userData5">The value for the UserData5 column.</param>
        /// <param name="userData6">The value for the UserData6 column.</param>
        /// <param name="userData7">The value for the UserData7 column.</param>
        public static void Insert(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int accountId, int positionTypeCode, int securityId, object userData0, object userData1, object userData2, object userData3, object userData4, object userData5, object userData6, object userData7)
        {
            // Accessor for the Position Table.
            ServerMarketData.PositionDataTable positionTable = ServerMarketData.Position;
            // Apply Defaults
            if ((userData0 == null))
            {
                userData0 = System.DBNull.Value;
            }
            if ((userData1 == null))
            {
                userData1 = System.DBNull.Value;
            }
            if ((userData2 == null))
            {
                userData2 = System.DBNull.Value;
            }
            if ((userData3 == null))
            {
                userData3 = System.DBNull.Value;
            }
            if ((userData4 == null))
            {
                userData4 = System.DBNull.Value;
            }
            if ((userData5 == null))
            {
                userData5 = System.DBNull.Value;
            }
            if ((userData6 == null))
            {
                userData6 = System.DBNull.Value;
            }
            if ((userData7 == null))
            {
                userData7 = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.PositionRow positionRow = positionTable.NewPositionRow();
            positionRow[positionTable.RowVersionColumn]       = rowVersion;
            positionRow[positionTable.AccountIdColumn]        = accountId;
            positionRow[positionTable.PositionTypeCodeColumn] = positionTypeCode;
            positionRow[positionTable.SecurityIdColumn]       = securityId;
            positionRow[positionTable.UserData0Column]        = userData0;
            positionRow[positionTable.UserData1Column]        = userData1;
            positionRow[positionTable.UserData2Column]        = userData2;
            positionRow[positionTable.UserData3Column]        = userData3;
            positionRow[positionTable.UserData4Column]        = userData4;
            positionRow[positionTable.UserData5Column]        = userData5;
            positionRow[positionTable.UserData6Column]        = userData6;
            positionRow[positionTable.UserData7Column]        = userData7;
            positionTable.AddPositionRow(positionRow);
            adoTransaction.DataRows.Add(positionRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Position"" (""rowVersion"",""AccountId"",""PositionTypeCode"",""SecurityId"",""UserData0"",""UserData1"",""UserData2"",""UserData3"",""UserData4"",""UserData5"",""UserData6"",""UserData7"") values (@rowVersion,@accountId,@positionTypeCode,@securityId,@userData0,@userData1,@userData2,@userData3,@userData4,@userData5,@userData6,@userData7)");

            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("@accountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accountId));
            sqlCommand.Parameters.Add(new SqlParameter("@positionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, positionTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.Parameters.Add(new SqlParameter("@userData0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData0));
            sqlCommand.Parameters.Add(new SqlParameter("@userData1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData1));
            sqlCommand.Parameters.Add(new SqlParameter("@userData2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData2));
            sqlCommand.Parameters.Add(new SqlParameter("@userData3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData3));
            sqlCommand.Parameters.Add(new SqlParameter("@userData4", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData4));
            sqlCommand.Parameters.Add(new SqlParameter("@userData5", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData5));
            sqlCommand.Parameters.Add(new SqlParameter("@userData6", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData6));
            sqlCommand.Parameters.Add(new SqlParameter("@userData7", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData7));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #5
0
        /// <summary>Updates a Position 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="accountId">The value for the AccountId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="userData0">The value for the UserData0 column.</param>
        /// <param name="userData1">The value for the UserData1 column.</param>
        /// <param name="userData2">The value for the UserData2 column.</param>
        /// <param name="userData3">The value for the UserData3 column.</param>
        /// <param name="userData4">The value for the UserData4 column.</param>
        /// <param name="userData5">The value for the UserData5 column.</param>
        /// <param name="userData6">The value for the UserData6 column.</param>
        /// <param name="userData7">The value for the UserData7 column.</param>
        public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int accountId, int positionTypeCode, int securityId, object userData0, object userData1, object userData2, object userData3, object userData4, object userData5, object userData6, object userData7)
        {
            // Accessor for the Position Table.
            ServerMarketData.PositionDataTable positionTable = ServerMarketData.Position;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.PositionRow positionRow = positionTable.FindByAccountIdSecurityIdPositionTypeCode(accountId, securityId, positionTypeCode);
            if ((positionRow == null))
            {
                throw new Exception(string.Format("The Position table does not have an element identified by {0}{0}{0}", accountId, securityId, positionTypeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((positionRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((userData0 == null))
            {
                userData0 = positionRow[positionTable.UserData0Column];
            }
            if ((userData1 == null))
            {
                userData1 = positionRow[positionTable.UserData1Column];
            }
            if ((userData2 == null))
            {
                userData2 = positionRow[positionTable.UserData2Column];
            }
            if ((userData3 == null))
            {
                userData3 = positionRow[positionTable.UserData3Column];
            }
            if ((userData4 == null))
            {
                userData4 = positionRow[positionTable.UserData4Column];
            }
            if ((userData5 == null))
            {
                userData5 = positionRow[positionTable.UserData5Column];
            }
            if ((userData6 == null))
            {
                userData6 = positionRow[positionTable.UserData6Column];
            }
            if ((userData7 == null))
            {
                userData7 = positionRow[positionTable.UserData7Column];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            positionRow[positionTable.RowVersionColumn] = rowVersion;
            positionRow[positionTable.UserData0Column]  = userData0;
            positionRow[positionTable.UserData1Column]  = userData1;
            positionRow[positionTable.UserData2Column]  = userData2;
            positionRow[positionTable.UserData3Column]  = userData3;
            positionRow[positionTable.UserData4Column]  = userData4;
            positionRow[positionTable.UserData5Column]  = userData5;
            positionRow[positionTable.UserData6Column]  = userData6;
            positionRow[positionTable.UserData7Column]  = userData7;
            adoTransaction.DataRows.Add(positionRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Position"" set ""RowVersion""=@rowVersion,""UserData0""=@userData0,""UserData1""=@userData1,""UserData2""=@userData2,""UserData3""=@userData3,""UserData4""=@userData4,""UserData5""=@userData5,""UserData6""=@userData6,""UserData7""=@userData7 where ""AccountId""=@accountId and ""PositionTypeCode""=@positionTypeCode and ""SecurityId""=@securityId");

            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("@accountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accountId));
            sqlCommand.Parameters.Add(new SqlParameter("@positionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, positionTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.Parameters.Add(new SqlParameter("@userData0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData0));
            sqlCommand.Parameters.Add(new SqlParameter("@userData1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData1));
            sqlCommand.Parameters.Add(new SqlParameter("@userData2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData2));
            sqlCommand.Parameters.Add(new SqlParameter("@userData3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData3));
            sqlCommand.Parameters.Add(new SqlParameter("@userData4", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData4));
            sqlCommand.Parameters.Add(new SqlParameter("@userData5", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData5));
            sqlCommand.Parameters.Add(new SqlParameter("@userData6", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData6));
            sqlCommand.Parameters.Add(new SqlParameter("@userData7", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData7));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }