protected virtual void LogWatcherTimerElapsedCallback(object sender, ElapsedEventArgs e) { if (!IsSolutionOpen()) { return; } var logFileStatus = GetLogFileStatus(); // Log file has been deleted. if (logFileStatus == null && _previousLogFileStatus != null) { LogUpdated?.Invoke(this, new LogChangedEventArgs { LogFileStatus = new LogFileStatus { Exists = false, LastUpdatedUtc = DateTime.UtcNow, HasContent = false, Path = _previousLogFileStatus.Path } }); } // Log file has been added or changed. else if (_previousLogFileStatus == null && logFileStatus != null || logFileStatus != null && !logFileStatus.Equals(_previousLogFileStatus)) { LogUpdated?.Invoke(this, new LogChangedEventArgs { LogFileStatus = logFileStatus }); } _previousLogFileStatus = logFileStatus; }
private void LogFileUpdatedCallback(object sender, LogChangedEventArgs context) { _hasSeenErrorLogUpdate = !context.LogFileStatus.HasContent; _latestUpdatedLogFileStatus = context.LogFileStatus; UpdateOpenErrorLogCommandAccessibilityAndText(context.LogFileStatus); }
public virtual void StopWatching() { if (!_isWatching) { return; } _timer.Stop(); _timer.Elapsed -= LogWatcherTimerElapsedCallback; _isWatching = false; _previousLogFileStatus = null; }
public virtual void StartWatching() { if (_isWatching) { return; } _previousLogFileStatus = GetLogFileStatus(); _timer.Interval = DefaultLogWatcherTimerIntervalInMilliseconds; _timer.AutoReset = true; _timer.Elapsed += LogWatcherTimerElapsedCallback; _timer.Start(); _isWatching = true; }
private void LogWatcherTimerElapsedCallback(object sender, ElapsedEventArgs e) { if (!IsSolutionOpen()) { return; } var logFileStatus = GetLogFileStatus(); if (!logFileStatus.Equals(_previousLogFileStatus)) { LogUpdated?.Invoke(this, new LogChangedEventArgs { LogFileStatus = logFileStatus }); _previousLogFileStatus = logFileStatus; } }
private void UpdateOpenErrorLogCommandAccessibilityAndText(ILogFileStatus logFileStatus = null) { if (!_dte.Solution.IsOpen) { _openErrorLogCommand.Enabled = false; _openErrorLogCommand.Text = "Solution is not open"; } else if (_lazyLogWatcherSettings.Value.LogWatcherEnabled && ((logFileStatus?.HasContent ?? false) || !_hasSeenErrorLogUpdate)) { _openErrorLogCommand.Enabled = true; _openErrorLogCommand.Text = "Open Orchard error log"; } else { _openErrorLogCommand.Enabled = false; _openErrorLogCommand.Text = "Orchard error log doesn't exist or hasn't been updated"; } }