void IAlarmSource.RunThread()
{
var intervalLogger = new ExceptionIntervalLogger(TimeSpan.FromMinutes(10));
while (true)
{
try
{
//.tif or .pdf
FileInfo[] files = _faxPath.GetFiles("*.*", SearchOption.TopDirectoryOnly)
.Where(_ => _.Name.EndsWith(".tif", StringComparison.InvariantCultureIgnoreCase) || _.Name.EndsWith(".pdf", StringComparison.InvariantCultureIgnoreCase))
.ToArray();
if (files.Length > 0)
{
Logger.Instance.LogFormat(LogType.Trace, this, Properties.Resources.BeginProcessingFaxes, files.Length);
foreach (FileInfo file in files)
{
if(file.Extension == ".pdf")
{
ProcessNewPdf(file);
}
else
{
ProcessNewImage(file);
}
}
Logger.Instance.LogFormat(LogType.Trace, this, Properties.Resources.ProcessingFaxesComplete);
}
intervalLogger.ResetExceptionCollection();
Thread.Sleep(RoutineIntervalMs);
}
catch(Exception ex)
{
intervalLogger.LogFormat(ex, LogType.Warning, this, Properties.Resources.FaxDirAccessError, _faxPath.FullName, ex.ToString());
}
}
}