Created
June 23, 2016 17:25
-
-
Save alex-doe/f1dc3ff558e62f48837c5a43c33382fd to your computer and use it in GitHub Desktop.
Idee ohne endlosem Logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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