aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-07-01 17:56:49 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-07-01 17:56:49 +0300
commit8a1e772f025eaf3bfdf17905d9e33c460993e559 (patch)
treeb6d705cca71033cd6c5f814596ceb9abc849bf50 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Events
parentc0fd8dcc53e45aa5aa0095cc2c8c5f39a34f7886 (diff)
downloadTango-8a1e772f025eaf3bfdf17905d9e33c460993e559.tar.gz
Tango-8a1e772f025eaf3bfdf17905d9e33c460993e559.zip
Many bug fixes !!!
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Events')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs24
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml27
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml.cs28
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj9
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs6
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml2
6 files changed, 86 insertions, 10 deletions
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 b0d00bf9f..47c9e0ddf 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
@@ -7,30 +7,40 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using Tango.BL.Entities;
+using Tango.BL.Enumerations;
+using Tango.PPC.Events.EventsViews;
namespace Tango.PPC.Events.Converters
{
public class MachineEventToViewConverter : IValueConverter
{
- private static List<FrameworkElement> _views = new List<FrameworkElement>();
+ private static Dictionary<EventTypes, Type> _eventViews = new Dictionary<EventTypes, Type>();
+
+ static MachineEventToViewConverter()
+ {
+ _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));
+ }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
MachinesEvent ev = value as MachinesEvent;
+ FrameworkElement view = null;
if (ev != null)
{
- FrameworkElement view = _views.SingleOrDefault(x => x.GetType() == typeof(EventsViews.GeneralView));
-
- if (view != null)
+ if (_eventViews.ContainsKey(ev.Type))
{
- return view;
+ view = Activator.CreateInstance(_eventViews[ev.Type]) as FrameworkElement;
}
else
{
- view = Activator.CreateInstance<EventsViews.GeneralView>();
- return view;
+ view = Activator.CreateInstance<GeneralView>();
}
+
+ return view;
}
else
{
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
new file mode 100644
index 000000000..d283b08d3
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml
@@ -0,0 +1,27 @@
+<UserControl x:Class="Tango.PPC.Events.EventsViews.JobEventView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ 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: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}">
+ <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}">
+ <DockPanel>
+ <Image Stretch="None" Margin="20" DockPanel.Dock="Right" Source="../Images/machine_small.png" RenderOptions.BitmapScalingMode="Fant" />
+ <DockPanel Margin="35 20 20 20">
+ <TextBlock FontSize="{StaticResource TangoTitleFontSize}" FontWeight="SemiBold" DockPanel.Dock="Top" Text="{Binding EventType.Title,FallbackValue='Unknown Event'}"></TextBlock>
+
+ <StackPanel Margin="0 30 0 0">
+ <TextBlock TextWrapping="Wrap" FontWeight="SemiBold" Text="{Binding EventType.Description,FallbackValue='No Description'}"></TextBlock>
+ <Rectangle Margin="0 5 0 10" StrokeThickness="2" Stroke="{StaticResource TangoDividerBrush}" />
+
+ <TextBlock Text="{Binding Description}" TextWrapping="Wrap">
+
+ </TextBlock>
+ </StackPanel>
+ </DockPanel>
+ </DockPanel>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml.cs
new file mode 100644
index 000000000..89faa3a85
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.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
+{
+ /// <summary>
+ /// Interaction logic for JobEventView.xaml
+ /// </summary>
+ public partial class JobEventView : UserControl
+ {
+ public JobEventView()
+ {
+ InitializeComponent();
+ }
+ }
+}
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 e446e3812..e2133e585 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 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="EventsViews\JobEventView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Resources\Styles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -91,6 +95,9 @@
<Compile Include="EventsViews\GeneralView.xaml.cs">
<DependentUpon>GeneralView.xaml</DependentUpon>
</Compile>
+ <Compile Include="EventsViews\JobEventView.xaml.cs">
+ <DependentUpon>JobEventView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@@ -173,7 +180,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs
index 997ea70d5..d2a730cd7 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs
@@ -97,7 +97,7 @@ namespace Tango.PPC.Events.ViewModels
using (var db = ObservablesContext.CreateDefault())
{
var last_week = DateTime.UtcNow.AddDays(-7);
- HistoryEvents = (await db.MachinesEvents.Where(x => x.MachineGuid == MachineProvider.Machine.Guid && x.DateTime > last_week).Take(100).Include(x => x.EventType).Where(x => (EventTypeNotificationTimes)x.EventType.EventNotificationTime != EventTypeNotificationTimes.None).ToListAsync()).OrderByDescending(x => x.DateTime).ToObservableCollection();
+ HistoryEvents = (await db.MachinesEvents.Where(x => x.MachineGuid == MachineProvider.Machine.Guid && x.DateTime > last_week).Take(100).Include(x => x.EventType).Where(x => (EventTypeNotificationTimes)x.EventType.EventNotificationTime != EventTypeNotificationTimes.None || x.EventType.Code == (int)EventTypes.JOB_FAILED || x.EventType.Code == (int)EventTypes.JOB_STARTED || x.EventType.Code == (int)EventTypes.JOB_COMPLETED || x.EventType.Code == (int)EventTypes.JOB_ABORTED).ToListAsync()).OrderByDescending(x => x.DateTime).ToObservableCollection();
}
MachineProvider.MachineOperator.StatusChanged += MachineOperator_StatusChanged;
@@ -160,6 +160,10 @@ namespace Tango.PPC.Events.ViewModels
_notifications.Add(new KeyValuePair<EventTypes, NotificationItem>(ev.EventType.Type, notificationItem));
}
+ else if (ev.IsJobProgressEvent())
+ {
+ HistoryEvents.Insert(0, ev);
+ }
});
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml
index f263e4b7b..af42a5576 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml
@@ -135,7 +135,7 @@
</Style.Triggers>
</Style>
</Grid.Style>
- <touch:LightTouchDataGrid x:Name="gridEventsHistory" SelectionChanged="gridEventsHistory_SelectionChanged" RenderOptions.EdgeMode="Unspecified" SelectionMode="Single" EnableDragAndDrop="False" Style="{StaticResource TangoEventsGridHistory}" ItemsSource="{Binding HistoryEvents}" SelectedItem="{Binding SelectedHistoryEvent,Mode=TwoWay}" Margin="10">
+ <touch:LightTouchDataGrid x:Name="gridEventsHistory" SelectionChanged="gridEventsHistory_SelectionChanged" RenderOptions.EdgeMode="Unspecified" SelectionMode="Single" EnableDragAndDrop="False" Style="{StaticResource TangoEventsGrid}" ItemsSource="{Binding HistoryEvents}" SelectedItem="{Binding SelectedHistoryEvent,Mode=TwoWay}" Margin="10">
<touch:LightTouchDataGrid.Columns>
<touch:LightTouchDataGridColumn Width="120" Header="Severity" HorizontalContentAlignment="Center" SortMember="Category">
<touch:LightTouchDataGridColumn.CellTemplate>