From 48f781d037a83c51fdd555fb6c9d1c2b4e424efe Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 11 Dec 2018 19:43:35 +0200 Subject: Working on PPC hotspot and external bridge. --- .../StudioApplication/DefaultStudioApplicationManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index 6303b1ac8..ccedde974 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -362,6 +362,12 @@ namespace Tango.MachineStudio.UI.StudioApplication if (connectedMachine != null) { Machine = ObservablesStaticCollections.Instance.Machines.SingleOrDefault(x => x.SerialNumber == connectedMachine.SerialNumber); + + if (Machine == null) + { + throw new NullReferenceException($"The specified machine '{connectedMachine.SerialNumber}' could not be found on the database."); + } + ConnectedMachine = connectedMachine; ConnectedMachine.SetMachine(Machine); } -- cgit v1.3.1 From 3e71ab50870db524f7e17aa9d2042da52b15ad63 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 26 Dec 2018 14:04:34 +0200 Subject: Implemented integration IJobRunsLogger. Implemented DEBUG/RELEASE JsonController. Implemented Local/Remote machine studio setting. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 22675456 bytes .../ViewModels/MainViewVM.cs | 5 + .../Views/MachineJobSelectionView.xaml | 2 +- .../ViewModels/MainViewVM.cs | 7 +- .../JobRunsLogging/DefaultJobRunsLogger.cs | 113 ----------- .../JobRunsLogging/IJobRunsLogger.cs | 14 -- .../MachineStudioSettings.cs | 12 ++ .../Tango.MachineStudio.Common.csproj | 4 +- .../DefaultAuthenticationProvider.cs | 6 +- .../DefaultStudioApplicationManager.cs | 6 +- .../Tango.MachineStudio.UI/ViewModelLocator.cs | 3 - .../ViewModels/LoginViewVM.cs | 2 +- .../JobRuns/BasicJobRunsLogger.cs | 221 +++++++++++++++++++++ .../Tango.Integration/JobRuns/IJobRunsLogger.cs | 41 ++++ .../Operation/IMachineOperator.cs | 6 + .../Tango.Integration/Operation/MachineOperator.cs | 8 + .../Tango.Integration/Tango.Integration.csproj | 4 +- .../Tango.Web/Controllers/JsonController.cs | 4 + .../MachineService - Web Deploy.pubxml | 2 +- 20 files changed, 315 insertions(+), 145 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/JobRunsLogging/DefaultJobRunsLogger.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/JobRunsLogging/IJobRunsLogger.cs create mode 100644 Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs create mode 100644 Software/Visual_Studio/Tango.Integration/JobRuns/IJobRunsLogger.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index ec34a5443..7752f6ed6 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 91c25afa9..ae6147d84 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ 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 333a31802..84fffcc74 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 @@ -1845,6 +1845,11 @@ namespace Tango.MachineStudio.Developer.ViewModels { await _machineDbContext.Jobs.Where(x => x.MachineGuid == SelectedMachine.Guid).Include(x => x.User).Include(x => x.User.Contact).LoadAsync(); + foreach (var job in SelectedMachine.Jobs) + { + await job.Reload(_machineDbContext); + } + await _machineDbContext.ColorSpaces.LoadAsync(); await Task.Factory.StartNew(() => diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml index 1cb8536e0..ab97d7858 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml @@ -196,7 +196,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs index 492ccd30e..fd897e811 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs @@ -78,8 +78,11 @@ namespace Tango.MachineStudio.Statistics.ViewModels InvokeUIOnIdle(() => { - GenerateTimelineJobStatusChart(); - GeneratePieFailedReasonsChart(); + if (_job_runs.Count > 0) + { + GenerateTimelineJobStatusChart(); + GeneratePieFailedReasonsChart(); + } }); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/JobRunsLogging/DefaultJobRunsLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/JobRunsLogging/DefaultJobRunsLogger.cs deleted file mode 100644 index b405a6729..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/JobRunsLogging/DefaultJobRunsLogger.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL; -using Tango.BL.Entities; -using Tango.BL.Enumerations; -using Tango.Core; -using Tango.Core.DI; -using Tango.Integration.ExternalBridge; -using Tango.Integration.Operation; -using Tango.MachineStudio.Common.StudioApplication; - -namespace Tango.MachineStudio.Common.JobRunsLogging -{ - public class DefaultJobRunsLogger : ExtendedObject, IJobRunsLogger - { - private ObservablesContext _context; - private DateTime _start_date; - private Job _job; - private IStudioApplicationManager applicationManager; - - public void Init(IStudioApplicationManager appManager) - { - applicationManager = appManager; - _context = ObservablesContext.CreateDefault(); - applicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; - } - - private void ApplicationManager_ConnectedMachineChanged(object sender, IExternalBridgeClient machine) - { - if (machine != null) - { - machine.PrintingStarted -= Machine_PrintingStarted; - machine.PrintingStarted += Machine_PrintingStarted; - machine.PrintingCompleted -= Machine_PrintingCompleted; - machine.PrintingCompleted += Machine_PrintingCompleted; - machine.PrintingAborted -= Machine_PrintingAborted; - machine.PrintingAborted += Machine_PrintingAborted; - machine.PrintingFailed -= Machine_PrintingFailed; - machine.PrintingFailed += Machine_PrintingFailed; - } - } - - private void Machine_PrintingFailed(object sender, PrintingFailedEventArgs e) - { - if (e.Job.Guid == _job.Guid) - { - Task.Factory.StartNew(() => - { - _context.JobRuns.Add(new JobRun() - { - StartDate = _start_date, - EndDate = DateTime.UtcNow, - JobGuid = _job.Guid, - JobRunStatus = JobRunStatus.Failed, - EndPosition = e.JobHandler.Status.Progress, - FailedMessage = e.Exception.Message, - }); - - _context.SaveChanges(); - }); - } - } - - private void Machine_PrintingAborted(object sender, PrintingEventArgs e) - { - if (e.Job.Guid == _job.Guid) - { - Task.Factory.StartNew(() => - { - _context.JobRuns.Add(new JobRun() - { - StartDate = _start_date, - EndDate = DateTime.UtcNow, - JobGuid = _job.Guid, - EndPosition = e.JobHandler.Status.Progress, - JobRunStatus = JobRunStatus.Aborted, - }); - - _context.SaveChanges(); - }); - } - } - - private void Machine_PrintingCompleted(object sender, PrintingEventArgs e) - { - if (e.Job.Guid == _job.Guid) - { - Task.Factory.StartNew(() => - { - _context.JobRuns.Add(new JobRun() - { - StartDate = _start_date, - EndDate = DateTime.UtcNow, - JobGuid = _job.Guid, - EndPosition = e.JobHandler.Status.Progress, - JobRunStatus = JobRunStatus.Completed, - }); - - _context.SaveChanges(); - }); - } - } - - private void Machine_PrintingStarted(object sender, PrintingEventArgs e) - { - _job = e.Job; - _start_date = DateTime.UtcNow; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/JobRunsLogging/IJobRunsLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/JobRunsLogging/IJobRunsLogger.cs deleted file mode 100644 index c3eca953b..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/JobRunsLogging/IJobRunsLogger.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.MachineStudio.Common.StudioApplication; - -namespace Tango.MachineStudio.Common.JobRunsLogging -{ - public interface IJobRunsLogger - { - void Init(IStudioApplicationManager appManager); - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs index 1d3660c5f..2de954cbe 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs @@ -18,6 +18,12 @@ namespace Tango.MachineStudio.Common public WindowState State { get; set; } } + public enum WorkingEnvironment + { + Remote, + Local + } + /// /// Gets or sets the last login email. /// @@ -88,6 +94,11 @@ namespace Tango.MachineStudio.Common /// public String LastMainModuleName { get; set; } + /// + /// Gets or sets the working environment. + /// + public WorkingEnvironment Environment { get; set; } + /// /// Initializes a new instance of the class. /// @@ -98,6 +109,7 @@ namespace Tango.MachineStudio.Common MachineServiceAddress = "http://machineservice.twine-srv.com/"; DefaultIssueReportTags = new List(); StudioModulesBounds = new List(); + Environment = WorkingEnvironment.Remote; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index cd99b00d0..85b194173 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -104,8 +104,6 @@ - - @@ -310,7 +308,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs index 4acc76c25..19192020e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -54,6 +54,7 @@ namespace Tango.MachineStudio.UI.Authentication { var settings = SettingsManager.Default.GetOrCreate(); + IWebTransportClient service = new WebTransportClient(); var response = service.PostJson(settings.MachineServiceAddress + "/api/MachineStudio/Login", new LoginRequest() { @@ -65,7 +66,10 @@ namespace Tango.MachineStudio.UI.Authentication AccessToken = response.Token; - ObservablesContext.OverrideSettingsDataSource(response.DataSource); + if (settings.Environment == MachineStudioSettings.WorkingEnvironment.Remote) + { + ObservablesContext.OverrideSettingsDataSource(response.DataSource); + } ObservablesStaticCollections.Instance.Initialize(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index ccedde974..baa550017 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -26,7 +26,6 @@ using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.UI.Views; using Tango.Integration.Operation; using Tango.MachineStudio.UI.Windows; -using Tango.MachineStudio.Common.JobRunsLogging; namespace Tango.MachineStudio.UI.StudioApplication { @@ -40,7 +39,6 @@ namespace Tango.MachineStudio.UI.StudioApplication private INavigationManager _navigationManager; private IStudioModuleLoader _moduleLoader; private INotificationProvider _notification; - private IJobRunsLogger _jobRunsLogger; private List _openedWindows; private List _notified_view_models; @@ -53,9 +51,8 @@ namespace Tango.MachineStudio.UI.StudioApplication /// Initializes a new instance of the class. /// /// The navigation manager. - public DefaultStudioApplicationManager(INavigationManager navigationManager, IStudioModuleLoader moduleLoader, INotificationProvider notification, IJobRunsLogger jobRunsLogger) + public DefaultStudioApplicationManager(INavigationManager navigationManager, IStudioModuleLoader moduleLoader, INotificationProvider notification) { - _jobRunsLogger = jobRunsLogger; _moduleLoader = moduleLoader; _navigationManager = navigationManager; _notification = notification; @@ -350,7 +347,6 @@ namespace Tango.MachineStudio.UI.StudioApplication }); ApplicationReady?.Invoke(this, new EventArgs()); - _jobRunsLogger.Init(this); } /// diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index cac4ee0c0..3c548855d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -8,7 +8,6 @@ using Tango.MachineStudio.Common.Diagnostics; using Tango.MachineStudio.Common.EventLogging; using Tango.MachineStudio.Common.FirmwareUpgrade; using Tango.MachineStudio.Common.Html; -using Tango.MachineStudio.Common.JobRunsLogging; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; @@ -71,7 +70,6 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); - TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); @@ -80,7 +78,6 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); - TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index 59cc69a57..730027a67 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -139,7 +139,7 @@ namespace Tango.MachineStudio.UI.ViewModels catch (Exception ex) { LogManager.Log(ex, "Login Error."); - _notificationProvider.ShowError($"The specified email or password was incorrect, or you don't have a permission to run this application.\nError: {ex.Message}"); + _notificationProvider.ShowError($"The specified email or password was incorrect, or you don't have a permission to run this application.\nError: {ex.FlattenMessage()}"); } finally { diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs new file mode 100644 index 000000000..07844af17 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs @@ -0,0 +1,221 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Integration.Operation; + +namespace Tango.Integration.JobRuns +{ + /// + /// Represents a basic database job runs logger. + /// + /// + public class BasicJobRunsLogger : IJobRunsLogger + { + private DateTime _start_date; + private Job _job; + + #region Properties + + /// + /// Gets the machine operator. + /// + public IMachineOperator MachineOperator { get; private set; } + + /// + /// Gets a value indicating whether this instance is started. + /// + public bool IsStarted { get; private set; } + + /// + /// Gets or sets the job designations of which the logger should log (supports multiple flags). + /// + public JobDesignations JobDesignation { get; set; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The machine operator. + public BasicJobRunsLogger(IMachineOperator machineOperator) + { + JobDesignation = JobDesignations.Default; + MachineOperator = machineOperator; + Init(); + } + + #endregion + + #region Private Methods + + /// + /// Initializes this instance. + /// + private void Init() + { + MachineOperator.PrintingStarted -= Machine_PrintingStarted; + MachineOperator.PrintingStarted += Machine_PrintingStarted; + MachineOperator.PrintingCompleted -= Machine_PrintingCompleted; + MachineOperator.PrintingCompleted += Machine_PrintingCompleted; + MachineOperator.PrintingAborted -= Machine_PrintingAborted; + MachineOperator.PrintingAborted += Machine_PrintingAborted; + MachineOperator.PrintingFailed -= Machine_PrintingFailed; + MachineOperator.PrintingFailed += Machine_PrintingFailed; + } + + private bool ShouldLog() + { + return IsStarted && _job != null && JobDesignation.HasFlag(_job.Designation); + } + + #endregion + + #region Public Methods + + /// + /// Starts the logger. + /// + public void Start() + { + IsStarted = true; + } + + /// + /// Stops the logger. + /// + public void Stop() + { + IsStarted = false; + } + + #endregion + + #region Event Handlers + + private void Machine_PrintingFailed(object sender, PrintingFailedEventArgs e) + { + if (ShouldLog()) + { + if (e.Job.Guid == _job.Guid) + { + Task.Factory.StartNew(() => + { + using (var db = ObservablesContext.CreateDefault()) + { + db.JobRuns.Add(new JobRun() + { + StartDate = _start_date, + EndDate = DateTime.UtcNow, + JobGuid = _job.Guid, + JobRunStatus = JobRunStatus.Failed, + EndPosition = e.JobHandler.Status.Progress, + FailedMessage = e.Exception.Message, + }); + + e.Job.LastRun = DateTime.UtcNow; + _job.LastRun = DateTime.UtcNow; + + var job = db.Jobs.SingleOrDefault(x => x.Guid == _job.Guid); + + if (job != null) + { + job.LastRun = DateTime.UtcNow; + } + + db.SaveChanges(); + } + }); + } + } + } + + private void Machine_PrintingAborted(object sender, PrintingEventArgs e) + { + if (ShouldLog()) + { + if (e.Job.Guid == _job.Guid) + { + Task.Factory.StartNew(() => + { + using (var db = ObservablesContext.CreateDefault()) + { + db.JobRuns.Add(new JobRun() + { + StartDate = _start_date, + EndDate = DateTime.UtcNow, + JobGuid = _job.Guid, + EndPosition = e.JobHandler.Status.Progress, + JobRunStatus = JobRunStatus.Aborted, + }); + + e.Job.LastRun = DateTime.UtcNow; + _job.LastRun = DateTime.UtcNow; + + var job = db.Jobs.SingleOrDefault(x => x.Guid == _job.Guid); + + if (job != null) + { + job.LastRun = DateTime.UtcNow; + } + + db.SaveChanges(); + } + }); + } + } + } + + private void Machine_PrintingCompleted(object sender, PrintingEventArgs e) + { + if (ShouldLog()) + { + if (e.Job.Guid == _job.Guid) + { + Task.Factory.StartNew(() => + { + using (var db = ObservablesContext.CreateDefault()) + { + db.JobRuns.Add(new JobRun() + { + StartDate = _start_date, + EndDate = DateTime.UtcNow, + JobGuid = _job.Guid, + EndPosition = e.JobHandler.Status.Progress, + JobRunStatus = JobRunStatus.Completed, + }); + + e.Job.LastRun = DateTime.UtcNow; + _job.LastRun = DateTime.UtcNow; + + var job = db.Jobs.SingleOrDefault(x => x.Guid == _job.Guid); + + if (job != null) + { + job.LastRun = DateTime.UtcNow; + } + + db.SaveChanges(); + } + }); + } + } + } + + private void Machine_PrintingStarted(object sender, PrintingEventArgs e) + { + _job = e.Job; + _start_date = DateTime.UtcNow; + } + + + + #endregion + } +} diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/IJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/IJobRunsLogger.cs new file mode 100644 index 000000000..8c4174311 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/IJobRunsLogger.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Enumerations; +using Tango.Integration.Operation; + +namespace Tango.Integration.JobRuns +{ + /// + /// Represents a machine operator job runs logger + /// + public interface IJobRunsLogger + { + /// + /// Gets the machine operator. + /// + IMachineOperator MachineOperator { get; } + + /// + /// Gets or sets the job designations of which the logger should log (supports multiple flags). + /// + JobDesignations JobDesignation { get; set; } + + /// + /// Gets a value indicating whether this instance is started. + /// + bool IsStarted { get; } + + /// + /// Starts the logger. + /// + void Start(); + + /// + /// Stops the logger. + /// + void Stop(); + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index d0eb0ae17..d2293bcd0 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -20,6 +20,7 @@ using System.IO; using Tango.Integration.Upgrade; using Tango.PMR.IO; using Tango.PMR.FirmwareUpgrade; +using Tango.Integration.JobRuns; namespace Tango.Integration.Operation { @@ -164,6 +165,11 @@ namespace Tango.Integration.Operation /// IMachineEventsStateProvider MachineEventsStateProvider { get; set; } + /// + /// Gets or sets the job runs logger. + /// + IJobRunsLogger JobRunsLogger { get; set; } + /// /// Prints the specified job. /// The process parameters table will be calculated using color conversion gamut region. diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 45b2943c1..2efd2fc9b 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -32,6 +32,7 @@ using Tango.PMR.IO; using Tango.Integration.Upgrade; using Tango.PMR.FirmwareUpgrade; using Tango.Integration.Logging; +using Tango.Integration.JobRuns; namespace Tango.Integration.Operation { @@ -79,6 +80,8 @@ namespace Tango.Integration.Operation { DeviceInformation = new DeviceInformation(); MachineEventsStateProvider = new DefaultMachineEventsStateProvider(); + JobRunsLogger = new BasicJobRunsLogger(this); + JobRunsLogger.Start(); EnableEventsNotification = true; EnableJobResume = true; LogEmbeddedDebuggingToFile = true; @@ -329,6 +332,11 @@ namespace Tango.Integration.Operation /// public IMachineEventsStateProvider MachineEventsStateProvider { get; set; } + /// + /// Gets or sets the job runs logger. + /// + public IJobRunsLogger JobRunsLogger { get; set; } + /// /// Gets the last process parameters table sent to the embedded device. /// diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index 8edb04384..eebee5e81 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -87,6 +87,8 @@ + + @@ -168,7 +170,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs b/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs index 9d9016d5a..1fae9cccc 100644 --- a/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs +++ b/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs @@ -65,7 +65,11 @@ namespace Tango.Web.Controllers code = HttpStatusCode.Unauthorized; } +#if DEBUG throw new HttpResponseException(Request.CreateErrorResponse(code, ex.ToString())); +#else + throw new HttpResponseException(Request.CreateErrorResponse(code, ex.FlattenMessage())); +#endif } } } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml index 277a89d38..612e38bfb 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml +++ b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml @@ -9,7 +9,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt /subscriptions/10c8aa60-3b15-4e0d-b412-6aeef90e5e91/resourceGroups/Tango/providers/Microsoft.Web/sites/MachineService Tango AzureWebSite - Release + Debug Any CPU http://machineservice.azurewebsites.net True -- cgit v1.3.1