private void TimerTick(object state)
        {
            _timer.Change(Timeout.Infinite, Timeout.Infinite);

            _log.Info("Looking for new version");

            try
            {
                var updateInfo = new UpdateInfoCollector(_watchFolder, _port).Collect();

                _log.InfoFormat(updateInfo.ToString());

                using (var service = new ServiceController("AsimovDeploy.WinAgent"))
                {
                    if (!updateInfo.NeedsAnyUpdate())
                    {
                        return;
                    }

                    StopService(service);

                    if (updateInfo.NewBuildFound())
                    {
                        UpdateWinAgentWithNewBuild(updateInfo.LastBuild);
                        if (updateInfo.HasLastConfig)
                        {
                            UpdateWinAgentConfig(updateInfo.LastConfig);
                        }
                    }

                    if (updateInfo.NewConfigFound())
                    {
                        UpdateWinAgentConfig(updateInfo.LastConfig);
                    }

                    StartService(service);
                }
            }
            catch (Exception ex)
            {
                _log.Error("Failed to check for upgrade", ex);
            }
            finally
            {
                _timer.Change(interval, interval);
            }
        }
Beispiel #2
0
        private void TimerTick(object state)
        {
            _timer.Change(Timeout.Infinite, Timeout.Infinite);

            _log.Info("Looking for new version");

            try
            {
                var updateInfo = new UpdateInfoCollector(_watchFolder, _port).Collect();

                _log.InfoFormat(updateInfo.ToString());

                using (var service = new ServiceController("AsimovDeploy.WinAgent"))
                {
                    if (!updateInfo.NeedsAnyUpdate())
                        return;

                    StopService(service);

                    if (updateInfo.NewBuildFound())
                    {
                        UpdateWinAgentWithNewBuild(updateInfo.LastBuild);
                        if (updateInfo.HasLastConfig)
                        {
                            UpdateWinAgentConfig(updateInfo.LastConfig);
                        }
                    }

                    if (updateInfo.NewConfigFound())
                    {
                        UpdateWinAgentConfig(updateInfo.LastConfig);
                    }

                    StartService(service);
                }

            }
            catch(Exception ex)
            {
                _log.Error("Failed to check for upgrade", ex);
            }
            finally
            {
                _timer.Change(interval, interval);
            }
        }