/// <summary> /// Creates the DOM and Refreshes the spreadsheet control in the background. /// </summary> /// <remarks> /// This thread is responsible for recreating the Document Object Model for the blotter and translating /// that DOM into a format compatible with the spreadsheet viewer. It will call the foreground when the /// DOM is complete to either update the entire document, if the structure has changed, or only update /// the changed cells, when only the data has changed. /// </remarks> private void DrawFragmentCommand(object parameter) { // Extract the list of fragments from the thread parameters. FragmentList fragmentList = (FragmentList)parameter; #if DEBUGXML // This will create an XML Document containing only the records and fields that have changed since the viewer was // last updated. XmlDocument stagedOrderFragment = new MatchHistoryDocument(fragmentList); // Make sure that writing the debug file doesn't interrupt the session. try { // During debugging, it's very useful to have a copy of the DOM on the disk. stagedOrderFragment.Save("stagedOrderFragment.xml"); } catch (Exception exception) { // Write the error and stack trace out to the event log. EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace); } // This will write the changes to the viewer by passing it through the stylesheet. this.XmlDocument = stagedOrderFragment; #else // This will write the changes to the viewer by passing it through the stylesheet. //this.XmlDocument = new MatchHistoryDocument(fragmentList); this.XmlDocument = new QuoteDocument(fragmentList); #endif }
/// <summary> /// Creates the DOM and Refreshes the spreadsheet control in the background. /// </summary> /// <remarks> /// This thread is responsible for recreating the Document Object Model for the blotter and translating /// that DOM into a format compatible with the spreadsheet viewer. It will call the foreground when the /// DOM is complete to either update the entire document, if the structure has changed, or only update /// the changed cells, when only the data has changed. /// </remarks> protected override void DrawDocumentCommand(object parameter) { // Extract the document from the thread parameters. Blotter blotter = null; if (parameter is Blotter) { blotter = (Blotter)parameter; } if (parameter is BlotterMatchDetail) { blotter = ((BlotterMatchDetail)parameter).Blotter; } #if DEBUGXML // Create the blotter document. MatchHistoryDocument matchDocument = new MatchHistoryDocument(blotter.BlotterId); // Make sure that writing the debug file doesn't interrupt the session. try { // During debugging, it's very useful to have a copy of the DOM on the disk. matchDocument.Save("matchHistoryDOM.xml"); } catch (Exception exception) { // Write the error and stack trace out to the debug listener EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace); } // This will display the this.XmlDocument = matchDocument; #else // This will display the quote viewer this.XmlDocument = new QuoteDocument(Convert.ToInt32(this.Tag)); #endif }
public MatchElement(MatchHistoryDocument matchDocument, ClientMarketData.MatchRow matchRow, FieldArray fields) : base("Match", matchDocument) { // WorkingOrderId AddAttribute("MatchId", matchRow.MatchId); AddAttribute("WorkingOrderId", matchRow.WorkingOrderId); AddAttribute("ContraOrderId", matchRow.ContraOrderId); // Status if (fields[Field.Status]) { AddAttribute("StatusCode", matchRow.StatusCode); AddAttribute("StatusName", matchRow.StatusRow.Mnemonic); } // Blotter if (fields[Field.Blotter]) { AddAttribute("Blotter", matchRow.WorkingOrderRow.BlotterRow.BlotterId); AddAttribute("BlotterName", matchRow.WorkingOrderRow.BlotterRow.ObjectRow.Name); } // Security if (fields[Field.Security]) { AddAttribute("SecurityId", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.SecurityId); AddAttribute("SecuritySymbol", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Symbol); AddAttribute("SecurityName", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.ObjectRow.Name); if (!matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.IsAverageDailyVolumeNull()) { AddAttribute("AverageDailyVolume", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.AverageDailyVolume / 1000); } if (!matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.IsMarketCapitalizationNull()) { AddAttribute("MarketCapitalization", matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.MarketCapitalization / 1000000); } MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(matchRow.WorkingOrderRow.SecurityRowBySecurityWorkingOrderSecurityId.Logo)); Bitmap bitmap = new Bitmap(memoryStream); Bitmap halfBitmap = new Bitmap(bitmap, new Size(bitmap.Width / 2, bitmap.Height / 2)); MemoryStream halfStream = new MemoryStream(); halfBitmap.Save(halfStream, System.Drawing.Imaging.ImageFormat.Png); AddAttribute("SecurityImage", Convert.ToBase64String(halfStream.GetBuffer())); } // Submitted Quantity if (fields[Field.SubmittedQuantity]) { AddAttribute("SubmittedQuantity", matchRow.WorkingOrderRow.SubmittedQuantity); } // Quantity Executed if (fields[Field.Execution]) { decimal executedQuantity = decimal.Zero; decimal marketValue = decimal.Zero; foreach (ClientMarketData.NegotiationRow negotiationRow in matchRow.GetNegotiationRows()) { if (negotiationRow.ExecutionRow != null) { executedQuantity = negotiationRow.ExecutionRow.ExecutionQuantity; marketValue = negotiationRow.ExecutionRow.ExecutionPrice * negotiationRow.ExecutionRow.ExecutionQuantity; } } if (executedQuantity != decimal.Zero) { AddAttribute("ExecutedQuantity", executedQuantity); AddAttribute("AveragePrice", marketValue / executedQuantity); } } // Direction (OrderType) if (fields[Field.OrderTypeCode]) { AddAttribute("OrderTypeCode", matchRow.WorkingOrderRow.OrderTypeCode); AddAttribute("OrderTypeMnemonic", matchRow.WorkingOrderRow.OrderTypeRow.Mnemonic); AddAttribute("OrderTypeDescription", matchRow.WorkingOrderRow.OrderTypeRow.Description); } // Created Time. if (fields[Field.CreatedTime]) { AddAttribute("CreatedTime", matchRow.CreatedTime.ToString("s")); } // Find the pricing record. if (!matchRow.WorkingOrderRow.IsSettlementIdNull()) { ClientMarketData.PriceRow priceRow = ClientMarketData.Price.FindBySecurityId(matchRow.WorkingOrderRow.SecurityId); if (priceRow != null) { if (fields[Field.LastPrice]) { AddAttribute("LastPrice", priceRow.LastPrice); } if (fields[Field.BidPrice]) { AddAttribute("BidPrice", priceRow.BidPrice); } if (fields[Field.AskPrice]) { AddAttribute("AskPrice", priceRow.AskPrice); } if (fields[Field.LastSize]) { AddAttribute("LastSize", priceRow.LastSize); } if (fields[Field.BidSize]) { AddAttribute("BidSize", priceRow.BidSize); } if (fields[Field.AskPrice]) { AddAttribute("AskSize", priceRow.AskSize); } if (fields[Field.Volume]) { AddAttribute("Volume", priceRow.Volume); } if (fields[Field.VolumeWeightedAveragePrice]) { AddAttribute("VolumeWeightedAveragePrice", priceRow.VolumeWeightedAveragePrice); } } } }