Exemple #1
0
        private static void TimerElapsed(object sender, EventArgs e)
        {
            try
            {
                _appTimer.Stop();
                _eventLogger.LogMessage("Running ip check...");
                var result = _serviceHelper.Check();

                if (result.Success)
                {
                    _eventLogger.LogMessage(result.Updated
                        ? $"IP Address was updated from {result.OldAddress} to {result.NewAddress}"
                        : $"IP Address was not updated since the old ({result.OldAddress}) and new ({result.NewAddress}) are the same");
                }
                else
                {
                    _eventLogger.LogMessage(result.Exception.Message, EventLogEntryType.Error);
                }
                _appTimer.Start();
            }
            catch (Exception ex)
            {
                _eventLogger.LogMessage(JsonConvert.SerializeObject(ex), EventLogEntryType.Error);
            }
        }