/// <summary> /// Creates a proposed order record. /// </summary> /// <param name="taxLotRow">A proposed order record from the primary ADO database.</param> /// <returns>A TaxLot record based on the ADO record.</returns> internal static TaxLot Make(ClientMarketData.TaxLotRow taxLotRow) { // Initialize the object DataRowVersion dataRowVersion = taxLotRow.RowState == DataRowState.Deleted ? DataRowVersion.Original : DataRowVersion.Current; // Extract the data from the ADO record. int taxLotId = (int)taxLotRow[ClientMarketData.TaxLot.TaxLotIdColumn, dataRowVersion]; int accountId = (int)taxLotRow[ClientMarketData.TaxLot.AccountIdColumn, dataRowVersion]; int securityId = (int)taxLotRow[ClientMarketData.TaxLot.SecurityIdColumn, dataRowVersion]; int positionTypeCode = (int)taxLotRow[ClientMarketData.TaxLot.PositionTypeCodeColumn, dataRowVersion]; Position position = Position.Make(accountId, securityId, positionTypeCode); decimal quantity = (decimal)taxLotRow[ClientMarketData.TaxLot.QuantityColumn, dataRowVersion]; decimal cost = (decimal)taxLotRow[ClientMarketData.TaxLot.CostColumn, dataRowVersion]; // Create a new record based on the data extracted from the ADO database. return(new TaxLot(taxLotId, position, quantity, cost)); }
/// <summary> /// Catches the Data Model events and rebroadcasts the event to the Rules Language Handlers. /// </summary> /// <param name="sender">The object that originated the event.</param> /// <param name="taxLotRowChangeEvent">The record change event argument.</param> public static void TaxLotHandler(object sender, ClientMarketData.TaxLotRowChangeEvent taxLotRowChangeEvent) { // Extract the record from the event argument. ClientMarketData.TaxLotRow taxLotRow = taxLotRowChangeEvent.Row; // Translate the ADO.NET row states into a record state used by the Rules Engine. Action action = Action.Nothing; switch (taxLotRowChangeEvent.Action) { case DataRowAction.Add: action = Action.Add; break; case DataRowAction.Delete: action = Action.Delete; break; case DataRowAction.Change: action = Action.Change; break; } // Place the event into a list that will be processed when the tables are no longer locked. TaxLot.taxLotEventArgList.Add(new TaxLotEventArgs(action, TaxLot.Make(taxLotRow))); }