🐛 Fix Error Handling of Job Factory
This commit is contained in:
parent
a22a3b0cfd
commit
49ee9b1079
3 changed files with 16 additions and 13 deletions
|
|
@ -147,7 +147,7 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
|
|||
var machine = job.MachineName?.TrimStart('\\');
|
||||
var username = job.UserName;
|
||||
|
||||
LogDebug($"Searching for session of {domain}\\{username} on {machine} !");
|
||||
LogDebug($"Searching for session of {domain}\\{username} on {machine}!");
|
||||
|
||||
if (domain == null || machine == null || username == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
|
|||
[NotNull]
|
||||
private readonly IJobProcessor _jobProcessor;
|
||||
|
||||
private IDirectoryHelper _directoryHelper;
|
||||
[NotNull]
|
||||
private readonly IDirectoryHelper _directoryHelper;
|
||||
|
||||
private TcpListener _socket;
|
||||
private FileSystemWatcher _watcher;
|
||||
private string _outputDir;
|
||||
|
|
@ -101,19 +103,20 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
|
|||
|
||||
LogDebug($"{remote} --> {local}");
|
||||
job = _jobFactory.Create(printer, client.GetStream());
|
||||
if (job == null)
|
||||
{
|
||||
LogError("Job could not be created.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LogDebug($"Temporarily printed '{job.RawDataPath}'!");
|
||||
socket.BeginAcceptTcpClient(HandleClient, ar.AsyncState);
|
||||
|
||||
_jobService.Start(job);
|
||||
|
||||
RestartFileWatcherIfNeeded(job.SessionInfo.Sid);
|
||||
|
||||
if (job == null)
|
||||
{
|
||||
LogError("Job could not be created. Check your Printer Settings.");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebug($"Temporarily printed '{job.RawDataPath}'!");
|
||||
_jobService.Start(job);
|
||||
RestartFileWatcherIfNeeded(job.SessionInfo.Sid);
|
||||
}
|
||||
}
|
||||
|
||||
private void RestartFileWatcherIfNeeded(string sid)
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ namespace AmagnoVirtualPrinter.Utils
|
|||
}
|
||||
|
||||
[ContractAnnotation("key:null => void")]
|
||||
private void CheckForNull(RegistryKey key, string keyName)
|
||||
private static void CheckForNull(RegistryKey key, string keyName)
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue