/// <summary>
        /// Constructs a well formed Document Object Model for a group of executions on a block order.
        /// </summary>
        /// <param name="blockOrderId">The block order for which we want a execution document.</param>
        public ExecutionDocument(int blockOrderId, ExecutionSet executionSet)
        {
            // Create the root element for the document.
            XmlElement rootElement = this.CreateElement("Execution");

            this.AppendChild(rootElement);

            // This list is used to sort the executions.
            ArrayList executionsList = new ArrayList();

            // Start with the block order.  All the executions flow from this record.
            ClientMarketData.BlockOrderRow blockOrderRow = ClientMarketData.BlockOrder.FindByBlockOrderId(blockOrderId);
            if (blockOrderRow != null)
            {
                // This element holds all the information related to the block order.
                XmlElement blockOrderElement = this.CreateBlockOrderElement(blockOrderRow);
                rootElement.AppendChild(blockOrderElement);

                // We are going to run through all the executions posted against the block order and construct a
                // hierarchical structure of brokers.  Since they aren't arranged that way in the data model, we need to
                // scan the whole table looking for distinct brokers.
                foreach (ClientMarketData.ExecutionRow executionRow in blockOrderRow.GetExecutionRows())
                {
                    // Sort the list of executions by the created time.
                    int index;
                    for (index = 0; index < executionsList.Count; index++)
                    {
                        if (((ClientMarketData.ExecutionRow)executionsList[index]).CreatedTime > executionRow.CreatedTime)
                        {
                            executionsList.Insert(index, executionRow);
                            break;
                        }
                    }

                    // If the row wasn't sorted into the array above, it's added to the end of the list here.
                    if (index == executionsList.Count)
                    {
                        executionsList.Add(executionRow);
                    }
                }

                // Add all of the executions as children of the broker.
                foreach (ClientMarketData.ExecutionRow executionRow in executionsList)
                {
                    blockOrderElement.AppendChild(this.CreateGlobalExecutionElement(executionRow));
                }

                // Add the local executions.
                ExecutionSet.BlockOrderRow localBlockOrder = executionSet.BlockOrder.FindByBlockOrderId(blockOrderId);
                if (localBlockOrder != null)
                {
                    foreach (ExecutionSet.ExecutionRow executionRow in localBlockOrder.GetExecutionRows())
                    {
                        if (executionRow.RowState == DataRowState.Detached)
                        {
                            Console.WriteLine("{0} is Detached", executionRow["ExecutionId", DataRowVersion.Original]);
                        }
                        blockOrderElement.AppendChild(this.CreateLocalExecutionElement(executionRow));
                    }
                }
            }

            // The placeholder is a queue for the document manager to create a new execution.
            this.DocumentElement.AppendChild(this.CreatePlaceholderElement());
        }
Beispiel #2
0
 /// <summary>
 /// Constructor used to pass argument to the 'ExecutionRefresh' thread.
 /// </summary>
 public ExecutionDrawArgs(ExecutionSet executionSet)
 {
     // Initialize members.
     this.executionSet = executionSet;
 }