Skip to content

Instantly share code, notes, and snippets.

@alex-doe
Created June 23, 2016 17:25
Show Gist options
  • Save alex-doe/f1dc3ff558e62f48837c5a43c33382fd to your computer and use it in GitHub Desktop.
Save alex-doe/f1dc3ff558e62f48837c5a43c33382fd to your computer and use it in GitHub Desktop.
Idee ohne endlosem Logging
void IAlarmSource.RunThread()
{
bool isNewError = true;
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);
}
}
isNewError = true;
Logger.Instance.LogFormat(LogType.Trace, this, Properties.Resources.ProcessingFaxesComplete);
}
Thread.Sleep(RoutineIntervalMs);
}
catch(Exception ex)
{
if(isNewError)
{
Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.FaxDirAccessError, _faxPath.FullName, ex.ToString());
isNewError = false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment