/// <summary>
        ///
        /// </summary>
        public void StartBOMAMClosedTrades()
        {
            var lastProcessedID = 0;
            var tradeHistoryBO  = new TradesHistoryBO();
            var bobMAMTradeBO   = new BOMAMTradeBO();

            while (true)
            {
                if (isInitiated)
                {
                    try
                    {
                        if (assetManagerDict.Keys.Count > 0)
                        {
                            //If The LastProcessID is 0 get it from database
                            if (lastProcessedID == 0)
                            {
                                //Get The Last ClosedTradeProcessedID
                                lastProcessedID = bobMAMTradeBO.GetLastClosedTradeProcessedID();
                            }

                            //Updates to Get Last ProcessedID
                            lastProcessedID = bobMAMTradeBO.UpdateBOMAMOpenToCloseTrade(assetManagerDict, lastProcessedID);
                        }
                    }
                    catch (Exception exceptionMessage)
                    {
                        //Log Error
                        CurrentDeskLog.Error("Monitoring Closed Trades :" + exceptionMessage);
                    }
                }
            }
        }
        /// <summary>
        /// This Function is running in thread
        /// it will get all the trades after the
        /// processed id and than populateBOBOpen Trades data.
        /// </summary>
        public void StartBOMAMOpenTrades()
        {
            var lastProcessedID = 0;
            var tradeBO         = new TradeBO();
            var boMAMTradeBO    = new BOMAMTradeBO();
            var clientAccountBO = new Client_AccountBO();

            while (true)
            {
                //Check If Initiated
                if (isInitiated)
                {
                    try
                    {
                        if (assetManagerDict.Keys.Count > 0)
                        {
                            //If The LastProcessID is 0 get it from database
                            if (lastProcessedID == 0)
                            {
                                lastProcessedID = boMAMTradeBO.GetLastOpenTradeProcessedID();
                            }

                            //Get All Open Trades For All the asset Manager
                            var openTradeResult = tradeBO.GetAssetManagerOpenTrades(assetManagerDict.Keys.ToList(), lastProcessedID);

                            //Check If the Count > 0
                            if (openTradeResult.Count > 0)
                            {
                                lastProcessedID = openTradeResult.Max(x => x.PK_TradeID);
                                var boMAMTradeList = new List <BOMAMTrade>();

                                //Loop Through The Open trades
                                foreach (var item in openTradeResult)
                                {
                                    foreach (var res in assetManagerDict[(int)item.Login])
                                    {
                                        BOMAMTrade openBOMAMTrade = new BOMAMTrade();
                                        openBOMAMTrade.OrderID            = (int)item.OrderID;
                                        openBOMAMTrade.OpenPrice          = item.OpenPrice;
                                        openBOMAMTrade.ClosePrice         = item.ClosePrice;
                                        openBOMAMTrade.OpenTime           = item.OpenTime;
                                        openBOMAMTrade.CloseTime          = item.CloseTime;
                                        openBOMAMTrade.Agent              = "";
                                        openBOMAMTrade.FK_IBID            = (int)res.FK_IBID;
                                        openBOMAMTrade.FK_ClientAccountID = (int)res.FK_ClientAccountID;
                                        openBOMAMTrade.Symbol             = item.Symbol;
                                        openBOMAMTrade.LastIDProcessed    = item.PK_TradeID;
                                        openBOMAMTrade.Size         = item.Volume != null ? (double)item.Volume * slaveAllocationDict[(int)res.FK_ClientAccountID] : 0.0;
                                        openBOMAMTrade.Commission   = item.Commission != null ? (double)item.Commission * slaveAllocationDict[(int)res.FK_ClientAccountID] : 0.0;
                                        openBOMAMTrade.Swap         = item.Storage != null ? (double)item.Storage * slaveAllocationDict[(int)res.FK_ClientAccountID] : 0.0;
                                        openBOMAMTrade.Pnl          = item.Profit != null ? (double)item.Profit * slaveAllocationDict[(int)res.FK_ClientAccountID] : 0.0;
                                        openBOMAMTrade.IsopenTrades = true;
                                        boMAMTradeList.Add(openBOMAMTrade);
                                    }
                                }

                                //If Count > 0 Add it to the database
                                if (boMAMTradeList.Count > 0)
                                {
                                    boMAMTradeBO.AddBOMAMOpenTrades(boMAMTradeList);
                                }
                            }
                        }
                    }
                    catch (Exception exceptionMessage)
                    {
                        //Log Error
                        CurrentDeskLog.Error("Monitoring Open Trades :" + exceptionMessage);
                    }
                }
            }
        }