Exemplo n.º 1
0
        /// <summary>Archives a TaxLot 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="taxLotId">The value for the TaxLotId 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 taxLotId)
        {
            // Accessor for the TaxLot Table.
            ServerDataModel.TaxLotDataTable taxLotTable = ServerDataModel.TaxLot;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.TaxLotRow taxLotRow = taxLotTable.FindByTaxLotId(taxLotId);
            if ((taxLotRow == null))
            {
                throw new Exception(string.Format("The TaxLot table does not have an element identified by {0}", taxLotId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((taxLotRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            taxLotRow[taxLotTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(taxLotRow);
            taxLotRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"TaxLot\" set \"IsArchived\" = 1 where \"TaxLotId\"=@taxLotId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@taxLotId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, taxLotId));
            sqlCommand.ExecuteNonQuery();
        }
Exemplo n.º 2
0
        /// <summary>Archives a PositionType 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="positionTypeCode">The value for the PositionTypeCode 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 positionTypeCode)
        {
            // Accessor for the PositionType Table.
            ServerDataModel.PositionTypeDataTable positionTypeTable = ServerDataModel.PositionType;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.PositionTypeRow positionTypeRow = positionTypeTable.FindByPositionTypeCode(positionTypeCode);
            if ((positionTypeRow == null))
            {
                throw new Exception(string.Format("The PositionType table does not have an element identified by {0}", positionTypeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((positionTypeRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < positionTypeRow.GetPositionRows().Length); index = (index + 1))
            {
                ServerDataModel.PositionRow childPositionRow = positionTypeRow.GetPositionRows()[index];
                Position.Archive(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode);
            }
            for (int index = 0; (index < positionTypeRow.GetPositionTargetRows().Length); index = (index + 1))
            {
                ServerDataModel.PositionTargetRow childPositionTargetRow = positionTypeRow.GetPositionTargetRows()[index];
                PositionTarget.Archive(adoTransaction, sqlTransaction, childPositionTargetRow.RowVersion, childPositionTargetRow.ModelId, childPositionTargetRow.SecurityId, childPositionTargetRow.PositionTypeCode);
            }
            for (int index = 0; (index < positionTypeRow.GetTaxLotRows().Length); index = (index + 1))
            {
                ServerDataModel.TaxLotRow childTaxLotRow = positionTypeRow.GetTaxLotRows()[index];
                TaxLot.Archive(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId);
            }
            for (int index = 0; (index < positionTypeRow.GetViolationRows().Length); index = (index + 1))
            {
                ServerDataModel.ViolationRow childViolationRow = positionTypeRow.GetViolationRows()[index];
                Violation.Archive(adoTransaction, sqlTransaction, childViolationRow.RowVersion, childViolationRow.ViolationId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            positionTypeRow[positionTypeTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(positionTypeRow);
            positionTypeRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"PositionType\" set \"IsArchived\" = 1 where \"PositionTypeCode\"=@positionType" +
                                                   "Code");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@positionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, positionTypeCode));
            sqlCommand.ExecuteNonQuery();
        }
Exemplo n.º 3
0
 /// <summary>Updates a TaxLot 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 TaxLot Table.
     ServerDataModel.TaxLotDataTable taxLotTable = ServerDataModel.TaxLot;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalTaxLotId = ((string)(parameters["taxLotId"]));
     object externalSecurityId = parameters["securityId"].Value;
     object externalAccountId = parameters["accountId"].Value;
     object externalPositionTypeCode = parameters["positionTypeCode"].Value;
     object quantity = parameters["quantity"].Value;
     object cost = parameters["cost"].Value;
     object localCost = parameters["localCost"].Value;
     object tradeDate = parameters["tradeDate"].Value;
     object settlementDate = parameters["settlementDate"].Value;
     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 taxLotId = TaxLot.FindRequiredKey(configurationId, "taxLotId", externalTaxLotId);
     object securityId = Security.FindOptionalKey(configurationId, "securityId", externalSecurityId);
     object accountId = Account.FindOptionalKey(configurationId, "accountId", externalAccountId);
     object positionTypeCode = PositionType.FindOptionalKey(configurationId, "positionTypeCode", externalPositionTypeCode);
     // 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.
     ServerDataModel.TaxLotRow taxLotRow = taxLotTable.FindByTaxLotId(taxLotId);
     rowVersion = ((long)(taxLotRow[taxLotTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.TaxLot.Update(adoTransaction, sqlTransaction, ref rowVersion, taxLotId, securityId, accountId, positionTypeCode, quantity, cost, localCost, tradeDate, settlementDate, userData0, userData1, userData2, userData3, userData4, userData5, userData6, userData7, null, null, null, null);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemplo n.º 4
0
 /// <summary>Archives a TaxLot 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 TaxLot Table.
     ServerDataModel.TaxLotDataTable taxLotTable = ServerDataModel.TaxLot;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalTaxLotId = parameters["taxLotId"];
     // 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 taxLotId = TaxLot.FindRequiredKey(configurationId, "taxLotId", externalTaxLotId);
     // 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.
     ServerDataModel.TaxLotRow taxLotRow = taxLotTable.FindByTaxLotId(taxLotId);
     rowVersion = ((long)(taxLotRow[taxLotTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.TaxLot.Archive(adoTransaction, sqlTransaction, rowVersion, taxLotId);
 }
Exemplo n.º 5
0
 /// <summary>Loads a TaxLot 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 TaxLot Table.
     ServerDataModel.TaxLotDataTable taxLotTable = ServerDataModel.TaxLot;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object externalTaxLotId = parameters["taxLotId"].Value;
     string externalSecurityId = parameters["securityId"];
     string externalAccountId = parameters["accountId"];
     string externalPositionTypeCode = parameters["positionTypeCode"];
     decimal quantity = parameters["quantity"];
     decimal cost = parameters["cost"];
     object localCost = parameters["localCost"].Value;
     object tradeDate = parameters["tradeDate"].Value;
     object settlementDate = parameters["settlementDate"].Value;
     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;
     object externalId0 = parameters["externalId0"].Value;
     object externalId1 = parameters["externalId1"].Value;
     object externalId2 = parameters["externalId2"].Value;
     object externalId3 = parameters["externalId3"].Value;
     // 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 taxLotId = TaxLot.FindKey(configurationId, "taxLotId", externalTaxLotId);
     int securityId = Security.FindRequiredKey(configurationId, "securityId", externalSecurityId);
     int accountId = Account.FindRequiredKey(configurationId, "accountId", externalAccountId);
     int positionTypeCode = PositionType.FindRequiredKey(configurationId, "positionTypeCode", externalPositionTypeCode);
     // 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 ((taxLotId == 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 = TaxLot.GetExternalKeyIndex(configurationId, "taxLotId");
         object[] externalIdArray = new object[4];
         externalIdArray[externalKeyIndex] = externalTaxLotId;
         externalId0 = externalIdArray[0];
         externalId1 = externalIdArray[1];
         externalId2 = externalIdArray[2];
         externalId3 = externalIdArray[3];
         // Call the internal method to complete the operation.
         MarkThree.Quasar.Core.TaxLot.Insert(adoTransaction, sqlTransaction, ref rowVersion, securityId, accountId, positionTypeCode, quantity, cost, localCost, tradeDate, settlementDate, userData0, userData1, userData2, userData3, userData4, userData5, userData6, userData7, externalId0, externalId1, externalId2, externalId3);
     }
     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.
         ServerDataModel.TaxLotRow taxLotRow = taxLotTable.FindByTaxLotId(taxLotId);
         rowVersion = ((long)(taxLotRow[taxLotTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Quasar.Core.TaxLot.Update(adoTransaction, sqlTransaction, ref rowVersion, taxLotId, securityId, accountId, positionTypeCode, quantity, cost, localCost, tradeDate, settlementDate, userData0, userData1, userData2, userData3, userData4, userData5, userData6, userData7, externalId0, externalId1, externalId2, externalId3);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemplo n.º 6
0
        /// <summary>Inserts a TaxLot record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="accountId">The value for the AccountId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="cost">The value for the Cost column.</param>
        /// <param name="localCost">The value for the LocalCost column.</param>
        /// <param name="tradeDate">The value for the TradeDate column.</param>
        /// <param name="settlementDate">The value for the SettlementDate 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>
        /// <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>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            int securityId,
            int accountId,
            int positionTypeCode,
            decimal quantity,
            decimal cost,
            object localCost,
            object tradeDate,
            object settlementDate,
            object userData0,
            object userData1,
            object userData2,
            object userData3,
            object userData4,
            object userData5,
            object userData6,
            object userData7,
            object externalId0,
            object externalId1,
            object externalId2,
            object externalId3)
        {
            // Accessor for the TaxLot Table.
            ServerDataModel.TaxLotDataTable taxLotTable = ServerDataModel.TaxLot;
            // Apply Defaults
            if ((localCost == null))
            {
                localCost = 0.0m;
            }
            if ((tradeDate == null))
            {
                tradeDate = System.DBNull.Value;
            }
            if ((settlementDate == null))
            {
                settlementDate = System.DBNull.Value;
            }
            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;
            }
            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 = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.TaxLotRow taxLotRow = taxLotTable.NewTaxLotRow();
            taxLotRow[taxLotTable.RowVersionColumn]       = rowVersion;
            taxLotRow[taxLotTable.SecurityIdColumn]       = securityId;
            taxLotRow[taxLotTable.AccountIdColumn]        = accountId;
            taxLotRow[taxLotTable.PositionTypeCodeColumn] = positionTypeCode;
            taxLotRow[taxLotTable.QuantityColumn]         = quantity;
            taxLotRow[taxLotTable.CostColumn]             = cost;
            taxLotRow[taxLotTable.LocalCostColumn]        = localCost;
            taxLotRow[taxLotTable.TradeDateColumn]        = tradeDate;
            taxLotRow[taxLotTable.SettlementDateColumn]   = settlementDate;
            taxLotRow[taxLotTable.UserData0Column]        = userData0;
            taxLotRow[taxLotTable.UserData1Column]        = userData1;
            taxLotRow[taxLotTable.UserData2Column]        = userData2;
            taxLotRow[taxLotTable.UserData3Column]        = userData3;
            taxLotRow[taxLotTable.UserData4Column]        = userData4;
            taxLotRow[taxLotTable.UserData5Column]        = userData5;
            taxLotRow[taxLotTable.UserData6Column]        = userData6;
            taxLotRow[taxLotTable.UserData7Column]        = userData7;
            taxLotRow[taxLotTable.ExternalId0Column]      = externalId0;
            taxLotRow[taxLotTable.ExternalId1Column]      = externalId1;
            taxLotRow[taxLotTable.ExternalId2Column]      = externalId2;
            taxLotRow[taxLotTable.ExternalId3Column]      = externalId3;
            taxLotTable.AddTaxLotRow(taxLotRow);
            adoTransaction.DataRows.Add(taxLotRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""TaxLot"" (""rowVersion"",""TaxLotId"",""SecurityId"",""AccountId"",""PositionTypeCode"",""Quantity"",""Cost"",""LocalCost"",""TradeDate"",""SettlementDate"",""UserData0"",""UserData1"",""UserData2"",""UserData3"",""UserData4"",""UserData5"",""UserData6"",""UserData7"",""ExternalId0"",""ExternalId1"",""ExternalId2"",""ExternalId3"") values (@rowVersion,@taxLotId,@securityId,@accountId,@positionTypeCode,@quantity,@cost,@localCost,@tradeDate,@settlementDate,@userData0,@userData1,@userData2,@userData3,@userData4,@userData5,@userData6,@userData7,@externalId0,@externalId1,@externalId2,@externalId3)");

            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("@taxLotId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, taxLotRow[taxLotTable.TaxLotIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            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("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@cost", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, cost));
            sqlCommand.Parameters.Add(new SqlParameter("@localCost", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, localCost));
            sqlCommand.Parameters.Add(new SqlParameter("@tradeDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, tradeDate));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            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.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.ExecuteNonQuery();
            // Return Statements
            return(taxLotRow.TaxLotId);
        }
Exemplo n.º 7
0
        /// <summary>Updates a TaxLot 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="taxLotId">The value for the TaxLotId column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="accountId">The value for the AccountId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="cost">The value for the Cost column.</param>
        /// <param name="localCost">The value for the LocalCost column.</param>
        /// <param name="tradeDate">The value for the TradeDate column.</param>
        /// <param name="settlementDate">The value for the SettlementDate 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>
        /// <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>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            int taxLotId,
            object securityId,
            object accountId,
            object positionTypeCode,
            object quantity,
            object cost,
            object localCost,
            object tradeDate,
            object settlementDate,
            object userData0,
            object userData1,
            object userData2,
            object userData3,
            object userData4,
            object userData5,
            object userData6,
            object userData7,
            object externalId0,
            object externalId1,
            object externalId2,
            object externalId3)
        {
            // Accessor for the TaxLot Table.
            ServerDataModel.TaxLotDataTable taxLotTable = ServerDataModel.TaxLot;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.TaxLotRow taxLotRow = taxLotTable.FindByTaxLotId(taxLotId);
            if ((taxLotRow == null))
            {
                throw new Exception(string.Format("The TaxLot table does not have an element identified by {0}", taxLotId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((taxLotRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((securityId == null))
            {
                securityId = taxLotRow[taxLotTable.SecurityIdColumn];
            }
            if ((accountId == null))
            {
                accountId = taxLotRow[taxLotTable.AccountIdColumn];
            }
            if ((positionTypeCode == null))
            {
                positionTypeCode = taxLotRow[taxLotTable.PositionTypeCodeColumn];
            }
            if ((quantity == null))
            {
                quantity = taxLotRow[taxLotTable.QuantityColumn];
            }
            if ((cost == null))
            {
                cost = taxLotRow[taxLotTable.CostColumn];
            }
            if ((localCost == null))
            {
                localCost = taxLotRow[taxLotTable.LocalCostColumn];
            }
            if ((tradeDate == null))
            {
                tradeDate = taxLotRow[taxLotTable.TradeDateColumn];
            }
            if ((settlementDate == null))
            {
                settlementDate = taxLotRow[taxLotTable.SettlementDateColumn];
            }
            if ((userData0 == null))
            {
                userData0 = taxLotRow[taxLotTable.UserData0Column];
            }
            if ((userData1 == null))
            {
                userData1 = taxLotRow[taxLotTable.UserData1Column];
            }
            if ((userData2 == null))
            {
                userData2 = taxLotRow[taxLotTable.UserData2Column];
            }
            if ((userData3 == null))
            {
                userData3 = taxLotRow[taxLotTable.UserData3Column];
            }
            if ((userData4 == null))
            {
                userData4 = taxLotRow[taxLotTable.UserData4Column];
            }
            if ((userData5 == null))
            {
                userData5 = taxLotRow[taxLotTable.UserData5Column];
            }
            if ((userData6 == null))
            {
                userData6 = taxLotRow[taxLotTable.UserData6Column];
            }
            if ((userData7 == null))
            {
                userData7 = taxLotRow[taxLotTable.UserData7Column];
            }
            if ((externalId0 == null))
            {
                externalId0 = taxLotRow[taxLotTable.ExternalId0Column];
            }
            if ((externalId1 == null))
            {
                externalId1 = taxLotRow[taxLotTable.ExternalId1Column];
            }
            if ((externalId2 == null))
            {
                externalId2 = taxLotRow[taxLotTable.ExternalId2Column];
            }
            if ((externalId3 == null))
            {
                externalId3 = taxLotRow[taxLotTable.ExternalId3Column];
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Update the record in the ADO database.
            taxLotRow[taxLotTable.RowVersionColumn]       = rowVersion;
            taxLotRow[taxLotTable.SecurityIdColumn]       = securityId;
            taxLotRow[taxLotTable.AccountIdColumn]        = accountId;
            taxLotRow[taxLotTable.PositionTypeCodeColumn] = positionTypeCode;
            taxLotRow[taxLotTable.QuantityColumn]         = quantity;
            taxLotRow[taxLotTable.CostColumn]             = cost;
            taxLotRow[taxLotTable.LocalCostColumn]        = localCost;
            taxLotRow[taxLotTable.TradeDateColumn]        = tradeDate;
            taxLotRow[taxLotTable.SettlementDateColumn]   = settlementDate;
            taxLotRow[taxLotTable.UserData0Column]        = userData0;
            taxLotRow[taxLotTable.UserData1Column]        = userData1;
            taxLotRow[taxLotTable.UserData2Column]        = userData2;
            taxLotRow[taxLotTable.UserData3Column]        = userData3;
            taxLotRow[taxLotTable.UserData4Column]        = userData4;
            taxLotRow[taxLotTable.UserData5Column]        = userData5;
            taxLotRow[taxLotTable.UserData6Column]        = userData6;
            taxLotRow[taxLotTable.UserData7Column]        = userData7;
            taxLotRow[taxLotTable.ExternalId0Column]      = externalId0;
            taxLotRow[taxLotTable.ExternalId1Column]      = externalId1;
            taxLotRow[taxLotTable.ExternalId2Column]      = externalId2;
            taxLotRow[taxLotTable.ExternalId3Column]      = externalId3;
            adoTransaction.DataRows.Add(taxLotRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""TaxLot"" set ""RowVersion""=@rowVersion,""SecurityId""=@securityId,""AccountId""=@accountId,""PositionTypeCode""=@positionTypeCode,""Quantity""=@quantity,""Cost""=@cost,""LocalCost""=@localCost,""TradeDate""=@tradeDate,""SettlementDate""=@settlementDate,""UserData0""=@userData0,""UserData1""=@userData1,""UserData2""=@userData2,""UserData3""=@userData3,""UserData4""=@userData4,""UserData5""=@userData5,""UserData6""=@userData6,""UserData7""=@userData7,""ExternalId0""=@externalId0,""ExternalId1""=@externalId1,""ExternalId2""=@externalId2,""ExternalId3""=@externalId3 where ""TaxLotId""=@taxLotId");

            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("@taxLotId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, taxLotId));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            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("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@cost", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, cost));
            sqlCommand.Parameters.Add(new SqlParameter("@localCost", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, localCost));
            sqlCommand.Parameters.Add(new SqlParameter("@tradeDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, tradeDate));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            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.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));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Exemplo n.º 8
0
        /// <summary>ArchiveChildrens a Security 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="securityId">The value for the SecurityId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int securityId)
        {
            // Accessor for the Security Table.
            ServerDataModel.SecurityDataTable securityTable = ServerDataModel.Security;
            // This record can be used to iterate through all the children.
            ServerDataModel.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
            // Archive the child records.
            for (int index = 0; (index < securityRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = securityRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsByFKSecurityAllocationSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.AllocationRow childAllocationRow = securityRow.GetAllocationRowsByFKSecurityAllocationSecurityId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsByFKSecurityAllocationSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.AllocationRow childAllocationRow = securityRow.GetAllocationRowsByFKSecurityAllocationSettlementId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.BlockOrderRow childBlockOrderRow = securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSecurityId()[index];
                BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId);
            }
            for (int index = 0; (index < securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.BlockOrderRow childBlockOrderRow = securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSettlementId()[index];
                BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId);
            }
            for (int index = 0; (index < securityRow.GetBlotterMapRows().Length); index = (index + 1))
            {
                ServerDataModel.BlotterMapRow childBlotterMapRow = securityRow.GetBlotterMapRows()[index];
                BlotterMap.Archive(adoTransaction, sqlTransaction, childBlotterMapRow.RowVersion, childBlotterMapRow.BlotterMapId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsByFKSecurityDebtDebtId().Length); index = (index + 1))
            {
                ServerDataModel.DebtRow childDebtRow = securityRow.GetDebtRowsByFKSecurityDebtDebtId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsByFKSecurityDebtSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.DebtRow childDebtRow = securityRow.GetDebtRowsByFKSecurityDebtSettlementId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetCurrencyRows().Length); index = (index + 1))
            {
                ServerDataModel.CurrencyRow childCurrencyRow = securityRow.GetCurrencyRows()[index];
                Currency.ArchiveChildren(adoTransaction, sqlTransaction, childCurrencyRow.RowVersion, childCurrencyRow.CurrencyId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsByFKSecurityEquityEquityId().Length); index = (index + 1))
            {
                ServerDataModel.EquityRow childEquityRow = securityRow.GetEquityRowsByFKSecurityEquityEquityId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsByFKSecurityEquitySettlementId().Length); index = (index + 1))
            {
                ServerDataModel.EquityRow childEquityRow = securityRow.GetEquityRowsByFKSecurityEquitySettlementId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetOrderRowsByFKSecurityOrderSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.OrderRow childOrderRow = securityRow.GetOrderRowsByFKSecurityOrderSecurityId()[index];
                Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
            }
            for (int index = 0; (index < securityRow.GetOrderRowsByFKSecurityOrderSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.OrderRow childOrderRow = securityRow.GetOrderRowsByFKSecurityOrderSettlementId()[index];
                Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
            }
            for (int index = 0; (index < securityRow.GetPositionRows().Length); index = (index + 1))
            {
                ServerDataModel.PositionRow childPositionRow = securityRow.GetPositionRows()[index];
                Position.Archive(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode);
            }
            for (int index = 0; (index < securityRow.GetPositionTargetRows().Length); index = (index + 1))
            {
                ServerDataModel.PositionTargetRow childPositionTargetRow = securityRow.GetPositionTargetRows()[index];
                PositionTarget.Archive(adoTransaction, sqlTransaction, childPositionTargetRow.RowVersion, childPositionTargetRow.ModelId, childPositionTargetRow.SecurityId, childPositionTargetRow.PositionTypeCode);
            }
            for (int index = 0; (index < securityRow.GetPriceRows().Length); index = (index + 1))
            {
                ServerDataModel.PriceRow childPriceRow = securityRow.GetPriceRows()[index];
                Price.Archive(adoTransaction, sqlTransaction, childPriceRow.RowVersion, childPriceRow.SecurityId, childPriceRow.CurrencyId);
            }
            for (int index = 0; (index < securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderRow childProposedOrderRow = securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSecurityId()[index];
                ProposedOrder.Archive(adoTransaction, sqlTransaction, childProposedOrderRow.RowVersion, childProposedOrderRow.ProposedOrderId);
            }
            for (int index = 0; (index < securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderRow childProposedOrderRow = securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSettlementId()[index];
                ProposedOrder.Archive(adoTransaction, sqlTransaction, childProposedOrderRow.RowVersion, childProposedOrderRow.ProposedOrderId);
            }
            for (int index = 0; (index < securityRow.GetTaxLotRows().Length); index = (index + 1))
            {
                ServerDataModel.TaxLotRow childTaxLotRow = securityRow.GetTaxLotRows()[index];
                TaxLot.Archive(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId);
            }
            for (int index = 0; (index < securityRow.GetViolationRows().Length); index = (index + 1))
            {
                ServerDataModel.ViolationRow childViolationRow = securityRow.GetViolationRows()[index];
                Violation.Archive(adoTransaction, sqlTransaction, childViolationRow.RowVersion, childViolationRow.ViolationId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            securityRow[securityTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(securityRow);
            securityRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Security\" set \"IsArchived\" = 1 where \"SecurityId\"=@securityId");

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