aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs342
1 files changed, 125 insertions, 217 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
index fc0680d9c..3a1f3fb11 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
@@ -50,9 +50,6 @@ using Tango.Core.ExtensionMethods;
using Tango.ColorConversion;
using Tango.PMR.Exports;
using Microsoft.WindowsAPICodePack.Dialogs;
-using Tango.BL.Enumerations;
-using Tango.BL.DTO;
-using Tango.BL.ActionLogs;
namespace Tango.MachineStudio.Developer.ViewModels
{
@@ -88,9 +85,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
private TaskItem _preparingTaskItem;
private IColorConverter _converter;
private string _current_job_string;
- private JobDTO _beforeSaveJobDTO;
- private IActionLogManager _actionLogManager;
- private RmlDTO _selectedRMLBeforeLiquidFactorsSaves;
#region Properties
@@ -753,7 +747,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
/// <param name="applicationManager">The application manager.</param>
/// <param name="notificationProvider">The notification provider.</param>
- public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, INavigationManager navigationManager, IAuthenticationProvider authentication, IEventLogger eventLogger, ISpeechProvider speech, IActionLogManager actionLogManager)
+ public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, INavigationManager navigationManager, IAuthenticationProvider authentication, IEventLogger eventLogger, ISpeechProvider speech)
{
_converter = new DefaultColorConverter();
@@ -762,7 +756,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
AuthenticationProvider = authentication;
- _actionLogManager = actionLogManager;
_notification = notificationProvider;
_speech = speech;
_navigation = navigation;
@@ -880,7 +873,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
foreach (var stop in stops)
{
- if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32())
+ if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32() && !stop.IsLiquidVolumesOutOfRange)
{
try
{
@@ -1041,11 +1034,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
var percent = (e.Progress / e.Total * 100d);
- if (_preparingTaskItem != null)
- {
- _preparingTaskItem.Message = $"Preparing job for printing {(e.Progress / e.Total * 100d).ToString("0.0")}%...";
- }
-
if (_preparingTaskItem == null && percent == 0)
{
_preparingTaskItem = _notification.PushTaskItem("Preparing job for printing...");
@@ -1055,6 +1043,13 @@ namespace Tango.MachineStudio.Developer.ViewModels
_preparingTaskItem.Pop();
_preparingTaskItem = null;
}
+ else
+ {
+ if (_preparingTaskItem != null)
+ {
+ _preparingTaskItem.Message = $"Preparing job for printing {(e.Progress / e.Total * 100d).ToString("0.0")}%...";
+ }
+ }
}
private void MachineOperator_ResumingJob(object sender, ResumingJobEventArgs e)
@@ -1257,7 +1252,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
||
j.Name.ToLower().Contains(filter) //Job name
||
- (j.User != null && j.User.Contact.FirstName.ToLower().Contains(filter)) // User first name
+ j.User.Contact.FirstName.ToLower().Contains(filter) // User first name
||
j.Length.ToString().Contains(filter); //Job length
};
@@ -1376,7 +1371,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// <summary>
/// Starts the job.
/// </summary>
- private async void StartJob(Func<JobHandler> resumeFunc = null)
+ private async void StartJob(Func<Job, JobHandler> resumeFunc = null)
{
SettingsManager.Default.Save();
@@ -1441,13 +1436,15 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
else
{
- JobHandler = resumeFunc();
+ JobHandler = resumeFunc(ActiveJob);
}
_navigation.NavigateTo(DeveloperNavigationView.RunningJobView);
IsJobRunning = true;
ShowJobStatus = true;
+ _eventLogger.Log(String.Format("Job '{0}' started...", ActiveJob.Name));
+
JobHandler.StatusChanged += (x, status) =>
{
if (IsJobRunning)
@@ -1467,21 +1464,25 @@ namespace Tango.MachineStudio.Developer.ViewModels
if (!segment.IsInterSegment)
{
_speech.SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex));
+ _eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex) + Environment.NewLine + segment.ToJsonString());
}
else
{
_speech.SpeakInfo(String.Format("Inter Segment Started."));
+ _eventLogger.Log("Inter Segment Started.");
}
};
JobHandler.UnitCompleted += (x, unit) =>
{
_speech.SpeakInfo(String.Format("{0} Units Completed.", unit + 1));
+ _eventLogger.Log(String.Format("{0} Units Completed.", unit + 1));
};
JobHandler.Failed += (x, ex) =>
{
LogManager.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name));
+ _eventLogger.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name));
SetJobFailed();
InvokeUI(() =>
@@ -1495,11 +1496,13 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
_speech.SpeakInfo("Finalizing job...");
LogManager.Log(String.Format("Finalizing job {0}.", RunningJob.Name));
+ _eventLogger.Log(String.Format("Finalizing job {0}.", RunningJob.Name));
};
JobHandler.Completed += (x, e) =>
{
LogManager.Log(String.Format("Job {0} has completed.", RunningJob.Name));
+ _eventLogger.Log(String.Format("Job {0} has completed.", RunningJob.Name));
SetJobCompleted();
StopRecordingIfInProgress();
};
@@ -1513,6 +1516,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
LogManager.Log(String.Format("Job {0} has been canceled.", RunningJob.Name));
+ _eventLogger.Log(String.Format("Job {0} has been canceled.", RunningJob.Name));
StopRecordingIfInProgress();
//Finally Canceled..
};
@@ -1530,6 +1534,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
catch (Exception ex)
{
LogManager.Log(ex);
+ _eventLogger.Log(ex, "An error occurred while starting the job.");
_notification.ShowError("An error occurred while starting the job. " + Environment.NewLine + ex.Message);
SetJobFailed();
StopRecordingIfInProgress();
@@ -1589,12 +1594,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
LogManager.Log(String.Format("Saving liquid factors for RML {0}...", SelectedRML.Name));
await SelectedRML.SaveAsync(_activeJobDbContext);
- var rmlAfterChange = RmlDTO.FromObservable(SelectedRML);
- _actionLogManager.InsertLog(ActionLogType.RmlSaved, AuthenticationProvider.CurrentUser, SelectedRML.Name, _selectedRMLBeforeLiquidFactorsSaves, rmlAfterChange, "RML liquid factors changed from Machine Studio Research module.");
- _selectedRMLBeforeLiquidFactorsSaves = rmlAfterChange;
LiquidTypesRmls = ActiveJob.Machine.Configuration.GetSupportedIdsPacks(SelectedRML).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList();
-
foreach (var segment in ActiveJob.Segments)
{
SetSegmentBrushStopsLiquidVolumes(segment);
@@ -1622,9 +1623,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
LogManager.Log("Invalidating liquid factors, process parameters and process group history...");
- _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML.Guid).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().WithSpools().Build();
-
- _selectedRMLBeforeLiquidFactorsSaves = RmlDTO.FromObservable(_selectedRML);
+ _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML.Guid).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().Build();
if (_selectedRML.Cct == null)
{
@@ -1673,17 +1672,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
await Task.Factory.StartNew(() =>
{
- try
- {
- IsFree = false;
- InvalidateLiquidFactorsAndProcessTables();
- }
- catch
- {}
- finally
- {
- IsFree = true;
- }
+ InvalidateLiquidFactorsAndProcessTables();
});
}
}
@@ -1691,23 +1680,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
#endregion
- #region Color Space
-
- public void OnBrushStopColorSpaceChanged(BrushStop stop)
- {
- if (stop != null && stop.ColorSpace != null && stop.BrushColorSpace != BL.Enumerations.ColorSpaces.Volume)
- {
- var lubricant = stop.LiquidVolumes.SingleOrDefault(x => x.LiquidType == LiquidTypes.Lubricant);
-
- if (lubricant != null)
- {
- lubricant.Volume = 100;
- }
- }
- }
-
- #endregion
-
#region Process Parameters Management
/// <summary>
@@ -1719,12 +1691,12 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
try
{
- LogManager.Log($"Uploading process parameters table {SelectedProcessParametersTable.Name}...");
+ LogManager.Log(String.Format("Uploading process parameters table {0}...", SelectedProcessParametersTable.Name));
await MachineOperator.UploadProcessParameters(SelectedProcessParametersTable);
}
catch (Exception ex)
{
- LogManager.Log(ex, $"Failed to upload process parameters table {SelectedProcessParametersTable.Name}");
+ LogManager.LogFormat(ex, "Failed to upload process parameters table {0}", SelectedProcessParametersTable.Name);
_notification.ShowError("Failed to upload the selected process parameters." + Environment.NewLine + ex.Message);
}
}
@@ -1743,8 +1715,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
using (_notification.PushTaskItem("Saving Parameters Group..."))
{
- var processGroupBefore = ProcessParametersTablesGroupDTO.FromObservable(SelectedRML.GetActiveProcessGroup());
-
using (var db = ObservablesContext.CreateDefault())
{
var active_groups = db.ProcessParametersTablesGroups.Where(x => x.RmlGuid == SelectedRML.Guid && x.Active).ToList();
@@ -1786,8 +1756,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
SelectedRML.ProcessParametersTablesGroups.Add(group);
await SelectedRML.SaveAsync(_activeJobDbContext);
- _actionLogManager.InsertLog(ActionLogType.RmlActiveProcessParametersChanged, AuthenticationProvider.CurrentUser, SelectedRML.Name, processGroupBefore, ProcessParametersTablesGroupDTO.FromObservable(SelectedRML.GetActiveProcessGroup()), "RML Active process parameters changed from Machine Studio Research module.");
-
InvalidateLiquidFactorsAndProcessTables();
}
@@ -1832,110 +1800,97 @@ namespace Tango.MachineStudio.Developer.ViewModels
using (_notification.PushTaskItem("Loading job details..."))
{
- try
+ await Task.Factory.StartNew(() =>
{
- await Task.Factory.StartNew(() =>
- {
- _disable_gamut_check = true;
-
- LogManager.Log(String.Format("Loading job {0}...", SelectedMachineJob.Name));
- SelectedSegments = new ObservableCollection<Segment>();
- SelectedBrushStops = new ObservableCollection<BrushStop>();
- SelectedRML = null;
- SelectedSegment = null;
- SelectedGroupHistory = null;
- SelectedBrushStop = null;
- SelectedProcessParametersTable = null;
- RmlProcessParametersTableGroup = null;
-
- _blockInvalidateCommands = false;
+ _disable_gamut_check = true;
- LogManager.Log("Creating active job DB context...");
- _activeJobDbContext = ObservablesContext.CreateDefault();
+ LogManager.Log(String.Format("Loading job {0}...", SelectedMachineJob.Name));
+ SelectedSegments = new ObservableCollection<Segment>();
+ SelectedBrushStops = new ObservableCollection<BrushStop>();
+ SelectedRML = null;
+ SelectedSegment = null;
+ SelectedGroupHistory = null;
+ SelectedBrushStop = null;
+ SelectedProcessParametersTable = null;
+ RmlProcessParametersTableGroup = null;
- LogManager.Log("Initializing available color spaces, RMLs & Winding methods...");
+ _blockInvalidateCommands = false;
- //var processParamsGroups = _activeJobDbContext.ProcessParametersTablesGroups.ToList();
- //var processParams = _activeJobDbContext.ProcessParametersTables.ToList();
+ LogManager.Log("Creating active job DB context...");
+ _activeJobDbContext = ObservablesContext.CreateDefault();
- ColorSpaces = _activeJobDbContext.ColorSpaces.ToObservableCollection();
- Rmls = _activeJobDbContext.Rmls.OrderBy(i => i.Name).ToObservableCollection();
- WindingMethods = _activeJobDbContext.WindingMethods.ToObservableCollection();
- SpoolTypes = _activeJobDbContext.SpoolTypes.ToObservableCollection();
+ LogManager.Log("Initializing available color spaces, RMLs & Winding methods...");
- LogManager.Log("Loading machine spools...");
- _activeJobDbContext.Spools.Where(x => x.MachineGuid == SelectedMachine.Guid).Load();
+ //var processParamsGroups = _activeJobDbContext.ProcessParametersTablesGroups.ToList();
+ //var processParams = _activeJobDbContext.ProcessParametersTables.ToList();
- LogManager.Log("Setting active job...");
- ActiveJob = new JobBuilder(_activeJobDbContext).Set(SelectedMachineJob.Guid).WithUser().WithSegments().WithBrushStops().WithConfiguration().WithRML().Build();
+ ColorSpaces = _activeJobDbContext.ColorSpaces.ToObservableCollection();
+ Rmls = _activeJobDbContext.Rmls.ToObservableCollection();
+ WindingMethods = _activeJobDbContext.WindingMethods.ToObservableCollection();
+ SpoolTypes = _activeJobDbContext.SpoolTypes.ToObservableCollection();
- //_activeJobDbContext.Ccts.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList();
- //_activeJobDbContext.Cats.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList();
- //_activeJobDbContext.Machines.SingleOrDefault(x => x.Guid == ActiveJob.MachineGuid);
- //_activeJobDbContext.Configurations.SingleOrDefault(x => x.Guid == ActiveJob.Machine.ConfigurationGuid);
+ LogManager.Log("Loading machine spools...");
+ _activeJobDbContext.Spools.Where(x => x.MachineGuid == SelectedMachine.Guid).Load();
- //_activeJobDbContext.LiquidTypesRmls.ToList();
+ LogManager.Log("Setting active job...");
+ ActiveJob = new JobBuilder(_activeJobDbContext).Set(SelectedMachineJob.Guid).WithUser().WithSegments().WithBrushStops().WithConfiguration().WithRML().Build();
- //_activeJobDbContext.IdsPackFormulas.ToList();
- //_activeJobDbContext.LiquidTypes.ToList();
- //_activeJobDbContext.MidTankTypes.ToList();
- //_activeJobDbContext.DispenserTypes.ToList();
+ //_activeJobDbContext.Ccts.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList();
+ //_activeJobDbContext.Cats.Where(x => x.RmlGuid == ActiveJob.RmlGuid).ToList();
+ //_activeJobDbContext.Machines.SingleOrDefault(x => x.Guid == ActiveJob.MachineGuid);
+ //_activeJobDbContext.Configurations.SingleOrDefault(x => x.Guid == ActiveJob.Machine.ConfigurationGuid);
- //_activeJobDbContext.IdsPacks.Where(x => x.ConfigurationGuid == ActiveJob.Machine.ConfigurationGuid).ToList();
+ //_activeJobDbContext.LiquidTypesRmls.ToList();
- _beforeSaveJobDTO = JobDTO.FromObservable(ActiveJob);
+ //_activeJobDbContext.IdsPackFormulas.ToList();
+ //_activeJobDbContext.LiquidTypes.ToList();
+ //_activeJobDbContext.MidTankTypes.ToList();
+ //_activeJobDbContext.DispenserTypes.ToList();
+ //_activeJobDbContext.IdsPacks.Where(x => x.ConfigurationGuid == ActiveJob.Machine.ConfigurationGuid).ToList();
- LogManager.Log("Setting selected segment...");
- _selectedSegment = ActiveJob.OrderedSegments.FirstOrDefault();
- ActiveJob.LengthChanged -= ActiveJob_LengthChanged;
- ActiveJob.LengthChanged += ActiveJob_LengthChanged;
- _selectedRML = ActiveJob.Rml;
- InvalidateLiquidFactorsAndProcessTables();
- RaisePropertyChanged(nameof(SelectedRML));
+ LogManager.Log("Setting selected segment...");
+ _selectedSegment = ActiveJob.OrderedSegments.FirstOrDefault();
- UpdateEstimatedDuration();
+ ActiveJob.LengthChanged -= ActiveJob_LengthChanged;
+ ActiveJob.LengthChanged += ActiveJob_LengthChanged;
- _blockInvalidateCommands = false;
- InvalidateRelayCommands();
+ _selectedRML = ActiveJob.Rml;
+ InvalidateLiquidFactorsAndProcessTables();
+ RaisePropertyChanged(nameof(SelectedRML));
- _disable_gamut_check = false;
+ UpdateEstimatedDuration();
- _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null;
- _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null;
+ _blockInvalidateCommands = false;
+ InvalidateRelayCommands();
- _settings.Save();
- });
-
- SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments);
- SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending));
+ _disable_gamut_check = false;
- foreach (var segment in ActiveJob.Segments)
- {
- SetSegmentBrushStopsLiquidVolumes(segment);
- }
+ _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null;
+ _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null;
- SelectedSegment = _selectedSegment;
+ _settings.Save();
+ });
- if (ActiveJob != null)
- {
- _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString();
- }
+ SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments);
+ SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending));
- UIHelper.DoEvents();
- _navigation.NavigateTo(DeveloperNavigationView.JobView);
- }
- catch (Exception ex)
+ foreach (var segment in ActiveJob.Segments)
{
- LogManager.Log(ex, "Error loading job.");
- _notification.ShowError($"An error occurred while trying to load the selected job.\n{ex.FlattenMessage()}");
+ SetSegmentBrushStopsLiquidVolumes(segment);
}
- finally
+
+ SelectedSegment = _selectedSegment;
+
+ if (ActiveJob != null)
{
- CanWork = true;
+ _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString();
}
+
+ UIHelper.DoEvents();
+ _navigation.NavigateTo(DeveloperNavigationView.JobView);
}
CanWork = true;
@@ -1953,65 +1908,50 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
CanWork = false;
- try
+ using (_notification.PushTaskItem("Saving job details..."))
{
- using (_notification.PushTaskItem("Saving job details..."))
+ await Task.Factory.StartNew(() =>
{
- await Task.Factory.StartNew(() =>
- {
- LogManager.Log(String.Format("Saving the active job {0}...", ActiveJob.Name));
- ActiveJob.LastUpdated = DateTime.UtcNow;
- ActiveJob.IsSynchronized = false;
- ActiveJob.Rml = SelectedRML;
- ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds;
- ActiveJob.MarkModified(_activeJobDbContext);
- _activeJobDbContext.SaveChanges();
-
- var afterJobDTO = JobDTO.FromObservable(ActiveJob);
- _actionLogManager.InsertLog(ActionLogType.JobSaved, AuthenticationProvider.CurrentUser, _beforeSaveJobDTO.Name, _beforeSaveJobDTO, afterJobDTO, "Job saved from research module in Machine Studio.");
- _beforeSaveJobDTO = afterJobDTO;
+ LogManager.Log(String.Format("Saving the active job {0}...", ActiveJob.Name));
+ ActiveJob.LastUpdated = DateTime.UtcNow;
+ ActiveJob.Rml = SelectedRML;
+ ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds;
+ _activeJobDbContext.SaveChanges();
- _machineDbContext.Entry(SelectedMachineJob).Reload();
+ _machineDbContext.Entry(SelectedMachineJob).Reload();
- _machineDbContext.Entry(SelectedMachineJob).Collection(x => x.Segments).Load();
- foreach (var segment in SelectedMachineJob.Segments.ToList())
- {
- _machineDbContext.Entry(segment).Collection(x => x.BrushStops).Load();
+ _machineDbContext.Entry(SelectedMachineJob).Collection(x => x.Segments).Load();
- foreach (var brushStop in segment.BrushStops.ToList())
- {
- _machineDbContext.Entry(brushStop).Reload();
- }
-
- _machineDbContext.Entry(segment).Reload();
- }
+ foreach (var segment in SelectedMachineJob.Segments.ToList())
+ {
+ _machineDbContext.Entry(segment).Collection(x => x.BrushStops).Load();
- InvokeUI(() =>
+ foreach (var brushStop in segment.BrushStops.ToList())
{
- SelectedMachineJob.Segments = SelectedMachineJob.Segments;
- });
+ _machineDbContext.Entry(brushStop).Reload();
+ }
- var settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>();
- settings.DefaultJobRmlGuid = ActiveJob.RmlGuid;
- settings.Save();
+ _machineDbContext.Entry(segment).Reload();
+ }
- if (ActiveJob != null)
- {
- _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString();
- }
+ InvokeUI(() =>
+ {
+ SelectedMachineJob.Segments = SelectedMachineJob.Segments;
});
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error saving active job.");
- _notification.ShowError($"An error occurred while trying to save the current job.\n{ex.FlattenMessage()}");
- }
- finally
- {
- CanWork = true;
+
+ var settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>();
+ settings.DefaultJobRmlGuid = ActiveJob.RmlGuid;
+ settings.Save();
+
+ if (ActiveJob != null)
+ {
+ _current_job_string = ActiveJob.ToJobFileWhenLoaded().ToString();
+ }
+ });
}
+
+ CanWork = true;
}
}
@@ -2199,7 +2139,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
if (ActiveJob != null)
{
- LogManager.Log($"Adding new segment to job {ActiveJob.Name}...");
+ LogManager.LogFormat("Adding new segment to job {0}...", ActiveJob.Name);
Segment seg = new Segment();
seg.Job = ActiveJob;
seg.Name = "SEGMENT";
@@ -2231,8 +2171,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
if (_notification.ShowQuestion("Are you sure you want to delete the selected jobs?"))
{
- var jobsToReport = SelectedJobs.Select(x => JobDTO.FromObservable(x)).ToList();
-
LogManager.Log(String.Format("Removing {0} jobs...", SelectedJobs.Count));
SelectedJobs.ToList().ForEach(x =>
{
@@ -2244,11 +2182,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Saving selected machine to database...");
await SelectedMachine.SaveAsync(_machineDbContext);
}
-
- foreach (var job in jobsToReport)
- {
- _actionLogManager.InsertLog(ActionLogType.JobDeleted, AuthenticationProvider.CurrentUser, job.Name, job, "Job deleted using Machine Studio.", true);
- }
}
}
}
@@ -2269,8 +2202,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
var settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>();
Job newJob = new Job();
- newJob.LastUpdated = DateTime.UtcNow;
- newJob.JobSource = JobSource.Remote;
newJob.Name = jobName;
newJob.CreationDate = DateTime.UtcNow;
newJob.UserGuid = AuthenticationProvider.CurrentUser.Guid;
@@ -2305,7 +2236,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Saving selected machine to database...");
await SelectedMachine.SaveAsync(_machineDbContext);
- _actionLogManager.InsertLog(ActionLogType.JobCreated, AuthenticationProvider.CurrentUser, newJob.Name, newJob, "Job created using Machine Studio.");
SelectedMachineJob = newJob;
LoadSelectedJob();
}
@@ -2331,13 +2261,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
return;
}
SelectedSegment.BrushStops.Remove(x);
- var existingBrushStop = _activeJobDbContext.BrushStops.FirstOrDefault(y => y.Guid == x.Guid);
- if(existingBrushStop != null)
- {
- _activeJobDbContext.BrushStops.Remove(existingBrushStop);
- }
-
-
});
ArrangeBrushStopsIndices();
@@ -2352,7 +2275,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
if (SelectedSegment != null)
{
- LogManager.Log($"Adding new brush stop to segment '{SelectedSegment.SegmentIndex}'...");
+ LogManager.LogFormat("Adding new brush stop to segment...", SelectedSegment.SegmentIndex.ToString());
var stop = new BrushStop();
@@ -2372,7 +2295,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
stop.SetAllDispensingStepDivisions(BL.Dispensing.DispenserStepDivisions.D8);
stop.SetLiquidVolumes(SelectedMachine.Configuration, SelectedRML, SelectedProcessParametersTable);
SelectedSegment.BrushStops.Add(stop);
- // _activeJobDbContext.BrushStops.Add(stop);
SelectedSegment.BrushStops.ToList().ForEach(x => x.RaiseOffsetChanged());
ArrangeBrushStopsIndices();
}
@@ -2383,7 +2305,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
private void DuplicateSelectedBrushStops()
{
- LogManager.Log($"Duplicating {SelectedBrushStops.Count} brush stops...");
+ LogManager.LogFormat("Duplicating {0} brush stops...", SelectedBrushStops.Count);
foreach (var stop in SelectedBrushStops.OrderBy(x => x.StopIndex))
{
@@ -2401,7 +2323,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
private void DuplicateSelectedSegments()
{
- LogManager.Log($"Duplicating {SelectedSegments.Count} segments...");
+ LogManager.LogFormat("Duplicating {0} segments...", SelectedSegments.Count);
int start_index = SelectedSegments.Max(x => x.SegmentIndex);
@@ -2429,7 +2351,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
CanWork = false;
- LogManager.Log($"Duplicating {SelectedJobs.Count} jobs...");
+ LogManager.LogFormat("Duplicating {0} jobs...", SelectedJobs.Count);
int index = SelectedMachine.Jobs.Max(x => x.JobIndex);
@@ -2443,11 +2365,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Saving selected machine to database...");
await SelectedMachine.SaveAsync(_machineDbContext);
- foreach (var job in SelectedJobs)
- {
- _actionLogManager.InsertLog(ActionLogType.JobCreated, AuthenticationProvider.CurrentUser, job.Name, job, "Job cloned using Machine Studio.");
- }
-
CanWork = true;
}
}
@@ -2671,26 +2588,17 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log($"Importing job files...");
- List<Job> jobsToReport = new List<Job>();
-
foreach (var file in dlg.FileNames)
{
var bytes = File.ReadAllBytes(file);
var jobFile = JobFile.Parser.ParseFrom(bytes);
var job = await Job.FromJobFile(jobFile, SelectedMachine.Guid, AuthenticationProvider.CurrentUser.Guid);
- job.JobSource = JobSource.Remote;
_machineDbContext.Jobs.Add(job);
- jobsToReport.Add(job);
}
await _machineDbContext.SaveChangesAsync();
- foreach (var job in jobsToReport)
- {
- _actionLogManager.InsertLog(ActionLogType.JobImported, AuthenticationProvider.CurrentUser, job.Name, job, "Job imported using Machine Studio.");
- }
-
IsFree = true;
_notification.ShowInfo($"Jobs imported successfully.");