private void WriteLogNode(XmlTextWriter writer, LogItem m) { writer.WriteStartElement("logfile-item"); WriteElement(writer, "log-dir", m.LogDir); WriteElement(writer, "filespec", m.Filespec); WriteElement(writer, "datemailed", string.Format("{0:u}", m.MailDate)); writer.WriteEndElement(); }
public void PutItem(LogItem m) { var filespec = m.Filespec; if (!TheHt.ContainsKey(filespec)) { TheHt.Add(filespec, m); IsDirty = true; } }
private DateTime MailLogFiles(LogItem logitem) { var lastDate = new DateTime( 1, 1, 1 ); var filesFound = LogFileDetector.DetectLogFileIn( logitem.LogDir, logitem.Filespec, logitem.MailDate ); LogitIfThereWereNofilesFound( logitem, filesFound ); foreach ( var file in filesFound ) { var errorMsg = MailMan.SendMail( message: "Recently Added", subject: SubjectLine(file), attachment: file ); lastDate = LogResult( logitem, lastDate, file, errorMsg ); } return lastDate; }
private void LogitIfThereWereNofilesFound( LogItem logitem, List<string> filesFound ) { if ( NoFilesWereFound( filesFound ) ) { Logger.Info( string.Format( " No Files were found in {0} like {1} later than {2}", logitem.LogDir, logitem.Filespec, logitem.MailDate ) ); } }
private DateTime LogResult( LogItem logitem, DateTime lastDate, string file, string errorMsg ) { if ( string.IsNullOrEmpty( errorMsg ) ) { lastDate = LogFileDetector.FileDate( logitem.LogDir, LogFileDetector.FilePartFile( logitem.LogDir, file ) ); LogsMailed++; Logger.Info( string.Format( "Emailed {0}", file ) ); } else { Logger.Error( string.Format( "Failed to email {0} - {1}", file, errorMsg ) ); } return lastDate; }
private DateTime MailLogFiles(LogItem logitem) { var lastDate = new DateTime(1, 1, 1); var filesFound = LogFileDetector.DetectLogFileIn(logitem.LogDir, logitem.Filespec, logitem.MailDate); foreach (var file in filesFound) { var errorMsg = MailMan.SendMail(message: "Log file", subject: "For perusal", attachment:file); if (string.IsNullOrEmpty(errorMsg)) { lastDate = LogFileDetector.FileDate(logitem.LogDir, LogFileDetector.FilePartFile(logitem.LogDir, file)); LogsMailed++; Logger.Info(string.Format("Emailed {0}", file)); } else { Logger.Error(string.Format("Failed to email {0} - {1}", file, errorMsg)); } } return lastDate; }
private void AddLogItem(LogItem logItem) { PutItem(logItem); }