예제 #1
0
        private void RecurseBlotter(ClientMarketData.ObjectRow objectRow)
        {
            foreach (ClientMarketData.ObjectTreeRow objectTreeRow in objectRow.GetObjectTreeRowsByFKObjectObjectTreeParentId())
            {
                RecurseBlotter(objectTreeRow.ObjectRowByFKObjectObjectTreeChildId);
            }

            foreach (ClientMarketData.BlotterRow blotterRow in objectRow.GetBlotterRows())
            {
                foreach (ClientMarketData.BlockOrderRow blockOrderRow in blotterRow.GetBlockOrderRows())
                {
                    if (blockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeChildId().Length == 0)
                    {
                        // At this point, we've found an element that has no parents.  Add it to the tree and recurse down in
                        // to the structure to find all the children.
                        BlockOrderElement blockOrdersElement = this.CreateBlockOrderElement(blockOrderRow);
                        this.DocumentElement.AppendChild(blockOrdersElement);
                        RecurseTree(blockOrdersElement);

                        // This is a CPU intensive task, so sleep between each major branch that's uncovered.
                        Thread.Sleep(0);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Construct a hierarchical tree structure by recursively scanning the parent-child relations.
        /// </summary>
        /// <param name="objectNode">The current node in the tree structure.</param>
        private void RecurseTree(BlockOrderElement parentElement)
        {
            // Recursion is sometimes difficult to follow.  At this point, we have a parent block order.  The 'BlockOrderTree' table can be used effectively for this.  Simply trace the parent
            // relation back to the 'BlockOrderTree' and you have a list of children block orders.  For every child we
            // find, we're going to recurse down until there are no more descendants.
            foreach (ClientMarketData.BlockOrderTreeRow blockOrdersTreeRow in
                     parentElement.BlockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeParentId())
            {
                // Trace the 'child id' column back to the 'objects' table and get the full record that belongs to
                // this relation.  We can create a new node from this information and add it to the tree.
                BlockOrderElement childElement =
                    this.CreateBlockOrderElement(blockOrdersTreeRow.BlockOrderRowByFKBlockOrderBlockOrderTreeChildId);
                parentElement.AppendChild(childElement);

                // Go look for any children of this node.
                RecurseTree(childElement);
            }

            // Orders are also children of block orders: the relationship is easily defined.  There are no children of
            // orders, so that's as far as we have to follow the relationships.
            foreach (ClientMarketData.OrderRow orderRow in parentElement.BlockOrderRow.GetOrderRows())
            {
                parentElement.AppendChild(this.CreateOrdersElement(orderRow));
            }

            foreach (ClientMarketData.PlacementRow placementRow in parentElement.BlockOrderRow.GetPlacementRows())
            {
                parentElement.AppendChild(this.CreatePlacementsElement(placementRow));
            }

            foreach (ClientMarketData.ExecutionRow executionRow in parentElement.BlockOrderRow.GetExecutionRows())
            {
                parentElement.AppendChild(this.CreateExecutionElement(executionRow));
            }
        }