예제 #1
0
        public TeamCityBuildChecker(BuildLocator buildLocator, ITeamCityClient client, string name,
                                    TimeConfig timeConfig)
        {
            _buildLocator = buildLocator;
            _client       = client;
            _name         = name;
            _timeConfig   = timeConfig;

            Branch = name;
        }
예제 #2
0
        public Task StartBot(ISkypeAdapter skype, ITeamCityClient teamCity, BotParameters botParameters,
                             Dictionary <string, string> moduleParameters, TimeConfig timeConfig)
        {
            _working       = true;
            _skype         = skype;
            _teamcity      = teamCity;
            _botParameters = botParameters;
            _timeConfig    = timeConfig;

            var task = Task.Run(delegate
            {
                try
                {
                    _publishChat = _skype.GetChat(botParameters.PublishChatName);
                    if (_publishChat != null)
                    {
                        Console.WriteLine("publish chat found!");
                    }
                    else
                    {
                        Console.WriteLine("publish chat NOT found!");
                    }
                    _skype.OnMessageReceived += OnMessageReceived;

                    _timer = new Timer {
                        Interval = timeConfig.BuildCheckInterval.TotalMilliseconds
                    };
                    _timer.Elapsed  += timer_Elapsed;
                    _timer.AutoReset = false;
                    _timer.Start();

                    while (_working)
                    {
                        Thread.Sleep(5);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("top lvl exception : " + ex);
                }
            });

            buildCheckers =
                _botParameters.Branches.Select(
                    x =>
                    new TeamCityBuildChecker(
                        BuildLocator.WithDimensions(BuildTypeLocator.WithId(_botParameters.BuildConfigId),
                                                    branch: x), _teamcity, x, _timeConfig)).ToList();

            _bot = new HelloBot(moduleParameters, buildCheckers, MailSettingsSectionGroup => SendMessage(MailSettingsSectionGroup, _publishChat));
            _bot.OnErrorOccured += BotOnErrorOccured;

            return(task);
        }