示例#1
0
        public bool Start(Account accountInfo)
        {
            if (state != RobotFarmState.Stopped)
            {
                return(false);
            }
            if (accountInfo == null)
            {
                return(false);
            }
            robotContext = new TerminalLiveRobotContext(MainForm.serverProxyTrade, accountInfo, () => AccountStatus.Instance.Login,
                                                        () =>
            {
                var chartTickers = MainForm.Instance.GetChartList(false)
                                   .Select(c => new Cortege2 <string, BarSettings>(c.Symbol, c.Timeframe)).Distinct();
                var robotTickers = robots.SelectMany(r => r.Graphics).Distinct();
                return(chartTickers.Union(robotTickers).Distinct().ToList());
            });
            // загрузить роботов
            robots = LoadRobots();
            Logger.InfoFormat("Загружено {0} роботов", robots.Count);
            foreach (var robot in robots)
            {
                robot.Initialize(robotContext, CurrentProtectedContext.Instance);
            }
            if (robots.Count == 0)
            {
                return(false);
            }

            if (MainForm.Instance.ChatEngine != null)
            {
                foreach (Chat.Client.BL.IChatSpamRobot bot in robots.Where(r => r is Chat.Client.BL.IChatSpamRobot))
                {
                    bot.EnterRoom         += MainForm.Instance.ChatEngine.EnterRoom;
                    bot.SendMessageInRoom += MainForm.Instance.ChatEngine.SendMessageInRoom;
                }
            }

            State = RobotFarmState.StartingUp;
            // загрузить историю для роботов
            startRoutine.RunWorkerAsync();
            return(true);
        }
示例#2
0
        public bool Start(Account accountInfo)
        {
            if (state != RobotFarmState.Stopped)
            {
                return(false);
            }
            if (accountInfo == null)
            {
                return(false);
            }
            robotContext = new TerminalLiveRobotContext(MainForm.serverProxyTrade, accountInfo, () => AccountStatus.Instance.Login);
            // загрузить роботов
            robots = LoadRobots();
            Logger.InfoFormat("Загружено {0} роботов", robots.Count);
            foreach (var robot in robots)
            {
                robot.Initialize(robotContext, CurrentProtectedContext.Instance);
            }
            if (robots.Count == 0)
            {
                return(false);
            }

            if (MainForm.Instance.ChatEngine != null)
            {
                foreach (Chat.Client.BL.IChatSpamRobot bot in robots.Where(r => r is Chat.Client.BL.IChatSpamRobot))
                {
                    bot.EnterRoom         += MainForm.Instance.ChatEngine.EnterRoom;
                    bot.SendMessageInRoom += MainForm.Instance.ChatEngine.SendMessageInRoom;
                }
            }

            State = RobotFarmState.StartingUp;
            // загрузить историю для роботов
            startRoutine.RunWorkerAsync();
            return(true);
        }
示例#3
0
        public bool Start(Account accountInfo)
        {
            if (state != RobotFarmState.Stopped) return false;
            if (accountInfo == null) return false;
            robotContext = new TerminalLiveRobotContext(MainForm.serverProxyTrade, accountInfo, () => AccountStatus.Instance.Login);
            // загрузить роботов
            robots = LoadRobots();
            Logger.InfoFormat("Загружено {0} роботов", robots.Count);
            foreach (var robot in robots)
                robot.Initialize(robotContext, CurrentProtectedContext.Instance);
            if (robots.Count == 0) return false;

            if (MainForm.Instance.ChatEngine != null)
                foreach (Chat.Client.BL.IChatSpamRobot bot in robots.Where(r => r is Chat.Client.BL.IChatSpamRobot))
                {
                    bot.EnterRoom += MainForm.Instance.ChatEngine.EnterRoom;
                    bot.SendMessageInRoom += MainForm.Instance.ChatEngine.SendMessageInRoom;
                }

            State = RobotFarmState.StartingUp;
            // загрузить историю для роботов
            startRoutine.RunWorkerAsync();
            return true;
        }