aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs51
1 files changed, 50 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
index 5b4a3e403..ed1e28f55 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
@@ -3,12 +3,15 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
+using Tango.BL.Builders;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.Integration.Operation;
using Tango.PPC.Common;
using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.Notifications.NotificationItems;
+using Tango.PPC.Jobs.Messages;
using Tango.PPC.Jobs.NavigationObjects;
using Tango.PPC.Jobs.Views;
@@ -20,6 +23,8 @@ namespace Tango.PPC.Jobs.ViewModels
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
public class MainViewVM : PPCViewModel
{
+ private NotificationItem _last_failed_job_notification;
+
/// <summary>
/// Called when the application has been started.
/// </summary>
@@ -27,6 +32,44 @@ namespace Tango.PPC.Jobs.ViewModels
{
MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted;
MachineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed;
+ MachineProvider.MachineOperator.ResumingJob += MachineOperator_ResumingJob;
+ }
+
+ private async void MachineOperator_ResumingJob(object sender, ResumingJobEventArgs e)
+ {
+ LogManager.Log($"Trying to resume job '{e.JobGuid}'...");
+
+ try
+ {
+ var job = await new JobBuilder(ObservablesContext.CreateDefault()).Set(e.JobGuid)
+ .WithConfiguration()
+ .WithRML()
+ .WithUser()
+ .WithSegments()
+ .WithBrushStops()
+ .BuildAsync();
+
+ e.Approve(job);
+
+ InvokeUI(() =>
+ {
+ NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView));
+
+ if (_last_failed_job_notification != null)
+ {
+ _last_failed_job_notification.Close();
+ _last_failed_job_notification = null;
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "An error occurred while trying to resume the job.");
+ InvokeUI(() =>
+ {
+ NotificationProvider.ShowError("An error occurred while trying to resume a job in progress.");
+ });
+ }
}
/// <summary>
@@ -36,7 +79,7 @@ namespace Tango.PPC.Jobs.ViewModels
/// <param name="e">The <see cref="Integration.Operation.PrintingFailedEventArgs"/> instance containing the event data.</param>
private void MachineOperator_PrintingFailed(object sender, PrintingFailedEventArgs e)
{
- NotificationProvider.PushNotification(new MessageNotificationItem(
+ _last_failed_job_notification = NotificationProvider.PushNotification(new MessageNotificationItem(
String.Format("'{0}' failed.", e.Job.Name),
String.Format("The job '{1}' has failed due to unexpected error.{0}{2}{0}{0}Tap to view this job details.", Environment.NewLine, e.Job.Name, e.Exception), MessageNotificationItem.MessageNotificationItemTypes.Error, () =>
{
@@ -79,5 +122,11 @@ namespace Tango.PPC.Jobs.ViewModels
}));
}
}
+
+ public override void OnNavigatedTo()
+ {
+ base.OnNavigatedTo();
+ RaiseMessage<NavigatedToJobsModuleMessage>();
+ }
}
}