diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-13 13:58:45 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-13 13:58:45 +0300 |
| commit | 4cc4089f36b0a9b9d754e33acb49da930f846699 (patch) | |
| tree | 314c77ca012d10ff1440a112893072943e479066 /Software/Visual_Studio/PPC/Tango.PPC.UI/Printing | |
| parent | 8d58d0b03648069600f8abf39dbe68b16c90559b (diff) | |
| download | Tango-4cc4089f36b0a9b9d754e33acb49da930f846699.tar.gz Tango-4cc4089f36b0a9b9d754e33acb49da930f846699.zip | |
Some fixed to TCC mobile design.
Implemented DFU reset on Machine Operator.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Printing')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs index 7d4aa154e..1f09023cb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -45,7 +45,6 @@ namespace Tango.PPC.UI.Printing /// <returns></returns> public async Task<JobHandler> Print(Job job, ObservablesContext context) { - JobHandler handler = null; #if STUBPRINT @@ -66,9 +65,25 @@ namespace Tango.PPC.UI.Printing { try { + job.JobStatus = JobStatuses.Completed; + + if (!context.IsDisposed) + { + await context.SaveChangesAsync(); + } + else + { + using (var newContext = ObservablesContext.CreateDefault()) + { + var newJob = newContext.Jobs.SingleOrDefault(y => y.Guid == job.Guid); + if (newJob != null) + { + newJob.JobStatus = JobStatuses.Completed; + await newContext.SaveChangesAsync(); + } + } + } - job.JobStatus = BL.Enumerations.JobStatuses.Completed; - await context.SaveChangesAsync(); RaiseJobSaved(job); } catch (Exception ex) @@ -76,12 +91,12 @@ namespace Tango.PPC.UI.Printing LogManager.Log(ex, "Error occurred after job printing completed."); } }; - handler.Canceled += async (x, e) => + handler.Canceled += (x, e) => { try { //No change in status ! - await context.SaveChangesAsync(); + //await context.SaveChangesAsync(); RaiseJobSaved(job); } catch (Exception ex) @@ -94,8 +109,25 @@ namespace Tango.PPC.UI.Printing try { - job.JobStatus = BL.Enumerations.JobStatuses.Disrupted; - await context.SaveChangesAsync(); + job.JobStatus = JobStatuses.Disrupted; + + if (!context.IsDisposed) + { + await context.SaveChangesAsync(); + } + else + { + using (var newContext = ObservablesContext.CreateDefault()) + { + var newJob = newContext.Jobs.SingleOrDefault(y => y.Guid == job.Guid); + if (newJob != null) + { + newJob.JobStatus = JobStatuses.Disrupted; + await newContext.SaveChangesAsync(); + } + } + } + RaiseJobSaved(job); } catch (Exception ex) |
