/// <summary> /// Reports an execution. /// </summary> /// <param name="message">The tag based message containing the execution report.</param> internal static void ReportExecution(Message[] messages) { Guid userId = UserService.GetUserId(); foreach (Message message in messages) { try { TenantDataModel tenantDataModel = DataModel.TenantDataModel; tenantDataModel.CreateExecution( null, null, null, null, DateTime.Now, userId, new Guid(message.ClOrdID), StateCode.Acknowledged, Guid.NewGuid(), message.Price, message.CumQty, null, null, DateTime.Now, userId, null, null, null, null, StateCode.Acknowledged, null, null, null, null); } catch { } } }
/// <summary> /// Updates prices using a United States ticker. /// </summary> /// <param name="symbolIndex">The index to use to find the symbol.</param> /// <param name="symbolKey">The symbol key.</param> /// <param name="currencyIndex">The index to use to find the currency.</param> /// <param name="currencyKey">The currency key.</param> /// <param name="quote">The quote used to update the price.</param> static void UpdatePriceBySymbolCurrency( DataModel.IEntityIndex symbolIndex, Object[] symbolKey, DataModel.IEntityIndex currencyIndex, Object[] currencyKey, Quote quote) { // The current transaction and the target data model is extracted from the thread. DataModelTransaction dataModelTransaction = DataModel.CurrentTransaction; TenantDataModel tenantDataSet = dataModelTransaction.TenantDataModel; // This will find the currency of the quote. DataModel.EntityRow currencyEntityRow = currencyIndex.Find(currencyKey); if (currencyEntityRow == null) { throw new FaultException <RecordNotFoundFault>(new RecordNotFoundFault("Entity", currencyKey)); } currencyEntityRow.AcquireReaderLock(dataModelTransaction.TransactionId, DataModel.LockTimeout); dataModelTransaction.AddLock(currencyEntityRow); if (currencyEntityRow.RowState == System.Data.DataRowState.Detached) { throw new FaultException <RecordNotFoundFault>(new RecordNotFoundFault("Entity", currencyKey)); } Guid currencyId = currencyEntityRow.EntityId; // This will find the security using the external identifier. DataModel.EntityRow securityEntityRow = symbolIndex.Find(symbolKey); if (securityEntityRow == null) { throw new FaultException <RecordNotFoundFault>(new RecordNotFoundFault("Entity", symbolKey)); } securityEntityRow.AcquireReaderLock(dataModelTransaction.TransactionId, DataModel.LockTimeout); dataModelTransaction.AddLock(securityEntityRow); if (securityEntityRow.RowState == System.Data.DataRowState.Detached) { throw new FaultException <RecordNotFoundFault>(new RecordNotFoundFault("Entity", symbolKey)); } Guid securityId = securityEntityRow.EntityId; // If the price record exists, then update it. If it doesn't exist then create it. Object[] priceKey = new Object[] { securityId, currencyId }; DataModel.PriceRow priceRow = DataModel.Price.PriceKey.Find(priceKey); if (priceRow == null) { tenantDataSet.CreatePrice( quote.AskPrice, quote.AskSize, quote.BidPrice, quote.BidSize, null, currencyId, null, quote.LastPrice, quote.LastSize, null, null, null, securityId, null, null); } else { priceRow.AcquireReaderLock(dataModelTransaction.TransactionId, DataModel.LockTimeout); dataModelTransaction.AddLock(priceRow); if (priceRow.RowState == System.Data.DataRowState.Detached) { throw new FaultException <RecordNotFoundFault>(new RecordNotFoundFault("Price", priceKey)); } tenantDataSet.UpdatePrice( quote.AskPrice, quote.AskSize, quote.BidPrice, quote.BidSize, null, currencyId, null, quote.LastPrice, quote.LastSize, null, null, null, priceKey, priceRow.RowVersion, securityId, null, null); } }