public void Process(MonitorJob monitorJob) { Log.DebugFormat("Stepped into process for monitorjob '{0}'", monitorJob.ID); if (!Directory.Exists(monitorJob.Path)) { Log.ErrorFormat("We could not find the directory '{0}'", monitorJob.Path); throw new DirectoryNotFoundException(monitorJob.Path); } var directoryInfo = new DirectoryInfo(monitorJob.Path); var allTheFiles = directoryInfo.GetFiles(monitorJob.FileExtensionToWatch); foreach (var fileInfo in allTheFiles) { if (fileInfo.CreationTime < _timeActions.Now().Subtract(GetTimeSpanToUse(monitorJob.Threshold, monitorJob.ThresholdType))) { var message = string.Format("There is a file '{0}' of type '{1}' older than the threshold '{2}' {3} in the directory '{4}'", fileInfo.Name, monitorJob.FileExtensionToWatch, monitorJob.Threshold, monitorJob.ThresholdType, monitorJob.Path); Log.InfoFormat(message); _emailActions.SendAlert(message); return; } } }
public void Process(MonitorJob monitorJob) { Log.DebugFormat("Stepped into process for monitorjob '{0}' with directory '{1}' and fileExtensionToWatch '{2}'", monitorJob.ID, monitorJob.Path, monitorJob.FileExtensionToWatch); if (!Directory.Exists(monitorJob.Path)) { Log.ErrorFormat("We could not find the directory '{0}'", monitorJob.Path); throw new DirectoryNotFoundException(monitorJob.Path); } DirectoryInfo directoryInfo = new DirectoryInfo(monitorJob.Path); var allTheFiles = directoryInfo.GetFiles(monitorJob.FileExtensionToWatch); Log.DebugFormat("We found '{0}' files with extension '{1}'to check the size on in the directory '{2}'", allTheFiles.Length, monitorJob.FileExtensionToWatch, monitorJob.Path); foreach (var fileInfo in allTheFiles) { Log.DebugFormat("FileSmallerThanThresholdMonitorer found '{0}' files to process", allTheFiles.Length); if (fileInfo.Length < monitorJob.MinFileSizeInBytes) { Log.DebugFormat("we are looking at a file of size '{0}'", fileInfo.Length); var message = string.Format("There is a file '{0}' of type '{1}' smaller than the min filesize'{2}' in the directory '{3}'", fileInfo.Name, monitorJob.FileExtensionToWatch, monitorJob.MinFileSizeInBytes, monitorJob.Path); Log.InfoFormat(message); _emailActions.SendAlert(message); return; } } Log.DebugFormat("FileSmallerThanThresholdMonitorer.Process did not find a file smaller than '{0}'bytes to process", monitorJob.MinFileSizeInBytes); }
public void Process(MonitorJob monitorJob) { Log.DebugFormat("Stepped into process for monitorjob '{0}'", monitorJob.ID); if (!Directory.Exists(monitorJob.Path)) { Log.ErrorFormat("We could not find the directory '{0}'", monitorJob.Path); throw new DirectoryNotFoundException(monitorJob.Path); } var lastWriteTime = Directory.GetLastWriteTime(monitorJob.Path); if (lastWriteTime < _timeActions.Now().Subtract(GetTimeSpanToUse(monitorJob.Threshold, monitorJob.ThresholdType))) { var emailMessage = string.Format("No new files have shown up in the directory '{0}' in the last '{1}' '{2}'", monitorJob.Path, monitorJob.Threshold, monitorJob.ThresholdType); Log.InfoFormat(emailMessage); _emailActions.SendAlert(emailMessage); } }
public void Process(MonitorJob monitorJob) { Log.DebugFormat("Stepped into process for monitorjob '{0}'", monitorJob.ID); if (!Directory.Exists(monitorJob.Path)) { Log.ErrorFormat("We could not find the BadFile directory '{0}'", monitorJob.Path); throw new DirectoryNotFoundException(monitorJob.Path); } string[] filesInBadFileDirectory = Directory.GetFiles(monitorJob.Path); if (filesInBadFileDirectory.Length > 0) { var message = string.Format("There are 'Bad Files' in the directory {0}", monitorJob.Path); Log.InfoFormat(message); _emailActions.SendAlert(message); return; } Log.DebugFormat("BadFilesFolderMonitorer did not find any files to gripe about in '{0}'", monitorJob.Path); }