Ejemplo n.º 1
0
        /// <summary>
        /// Count all of the working orders and matches in blotters below the parent entity. The caller should lock the DataModel.
        /// </summary>
        /// <param name="parent">The parent entity.</param>
        /// <param name="totalRecords">The total number of records. Should initially be 0.</param>
        /// <param name="matchedRecords">The number of of valid matches. Should initially be 0.</param>
        private void CountAccounts(EntityRow parent, ref int totalRecords, ref int matchedRecords)
        {
            BlotterRow blotter = DataModel.Blotter.BlotterKey.Find(parent.EntityId);

            if (blotter != null)
            {
                MatchRow[]        matches = blotter.GetMatchRows();
                WorkingOrderRow[] orders  = blotter.GetWorkingOrderRows();

                matchedRecords += matches.Length;

                // Count up the credit cards for everything.
                foreach (WorkingOrderRow order in orders)
                {
                    Guid             security = order.SecurityId;
                    ConsumerTrustRow trust    = DataModel.ConsumerTrust.ConsumerTrustKey.Find(security);

                    if (trust != null)
                    {
                        totalRecords += trust.ConsumerRow.GetCreditCardRows().Length;
                    }
                }
            }

            // Do the same for all of the blotters under this one.
            foreach (EntityTreeRow tree in DataModel.EntityTree)
            {
                if (tree.ParentId == parent.EntityId)
                {
                    this.CountAccounts(tree.EntityRowByFK_Entity_EntityTree_ChildId, ref totalRecords, ref matchedRecords);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Count all of the working orders and matches in blotters below the parent entity. The caller should lock the DataModel.
        /// </summary>
        /// <param name="parent">The parent entity.</param>
        /// <param name="orders">The total number of working orders. This should initially be 0.</param>
        /// <param name="matches">The total number of matches. This should initially be 0.</param>
        private void CountChildOrders(EntityRow parent, ref int orders, ref int matches)
        {
            BlotterRow blotter = DataModel.Blotter.BlotterKey.Find(parent.EntityId);

            if (blotter != null)
            {
                orders  += blotter.GetWorkingOrderRows().Count();
                matches += blotter.GetMatchRows().Count();
            }

            foreach (EntityTreeRow tree in DataModel.EntityTree)
            {
                if (tree.ParentId == parent.EntityId)
                {
                    this.CountChildOrders(tree.EntityRowByFK_Entity_EntityTree_ChildId, ref orders, ref matches);
                }
            }
        }
        /// <summary>
        /// Count all of the working orders and matches in blotters below the parent entity. The caller should lock the DataModel.
        /// </summary>
        /// <param name="parent">The parent entity.</param>
        /// <param name="matchedDollars">The total face value of the valid matches. Should initially be 0.0.</param>
        /// <param name="totalDollars">The total face value of all the records. Should initially be 0.0.</param>
        /// <param name="totalRecords">The total number of records. Should initially be 0.</param>
        /// <param name="matchedRecords">The number of of valid matches. Should initially be 0.</param>
        private void CountChildMoney(EntityRow parent, ref decimal matchedDollars, ref decimal totalDollars, ref int totalRecords, ref int matchedRecords)
        {
            BlotterRow blotter = DataModel.Blotter.BlotterKey.Find(parent.EntityId);

            if (blotter != null)
            {
                MatchRow[]        matches = blotter.GetMatchRows();
                WorkingOrderRow[] orders  = blotter.GetWorkingOrderRows();

                matchedRecords += matches.Length;
                totalRecords   += orders.Length;

                // Count up the match/match with funds credit card balances.
                foreach (MatchRow match in matches)
                {
                    if (match.StatusRow.StatusCode == Status.ValidMatch || match.StatusRow.StatusCode == Status.ValidMatchFunds)
                    {
                        Guid security = match.WorkingOrderRow.SecurityId;
                        matchedDollars += DataModel.ConsumerDebt.ConsumerDebtKey.Find(security).CreditCardRow.AccountBalance;
                    }
                }

                // Count up the credit card balances of _everything_, matched or not.
                foreach (WorkingOrderRow order in orders)
                {
                    Guid            security = order.SecurityId;
                    ConsumerDebtRow debt     = DataModel.ConsumerDebt.ConsumerDebtKey.Find(security);

                    if (debt != null)
                    {
                        totalDollars += debt.CreditCardRow.AccountBalance;
                    }
                }
            }

            // Do the same for all of the blotters under this one.
            foreach (EntityTreeRow tree in DataModel.EntityTree)
            {
                if (tree.ParentId == parent.EntityId)
                {
                    this.CountChildMoney(tree.EntityRowByFK_Entity_EntityTree_ChildId, ref matchedDollars, ref totalDollars, ref totalRecords, ref matchedRecords);
                }
            }
        }