From d100f0eab0fa25c861cbae2ced60afc5dfa8da6b Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 19 Jun 2025 01:54:33 +0300 Subject: Job Failed Event Impl. --- .../MachineEventToMachineTypeConverter.cs | 43 +++++++++++++++ .../Converters/MachineEventToViewConverter.cs | 2 +- .../Tango.PPC.Events/EventsViews/GeneralView.xaml | 23 +++++++- .../Tango.PPC.Events/EventsViews/JobEventView.xaml | 33 ++++++++--- .../EventsViews/JobFailedEventView.xaml | 61 +++++++++++++++++++++ .../EventsViews/JobFailedEventView.xaml.cs | 28 ++++++++++ .../EventsViews/ThreadBreakView.xaml | 25 ++++++++- .../Tango.PPC.Events/Images/machine_small_X4.png | Bin 0 -> 21958 bytes .../Tango.PPC.Events/Tango.PPC.Events.csproj | 11 ++++ .../EventLogging/DefaultEventLogger.cs | 14 +++-- .../Tango.PPC.Common/EventLogging/IEventLogger.cs | 2 +- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../Tango.BL/Entities/MachinesEvent.cs | 4 ++ 13 files changed, 230 insertions(+), 18 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToMachineTypeConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobFailedEventView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobFailedEventView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Images/machine_small_X4.png (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToMachineTypeConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToMachineTypeConverter.cs new file mode 100644 index 000000000..c1d2bcc0e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToMachineTypeConverter.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core.DI; +using Tango.PPC.Common.Build; + +namespace Tango.PPC.Events.Converters +{ + public class MachineEventToMachineTypeConverter : IValueConverter + { + private static MachineTypes? _machineType = null; + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (_machineType == null) + { + IBuildProvider buildProvider = TangoIOC.Default.GetInstance(); + + if (buildProvider != null) + { + _machineType = buildProvider.MachineType; + } + else + { + return MachineTypes.TS1800; + } + } + + return _machineType.Value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs index 5198498a3..6ed2b13d0 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs @@ -22,7 +22,7 @@ namespace Tango.PPC.Events.Converters _eventViews.Add(EventTypes.JOB_STARTED, typeof(JobEventView)); _eventViews.Add(EventTypes.JOB_ABORTED, typeof(JobEventView)); _eventViews.Add(EventTypes.JOB_COMPLETED, typeof(JobEventView)); - _eventViews.Add(EventTypes.JOB_FAILED, typeof(JobEventView)); + _eventViews.Add(EventTypes.JOB_FAILED, typeof(JobFailedEventView)); //Thread Break _eventViews.Add(EventTypes.THREAD_BREAK, typeof(ThreadBreakView)); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml index 3610a2850..2b3435734 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml @@ -4,12 +4,33 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" + xmlns:converters="clr-namespace:Tango.PPC.Events.Converters" xmlns:local="clr-namespace:Tango.PPC.Events.EventsViews" mc:Ignorable="d" d:DesignHeight="220" d:DesignWidth="750" d:DataContext="{d:DesignInstance Type=entities:MachinesEvent, IsDesignTimeCreatable=False}"> + + + - + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml index d283b08d3..69a2d56f4 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml @@ -4,22 +4,39 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" + xmlns:converters="clr-namespace:Tango.PPC.Events.Converters" xmlns:local="clr-namespace:Tango.PPC.Events.EventsViews" mc:Ignorable="d" d:DesignHeight="220" d:DesignWidth="750" d:DataContext="{d:DesignInstance Type=entities:MachinesEvent, IsDesignTimeCreatable=False}"> + + + + - + + + + + - + - - - - - - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobFailedEventView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobFailedEventView.xaml new file mode 100644 index 000000000..710e6b4da --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobFailedEventView.xaml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + (#) + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobFailedEventView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobFailedEventView.xaml.cs new file mode 100644 index 000000000..faac1576d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobFailedEventView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Events.EventsViews +{ + /// + /// Interaction logic for JobEventView.xaml + /// + public partial class JobFailedEventView : UserControl + { + public JobFailedEventView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/ThreadBreakView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/ThreadBreakView.xaml index 71c4ced07..e1316ddc3 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/ThreadBreakView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/ThreadBreakView.xaml @@ -5,12 +5,35 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" + xmlns:converters="clr-namespace:Tango.PPC.Events.Converters" xmlns:local="clr-namespace:Tango.PPC.Events.EventsViews" mc:Ignorable="d" d:DesignHeight="220" d:DesignWidth="750" d:DataContext="{d:DesignInstance Type=entities:MachinesEvent, IsDesignTimeCreatable=False}"> + + + + + - + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Images/machine_small_X4.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Images/machine_small_X4.png new file mode 100644 index 000000000..a2e881ddf Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Images/machine_small_X4.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj index 540c33e1c..d82ad3cce 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj @@ -72,6 +72,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -97,12 +101,16 @@ GlobalVersionInfo.cs + GeneralView.xaml + + JobFailedEventView.xaml + JobEventView.xaml @@ -191,6 +199,9 @@ + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs index 4e00474f4..59c56ed42 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs @@ -155,18 +155,17 @@ namespace Tango.PPC.Common.EventLogging /// The instance containing the event data. private void MachineOperator_PrintingFailed(object sender, PrintingFailedEventArgs e) { - String eventInfo = String.Empty; + EventTypes? relatedEventType = null; if (e.Exception is Transport.ResponseErrorException responseError) { if (responseError.Container.EventCode > 0) { - EventTypes evType = (EventTypes)responseError.Container.EventCode; - eventInfo = "\n#" + responseError.Container.EventCode + " " + evType.ToDescription(); + relatedEventType = (EventTypes)responseError.Container.EventCode; } } - Log(EventTypes.JOB_FAILED, e.Exception.Message + eventInfo); + Log(EventTypes.JOB_FAILED, e.Exception.Message, relatedEventType); } /// @@ -330,7 +329,7 @@ namespace Tango.PPC.Common.EventLogging /// /// Type of the event. /// The message. - public void Log(EventTypes eventType, string message) + public void Log(EventTypes eventType, string message, EventTypes? relatedEventType = null) { Init(); @@ -340,6 +339,11 @@ namespace Tango.PPC.Common.EventLogging machineEvent.EventType = _eventTypesGuids[eventType]; machineEvent.EventTypeGuid = machineEvent.EventType.Guid; + if (relatedEventType != null) + { + machineEvent.RelatedEventType = _eventTypesGuids[relatedEventType.Value]; + } + Log(machineEvent); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/IEventLogger.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/IEventLogger.cs index 81cce927d..a39f36cc1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/IEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/IEventLogger.cs @@ -36,7 +36,7 @@ namespace Tango.PPC.Common.EventLogging /// /// Type of the event. /// The message. - void Log(EventTypes eventType, String message); + void Log(EventTypes eventType, String message, EventTypes? relatedEventType = null); /// /// Logs the specified hardware event. diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/Software/Visual_Studio/Tango.BL/Entities/MachinesEvent.cs b/Software/Visual_Studio/Tango.BL/Entities/MachinesEvent.cs index 4572fe5ae..081fe01f1 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/MachinesEvent.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/MachinesEvent.cs @@ -108,6 +108,10 @@ namespace Tango.BL.Entities set { _eventUser = value; RaisePropertyChangedAuto(); } } + [JsonIgnore] + [NotMapped] + public EventType RelatedEventType { get; set; } + protected override void OnUserChanged(User user) { base.OnUserChanged(user); -- cgit v1.3.1