aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs92
1 files changed, 92 insertions, 0 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs
index 778297cbe..33297d103 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs
@@ -4,19 +4,26 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL.Enumerations;
+using Tango.BL.Helpers;
using Tango.Core.Commands;
using Tango.Core.DI;
+using Tango.Core.IO;
using Tango.Core.Threading;
+using Tango.CSV;
using Tango.FSE.Common;
using Tango.FSE.Common.HotFolder;
using Tango.FSE.Common.Navigation;
using Tango.FSE.Common.Notifications;
+using Tango.FSE.Common.RemoteJobUpload;
using Tango.FSE.UI.Dialogs;
using Tango.FSE.UI.Panes;
using Tango.FSE.UI.Views;
using Tango.Integration.ExternalBridge;
+using Tango.PPC.Shared.Statistics;
using Tango.SharedUI.Helpers;
using Tango.Transport;
+using static Tango.BL.Helpers.SegmentsCsvHelper;
namespace Tango.FSE.UI.ViewModels
{
@@ -114,6 +121,9 @@ namespace Tango.FSE.UI.ViewModels
[TangoInject]
public IHotFolderService HotFolderService { get; set; }
+ [TangoInject]
+ public IRemoteJobUploadProvider RemoteJobUploadProvider { get; set; }
+
#endregion
#region Commands
@@ -148,6 +158,11 @@ namespace Tango.FSE.UI.ViewModels
/// </summary>
public RelayCommand ConfigureHotFolderCommand { get; set; }
+ /// <summary>
+ /// Opens the job upload dialog.
+ /// </summary>
+ public RelayCommand UploadJobCommand { get; set; }
+
#endregion
#region Constructors
@@ -176,6 +191,8 @@ namespace Tango.FSE.UI.ViewModels
NavigateToEventsCommand = new RelayCommand(NavigateToEvents);
NavigateHomeCommand = new RelayCommand(NavigateHome);
ConfigureHotFolderCommand = new RelayCommand(ConfigureHotFolder);
+
+ UploadJobCommand = new RelayCommand(UploadJob);
}
#endregion
@@ -351,6 +368,81 @@ namespace Tango.FSE.UI.ViewModels
await NotificationProvider.ShowDialog<HotFolderConfigurationViewVM>();
}
+ private async void UploadJob()
+ {
+ RequiredFiltersData data = null;
+ try
+ {
+ using (NotificationProvider.PushTaskItem("Preparing job upload requirements..."))
+ {
+ await Task.Delay(1500);
+ data = await StatisticsProvider.GetRequiredFiltersData();
+ }
+ }
+ catch (Exception ex)
+ {
+ await NotificationProvider.ShowError($"Error preparing job upload requirements.\n{ex.FlattenMessage()}");
+ return;
+ }
+
+ var lastSelectedRml = data.Rmls.FirstOrDefault(x => x.Guid == Settings.LastJobUploadThreadGuid);
+ if (lastSelectedRml == null) lastSelectedRml = data.Rmls.FirstOrDefault();
+ var vm = await NotificationProvider.ShowDialog(new JobUploadViewVM() { Rmls = data.Rmls, SelectedRML = lastSelectedRml });
+
+ if (vm.DialogResult)
+ {
+ TemporaryFile tmpFile = TemporaryManager.CreateFile(".csv");
+
+ try
+ {
+ Settings.LastJobUploadThreadGuid = vm.SelectedRML.Guid;
+ Settings.Save();
+
+ SegmentCsvModel model = new SegmentCsvModel();
+ List<string> columnNames = model.GetType().GetProperties().Select(x => x.Name).ToList();
+ CsvFile<SegmentCsvModel> csvFile = new CsvFile<SegmentCsvModel>(new CsvDestination(tmpFile), new CsvDefinition()
+ {
+ Columns = columnNames
+ });
+
+ model.Index = "1";
+ model.ThreadName = vm.SelectedRML.Name;
+ model.ColorSpace = ColorSpaces.Volume.ToDescription();
+ model.Length = vm.Length.ToString();
+ model.Cyan1 = vm.C.ToString();
+ model.Magenta1 = vm.M.ToString();
+ model.Yellow1 = vm.Y.ToString();
+ model.Black1 = vm.K.ToString();
+
+ csvFile.Append(model);
+ csvFile.Dispose();
+ }
+ catch (Exception ex)
+ {
+ await NotificationProvider.ShowError($"Error creating job upload file.\n{ex.FlattenMessage()}");
+ tmpFile.Delete();
+ return;
+ }
+
+ SnackbarItem progress = null;
+
+ try
+ {
+ progress = NotificationProvider.PushProgressSnackbar("Job Upload", $"Uploading job '{vm.Name}'...");
+ await Task.Delay(1500);
+ await RemoteJobUploadProvider.UploadJob(tmpFile, PPC.Shared.RemoteJobUpload.RemoteJobUploadType.CSV, vm.Name);
+
+ progress.ProgressCompleted("Job uploaded successfully", TimeSpan.FromSeconds(2));
+ }
+ catch (Exception ex)
+ {
+ progress.ProgressFailed($"Error uploading job.\n{ex.Message}");
+ return;
+ }
+ }
+
+ }
+
#endregion
}
}