コード例 #1
0
ファイル: StartUp.cs プロジェクト: gurgelx/Teaminator
        public void Configuration(IAppBuilder app)
        {
            Settings.SettingsManager.Init();
            var buildsToWatch = Settings.SettingsManager.Settings.BuildIds;

            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();


            BuildDetails currentThreat = null;
            var listner = new TeamcityService.TeamcityListener(buildsToWatch);
            var missileService = new UserMissileService();

            listner.BuildSuccess += (sender, args) =>
            {
                var build = sender as BuildDetails;
                if (currentThreat != null && build.buildTypeId == currentThreat.buildTypeId)
                {
                    currentThreat = null;
                    //missileService.Reset();
                    //killTimer?.Abort();
                }
                else
                {
                    switch (build.state)
                    {
                        case "running":
                            missileService.AimAtUser(GetUsername(build));
                            break;
                        case "finished":
                            missileService.Nod();
                            break;
                    }
                }
            };

            listner.BuildError += (sender, args) =>
            {
                var build = sender as BuildDetails;
                //if (currentThreat == null) currentThreat = build;
                if(!missileService.AimAtUser(GetUsername(build)))
                    missileService.Shake();
                else
                    missileService.AttackUser(GetUsername(build));
                //killTimer = new Thread(() =>
                //{
                //    Thread.Sleep(1000 * new Random(DateTime.Now.Millisecond).Next(10));
                //    if (currentThreat != null)

                //});
                //killTimer.Start();
            };

            listner.Begin();



            app.UseWebApi(config);
        }
コード例 #2
0
ファイル: StartUp.cs プロジェクト: sunker/Teaminator
        public void Configuration(IAppBuilder app)
        {
            Settings.SettingsManager.Init();
            var buildsToWatch = Settings.SettingsManager.Settings.BuildIds;

            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();


            BuildDetails currentThreat = null;
            var listner = new TeamcityService.TeamcityListener(buildsToWatch);
            var missileService = new UserMissileService();

            listner.BuildSuccess += (sender, args) =>
            {
                var build = sender as BuildDetails;
                if (currentThreat != null && build.buildTypeId == currentThreat.buildTypeId)
                {
                    currentThreat = null;
                    missileService.Reset();
                    killTimer?.Abort();
                }
                else
                {
                    switch (build.state)
                    {
                        case "running":
                            missileService.AimAtUser(build.lastChanges.change.First().username);
                            break;
                        case "finished":
                            missileService.Nod();
                            break;
                    }
                }
            };

            listner.BuildError += (sender, args) =>
            {
                var build = sender as BuildDetails;
                if (currentThreat == null) currentThreat = build;
                missileService.AimAtUser(currentThreat.lastChanges.change.First().username);

                killTimer = new Thread(() =>
                {
                    Thread.Sleep(300000);
                    if (currentThreat != null)
                        missileService.AttackUser(currentThreat.lastChanges.change.First().username);
                });
                killTimer.Start();
            };

            listner.Begin();



            app.UseWebApi(config);
        }