/// <summary> /// This procedure is used to update the TreeView control from the background. /// </summary> private void FolderListThread(params object[] argument) { // This node acts as the root that we'll use to build the tree folder list tree. It will eventually be // passed back to the main thread and into the TreeView control. ObjectNode rootNode = new ObjectNode(); try { // Lock all the tables that we'll reference while building a blotter document. Debug.Assert(!ClientMarketData.AreLocksHeld); ClientMarketData.FolderLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.LoginLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.ObjectLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.ObjectTreeLock.AcquireReaderLock(CommonTimeout.LockWait); // Recursively build the Tree View from the user's folder. ClientMarketData.LoginRow loginRow = ClientMarketData.Login.FindByLoginId(ClientPreferences.LoginId); if (loginRow != null && !loginRow.IsFolderIdNull()) { ClientMarketData.FolderRow folderRow = ClientMarketData.Folder.FindByFolderId(loginRow.FolderId); rootNode.Nodes.Add(new ObjectNode(folderRow.ObjectRow)); } } catch (Exception e) { // Catch the most general error and send it to the debug console. Debug.WriteLine(e.Message); } finally { // Release the tables used to build the folder list. if (ClientMarketData.FolderLock.IsReaderLockHeld) { ClientMarketData.FolderLock.ReleaseReaderLock(); } if (ClientMarketData.LoginLock.IsReaderLockHeld) { ClientMarketData.LoginLock.ReleaseReaderLock(); } if (ClientMarketData.ObjectLock.IsReaderLockHeld) { ClientMarketData.ObjectLock.ReleaseReaderLock(); } if (ClientMarketData.ObjectTreeLock.IsReaderLockHeld) { ClientMarketData.ObjectTreeLock.ReleaseReaderLock(); } Debug.Assert(!ClientMarketData.AreLocksHeld); } // Wait for the window handle to be created before trying to write to the control. The thread only needs to wait once. // After that, this event is permanently signaled. this.handleCreatedEvent.WaitOne(); // At this point, the tree is complete. This background thread needs to wait for a signal from the main application // thread that the TreeView control has been created. Once we get the signal, pass the entire tree structure back to // the main thread so it can copy the tree members. Note that the handle needs to be checked before invoking the // foreground method, even though we waited above for the "Handle Create" event. This test is meant to prevent events // from being called when the application is shutting down. if (this.IsHandleCreated) { Invoke(objectNodeDelegate, new object[] { rootNode }); } }
public GlobalTicket(ClientMarketData.ExecutionRow executionRow) { // Initialize members this.isLocal = false; this.blockOrderId = executionRow.BlockOrderId; this.brokerId = executionRow.BrokerId; this.transactionTypeCode = executionRow.BlockOrderRow.TransactionTypeCode; this.brokerName = executionRow.BrokerRow.ObjectRow.Name; this.brokerSymbol = executionRow.BrokerRow.Symbol; this.rowVersion = executionRow.RowVersion; this.executionId = executionRow.ExecutionId; this.quantity = executionRow.Quantity; this.price = executionRow.Price; this.commission = executionRow.Commission; this.accruedInterest = executionRow.AccruedInterest; this.userFee0 = executionRow.UserFee0; this.userFee1 = executionRow.UserFee1; this.userFee2 = executionRow.UserFee2; this.userFee3 = executionRow.UserFee3; this.tradeDate = executionRow.TradeDate; this.settlementDate = executionRow.SettlementDate; this.createdTime = executionRow.CreatedTime; this.createdLoginId = executionRow.CreatedLoginId; ClientMarketData.LoginRow createdLogin = ClientMarketData.Login.FindByLoginId(this.CreatedLoginId); if (createdLogin != null) { this.createdLoginName = createdLogin.ObjectRow.Name; } this.modifiedTime = executionRow.ModifiedTime; this.modifiedLoginId = executionRow.ModifiedLoginId; ClientMarketData.LoginRow modifiedLogin = ClientMarketData.Login.FindByLoginId(this.ModifiedLoginId); if (modifiedLogin != null) { this.modifiedLoginName = modifiedLogin.ObjectRow.Name; } // Initialize Field Status iRowVersionModified = true; isBlockOrderIdModified = true; isTransactionTypeCodeModified = true; isBrokerIdModified = true; isBrokerNameModified = true; isBrokerSymbolModified = true; isExecutionIdModified = true; isQuantityModified = true; isPriceModified = true; isCommissionModified = true; isAccruedInterestModified = true; isUserFee0Modified = true; isUserFee1Modified = true; isUserFee2Modified = true; isUserFee3Modified = true; isTradeDateModified = true; isSettlementDateModified = true; isCreatedTimeModified = true; isCreatedLoginIdModified = true; isCreatedLoginNameModified = true; isModifiedTimeModified = true; isModifiedLoginIdModified = true; isModifiedLoginNameModified = true; }
/// <summary> /// Creates an XML Element representing a placment in the placement document. /// </summary> /// <param name="xmlDocument">The destination XML document.</param> /// <param name="placementRow">A placement record.</param> public PlacementElement(XmlDocument xmlDocument, PlacementSet.PlacementRow placementRow) : base("Placement", xmlDocument) { // This is the primary identifier for the record. AddAttribute("PlacementId", placementRow.LocalPlacementId.ToString()); // Broker field if (!placementRow.IsBrokerIdNull()) { ClientMarketData.BrokerRow brokerRow = ClientMarketData.Broker.FindByBrokerId(placementRow.BrokerId); if (brokerRow != null) { AddAttribute("BrokerId", brokerRow.BrokerId.ToString()); AddAttribute("BrokerName", brokerRow.ObjectRow.Name); AddAttribute("BrokerSymbol", brokerRow.Symbol); } } // TimeInForce field if (!placementRow.IsTimeInForceCodeNull()) { ClientMarketData.TimeInForceRow timeInForceRow = ClientMarketData.TimeInForce.FindByTimeInForceCode(placementRow.TimeInForceCode); if (timeInForceRow != null) { AddAttribute("TimeInForceCode", placementRow.TimeInForceCode.ToString()); AddAttribute("TimeInForceMnemonic", timeInForceRow.Mnemonic); } } // OrderType field if (!placementRow.IsOrderTypeCodeNull()) { ClientMarketData.OrderTypeRow orderTypeRow = ClientMarketData.OrderType.FindByOrderTypeCode(placementRow.OrderTypeCode); if (orderTypeRow != null) { AddAttribute("OrderTypeCode", placementRow.OrderTypeCode.ToString()); AddAttribute("OrderTypeMnemonic", orderTypeRow.Mnemonic); } } // Quantity if (!placementRow.IsQuantityNull()) { AddAttribute("Quantity", placementRow.Quantity.ToString()); } // Price 1 if (!placementRow.IsPrice1Null()) { AddAttribute("Price1", placementRow.Price1.ToString()); } // Price 2 if (!placementRow.IsPrice2Null()) { AddAttribute("Price2", placementRow.Price2.ToString()); } // Created Time if (!placementRow.IsCreatedTimeNull()) { AddAttribute("CreatedTime", placementRow.CreatedTime.ToString("s")); } // Created Login if (!placementRow.IsCreatedLoginIdNull()) { ClientMarketData.LoginRow createdLoginRow = ClientMarketData.Login.FindByLoginId(placementRow.CreatedLoginId); if (createdLoginRow != null) { AddAttribute("CreatedLoginId", createdLoginRow.LoginId.ToString()); AddAttribute("CreatedLoginName", createdLoginRow.ObjectRow.Name); } } // Modified Time if (!placementRow.IsModifiedTimeNull()) { AddAttribute("ModifiedTime", placementRow.ModifiedTime.ToString("s")); } // Modified Login if (!placementRow.IsModifiedLoginIdNull()) { ClientMarketData.LoginRow modifiedLoginRow = ClientMarketData.Login.FindByLoginId(placementRow.ModifiedLoginId); if (modifiedLoginRow != null) { AddAttribute("ModifiedLoginId", modifiedLoginRow.LoginId.ToString()); AddAttribute("ModifiedLoginName", modifiedLoginRow.ObjectRow.Name); } } }