/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> internal new static void DeleteChildren(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Delete' operation. adoTransaction.LockRequests.AddWriterLock(ServerMarketData.AccountLock); Allocation.Delete(adoTransaction); Position.Delete(adoTransaction); TaxLot.Delete(adoTransaction); }
/// <summary>Inserts a TaxLot record using Metadata Parameters.</summary> /// <param name="parameters">Contains the metadata parameters.</param> public static void Delete(ParameterList parameters) { // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; long rowVersion = parameters["rowVersion"]; int taxLotId = parameters["taxLotId"]; // Call the internal method to complete the operation. TaxLot.Delete(adoTransaction, sqlTransaction, rowVersion, taxLotId); }
/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> internal static void DeleteChildren(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Delete' operation. adoTransaction.LockRequests.AddWriterLock(ServerMarketData.SecurityLock); AccountBase.DeleteChildren(adoTransaction); Allocation.Delete(adoTransaction); Currency.DeleteChildren(adoTransaction); Debt.DeleteChildren(adoTransaction); Equity.DeleteChildren(adoTransaction); Position.Delete(adoTransaction); Price.Delete(adoTransaction); SourceOrder.Delete(adoTransaction); TaxLot.Delete(adoTransaction); WorkingOrder.Delete(adoTransaction); }
/// <summary>Deletes 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 Delete(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int positionTypeCode) { // Accessor for the PositionType Table. ServerMarketData.PositionTypeDataTable positionTypeTable = ServerMarketData.PositionType; // Rule #1: Make sure the record exists before updating it. ServerMarketData.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."); } // Delete the child records. for (int index = 0; (index < positionTypeRow.GetPositionRows().Length); index = (index + 1)) { ServerMarketData.PositionRow childPositionRow = positionTypeRow.GetPositionRows()[index]; Position.Delete(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode); } for (int index = 0; (index < positionTypeRow.GetTaxLotRows().Length); index = (index + 1)) { ServerMarketData.TaxLotRow childTaxLotRow = positionTypeRow.GetTaxLotRows()[index]; TaxLot.Delete(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId); } // Increment the row version rowVersion = ServerMarketData.RowVersion.Increment(); // Delete the record in the ADO database. positionTypeRow[positionTypeTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(positionTypeRow); positionTypeRow.Delete(); // Delete the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"PositionType\" set \"IsDeleted\" = 1 where \"PositionTypeCode\"=@positionTypeC" + "ode"); 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(); }
/// <summary>DeleteChildrens a Account 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="archive">true to archive the object, false to unarchive it.</param> internal new static void DeleteChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int accountId) { // Accessor for the Account Table. ServerMarketData.AccountDataTable accountTable = ServerMarketData.Account; // This record can be used to iterate through all the children. ServerMarketData.AccountRow accountRow = accountTable.FindByAccountId(accountId); // Delete the child records. for (int index = 0; (index < accountRow.GetAllocationRows().Length); index = (index + 1)) { ServerMarketData.AllocationRow childAllocationRow = accountRow.GetAllocationRows()[index]; Allocation.Delete(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId); } for (int index = 0; (index < accountRow.GetPositionRows().Length); index = (index + 1)) { ServerMarketData.PositionRow childPositionRow = accountRow.GetPositionRows()[index]; Position.Delete(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode); } for (int index = 0; (index < accountRow.GetTaxLotRows().Length); index = (index + 1)) { ServerMarketData.TaxLotRow childTaxLotRow = accountRow.GetTaxLotRows()[index]; TaxLot.Delete(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId); } // Increment the row version rowVersion = ServerMarketData.RowVersion.Increment(); // Delete the record in the ADO database. accountRow[accountTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(accountRow); accountRow.Delete(); // Delete the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Account\" set \"IsDeleted\" = 1 where \"AccountId\"=@accountId"); 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.ExecuteNonQuery(); }
/// <summary>DeleteChildrens 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 DeleteChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int securityId) { // Accessor for the Security Table. ServerMarketData.SecurityDataTable securityTable = ServerMarketData.Security; // This record can be used to iterate through all the children. ServerMarketData.SecurityRow securityRow = securityTable.FindBySecurityId(securityId); // Delete the child records. for (int index = 0; (index < securityRow.GetAccountBaseRows().Length); index = (index + 1)) { ServerMarketData.AccountBaseRow childAccountBaseRow = securityRow.GetAccountBaseRows()[index]; AccountBase.DeleteChildren(adoTransaction, sqlTransaction, childAccountBaseRow.RowVersion, childAccountBaseRow.AccountBaseId); } for (int index = 0; (index < securityRow.GetAllocationRowsBySecurityAllocationSecurityId().Length); index = (index + 1)) { ServerMarketData.AllocationRow childAllocationRow = securityRow.GetAllocationRowsBySecurityAllocationSecurityId()[index]; Allocation.Delete(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId); } for (int index = 0; (index < securityRow.GetAllocationRowsBySecurityAllocationSettlementId().Length); index = (index + 1)) { ServerMarketData.AllocationRow childAllocationRow = securityRow.GetAllocationRowsBySecurityAllocationSettlementId()[index]; Allocation.Delete(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId); } for (int index = 0; (index < securityRow.GetCurrencyRows().Length); index = (index + 1)) { ServerMarketData.CurrencyRow childCurrencyRow = securityRow.GetCurrencyRows()[index]; Currency.DeleteChildren(adoTransaction, sqlTransaction, childCurrencyRow.RowVersion, childCurrencyRow.CurrencyId); } for (int index = 0; (index < securityRow.GetDebtRowsBySecurityDebtDebtId().Length); index = (index + 1)) { ServerMarketData.DebtRow childDebtRow = securityRow.GetDebtRowsBySecurityDebtDebtId()[index]; Debt.DeleteChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId); } for (int index = 0; (index < securityRow.GetDebtRowsBySecurityDebtSettlementId().Length); index = (index + 1)) { ServerMarketData.DebtRow childDebtRow = securityRow.GetDebtRowsBySecurityDebtSettlementId()[index]; Debt.DeleteChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId); } for (int index = 0; (index < securityRow.GetEquityRowsBySecurityEquityEquityId().Length); index = (index + 1)) { ServerMarketData.EquityRow childEquityRow = securityRow.GetEquityRowsBySecurityEquityEquityId()[index]; Equity.DeleteChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId); } for (int index = 0; (index < securityRow.GetEquityRowsBySecurityEquitySettlementId().Length); index = (index + 1)) { ServerMarketData.EquityRow childEquityRow = securityRow.GetEquityRowsBySecurityEquitySettlementId()[index]; Equity.DeleteChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId); } for (int index = 0; (index < securityRow.GetPositionRows().Length); index = (index + 1)) { ServerMarketData.PositionRow childPositionRow = securityRow.GetPositionRows()[index]; Position.Delete(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode); } for (int index = 0; (index < securityRow.GetPriceRows().Length); index = (index + 1)) { ServerMarketData.PriceRow childPriceRow = securityRow.GetPriceRows()[index]; Price.Delete(adoTransaction, sqlTransaction, childPriceRow.RowVersion, childPriceRow.SecurityId); } for (int index = 0; (index < securityRow.GetSourceOrderRowsBySecuritySourceOrderSecurityId().Length); index = (index + 1)) { ServerMarketData.SourceOrderRow childSourceOrderRow = securityRow.GetSourceOrderRowsBySecuritySourceOrderSecurityId()[index]; SourceOrder.Delete(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId); } for (int index = 0; (index < securityRow.GetSourceOrderRowsBySecuritySourceOrderSettlementId().Length); index = (index + 1)) { ServerMarketData.SourceOrderRow childSourceOrderRow = securityRow.GetSourceOrderRowsBySecuritySourceOrderSettlementId()[index]; SourceOrder.Delete(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId); } for (int index = 0; (index < securityRow.GetTaxLotRows().Length); index = (index + 1)) { ServerMarketData.TaxLotRow childTaxLotRow = securityRow.GetTaxLotRows()[index]; TaxLot.Delete(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId); } for (int index = 0; (index < securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSecurityId().Length); index = (index + 1)) { ServerMarketData.WorkingOrderRow childWorkingOrderRow = securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSecurityId()[index]; WorkingOrder.Delete(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId); } for (int index = 0; (index < securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSettlementId().Length); index = (index + 1)) { ServerMarketData.WorkingOrderRow childWorkingOrderRow = securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSettlementId()[index]; WorkingOrder.Delete(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId); } // Increment the row version rowVersion = ServerMarketData.RowVersion.Increment(); // Delete the record in the ADO database. securityRow[securityTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(securityRow); securityRow.Delete(); // Delete the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Security\" set \"IsDeleted\" = 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(); }