aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/HotFolder/DefaultHotFolderService.cs29
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteJobUpload/DefaultRemoteJobUploadProvider.cs7
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs112
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj6
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs137
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs4
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJobUpload/DefaultRemoteJobUploadService.cs5
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteJobUpload/RemoteJobUploadCompletedResponse.cs2
-rw-r--r--Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs108
9 files changed, 291 insertions, 119 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/HotFolder/DefaultHotFolderService.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/HotFolder/DefaultHotFolderService.cs
index 063f141da..09882b198 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/HotFolder/DefaultHotFolderService.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/HotFolder/DefaultHotFolderService.cs
@@ -21,6 +21,13 @@ namespace Tango.FSE.UI.HotFolder
public class DefaultHotFolderService : FSEExtendedObject, IHotFolderService
{
private Thread _watchThread;
+ private List<FailedItem> _failedItems;
+
+ private class FailedItem
+ {
+ public String File { get; set; }
+ public int Count { get; set; }
+ }
private bool _enabled;
public bool Enabled
@@ -53,6 +60,8 @@ namespace Tango.FSE.UI.HotFolder
public DefaultHotFolderService(IMachineProvider machineProvider)
{
+ _failedItems = new List<FailedItem>();
+
MachineProvider = machineProvider;
var settings = SettingsManager.Default.GetOrCreate<FSESettings>();
@@ -132,6 +141,13 @@ namespace Tango.FSE.UI.HotFolder
if (upload)
{
+ var failedItem = _failedItems.FirstOrDefault(x => x.File == file);
+
+ if (failedItem != null && failedItem.Count > 1)
+ {
+ continue;
+ }
+
LogManager.Log($"Found new hot folder item '{fileName}'. Uploading...");
var snackItem = NotificationProvider.PushProgressSnackbar("Hot Folder", $"Uploading '{fileName}' to machine '{MachineProvider.Machine.SerialNumber}'...");
@@ -154,8 +170,19 @@ namespace Tango.FSE.UI.HotFolder
}
catch (Exception ex)
{
+ failedItem = _failedItems.FirstOrDefault(x => x.File == file);
+
+ if (failedItem == null)
+ {
+ _failedItems.Add(new FailedItem() { File = file, Count = 1 });
+ }
+ else
+ {
+ failedItem.Count++;
+ }
+
LogManager.Log(ex, $"Error uploading hot folder item '{fileName}'.");
- snackItem.ProgressFailed($"'{fileName}' upload failed.");
+ snackItem.ProgressFailed($"'{fileName}' upload failed.\n{ex.Message}");
}
}
}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteJobUpload/DefaultRemoteJobUploadProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteJobUpload/DefaultRemoteJobUploadProvider.cs
index c695dd1e0..535e5edca 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteJobUpload/DefaultRemoteJobUploadProvider.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteJobUpload/DefaultRemoteJobUploadProvider.cs
@@ -51,11 +51,16 @@ namespace Tango.FSE.UI.RemoteJobUpload
throw handler.FailedException;
}
- await MachineProvider.MachineOperator.SendGenericRequest<RemoteJobUploadCompletedRequest, RemoteJobUploadCompletedResponse>(new RemoteJobUploadCompletedRequest()
+ var completedResponse = await MachineProvider.MachineOperator.SendGenericRequest<RemoteJobUploadCompletedRequest, RemoteJobUploadCompletedResponse>(new RemoteJobUploadCompletedRequest()
{
ID = uploadResponse.ID
}, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(20) });
+ if (completedResponse.Error.IsNotNullOrEmpty())
+ {
+ throw new OperationCanceledException(completedResponse.Error);
+ }
+
LogManager.Log($"Job upload '{filePath}' completed successfully.");
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs
index b37cd1c68..0b039b618 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs
@@ -893,71 +893,71 @@ namespace Tango.PPC.Jobs.ViewModels
private async void HandleCsvJobFileLoaded(List<ExplorerFileItem> files)
{
- var item = files.FirstOrDefault();
- if (item == null) return;
+ //var item = files.FirstOrDefault();
+ //if (item == null) return;
- var vm = new ImportCsvJobViewVM();
- vm.Name = Path.GetFileNameWithoutExtension(item.Name);
- await vm.Init();
- await NotificationProvider.ShowDialog<ImportCsvJobViewVM>(vm);
+ //var vm = new ImportCsvJobViewVM();
+ //vm.Name = Path.GetFileNameWithoutExtension(item.Name);
+ //await vm.Init();
+ //await NotificationProvider.ShowDialog<ImportCsvJobViewVM>(vm);
- if (vm.DialogResult && vm.SelectedRml != null)
- {
- try
- {
- NotificationProvider.SetGlobalBusyMessage("Importing job from file...");
+ //if (vm.DialogResult && vm.SelectedRml != null)
+ //{
+ // try
+ // {
+ // NotificationProvider.SetGlobalBusyMessage("Importing job from file...");
- using (ObservablesContext db = ObservablesContext.CreateDefault())
- {
- var segments = await SegmentsCsvHelper.FromFile(item.Path, MachineProvider.Machine, db);
+ // using (ObservablesContext db = ObservablesContext.CreateDefault())
+ // {
+ // var segments = await SegmentsCsvHelper.FromFile(item.Path, MachineProvider.Machine, db);
- Job job = new Job();
- job.LastUpdated = DateTime.UtcNow;
- job.JobSource = JobSource.Local;
- job.Name = vm.Name;
- job.NumberOfHeads = 1;
- job.NumberOfUnits = 1;
- job.SampleUnitsOrMeters = 1;
- job.CreationDate = DateTime.UtcNow;
- job.JobStatus = JobStatuses.Draft;
- job.JobType = JobTypes.Knitting;
- job.EnableLubrication = true;
- job.MachineGuid = MachineProvider.Machine.Guid;
- job.RmlGuid = vm.SelectedRml.Guid;
- job.Machine = await new MachineBuilder(db).Set(job.MachineGuid).WithCats().WithConfiguration().BuildAsync();
- job.Rml = await new RmlBuilder(db).Set(job.RmlGuid).WithActiveParametersGroup().WithCAT(MachineProvider.Machine.Guid).WithCCT().WithGbdAndLub().WithLiquidFactors().BuildAsync();
- job.WindingMethodGuid = Adapter.WindingMethods.FirstOrDefault().Guid;
- job.SpoolTypeGuid = Settings.SpoolTypeGuid != null ? Settings.SpoolTypeGuid : Adapter.SpoolTypes.FirstOrDefault().Guid;
+ // Job job = new Job();
+ // job.LastUpdated = DateTime.UtcNow;
+ // job.JobSource = JobSource.Local;
+ // job.Name = vm.Name;
+ // job.NumberOfHeads = 1;
+ // job.NumberOfUnits = 1;
+ // job.SampleUnitsOrMeters = 1;
+ // job.CreationDate = DateTime.UtcNow;
+ // job.JobStatus = JobStatuses.Draft;
+ // job.JobType = JobTypes.Knitting;
+ // job.EnableLubrication = true;
+ // job.MachineGuid = MachineProvider.Machine.Guid;
+ // job.RmlGuid = vm.SelectedRml.Guid;
+ // job.Machine = await new MachineBuilder(db).Set(job.MachineGuid).WithCats().WithConfiguration().BuildAsync();
+ // job.Rml = await new RmlBuilder(db).Set(job.RmlGuid).WithActiveParametersGroup().WithCAT(MachineProvider.Machine.Guid).WithCCT().WithGbdAndLub().WithLiquidFactors().BuildAsync();
+ // job.WindingMethodGuid = Adapter.WindingMethods.FirstOrDefault().Guid;
+ // job.SpoolTypeGuid = Settings.SpoolTypeGuid != null ? Settings.SpoolTypeGuid : Adapter.SpoolTypes.FirstOrDefault().Guid;
- foreach (var segment in segments)
- {
- segment.Job = job;
- job.Segments.Add(segment);
- }
+ // foreach (var segment in segments)
+ // {
+ // segment.Job = job;
+ // job.Segments.Add(segment);
+ // }
- IColorConverter converter = new DefaultColorConverter();
+ // IColorConverter converter = new DefaultColorConverter();
- foreach (var stop in segments.SelectMany(x => x.BrushStops.Where(y => y.BrushColorSpace == ColorSpaces.Volume)))
- {
- var output = converter.Convert(stop, false);
- var suggestion = output.CreateSingleSuggestion();
- stop.Color = suggestion.Color;
- }
+ // foreach (var stop in segments.SelectMany(x => x.BrushStops.Where(y => y.BrushColorSpace == ColorSpaces.Volume)))
+ // {
+ // var output = converter.Convert(stop, false);
+ // var suggestion = output.CreateSingleSuggestion();
+ // stop.Color = suggestion.Color;
+ // }
- db.Jobs.Add(job);
- await db.SaveChangesAsync();
- LoadJobs();
- }
+ // db.Jobs.Add(job);
+ // await db.SaveChangesAsync();
+ // LoadJobs();
+ // }
- NotificationProvider.ReleaseGlobalBusyMessage();
- }
- catch (Exception ex)
- {
- NotificationProvider.ReleaseGlobalBusyMessage();
- LogManager.Log(ex, "Error importing job from CSV.");
- await NotificationProvider.ShowError($"Error importing job from csv file.\n{ex.FlattenMessage()}");
- }
- }
+ // NotificationProvider.ReleaseGlobalBusyMessage();
+ // }
+ // catch (Exception ex)
+ // {
+ // NotificationProvider.ReleaseGlobalBusyMessage();
+ // LogManager.Log(ex, "Error importing job from CSV.");
+ // await NotificationProvider.ShowError($"Error importing job from csv file.\n{ex.FlattenMessage()}");
+ // }
+ //}
}
#endregion
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj
index 8edc18f1f..26c059d15 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj
@@ -458,6 +458,10 @@
<Project>{0be74eee-22cb-4dba-b896-793b9e1a3ac0}</Project>
<Name>Tango.PPC.Common</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\Tango.PPC.Shared\Tango.PPC.Shared.csproj">
+ <Project>{208c8bd8-72c6-4e3c-acaa-351091a2acc7}</Project>
+ <Name>Tango.PPC.Shared</Name>
+ </ProjectReference>
<ProjectReference Include="..\Tango.PPC.Storage\Tango.PPC.Storage.csproj">
<Project>{04febb02-f782-4b96-b47d-f6902afa43be}</Project>
<Name>Tango.PPC.Storage</Name>
@@ -715,7 +719,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs
index 1f6798881..38413b24c 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs
@@ -42,6 +42,9 @@ using Tango.PPC.Storage.Models;
using Tango.BL.Helpers;
using Tango.ColorConversion;
using Tango.PPC.Jobs.Models;
+using Tango.PPC.Shared.RemoteJobUpload;
+using Tango.PPC.Common.Notifications;
+using Tango.PPC.Common.Notifications.NotificationItems;
namespace Tango.PPC.Jobs.ViewModels
{
@@ -221,7 +224,7 @@ namespace Tango.PPC.Jobs.ViewModels
/// Gets or sets the export job command.
/// </summary>
public RelayCommand ExportJobCommand { get; set; }
-
+
#endregion
#region Constructors
@@ -248,7 +251,7 @@ namespace Tango.PPC.Jobs.ViewModels
DeleteJobsCommand = new RelayCommand(() => DeleteJobs(SelectedJobs));
CloneJobsCommand = new RelayCommand(() => CloneJobs(SelectedJobs));
ExportJobCommand = new RelayCommand(ExportJob);
-
+
RegisterForMessage<JobRemovedMessage>(HandleJobRemovedMessage);
RegisterForMessage<JobSavedMessage>(HandleJobSavedMessage);
RegisterForMessage<NavigatedToJobsModuleMessage>((x) => Filter = null);
@@ -345,7 +348,7 @@ namespace Tango.PPC.Jobs.ViewModels
/// <summary>
/// Loads the jobs from database.
/// </summary>
- public void LoadJobs(Action onCompleted = null)
+ public void LoadJobs(Action onCompleted = null, bool animate = true)
{
try
{
@@ -353,7 +356,7 @@ namespace Tango.PPC.Jobs.ViewModels
Task.Factory.StartNew(() =>
{
- IsLoadingJobs = true;
+ if (animate) IsLoadingJobs = true;
Thread.Sleep(500);
@@ -417,32 +420,32 @@ namespace Tango.PPC.Jobs.ViewModels
var settings = SettingsManager.Default.GetOrCreate<JobsModuleSettings>();
var machine = MachineProvider.Machine;
-
- if(_rmls.Count == 0)
+
+ if (_rmls.Count == 0)
{
await Task.Delay(200);
}
var selectedRmlGuid = Settings.DefaultRmlGuid;
- JobCreationViewVM vm = new JobCreationViewVM( _spoolTypes.ToList(), _rmls.ToList(), selectedRmlGuid, 0, false );
-
+ JobCreationViewVM vm = new JobCreationViewVM(_spoolTypes.ToList(), _rmls.ToList(), selectedRmlGuid, 0, false);
+
var selectedSpoolTypeGuid = Settings.SpoolTypeGuid;
- vm.SelectedSpoolType = false == String.IsNullOrEmpty(selectedSpoolTypeGuid ) ? _spoolTypes.FirstOrDefault( x=>x.Guid == selectedSpoolTypeGuid) : _spoolTypes.FirstOrDefault(x=>x.Type == SpoolTypes.StandardSpool);
+ vm.SelectedSpoolType = false == String.IsNullOrEmpty(selectedSpoolTypeGuid) ? _spoolTypes.FirstOrDefault(x => x.Guid == selectedSpoolTypeGuid) : _spoolTypes.FirstOrDefault(x => x.Type == SpoolTypes.StandardSpool);
if (twnFile == null)
{
vm = await NotificationProvider.ShowDialog<JobCreationViewVM>(vm);
if (!vm.DialogResult) return;
-
- if(vm.SelectedRML != null)
+
+ if (vm.SelectedRML != null)
{
selectedRmlGuid = vm.SelectedRML.Guid;
}
- if(vm.SelectedSpoolType != null)
+ if (vm.SelectedSpoolType != null)
{
selectedSpoolTypeGuid = vm.SelectedSpoolType.Guid;
}
-
+
}
-
+
Job job = new Job();
job.LastUpdated = DateTime.UtcNow;
job.JobSource = JobSource.Local;
@@ -463,7 +466,7 @@ namespace Tango.PPC.Jobs.ViewModels
job.RmlGuid = selectedRmlGuid;
job.WindingMethodGuid = Adapter.WindingMethods.FirstOrDefault().Guid;
job.SpoolTypeGuid = selectedSpoolTypeGuid;
-
+
if (Jobs.Count > 0)
{
job.JobIndex = Jobs.Max(x => x.JobIndex) + 1;
@@ -529,7 +532,7 @@ namespace Tango.PPC.Jobs.ViewModels
LogManager.Log($"Job {job.Name} added successfully.");
RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db });
-
+
await Task.Delay(200);
await NavigationManager.NavigateWithObject<JobsV2Module, JobView, JobNavigationObject>(new JobNavigationObject()
@@ -544,7 +547,7 @@ namespace Tango.PPC.Jobs.ViewModels
await NotificationProvider.ShowError("An error occurred while trying to add a new job.");
}
}
-
+
/// <summary>
/// Deletes the specified jobs from db.
/// </summary>
@@ -690,6 +693,8 @@ namespace Tango.PPC.Jobs.ViewModels
}
MachineDataSynchronizer.SynchronizationEnded += MachineDataSynchronizer_SynchronizationEnded;
+
+ RemoteJobUploadService.JobReceived += RemoteJobUploadService_JobReceived;
}
public override void OnNavigatedTo()
@@ -837,7 +842,9 @@ namespace Tango.PPC.Jobs.ViewModels
using (ObservablesContext db = ObservablesContext.CreateDefault())
{
- var segments = await SegmentsCsvHelper.FromFile(item.Path, MachineProvider.Machine, db);
+ var result = await SegmentsCsvHelper.FromFile(item.Path, MachineProvider.Machine, db);
+ var segments = result.Segments;
+
Job job = new Job();
job.LastUpdated = DateTime.UtcNow;
@@ -865,11 +872,16 @@ namespace Tango.PPC.Jobs.ViewModels
IColorConverter converter = new DefaultColorConverter();
- foreach (var stop in segments.SelectMany(x => x.BrushStops.Where(y => y.BrushColorSpace == ColorSpaces.Volume)))
+ foreach (var stop in segments.SelectMany(x => x.BrushStops))
{
var output = converter.Convert(stop, false);
var suggestion = output.CreateSingleSuggestion();
- stop.Color = suggestion.Color;
+ stop.Red = suggestion.Color.R;
+ stop.Green = suggestion.Color.G;
+ stop.Blue = suggestion.Color.B;
+ stop.BestMatchR = suggestion.Color.R;
+ stop.BestMatchG = suggestion.Color.G;
+ stop.BestMatchB = suggestion.Color.B;
}
db.Jobs.Add(job);
@@ -890,6 +902,91 @@ namespace Tango.PPC.Jobs.ViewModels
#endregion
+ #region Handle CSV Job File Received By Remote Job Upload Service
+
+ private void RemoteJobUploadService_JobReceived(object sender, Common.RemoteJobUpload.RemoteJobReceivedEventArgs e)
+ {
+ if (e.Type == RemoteJobUploadType.CSV)
+ {
+ Task.Factory.StartNew(async () =>
+ {
+ try
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ var result = await SegmentsCsvHelper.FromFile(e.FilePath, MachineProvider.Machine, db);
+ var segments = result.Segments;
+
+ String rmlGuid = null;
+
+ if (result.Rml != null)
+ {
+ rmlGuid = result.Rml.Guid;
+ }
+ else
+ {
+ rmlGuid = Settings.DefaultRmlGuid;
+ }
+
+ Job job = new Job();
+ job.LastUpdated = DateTime.UtcNow;
+ job.JobSource = JobSource.Local;
+ job.Name = e.Name;
+ job.NumberOfHeads = 1;
+ job.NumberOfUnits = 1;
+ job.SampleUnitsOrMeters = 1;
+ job.CreationDate = DateTime.UtcNow;
+ job.JobStatus = JobStatuses.Draft;
+ job.JobType = JobTypes.Knitting;
+ job.EnableLubrication = true;
+ job.MachineGuid = MachineProvider.Machine.Guid;
+ job.RmlGuid = rmlGuid;
+ job.Machine = await new MachineBuilder(db).Set(job.MachineGuid).WithCats().WithConfiguration().BuildAsync();
+ job.Rml = await new RmlBuilder(db).Set(job.RmlGuid).WithActiveParametersGroup().WithCAT(MachineProvider.Machine.Guid).WithCCT().WithGbdAndLub().WithLiquidFactors().BuildAsync();
+ job.WindingMethodGuid = Adapter.WindingMethods.FirstOrDefault().Guid;
+ job.SpoolTypeGuid = Settings.SpoolTypeGuid != null ? Settings.SpoolTypeGuid : Adapter.SpoolTypes.FirstOrDefault().Guid;
+
+ foreach (var segment in segments)
+ {
+ segment.Job = job;
+ job.Segments.Add(segment);
+ }
+
+ IColorConverter converter = new DefaultColorConverter();
+
+ foreach (var stop in segments.SelectMany(x => x.BrushStops).Where(x => x.BrushColorSpace != ColorSpaces.RGB))
+ {
+ var output = converter.Convert(stop, false);
+ var suggestion = output.CreateSingleSuggestion();
+ stop.Red = suggestion.Color.R;
+ stop.Green = suggestion.Color.G;
+ stop.Blue = suggestion.Color.B;
+ stop.BestMatchR = suggestion.Color.R;
+ stop.BestMatchG = suggestion.Color.G;
+ stop.BestMatchB = suggestion.Color.B;
+ }
+
+ db.Jobs.Add(job);
+ await db.SaveChangesAsync();
+ }
+
+ LoadJobs(() =>
+ {
+ NotificationProvider.PushNotification(new MessageNotificationItem($"Csv job '{e.Name}' received successfully.", "", MessageNotificationItem.MessageNotificationItemTypes.Success, () => { }, NotificationItem.NotificationPriority.Low));
+ e.Confirm();
+ }, false);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error occurred on remote job upload.");
+ e.Abort(ex.FlattenMessage());
+ }
+ });
+ }
+ }
+
+ #endregion
+
#region Handle TCC File Loading From Storage
private async void HandleColorProfileFileLoaded(List<ExplorerFileItem> tccFiles)
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
index a192f4d92..cdbfa909d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
@@ -18,6 +18,7 @@ using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.Printing;
using Tango.PPC.Common.RemoteAssistance;
using Tango.PPC.Common.RemoteDesktop;
+using Tango.PPC.Common.RemoteJobUpload;
using Tango.PPC.Common.Storage;
using Tango.PPC.Common.Synchronization;
using Tango.PPC.Common.ThreadLoading;
@@ -137,6 +138,9 @@ namespace Tango.PPC.Common
[TangoInject]
public IBitManager BitManager { get; set; }
+ [TangoInject]
+ public IRemoteJobUploadService RemoteJobUploadService { get; set; }
+
private PPCSettings _settings;
/// <summary>
/// Gets the main PPC settings.
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJobUpload/DefaultRemoteJobUploadService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJobUpload/DefaultRemoteJobUploadService.cs
index ec7e0b22d..a0205215c 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJobUpload/DefaultRemoteJobUploadService.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJobUpload/DefaultRemoteJobUploadService.cs
@@ -93,10 +93,11 @@ namespace Tango.PPC.Common.RemoteJobUpload
await receiver.SendGenericResponse(new RemoteJobUploadCompletedResponse(), token);
completion.SetResult(true);
- }, (error) =>
+ }, async (error) =>
{
job.File.Delete();
- completion.SetException(new OperationCanceledException(error));
+ await receiver.SendGenericResponse(new RemoteJobUploadCompletedResponse() { Error = error }, token);
+ completion.SetResult(true);
}) { Type = job.Type, FilePath = job.File.Path, Name = job.Name });
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteJobUpload/RemoteJobUploadCompletedResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteJobUpload/RemoteJobUploadCompletedResponse.cs
index ff8502dac..085f990f9 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteJobUpload/RemoteJobUploadCompletedResponse.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteJobUpload/RemoteJobUploadCompletedResponse.cs
@@ -8,6 +8,6 @@ namespace Tango.PPC.Shared.RemoteJobUpload
{
public class RemoteJobUploadCompletedResponse
{
-
+ public String Error { get; set; }
}
}
diff --git a/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs b/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs
index 395f9e826..f41d8c4f1 100644
--- a/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs
+++ b/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs
@@ -16,77 +16,91 @@ namespace Tango.BL.Helpers
{
private const double MAX_VOLUME = 200;
+ public class SegmentsCsvResult
+ {
+ public Rml Rml { get; set; }
+ public List<Segment> Segments { get; set; }
+
+ public SegmentsCsvResult()
+ {
+ Segments = new List<Segment>();
+ }
+ }
+
public class SegmentCsvModel
{
[CsvOrder(0)]
public String Index { get; set; }
[CsvOrder(1)]
- public String ColorSpace { get; set; }
+ public String ThreadName { get; set; }
[CsvOrder(2)]
+ public String ColorSpace { get; set; }
+
+ [CsvOrder(3)]
public String Length { get; set; }
- [CsvOrder(4)]
+ [CsvOrder(5)]
public String CatalogName1 { get; set; }
- [CsvOrder(5)]
+ [CsvOrder(6)]
public String CatalogItem1 { get; set; }
- [CsvOrder(6)]
- public String Red1 { get; set; }
[CsvOrder(7)]
- public String Green1 { get; set; }
+ public String Red1 { get; set; }
[CsvOrder(8)]
+ public String Green1 { get; set; }
+ [CsvOrder(9)]
public String Blue1 { get; set; }
- [CsvOrder(9)]
- public String L1 { get; set; }
[CsvOrder(10)]
- public String A1 { get; set; }
+ public String L1 { get; set; }
[CsvOrder(11)]
+ public String A1 { get; set; }
+ [CsvOrder(12)]
public String B1 { get; set; }
- [CsvOrder(12)]
- public String Cyan1 { get; set; }
[CsvOrder(13)]
- public String Magenta1 { get; set; }
+ public String Cyan1 { get; set; }
[CsvOrder(14)]
- public String Yellow1 { get; set; }
+ public String Magenta1 { get; set; }
[CsvOrder(15)]
+ public String Yellow1 { get; set; }
+ [CsvOrder(16)]
public String Black1 { get; set; }
- [CsvOrder(17)]
- public String CatalogName2 { get; set; }
[CsvOrder(18)]
+ public String CatalogName2 { get; set; }
+ [CsvOrder(19)]
public String CatalogItem2 { get; set; }
- [CsvOrder(19)]
- public String Red2 { get; set; }
[CsvOrder(20)]
- public String Green2 { get; set; }
+ public String Red2 { get; set; }
[CsvOrder(21)]
+ public String Green2 { get; set; }
+ [CsvOrder(22)]
public String Blue2 { get; set; }
- [CsvOrder(22)]
- public String L2 { get; set; }
[CsvOrder(23)]
- public String A2 { get; set; }
+ public String L2 { get; set; }
[CsvOrder(24)]
+ public String A2 { get; set; }
+ [CsvOrder(25)]
public String B2 { get; set; }
- [CsvOrder(25)]
- public String Cyan2{ get; set; }
[CsvOrder(26)]
- public String Magenta2 { get; set; }
+ public String Cyan2 { get; set; }
[CsvOrder(27)]
- public String Yellow2 { get; set; }
+ public String Magenta2 { get; set; }
[CsvOrder(28)]
+ public String Yellow2 { get; set; }
+ [CsvOrder(29)]
public String Black2 { get; set; }
-
+
public bool IsRgb2NullOrEqual()
{
if (String.IsNullOrWhiteSpace(Red2) || String.IsNullOrWhiteSpace(Green2) || String.IsNullOrWhiteSpace(Blue2)) return true;
@@ -96,7 +110,7 @@ namespace Tango.BL.Helpers
internal bool IsVolumeNullOrEqual()
{
- if (String.IsNullOrWhiteSpace(Cyan2) || String.IsNullOrWhiteSpace(Magenta2 ) || String.IsNullOrWhiteSpace(Yellow2) || String.IsNullOrWhiteSpace(Black2)) return true;
+ if (String.IsNullOrWhiteSpace(Cyan2) || String.IsNullOrWhiteSpace(Magenta2) || String.IsNullOrWhiteSpace(Yellow2) || String.IsNullOrWhiteSpace(Black2)) return true;
if (Cyan1 == Cyan2 && Magenta1 == Magenta2 && Yellow1 == Yellow2 && Black1 == Black2) return true;
return false;
}
@@ -116,12 +130,12 @@ namespace Tango.BL.Helpers
}
}
- public static Task<List<Segment>> FromFile(String filePath, Machine machine, ObservablesContext context)
+ public static Task<SegmentsCsvResult> FromFile(String filePath, Machine machine, ObservablesContext context)
{
return Task.Factory.StartNew(() =>
{
List<SegmentCsvModel> rows = CsvFile.Read<SegmentCsvModel>(new CsvSource(filePath)).ToList();
-
+
List<Segment> segments = new List<Segment>();
var catalogs = new CatalogsCollectionBuilder(context).SetAll().WithGroups().WithItems().BuildList();
@@ -132,6 +146,21 @@ namespace Tango.BL.Helpers
machine = new MachineBuilder(context).Set(machine.Guid).WithConfiguration().Build();
}
+ String threadName = null;
+
+ if (rows.Count > 0)
+ {
+ threadName = rows.First().ThreadName;
+ }
+
+ Rml rml = null;
+
+ if (threadName.IsNotNullOrEmpty())
+ {
+ rml = context.Rmls.FirstOrDefault(x => x.Name == threadName || x.DisplayName == threadName);
+ if (rml == null) throw new InvalidOperationException($"Thread type '{threadName}' not found.");
+ }
+
var idsPacks = machine.Configuration.NoneEmptyIdsPacks.ToList();
var cyanIdsPack = idsPacks.FirstOrDefault(x => x.LiquidType.Type == LiquidTypes.Cyan);
@@ -179,7 +208,7 @@ namespace Tango.BL.Helpers
if (colorSpace.Space == ColorSpaces.RGB)
{
int red1;
- if(!int.TryParse(row.Red1, out red1))
+ if (!int.TryParse(row.Red1, out red1))
{
throw new InvalidOperationException($"Value Red1 '{row.Red1}' should be a number on line'{lineCount}'.");
}
@@ -363,7 +392,7 @@ namespace Tango.BL.Helpers
else if (colorSpace.Space == ColorSpaces.LAB)
{
double number;
- if(!double.TryParse(row.L1, out number))
+ if (!double.TryParse(row.L1, out number))
throw new InvalidOperationException($"Value L1 '{row.L1}' should be a number on line'{lineCount}'.");
stop1.L = number;
if (stop1.L < 0 || stop1.L > 100) throw new InvalidOperationException($"Value L1 '{row.L1}' is out of range on line '{lineCount}'.");
@@ -387,7 +416,7 @@ namespace Tango.BL.Helpers
double l2;
if (!double.TryParse(row.L2, out l2))
throw new InvalidOperationException($"Value L2 '{row.L2}' should be a number on line'{lineCount}'.");
- stop2.L =l2;
+ stop2.L = l2;
if (stop2.L < 0 || stop2.L > 100) throw new InvalidOperationException($"Value L2 '{row.L2}' is out of range on line '{lineCount}'.");
double a2;
@@ -414,7 +443,11 @@ namespace Tango.BL.Helpers
}
}
- return segments;
+ return new SegmentsCsvResult()
+ {
+ Segments = segments,
+ Rml = rml
+ };
});
}
@@ -424,15 +457,16 @@ namespace Tango.BL.Helpers
{
SegmentCsvModel model = new SegmentCsvModel();
List<string> columnNames = model.GetType().GetProperties().Select(x => x.Name).ToList();
- CsvFile<SegmentCsvModel> csvFile = new CsvFile<SegmentCsvModel>(new CsvDestination(filePath), new CsvDefinition() {
+ CsvFile<SegmentCsvModel> csvFile = new CsvFile<SegmentCsvModel>(new CsvDestination(filePath), new CsvDefinition()
+ {
Columns = columnNames
});
- foreach(var segment in segments)
+ foreach (var segment in segments)
{
SegmentCsvModel csvmodel = new SegmentCsvModel();
csvmodel.Index = segment.SegmentIndex.ToString();
csvmodel.Length = segment.Length.ToString();
- if(segment.BrushStops.Count > 2 ) throw new InvalidOperationException($"Cannot save more than two brush stops!");
+ if (segment.BrushStops.Count > 2) throw new InvalidOperationException($"Cannot save more than two brush stops!");
//save first brush stop
if (segment.BrushStops.Count > 0)
{
@@ -491,7 +525,7 @@ namespace Tango.BL.Helpers
csvmodel.B2 = brushStop2.B.ToString();
}
}
-
+
csvFile.Append(csvmodel);
}
});