🐛 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 machine = job.MachineName?.TrimStart('\\');
|
||||||
var username = job.UserName;
|
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)
|
if (domain == null || machine == null || username == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private readonly IJobProcessor _jobProcessor;
|
private readonly IJobProcessor _jobProcessor;
|
||||||
|
|
||||||
private IDirectoryHelper _directoryHelper;
|
[NotNull]
|
||||||
|
private readonly IDirectoryHelper _directoryHelper;
|
||||||
|
|
||||||
private TcpListener _socket;
|
private TcpListener _socket;
|
||||||
private FileSystemWatcher _watcher;
|
private FileSystemWatcher _watcher;
|
||||||
private string _outputDir;
|
private string _outputDir;
|
||||||
|
|
@ -101,20 +103,21 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
|
||||||
|
|
||||||
LogDebug($"{remote} --> {local}");
|
LogDebug($"{remote} --> {local}");
|
||||||
job = _jobFactory.Create(printer, client.GetStream());
|
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);
|
socket.BeginAcceptTcpClient(HandleClient, ar.AsyncState);
|
||||||
|
|
||||||
|
if (job == null)
|
||||||
|
{
|
||||||
|
LogError("Job could not be created. Check your Printer Settings.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogDebug($"Temporarily printed '{job.RawDataPath}'!");
|
||||||
_jobService.Start(job);
|
_jobService.Start(job);
|
||||||
|
|
||||||
RestartFileWatcherIfNeeded(job.SessionInfo.Sid);
|
RestartFileWatcherIfNeeded(job.SessionInfo.Sid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void RestartFileWatcherIfNeeded(string sid)
|
private void RestartFileWatcherIfNeeded(string sid)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ namespace AmagnoVirtualPrinter.Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
[ContractAnnotation("key:null => void")]
|
[ContractAnnotation("key:null => void")]
|
||||||
private void CheckForNull(RegistryKey key, string keyName)
|
private static void CheckForNull(RegistryKey key, string keyName)
|
||||||
{
|
{
|
||||||
if (key == null)
|
if (key == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue