aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-03-01 17:47:27 +0200
committerAvi Levkovich <avi@twine-s.com>2020-03-01 17:47:27 +0200
commit6c1f8f8df6b9ee71104098f548ba8be8504fc89b (patch)
treefc0948888bb5dc156341f73d82306b26cc8523df /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics
parent046fce068413ae04454d07a0fd591bb200b30eef (diff)
parent2c0f48e170634b93daa75abda4e246e85ffed519 (diff)
downloadTango-6c1f8f8df6b9ee71104098f548ba8be8504fc89b.tar.gz
Tango-6c1f8f8df6b9ee71104098f548ba8be8504fc89b.zip
merge conflicts
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/CollectionConverter .cs44
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/LiquidTypeToColorConverter.cs43
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/MidTankLevelToElementHeightConverter.cs41
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToBoolYesNoNullConverter.cs37
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToFirstLetterConverter.cs30
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs44
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs45
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/RmlModel.cs15
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj27
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/ChartsViewVM.cs362
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs349
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs339
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml110
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml.cs35
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml468
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs67
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml114
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml.cs6
18 files changed, 1726 insertions, 450 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/CollectionConverter .cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/CollectionConverter .cs
new file mode 100644
index 000000000..4cea7f69f
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/CollectionConverter .cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Tango.MachineStudio.Statistics.Converters
+{
+ public class CollectionConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if(value != null && value is System.Collections.IEnumerable)
+ {
+ var colection = value as System.Collections.IEnumerable;
+ var text = new StringBuilder();
+ foreach(var val in colection)
+ {
+ string visibleText = val.ToString();
+ if (val is bool)
+ {
+ visibleText = (bool)val== true ? "Yes" : "No";
+ }
+ text.Append(visibleText);
+ text.Append("/");
+ }
+ string str_text = text.ToString();
+ if(str_text.Length > 1)
+ {
+ str_text = str_text.Remove(str_text.Length - 1);
+ }
+ return str_text;
+ }
+ return "";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/LiquidTypeToColorConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/LiquidTypeToColorConverter.cs
new file mode 100644
index 000000000..b36bf608e
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/LiquidTypeToColorConverter.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 System.Windows.Media;
+using Tango.BL;
+using Tango.BL.Enumerations;
+
+namespace Tango.MachineStudio.Statistics.Converters
+{
+ public class LiquidTypeToColorConverter : IValueConverter
+ {
+ private static Dictionary<LiquidTypes,Color> liquidTypes;
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (liquidTypes == null)
+ {
+ liquidTypes = new Dictionary<LiquidTypes, Color>();
+
+ foreach (var type in ObservablesStaticCollections.Instance.LiquidTypes.ToList())
+ {
+ liquidTypes.Add(type.Type, type.LiquidTypeColor);
+ }
+ }
+
+ if (value != null)
+ {
+ return liquidTypes[(LiquidTypes)value];
+ }
+
+ return value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/MidTankLevelToElementHeightConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/MidTankLevelToElementHeightConverter.cs
new file mode 100644
index 000000000..e9f513cc3
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/MidTankLevelToElementHeightConverter.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Globalization;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Tango.MachineStudio.Statistics.Converters
+{
+ public class MidTankLevelToElementHeightConverter : IMultiValueConverter
+ {
+ public const double MAX_QUANTITY = 130000000;
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ double parentActualHeight;
+ Double.TryParse(values[0].ToString(), out parentActualHeight);
+ double quantity;
+ Double.TryParse(values[1].ToString(), out quantity);
+
+ double midTankLevel = (double)Math.Min(quantity, MAX_QUANTITY);
+ double delta = ((midTankLevel / MAX_QUANTITY) * parentActualHeight);
+ if (midTankLevel < (MAX_QUANTITY/10))// if quantity < 10|% set 2 pixel
+ delta = 2.0;
+ var test = delta;
+ return test;// (parentActualHeight - (midTankLevel / MAX_QUANTITY) * parentActualHeight);
+ }
+ catch
+ {
+ return 0d;
+ }
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToBoolYesNoNullConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToBoolYesNoNullConverter.cs
new file mode 100644
index 000000000..f7633a7d0
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToBoolYesNoNullConverter.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace Tango.MachineStudio.Statistics.Converters
+{
+ public class StringToBoolYesNoNullConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if(value is bool)
+ {
+ return (bool)value ? "Yes" : "No";
+ }
+ return "Null";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ //throw new NotImplementedException();
+ if (value is ComboBoxItem)
+ {
+ string str_val = ((ComboBoxItem)value).Content.ToString();
+ if (str_val.ToUpper() == "NO")
+ return false;
+ if (str_val.ToUpper() == "YES")
+ return true;
+ }
+ return null;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToFirstLetterConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToFirstLetterConverter.cs
new file mode 100644
index 000000000..a1c9561b9
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToFirstLetterConverter.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Tango.MachineStudio.Statistics.Converters
+{
+ public class StringToFirstLetterConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null && value.ToString().Length > 1)
+ {
+ return value.ToString().First().ToString();
+ }
+ else
+ {
+ return value;
+ }
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+} \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs
index 8e5642e3d..2bf3a42a4 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs
@@ -1,45 +1,35 @@
-
-using System;
+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.Core.ExtensionMethods;
namespace Tango.MachineStudio.Statistics.Models
{
- public class JobRunModel : JobRun
+ public class JobRunModel
{
- private static Dictionary<String, Machine> _machines = new Dictionary<string, Machine>();
+ public JobRun JobRun { get; set; }
- public JobRunModel()
- {
+ public Machine Machine { get; set; }
- }
+ public User User { get; set; }
- public JobRunModel(JobRun run)
- {
- run.MapPropertiesTo(this, MappingFlags.NoReferenceTypes);
- }
+ public TimeSpan? UploadDuration { get; set; }
- public Task LoadMachine(ObservablesContext context)
+ public TimeSpan? HeatingDuration { get; set; }
+
+ public void Init()
{
- return Task.Factory.StartNew(() =>
+ if (JobRun.HeatingStartDate != null)
{
- if (!_machines.ContainsKey(MachineGuid))
- {
- Machine = context.Machines.SingleOrDefault(x => x.Guid == MachineGuid);
- _machines.Add(MachineGuid, Machine);
- }
- else
- {
- Machine = _machines[MachineGuid];
- }
- });
- }
+ UploadDuration = JobRun.HeatingStartDate - JobRun.StartDate;
+ }
- public Machine Machine { get; set; }
+ if (JobRun.ActualStartDate != null && JobRun.HeatingStartDate != null)
+ {
+ HeatingDuration = JobRun.ActualStartDate - JobRun.HeatingStartDate;
+ }
+ }
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs
new file mode 100644
index 000000000..98b719cae
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs
@@ -0,0 +1,45 @@
+
+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.Core.ExtensionMethods;
+
+namespace Tango.MachineStudio.Statistics.Models
+{
+ public class JobRunStatisticsModel : JobRun
+ {
+ private static Dictionary<String, Machine> _machines = new Dictionary<string, Machine>();
+
+ public JobRunStatisticsModel()
+ {
+
+ }
+
+ public JobRunStatisticsModel(JobRun run)
+ {
+ run.MapPropertiesTo(this, MappingFlags.NoReferenceTypes);
+ }
+
+ public Task LoadMachine(ObservablesContext context)
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ if (!_machines.ContainsKey(MachineGuid))
+ {
+ Machine = context.Machines.SingleOrDefault(x => x.Guid == MachineGuid);
+ _machines.Add(MachineGuid, Machine);
+ }
+ else
+ {
+ Machine = _machines[MachineGuid];
+ }
+ });
+ }
+
+ public Machine Machine { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/RmlModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/RmlModel.cs
new file mode 100644
index 000000000..789779e42
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/RmlModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.MachineStudio.Statistics.Models
+{
+ public class RmlModel
+ {
+ public string Guid { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj
index 36c371165..603429f94 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj
@@ -73,14 +73,29 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Converters\CollectionConverter .cs" />
+ <Compile Include="Converters\LiquidTypeToColorConverter.cs" />
+ <Compile Include="Converters\MidTankLevelToElementHeightConverter.cs" />
+ <Compile Include="Converters\StringToBoolYesNoNullConverter.cs" />
+ <Compile Include="Converters\StringToFirstLetterConverter.cs" />
<Compile Include="Models\JobRunModel.cs" />
+ <Compile Include="Models\JobRunStatisticsModel.cs" />
<Compile Include="Models\LabeledSeriesCollection.cs" />
+ <Compile Include="Models\RmlModel.cs" />
<Compile Include="Tooltips\PieChartTooltipControl.xaml.cs">
<DependentUpon>PieChartTooltipControl.xaml</DependentUpon>
</Compile>
<Compile Include="StatisticsModule.cs" />
<Compile Include="ViewModelLocator.cs" />
+ <Compile Include="ViewModels\ChartsViewVM.cs" />
+ <Compile Include="ViewModels\JobRunsViewVM.cs" />
<Compile Include="ViewModels\MainViewVM.cs" />
+ <Compile Include="Views\ChartsView.xaml.cs">
+ <DependentUpon>ChartsView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Views\JobRunsView.xaml.cs">
+ <DependentUpon>JobRunsView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
@@ -95,6 +110,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Views\ChartsView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="Views\JobRunsView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Views\MainView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -129,6 +152,10 @@
<Resource Include="Images\statistics.png" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\..\..\SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj">
+ <Project>{bb2abb74-ba58-4812-83aa-ec8171f42df4}</Project>
+ <Name>Tango.AutoComplete</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\..\Tango.BL\Tango.BL.csproj">
<Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project>
<Name>Tango.BL</Name>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/ChartsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/ChartsViewVM.cs
new file mode 100644
index 000000000..b06261306
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/ChartsViewVM.cs
@@ -0,0 +1,362 @@
+using LiveCharts;
+using LiveCharts.Wpf;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Media;
+using Tango.BL.Enumerations;
+using Tango.MachineStudio.Common;
+using Tango.MachineStudio.Statistics.Models;
+using Tango.BL.Entities;
+using Tango.SharedUI;
+using Tango.BL;
+using Tango.MachineStudio.Common.Notifications;
+using System.Threading.Tasks;
+
+namespace Tango.MachineStudio.Statistics.ViewModels
+{
+ public class ChartsViewVM : ViewModel
+ {
+ private INotificationProvider _notification;
+ private ObservablesContext _context;
+ private List<JobRunStatisticsModel> _job_runs;
+ private bool _loaded;
+
+ #region Properties
+ private LabeledSeriesCollection _timelineJobStatusSeries;
+ public LabeledSeriesCollection TimelineJobStatusSeries
+ {
+ get { return _timelineJobStatusSeries; }
+ set { _timelineJobStatusSeries = value; RaisePropertyChangedAuto(); }
+ }
+
+ private LabeledSeriesCollection _pieJobFailedReasons;
+ public LabeledSeriesCollection PieJobFailedReasons
+ {
+ get { return _pieJobFailedReasons; }
+ set { _pieJobFailedReasons = value; RaisePropertyChangedAuto(); }
+ }
+
+ private LabeledSeriesCollection _printPerWeekSeries;
+ public LabeledSeriesCollection PrintPerWeekSeries
+ {
+ get { return _printPerWeekSeries; }
+ set { _printPerWeekSeries = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DateTime _startDate;
+ public DateTime StartDate
+ {
+ get { return _startDate; }
+ set { _startDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); }
+ }
+
+ private DateTime _endDate;
+ public DateTime EndDate
+ {
+ get { return _endDate; }
+ set { _endDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); }
+ }
+
+ private DateTime _minDate;
+ public DateTime MinDate
+ {
+ get { return _minDate; }
+ set { _minDate = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DateTime _maxDate;
+ public DateTime MaxDate
+ {
+ get { return _maxDate; }
+ set { _maxDate = value; RaisePropertyChangedAuto(); }
+ }
+ #endregion
+
+ public ChartsViewVM(INotificationProvider notificationProvider)
+ {
+ _notification = notificationProvider;
+ StartDate = DateTime.Now.AddMonths(-1);
+ EndDate = DateTime.Now;
+ }
+
+ #region Generate Charts
+
+ public async void Init()
+ {
+ using (_notification.PushTaskItem("Loading statistics..."))
+ {
+ IsFree = false;
+
+ await Task.Factory.StartNew(() =>
+ {
+ _context = ObservablesContext.CreateDefault();
+ _job_runs = _context.JobRuns.OrderBy(x => x.StartDate).ToList().Select(x => new JobRunStatisticsModel(x)).ToList();
+ foreach (var run in _job_runs)
+ {
+ run.LoadMachine(_context).GetAwaiter().GetResult();
+ }
+ });
+
+ if (_job_runs.Count > 0)
+ {
+ MinDate = _job_runs.Min(x => x.StartDate);
+ MaxDate = _job_runs.Max(x => x.StartDate);
+ }
+
+ InvokeUIOnIdle(() =>
+ {
+ if (_loaded)
+ {
+ OnDateRangeChanged();
+ }
+ });
+
+ _loaded = true;
+ IsFree = true;
+ }
+ }
+
+ private List<JobRunStatisticsModel> GetJobRunsByDateRange(DateTime startDate, DateTime endTime, JobRunStatus? status = null)
+ {
+ return _job_runs.Where(x => x.StartDate.ToLocalTime() >= startDate && x.StartDate.ToLocalTime() <= endTime && (status == null || x.JobRunStatus == status)).ToList();
+ }
+
+ private List<JobRunStatisticsModel> GetJobRunsByDate(DateTime date, JobRunStatus? status = null)
+ {
+ return _job_runs.Where(x => x.StartDate.ToLocalTime().Date == date.Date && (status == null || x.JobRunStatus == status)).ToList();
+ }
+
+ private IEnumerable<DateTime> CreateDates(DateTime start, DateTime end)
+ {
+ for (DateTime date = start.Date; date.Date <= end.Date; date = date.AddDays(1))
+ {
+ yield return date;
+ }
+ }
+
+ private void GenerateTimelineJobStatusChart()
+ {
+ TimelineJobStatusSeries = new LabeledSeriesCollection()
+ {
+ Title = "Job Runs Status",
+ ChartTitle = "Number Of Runs",
+ LabelsTitle = "Date",
+ SeriesColors = new List<Color>()
+ {
+ Colors.Green,
+ Colors.Orange,
+ Colors.Red,
+ },
+ };
+
+ Series completed_job_runs = new ColumnSeries()
+ {
+ Title = "Completed",
+ Values = new ChartValues<int>(),
+ Fill = Brushes.Green,
+ MinWidth = 1,
+
+ };
+ Series aborted_job_runs = new ColumnSeries()
+ {
+ Title = "Aborted",
+ Values = new ChartValues<int>(),
+ Fill = Brushes.Orange,
+ MinWidth = 1,
+ };
+ Series failed_job_runs = new ColumnSeries()
+ {
+ Title = "Failed",
+ Values = new ChartValues<int>(),
+ Fill = Brushes.Red,
+ MinWidth = 1,
+ };
+
+ if (EndDate - StartDate > TimeSpan.FromDays(40))
+ {
+ completed_job_runs = new LineSeries()
+ {
+ Title = "Completed",
+ Values = new ChartValues<int>(),
+ Fill = new SolidColorBrush(Colors.Green) { Opacity = 0.5 },
+ MinWidth = 1,
+ PointGeometry = null,
+ StrokeThickness = 0,
+
+ };
+ aborted_job_runs = new LineSeries()
+ {
+ Title = "Aborted",
+ Values = new ChartValues<int>(),
+ Fill = new SolidColorBrush(Colors.Orange) { Opacity = 0.5 },
+ MinWidth = 1,
+ PointGeometry = null,
+ StrokeThickness = 0,
+ };
+ failed_job_runs = new LineSeries()
+ {
+ Title = "Failed",
+ Values = new ChartValues<int>(),
+ Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.5 },
+ MinWidth = 1,
+ PointGeometry = null,
+ StrokeThickness = 0,
+ };
+ }
+
+ foreach (var date in CreateDates(StartDate, EndDate))
+ {
+ completed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Completed).Count());
+ aborted_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Aborted).Count());
+ failed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Failed).Count());
+
+ TimelineJobStatusSeries.Labels.Add(date.ToShortDateString());
+ }
+
+
+
+ TimelineJobStatusSeries.SeriesCollection.Add(failed_job_runs);
+ TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs);
+ TimelineJobStatusSeries.SeriesCollection.Add(completed_job_runs);
+ }
+
+ private void GeneratePieFailedReasonsChart()
+ {
+ var groups = GetJobRunsByDateRange(StartDate, EndDate, JobRunStatus.Failed).GroupBy(x => x.FailedMessage).OrderBy(x => x.Count());
+
+ List<Color> colors = new List<Color>();
+
+ int max = groups.Count() > 0 ? groups.Max(x => x.Count()) : 0;
+
+ for (int i = 0; i < groups.Count(); i++)
+ {
+ int count = groups.ElementAt(i).Count();
+ double alpha = Math.Max(((double)(count) / max * 200), 20);
+ colors.Add(Color.FromArgb((byte)alpha, 200, 0, 0));
+ }
+
+ PieJobFailedReasons = new LabeledSeriesCollection()
+ {
+ Title = "Job Failure Reasons",
+ SeriesColors = colors,
+ };
+
+ int index = 0;
+
+ foreach (var group in groups)
+ {
+ int count = group.Count();
+
+ var series = new PieSeries()
+ {
+ Title = group.First().FailedMessage,
+ Values = new ChartValues<int>() { count },
+ Fill = new SolidColorBrush(colors[index++]),
+ DataLabels = true,
+ ToolTip = group.First().FailedMessage,
+ };
+
+ PieJobFailedReasons.SeriesCollection.Add(series);
+ }
+ }
+
+ private void GeneratePrintPerWeekChart()
+ {
+ List<JobRunStatisticsModel> range_job_runs = GetJobRunsByDateRange(StartDate, EndDate);
+
+ Dictionary<Machine, List<double>> weeks_print_avg = new Dictionary<Machine, List<double>>();
+
+ //Init machines weeks averages dictionary.
+ foreach (var machine in range_job_runs.Select(x => x.Machine).OrderBy(x => x.Name).DistinctBy(x => x.Guid))
+ {
+ weeks_print_avg[machine] = new List<double>();
+ }
+
+ //Create all available dates
+ List<DateTime> all_dates = range_job_runs.Select(x => x.StartDate).ToList();
+
+ //get first Sunday.
+ DateTime current_sunday = all_dates.FirstOrDefault(x => x.DayOfWeek == DayOfWeek.Sunday);
+
+ if (current_sunday != null && all_dates.Count > 0)
+ {
+ //Iterate over each week starting from the earliest Sunday.
+ while (current_sunday <= all_dates.Last())
+ {
+ var week_job_runs = range_job_runs.Where(x => x.EndPosition > 10 && x.StartDate >= current_sunday && x.StartDate <= current_sunday.AddDays(7)).ToList();
+
+ foreach (var machine_job_runs in week_job_runs.GroupBy(x => x.Machine))
+ {
+ weeks_print_avg[machine_job_runs.Key].Add(machine_job_runs.Select(x => x.EndPosition).Average());
+ }
+
+ current_sunday = current_sunday.AddDays(8);
+ }
+ }
+
+ Dictionary<Machine, double> week_print_avg = new Dictionary<Machine, double>();
+
+ //Init machines week average dictionary.
+ foreach (var machine in weeks_print_avg)
+ {
+ if (machine.Value.Count > 0)
+ {
+ week_print_avg[machine.Key] = machine.Value.Average();
+ }
+ }
+
+ //Init chart series
+ PrintPerWeekSeries = new LabeledSeriesCollection()
+ {
+ Title = "Average Printed Thread Per Week (m)",
+ ChartTitle = "Average Print Per Week (m)",
+ LabelsTitle = "Date",
+ SeriesColors = new List<Color>()
+ {
+
+ },
+ };
+
+ //Init series colors intensity by number of prints.
+ double max = week_print_avg.Count > 0 ? week_print_avg.Max(x => x.Value) : 0;
+ foreach (var machine in week_print_avg)
+ {
+ double a = (machine.Value / max);
+ PrintPerWeekSeries.SeriesColors.Add(Color.FromArgb((byte)(255d * (machine.Value / max)), 0, 200, 0));
+ }
+
+ //Init columns.
+ int index = 0;
+
+ foreach (var machine in week_print_avg)
+ {
+ var series = new ColumnSeries()
+ {
+ Title = machine.Key.Name,
+ Values = new ChartValues<int>() { (int)machine.Value },
+ Fill = new SolidColorBrush(PrintPerWeekSeries.SeriesColors[index++]),
+ DataLabels = true,
+ ToolTip = machine.Key.SerialNumber,
+ };
+
+ PrintPerWeekSeries.SeriesCollection.Add(series);
+ }
+ }
+
+ #endregion
+
+ #region Filter by Date
+ public void OnDateRangeChanged()
+ {
+ if (_job_runs != null && _job_runs.Count > 0)// && _loaded)
+ {
+ GenerateTimelineJobStatusChart();
+ GeneratePieFailedReasonsChart();
+ GeneratePrintPerWeekChart();
+ }
+ }
+ #endregion
+
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs
new file mode 100644
index 000000000..07e431751
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs
@@ -0,0 +1,349 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Data.Entity;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL;
+using Tango.BL.Builders;
+using Tango.BL.Entities;
+using Tango.BL.Enumerations;
+using Tango.Core.Commands;
+using Tango.MachineStudio.Common;
+using Tango.MachineStudio.Common.Notifications;
+using Tango.MachineStudio.Statistics.Models;
+using Tango.SharedUI;
+using Tango.SharedUI.Components;
+using Tango.AutoComplete.Editors;
+
+namespace Tango.MachineStudio.Statistics.ViewModels
+{
+ public class JobRunsViewVM : ViewModel
+ {
+ private INotificationProvider _notification;
+ private List<Machine> _allMachines;
+ private List<User> _allUsers;
+ private List<RmlModel> _rmlsModels;
+ private List<Job> _allJobRuns;
+
+ #region Properties
+
+ private ObservableCollection<JobRunModel> _jobRuns;
+ /// <summary>
+ /// Gets or sets the job runs. Contains filtered data of JobRunModel.
+ /// </summary>
+ public ObservableCollection<JobRunModel> JobRuns
+ {
+ get { return _jobRuns; }
+ set
+ {
+ _jobRuns = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private JobRunModel _selectedJobRun = null;
+ /// <summary>
+ /// Gets or sets the JobRunModel. Binding to selected item of grid items.
+ /// </summary>
+ public JobRunModel SelectedJobRun
+ {
+ get { return _selectedJobRun; }
+ set
+ {
+ _selectedJobRun = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private SelectedObjectCollection<Machine> _selectedMachines;
+ /// <summary>
+ /// Gets or sets the selected machines. Contains all available machines and selected machines. Binding to ComboBox Machines.
+ /// </summary>
+ public SelectedObjectCollection<Machine> SelectedMachines
+ {
+ get { return _selectedMachines; }
+ set
+ {
+ _selectedMachines = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private DateTime _startSelectedDate;
+ /// <summary>
+ /// Gets or sets the start selected date.
+ /// </summary>
+ public DateTime StartSelectedDate
+ {
+ get { return _startSelectedDate; }
+ set { _startSelectedDate = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DateTime _endSelectedDate;
+ /// <summary>
+ /// Gets or sets the end selected date.
+ /// </summary>
+ public DateTime EndSelectedDate
+ {
+ get { return _endSelectedDate; }
+ set { _endSelectedDate = value; RaisePropertyChangedAuto(); }
+ }
+
+ protected Double _lengthLowerValue;
+ /// <summary>
+ /// Gets or sets the length lower value of Range Slider
+ /// </summary>
+ public Double LengthLowerValue
+ {
+ get { return _lengthLowerValue; }
+ set
+ {
+ _lengthLowerValue = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ protected Double _lengthUpperValue;
+ /// <summary>
+ /// Gets or sets the length upper value of Range Slider.
+ /// </summary>
+ public Double LengthUpperValue
+ {
+ get { return _lengthUpperValue; }
+ set
+ {
+ _lengthUpperValue = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private SelectedObjectCollection<JobSource> _jobRunSelectedSources;
+ /// <summary>
+ /// Gets or sets the job run selected sources. Binding to ComboBox "Source".
+ /// </summary>
+ public SelectedObjectCollection<JobSource> JobRunSelectedSources
+ {
+ get { return _jobRunSelectedSources; }
+ set { _jobRunSelectedSources = value; RaisePropertyChangedAuto(); }
+ }
+
+ private SelectedObjectCollection<JobRunStatus> _jobRunSelectedStatuses;
+ /// <summary>
+ /// Gets or sets the job run selected statuses. Binding to ComboBox "Status".
+ /// </summary>
+ public SelectedObjectCollection<JobRunStatus> JobRunSelectedStatuses
+ {
+ get { return _jobRunSelectedStatuses; }
+ set { _jobRunSelectedStatuses = value; RaisePropertyChangedAuto(); }
+ }
+
+ public SelectedObjectCollection<bool> _isGradientSelection;
+ /// <summary>
+ /// Gets or sets the is gradient selection. Binding to ComboBox "IsGradient".
+ /// </summary>
+ public SelectedObjectCollection<bool> IsGradientSelection
+ {
+ get { return _isGradientSelection; }
+ set
+ {
+ _isGradientSelection = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private SelectedObjectCollection<RmlModel> _selectedThreads;
+ /// <summary>
+ /// Gets or sets the selected threads. Contains all available threads and selected threads. Binding to ComboBox "Thread".
+ /// </summary>
+ public SelectedObjectCollection<RmlModel> SelectedThreads
+ {
+ get { return _selectedThreads; }
+ set
+ {
+ _selectedThreads = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the JobRuns providers.
+ /// </summary>
+ public ISuggestionProvider JobsProvider { get; set; }
+
+ private Job _selectedJob;
+ /// <summary>
+ /// Gets or sets the job. Used as Sele
+ /// </summary>
+ public Job SelectedJob
+ {
+ get { return _selectedJob; }
+ set
+ {
+ _selectedJob = value;
+ SelectedJobName = _selectedJob != null ? _selectedJob.Name : "";
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the name of the selected job. Used in filter.
+ /// </summary>
+ private string SelectedJobName { get; set; }
+
+
+ #endregion
+
+ public RelayCommand LoadJobRunsCommand { get; set; }
+
+ public JobRunsViewVM(INotificationProvider notificationProvider)
+ {
+ _notification = notificationProvider;
+ JobRuns = new ObservableCollection<JobRunModel>();
+ LoadJobRunsCommand = new RelayCommand(async () => await LoadJobRuns(), ()=> IsFree);
+ LengthUpperValue = 5000.0;
+ LengthLowerValue = 0.0;
+ DateTime now = DateTime.Now;
+ StartSelectedDate = now.AddMonths(-1);
+ EndSelectedDate = now;
+
+ JobRunSelectedSources = new SelectedObjectCollection<JobSource>(new ObservableCollection<JobSource>()
+ {
+ JobSource.Local,
+ JobSource.Remote
+ }, new ObservableCollection<JobSource>()
+ {
+ JobSource.Local,
+ JobSource.Remote
+ });
+ JobRunSelectedSources.SelectionChanged -= (x, y) => RaisePropertyChanged(nameof(JobRunSelectedSources));
+ JobRunSelectedSources.SelectionChanged += (x, y) => RaisePropertyChanged(nameof(JobRunSelectedSources));
+
+ JobRunSelectedStatuses = new SelectedObjectCollection<JobRunStatus>(new ObservableCollection<JobRunStatus>()
+ {
+ JobRunStatus.Aborted,
+ JobRunStatus.Completed,
+ JobRunStatus.Failed,
+
+ }, new ObservableCollection<JobRunStatus>()
+ {
+ JobRunStatus.Aborted,
+ JobRunStatus.Completed,
+ JobRunStatus.Failed,
+
+ });
+ JobRunSelectedStatuses.SelectionChanged -= (x,y)=> RaisePropertyChanged(nameof(JobRunSelectedStatuses));
+ JobRunSelectedStatuses.SelectionChanged += (x, y) => RaisePropertyChanged(nameof(JobRunSelectedStatuses));
+
+ IsGradientSelection = new SelectedObjectCollection<bool>(new ObservableCollection<bool>
+ {
+ true,
+ false
+ }, new ObservableCollection<bool>
+ {
+ true,
+ false
+ });
+ IsGradientSelection.SelectionChanged -= (x, y) => RaisePropertyChanged(nameof(IsGradientSelection));
+ IsGradientSelection.SelectionChanged += (x, y) => RaisePropertyChanged(nameof(IsGradientSelection));
+ JobsProvider = new SuggestionProvider((filter) =>
+ {
+ try
+ {
+ SelectedJobName = filter;
+ return _allJobRuns.Where(x => x.Name != null && x.Name.ToString().StartsWith(filter, StringComparison.CurrentCultureIgnoreCase)).ToList();
+ }
+ catch
+ {
+ return null;
+ }
+ });
+
+ }
+
+ /// <summary>
+ /// Initializes this instance. Called form main view VM in OnApplicationReady
+ /// </summary>
+ public async void Init()
+ {
+ using (_notification.PushTaskItem("Loading job runs..."))
+ {
+ try
+ {
+ IsFree = false;
+
+ using (var db = ObservablesContext.CreateDefault())
+ {
+ _allJobRuns = await db.Jobs.ToListAsync(); ;
+ _allMachines = await db.Machines.ToListAsync();
+ _allUsers = await db.Users.Include(x => x.Contact).ToListAsync();
+ _rmlsModels = await db.Rmls.Select(x=> new RmlModel(){ Name = x.Name, Guid = x.Guid}).ToListAsync();
+ SelectedMachines = new SelectedObjectCollection<Machine>(_allMachines.ToObservableCollection(), new ObservableCollection<Machine>());
+ SelectedThreads = new SelectedObjectCollection<RmlModel>(_rmlsModels.ToObservableCollection(), new ObservableCollection<RmlModel>());
+
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error loading job runs.");
+ }
+ finally
+ {
+ IsFree = true;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Loads the job runs by filters.
+ /// </summary>
+ private async Task LoadJobRuns()
+ {
+ using (_notification.PushTaskItem("Loading job runs..."))
+ {
+ try
+ {
+ IsFree = false;
+
+ using (var db = ObservablesContext.CreateDefault())
+ {
+ DateTime startUtc = StartSelectedDate.ToUniversalTime();
+ TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(23, 59, 59);
+ DateTime endUtc = EndSelectedDate.ToUniversalTime() + offsetTime;
+
+ var runs = await new JobRunsCollectionBuilder(db).Set(x => x.ActualStartDate <= DbFunctions.TruncateTime(endUtc) && x.ActualStartDate >= DbFunctions.TruncateTime(startUtc.Date))
+ .WithMachines(SelectedMachines.SynchedSource.ToList())
+ .WithJobSource(JobRunSelectedSources.SynchedSource)
+ .WithJobStatus(JobRunSelectedStatuses.SynchedSource)
+ .WithGradient(IsGradientSelection.SynchedSource)
+ .WithRmls(SelectedThreads.SynchedSource.Select(x => x.Guid).ToList())
+ .Query(y => y.Where(x => (String.IsNullOrEmpty(SelectedJobName) || x.JobName.ToString().ToLower().StartsWith(SelectedJobName.ToLower()))
+ && ( x.JobLength < LengthUpperValue && x.JobLength >= LengthLowerValue)
+ ))
+ .BuildListAsync();
+
+ var modelList = runs.Select(x => new JobRunModel()
+ {
+ JobRun = x,
+ Machine = _allMachines.FirstOrDefault(y => y.Guid == x.MachineGuid),
+ User = _allUsers.SingleOrDefault(y => y.Guid == x.UserGuid),
+ }).ToList();
+
+ modelList.ForEach(x => x.Init());
+ JobRuns = modelList.ToObservableCollection();
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error loading job runs.");
+ }
+ finally
+ {
+ IsFree = true;
+ }
+ }
+ }
+
+ }
+}
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 dfbfe2648..4a75a41c8 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
@@ -19,349 +19,38 @@ namespace Tango.MachineStudio.Statistics.ViewModels
{
public class MainViewVM : StudioViewModel
{
- private ObservablesContext _context;
- private List<JobRunModel> _job_runs;
- private bool rendered;
private INotificationProvider _notification;
- private bool _loaded;
- private LabeledSeriesCollection _timelineJobStatusSeries;
- public LabeledSeriesCollection TimelineJobStatusSeries
+ private ChartsViewVM _chartsViewVM;
+ public ChartsViewVM ChartsViewVM
{
- get { return _timelineJobStatusSeries; }
- set { _timelineJobStatusSeries = value; RaisePropertyChangedAuto(); }
+ get { return _chartsViewVM; }
+ set { _chartsViewVM = value; RaisePropertyChangedAuto(); }
}
- private LabeledSeriesCollection _pieJobFailedReasons;
- public LabeledSeriesCollection PieJobFailedReasons
+ private JobRunsViewVM _jobRunsViewVM;
+ public JobRunsViewVM JobRunsViewVM
{
- get { return _pieJobFailedReasons; }
- set { _pieJobFailedReasons = value; RaisePropertyChangedAuto(); }
+ get { return _jobRunsViewVM; }
+ set { _jobRunsViewVM = value; RaisePropertyChangedAuto(); }
}
-
- private LabeledSeriesCollection _printPerWeekSeries;
- public LabeledSeriesCollection PrintPerWeekSeries
- {
- get { return _printPerWeekSeries; }
- set { _printPerWeekSeries = value; RaisePropertyChangedAuto(); }
- }
-
- private DateTime _startDate;
- public DateTime StartDate
- {
- get { return _startDate; }
- set { _startDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); }
- }
-
- private DateTime _endDate;
- public DateTime EndDate
- {
- get { return _endDate; }
- set { _endDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); }
- }
-
- private DateTime _minDate;
- public DateTime MinDate
- {
- get { return _minDate; }
- set { _minDate = value; RaisePropertyChangedAuto(); }
- }
-
- private DateTime _maxDate;
- public DateTime MaxDate
- {
- get { return _maxDate; }
- set { _maxDate = value; RaisePropertyChangedAuto(); }
- }
-
+
public MainViewVM(INotificationProvider notificationProvider)
{
_notification = notificationProvider;
-
- StartDate = DateTime.Now.AddMonths(-1);
- EndDate = DateTime.Now;
+ ChartsViewVM = new ChartsViewVM(_notification);
+ JobRunsViewVM = new JobRunsViewVM(_notification);
}
public override void OnApplicationReady()
{
-
- }
-
- private List<JobRunModel> GetJobRunsByDateRange(DateTime startDate, DateTime endTime, JobRunStatus? status = null)
- {
- return _job_runs.Where(x => x.StartDate.ToLocalTime() >= startDate && x.StartDate.ToLocalTime() <= endTime && (status == null || x.JobRunStatus == status)).ToList();
- }
-
- private List<JobRunModel> GetJobRunsByDate(DateTime date, JobRunStatus? status = null)
- {
- return _job_runs.Where(x => x.StartDate.ToLocalTime().Date == date.Date && (status == null || x.JobRunStatus == status)).ToList();
- }
-
- private IEnumerable<DateTime> CreateDates(DateTime start, DateTime end)
- {
- for (DateTime date = start.Date; date.Date <= end.Date; date = date.AddDays(1))
- {
- yield return date;
- }
+ JobRunsViewVM.Init();
}
- public override async void OnNavigatedTo()
+ public override void OnNavigatedTo()
{
base.OnNavigatedTo();
-
- if (rendered) return;
-
- rendered = true;
-
-
- using (_notification.PushTaskItem("Loading statistics..."))
- {
- IsFree = false;
-
- await Task.Factory.StartNew(() =>
- {
- _context = ObservablesContext.CreateDefault();
- _job_runs = _context.JobRuns.OrderBy(x => x.StartDate).ToList().Select(x => new JobRunModel(x)).ToList();
- foreach (var run in _job_runs)
- {
- run.LoadMachine(_context).GetAwaiter().GetResult();
- }
- });
-
- if (_job_runs.Count > 0)
- {
- MinDate = _job_runs.Min(x => x.StartDate);
- MaxDate = _job_runs.Max(x => x.StartDate);
- }
-
- InvokeUIOnIdle(() =>
- {
- OnDateRangeChanged();
- });
-
- _loaded = true;
-
- IsFree = true;
- }
- }
-
- private void OnDateRangeChanged()
- {
- if (_job_runs != null && _job_runs.Count > 0 && _loaded)
- {
- GenerateTimelineJobStatusChart();
- GeneratePieFailedReasonsChart();
- GeneratePrintPerWeekChart();
- }
- }
-
- private void GenerateTimelineJobStatusChart()
- {
- TimelineJobStatusSeries = new LabeledSeriesCollection()
- {
- Title = "Job Runs Status",
- ChartTitle = "Number Of Runs",
- LabelsTitle = "Date",
- SeriesColors = new List<Color>()
- {
- Colors.Green,
- Colors.Orange,
- Colors.Red,
- },
- };
-
- Series completed_job_runs = new ColumnSeries()
- {
- Title = "Completed",
- Values = new ChartValues<int>(),
- Fill = Brushes.Green,
- MinWidth = 1,
-
- };
- Series aborted_job_runs = new ColumnSeries()
- {
- Title = "Aborted",
- Values = new ChartValues<int>(),
- Fill = Brushes.Orange,
- MinWidth = 1,
- };
- Series failed_job_runs = new ColumnSeries()
- {
- Title = "Failed",
- Values = new ChartValues<int>(),
- Fill = Brushes.Red,
- MinWidth = 1,
- };
-
- if (EndDate - StartDate > TimeSpan.FromDays(40))
- {
- completed_job_runs = new LineSeries()
- {
- Title = "Completed",
- Values = new ChartValues<int>(),
- Fill = new SolidColorBrush(Colors.Green) { Opacity = 0.5 },
- MinWidth = 1,
- PointGeometry = null,
- StrokeThickness = 0,
-
- };
- aborted_job_runs = new LineSeries()
- {
- Title = "Aborted",
- Values = new ChartValues<int>(),
- Fill = new SolidColorBrush(Colors.Orange) { Opacity = 0.5 },
- MinWidth = 1,
- PointGeometry = null,
- StrokeThickness = 0,
- };
- failed_job_runs = new LineSeries()
- {
- Title = "Failed",
- Values = new ChartValues<int>(),
- Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.5 },
- MinWidth = 1,
- PointGeometry = null,
- StrokeThickness = 0,
- };
- }
-
- foreach (var date in CreateDates(StartDate, EndDate))
- {
- completed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Completed).Count());
- aborted_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Aborted).Count());
- failed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Failed).Count());
-
- TimelineJobStatusSeries.Labels.Add(date.ToShortDateString());
- }
-
-
-
- TimelineJobStatusSeries.SeriesCollection.Add(failed_job_runs);
- TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs);
- TimelineJobStatusSeries.SeriesCollection.Add(completed_job_runs);
- }
-
- private void GeneratePieFailedReasonsChart()
- {
- var groups = GetJobRunsByDateRange(StartDate, EndDate, JobRunStatus.Failed).GroupBy(x => x.FailedMessage).OrderBy(x => x.Count());
-
- List<Color> colors = new List<Color>();
-
- int max = groups.Count() > 0 ? groups.Max(x => x.Count()) : 0;
-
- for (int i = 0; i < groups.Count(); i++)
- {
- int count = groups.ElementAt(i).Count();
- double alpha = Math.Max(((double)(count) / max * 200), 20);
- colors.Add(Color.FromArgb((byte)alpha, 200, 0, 0));
- }
-
- PieJobFailedReasons = new LabeledSeriesCollection()
- {
- Title = "Job Failure Reasons",
- SeriesColors = colors,
- };
-
- int index = 0;
-
- foreach (var group in groups)
- {
- int count = group.Count();
-
- var series = new PieSeries()
- {
- Title = group.First().FailedMessage,
- Values = new ChartValues<int>() { count },
- Fill = new SolidColorBrush(colors[index++]),
- DataLabels = true,
- ToolTip = group.First().FailedMessage,
- };
-
- PieJobFailedReasons.SeriesCollection.Add(series);
- }
- }
-
- private void GeneratePrintPerWeekChart()
- {
- List<JobRunModel> range_job_runs = GetJobRunsByDateRange(StartDate, EndDate);
-
- Dictionary<Machine, List<double>> weeks_print_avg = new Dictionary<Machine, List<double>>();
-
- //Init machines weeks averages dictionary.
- foreach (var machine in range_job_runs.Select(x => x.Machine).OrderBy(x => x.Name).DistinctBy(x => x.Guid))
- {
- weeks_print_avg[machine] = new List<double>();
- }
-
- //Create all available dates
- List<DateTime> all_dates = range_job_runs.Select(x => x.StartDate).ToList();
-
- //get first Sunday.
- DateTime current_sunday = all_dates.FirstOrDefault(x => x.DayOfWeek == DayOfWeek.Sunday);
-
- if (current_sunday != null && all_dates.Count > 0)
- {
- //Iterate over each week starting from the earliest Sunday.
- while (current_sunday <= all_dates.Last())
- {
- var week_job_runs = range_job_runs.Where(x => x.EndPosition > 10 && x.StartDate >= current_sunday && x.StartDate <= current_sunday.AddDays(7)).ToList();
-
- foreach (var machine_job_runs in week_job_runs.GroupBy(x => x.Machine))
- {
- weeks_print_avg[machine_job_runs.Key].Add(machine_job_runs.Select(x => x.EndPosition).Average());
- }
-
- current_sunday = current_sunday.AddDays(8);
- }
- }
-
- Dictionary<Machine, double> week_print_avg = new Dictionary<Machine, double>();
-
- //Init machines week average dictionary.
- foreach (var machine in weeks_print_avg)
- {
- if (machine.Value.Count > 0)
- {
- week_print_avg[machine.Key] = machine.Value.Average();
- }
- }
-
- //Init chart series
- PrintPerWeekSeries = new LabeledSeriesCollection()
- {
- Title = "Average Printed Thread Per Week (m)",
- ChartTitle = "Average Print Per Week (m)",
- LabelsTitle = "Date",
- SeriesColors = new List<Color>()
- {
-
- },
- };
-
- //Init series colors intensity by number of prints.
- double max = week_print_avg.Count > 0 ? week_print_avg.Max(x => x.Value) : 0;
- foreach (var machine in week_print_avg)
- {
- double a = (machine.Value / max);
- PrintPerWeekSeries.SeriesColors.Add(Color.FromArgb((byte)(255d * (machine.Value / max)), 0, 200, 0));
- }
-
- //Init columns.
- int index = 0;
-
- foreach (var machine in week_print_avg)
- {
- var series = new ColumnSeries()
- {
- Title = machine.Key.Name,
- Values = new ChartValues<int>() { (int)machine.Value },
- Fill = new SolidColorBrush(PrintPerWeekSeries.SeriesColors[index++]),
- DataLabels = true,
- ToolTip = machine.Key.SerialNumber,
- };
-
- PrintPerWeekSeries.SeriesCollection.Add(series);
- }
+ ChartsViewVM.Init();
}
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml
new file mode 100644
index 000000000..ecd7e01ed
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml
@@ -0,0 +1,110 @@
+<UserControl x:Class="Tango.MachineStudio.Statistics.Views.ChartsView"
+ 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:vm="clr-namespace:Tango.MachineStudio.Statistics.ViewModels"
+ xmlns:global="clr-namespace:Tango.MachineStudio.Statistics"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:local="clr-namespace:Tango.MachineStudio.Statistics.Views"
+ xmlns:tooltips="clr-namespace:Tango.MachineStudio.Statistics.Tooltips"
+ xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
+ mc:Ignorable="d"
+ d:DesignHeight="450" d:DesignWidth="800">
+ <Grid IsEnabled="{Binding IsFree}">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="80"/>
+ <RowDefinition Height="337*"/>
+ </Grid.RowDefinitions>
+
+ <StackPanel Margin="60 20 0 0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
+ <StackPanel>
+ <TextBlock FontSize="10">Start Date:</TextBlock>
+ <DatePicker DisplayDateStart="{Binding MinDate}" DisplayDateEnd="{Binding MaxDate}" SelectedDate="{Binding StartDate}" materialDesign:HintAssist.Hint="Pick start date" Width="200" VerticalAlignment="Bottom" FontSize="16"></DatePicker>
+ </StackPanel>
+
+ <StackPanel Margin="40 0 0 0">
+ <TextBlock FontSize="10">End Date:</TextBlock>
+ <DatePicker DisplayDateStart="{Binding MinDate}" DisplayDateEnd="{Binding MaxDate}" SelectedDate="{Binding EndDate}" materialDesign:HintAssist.Hint="Pick end date" Width="200" VerticalAlignment="Bottom" FontSize="16"></DatePicker>
+ </StackPanel>
+ </StackPanel>
+
+ <UniformGrid Columns="3" Margin="50 20 50 50" Rows="2" Grid.Row="1">
+ <Border BorderBrush="{StaticResource Statistics.BorderBrush}" Padding="5" BorderThickness="1" CornerRadius="5" Margin="10">
+ <DockPanel>
+ <TextBlock DockPanel.Dock="Top" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Padding="10" Text="{Binding TimelineJobStatusSeries.Title}"></TextBlock>
+ <lvc:CartesianChart Series="{Binding TimelineJobStatusSeries.SeriesCollection}" LegendLocation="Bottom" SeriesColors="{Binding TimelineJobStatusSeries.SeriesColors}">
+ <lvc:CartesianChart.DataTooltip>
+ <lvc:DefaultTooltip BulletSize="20" Background="{StaticResource TransparentBackgroundBrush450}" Foreground="{StaticResource Dialog.Foreground}"/>
+ </lvc:CartesianChart.DataTooltip>
+ <lvc:CartesianChart.AxisX>
+ <lvc:Axis Title="{Binding TimelineJobStatusSeries.LabelsTitle}" Labels="{Binding TimelineJobStatusSeries.Labels}" Foreground="{StaticResource DarkGrayBrush200}">
+ <lvc:Axis.Separator>
+ <lvc:Separator Stroke="#A5A5A5" />
+ </lvc:Axis.Separator>
+ </lvc:Axis>
+ </lvc:CartesianChart.AxisX>
+ <lvc:CartesianChart.AxisY>
+ <lvc:Axis Title="{Binding TimelineJobStatusSeries.ChartTitle}" MinValue="0" Foreground="{StaticResource DarkGrayBrush200}" >
+ <lvc:Axis.Separator>
+ <lvc:Separator Stroke="#B0B0B0" />
+ </lvc:Axis.Separator>
+ </lvc:Axis>
+ </lvc:CartesianChart.AxisY>
+ </lvc:CartesianChart>
+ </DockPanel>
+ </Border>
+
+ <Border BorderBrush="{StaticResource Statistics.BorderBrush}" Padding="5" BorderThickness="1" CornerRadius="5" Margin="10">
+ <DockPanel>
+ <TextBlock DockPanel.Dock="Top" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Padding="10" Text="{Binding PieJobFailedReasons.Title}"></TextBlock>
+ <UniformGrid Columns="2">
+ <lvc:PieChart DataHover="PieChart_DataHover" Series="{Binding PieJobFailedReasons.SeriesCollection}" LegendLocation="None" SeriesColors="{Binding PieJobFailedReasons.SeriesColors}" Background="Transparent">
+ <lvc:PieChart.Resources>
+ <Style TargetType="lvc:PieSeries">
+ <Setter Property="Stroke" Value="#99F9F9F9"></Setter>
+ <Setter Property="StrokeThickness" Value="2"/>
+ </Style>
+ </lvc:PieChart.Resources>
+ <lvc:PieChart.DataTooltip>
+ <tooltips:PieChartTooltipControl Visibility="Hidden" />
+ </lvc:PieChart.DataTooltip>
+ </lvc:PieChart>
+
+ <TextBlock x:Name="txtPieTitle" TextWrapping="Wrap"></TextBlock>
+ </UniformGrid>
+ </DockPanel>
+ </Border>
+
+ <Border BorderBrush="{StaticResource Statistics.BorderBrush}" Padding="5" BorderThickness="1" CornerRadius="5" Margin="10">
+ <DockPanel>
+ <TextBlock DockPanel.Dock="Top" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Padding="10" Text="{Binding PrintPerWeekSeries.Title}"></TextBlock>
+ <lvc:CartesianChart Series="{Binding PrintPerWeekSeries.SeriesCollection}" LegendLocation="Bottom" SeriesColors="{Binding PrintPerWeekSeries.SeriesColors}" >
+ <lvc:CartesianChart.Resources>
+ <Style TargetType="lvc:ColumnSeries">
+ <Setter Property="Foreground" Value="{StaticResource DarkGrayBrush200}"></Setter>
+ </Style>
+ </lvc:CartesianChart.Resources>
+ <lvc:CartesianChart.AxisX>
+ <lvc:Axis Title="{Binding PrintPerWeekSeries.LabelsTitle}" Labels="{Binding PrintPerWeekSeries.Labels}" Foreground="{StaticResource DarkGrayBrush200}">
+ <lvc:Axis.Separator>
+ <lvc:Separator Stroke="#A5A5A5" />
+ </lvc:Axis.Separator>
+ </lvc:Axis>
+ </lvc:CartesianChart.AxisX>
+ <lvc:CartesianChart.AxisY>
+ <lvc:Axis Title="{Binding PrintPerWeekSeries.ChartTitle}" MinValue="0" Foreground="{StaticResource DarkGrayBrush200}" >
+ <lvc:Axis.Separator>
+ <lvc:Separator Stroke="#6F6F6F" />
+ </lvc:Axis.Separator>
+ </lvc:Axis>
+ </lvc:CartesianChart.AxisY>
+ <lvc:CartesianChart.DataTooltip>
+ <lvc:DefaultTooltip BulletSize="20" Background="{StaticResource TransparentBackgroundBrush450}" Foreground="{StaticResource Dialog.Foreground}"/>
+ </lvc:CartesianChart.DataTooltip>
+ </lvc:CartesianChart>
+ </DockPanel>
+ </Border>
+ </UniformGrid>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml.cs
new file mode 100644
index 000000000..d79d88281
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml.cs
@@ -0,0 +1,35 @@
+using LiveCharts;
+using LiveCharts.Wpf;
+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.MachineStudio.Statistics.Views
+{
+ /// <summary>
+ /// Interaction logic for ChartsView.xaml
+ /// </summary>
+ public partial class ChartsView : UserControl
+ {
+ public ChartsView()
+ {
+ InitializeComponent();
+ }
+ private void PieChart_DataHover(object sender, ChartPoint chartPoint)
+ {
+ var tooltip = ((chartPoint.ChartView as PieChart).DataTooltip as Tooltips.PieChartTooltipControl).Title;
+ txtPieTitle.Text = tooltip;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml
new file mode 100644
index 000000000..c82fa3beb
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml
@@ -0,0 +1,468 @@
+<UserControl x:Class="Tango.MachineStudio.Statistics.Views.JobRunsView"
+ 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:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:localConverters="clr-namespace:Tango.MachineStudio.Statistics.Converters"
+ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete"
+ xmlns:sys="clr-namespace:System;assembly=mscorlib"
+ xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL"
+ xmlns:local="clr-namespace:Tango.MachineStudio.Statistics.Views"
+ mc:Ignorable="d"
+ d:DesignHeight="450" d:DesignWidth="1800" Foreground="{StaticResource JobFieldForeground}">
+ <UserControl.Resources>
+ <sharedConverters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
+ <sharedConverters:BooleanToYesNoConverter x:Key="BooleanToYesNoConverter"/>
+ <sharedConverters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" />
+ <sharedConverters:TimeSpanToTwoDigitsTimeConverter x:Key="TimeSpanToTwoDigitsTimeConverter" />
+ <sharedConverters:DateTimeUTCToShortDateTimeConverter x:Key="DateTimeUTCToShortDateTimeConverter"/>
+ <localConverters:StringToBoolYesNoNullConverter x:Key="StringToBoolYesNoNullConverter"/>
+ <localConverters:LiquidTypeToColorConverter x:Key="LiquidTypeToColorConverter"/>
+ <localConverters:CollectionConverter x:Key="CollectionConverter"/>
+ <localConverters:StringToFirstLetterConverter x:Key="StringToFirstLetterConverter"/>
+ <localConverters:MidTankLevelToElementHeightConverter x:Key="MidTankLevelToElementHeightConverter"/>
+
+ <ResourceDictionary x:Key="SelectAllTextBoxResource">
+ <Style TargetType="TextBox">
+ <EventSetter Event="GotFocus" Handler="TextBox_GotFocus"></EventSetter>
+ <EventSetter Event="MouseDown" Handler="TextBox_PreviewMouseUp"></EventSetter>
+ </Style>
+ </ResourceDictionary>
+
+ <Style TargetType="{x:Type TextBlock}" x:Key="WrapText">
+ <Setter Property="TextWrapping" Value="Wrap"/>
+ </Style>
+
+ <DataTemplate x:Key="LiquidQuantitiesTemplate">
+ <DockPanel ToolTip="{Binding Quantity}">
+ <Grid DockPanel.Dock="Top" Height="40" Margin="2 0 2 -5" >
+ <Border x:Name="LiquidTypeBorder" BorderThickness="1" BorderBrush="{StaticResource borderBrush}" CornerRadius="2" ClipToBounds="True" >
+ <Canvas Width="16" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0">
+ <Border Height="39" Width="16" MinHeight="2" CornerRadius="0 0 2 2 " BorderThickness="0 0 0 3">
+ <Border.Background>
+ <SolidColorBrush Color="{Binding LiquidType,Converter={StaticResource LiquidTypeToColorConverter}}" />
+ </Border.Background>
+ <Border.Style>
+ <Style>
+ <Setter Property="Canvas.Top" >
+ <Setter.Value>
+ <MultiBinding Converter="{StaticResource MidTankLevelToElementHeightConverter}">
+ <Binding RelativeSource="{RelativeSource FindAncestor,AncestorType={x:Type Border}, AncestorLevel=1}" Path="ActualHeight" />
+ <Binding Path="Quantity" />
+ </MultiBinding>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ </Border.Style>
+ </Border>
+ </Canvas>
+ </Border>
+ </Grid>
+ <TextBlock DockPanel.Dock="Bottom" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0" Text="{Binding LiquidType,Converter={StaticResource StringToFirstLetterConverter}}" Foreground="Gray"/>
+ </DockPanel>
+ </DataTemplate>
+
+ </UserControl.Resources>
+
+ <Grid IsEnabled="{Binding IsFree}" >
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="3*"/>
+ <ColumnDefinition Width="1*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+ <Grid Grid.Row="0" Background="{StaticResource WhiteBackgroundBrush}" Width="Auto" Margin="20 0 0 1" >
+ <Border Padding="14 14 12 14" BorderBrush="DimGray" BorderThickness="0" Background="{StaticResource Logging.Background}" HorizontalAlignment="Stretch" CornerRadius="2" >
+ <Border.Effect>
+ <DropShadowEffect ShadowDepth="4" BlurRadius="10" Opacity="0.5"/>
+ </Border.Effect>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="120"/>
+ </Grid.ColumnDefinitions>
+
+ <Grid >
+ <Grid.RowDefinitions>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+ <StackPanel Orientation="Horizontal" Grid.Row="0">
+ <StackPanel Margin="10 5 0 0" Orientation="Vertical" HorizontalAlignment="Center">
+ <TextBlock Text="Machine:" VerticalAlignment="Center" FontSize="11"></TextBlock>
+ <ToggleButton Width="130" Margin="0 10 0 0" x:Name="selectMachineButton" HorizontalAlignment="Left" FontSize="16" VerticalAlignment="Center">
+ <ToggleButton.Template>
+ <ControlTemplate>
+ <Grid>
+ <Border CornerRadius="3" BorderBrush="{StaticResource borderBrush}" BorderThickness="1" TextElement.Foreground="Black" Height="24">
+ <DockPanel>
+ <Button x:Name="selectMachineButton" Width="18" Padding="0" Height="16" DockPanel.Dock="Right" BorderBrush="{x:Null}" HorizontalAlignment="Left" Click="Button_Click" Style="{StaticResource MaterialDesignFlatButton}" Foreground="{StaticResource MainWindow.Foreground}">
+ <materialDesign:PackIcon Width="16" Height="16" Kind="ChevronDown" VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" HorizontalAlignment="Right"/>
+ </Button>
+ <TextBlock VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" FontSize="11" Margin="5">
+ <TextBlock.Style>
+ <Style TargetType="{x:Type TextBlock}">
+ <Setter Property="Text" Value="{Binding SelectedMachines.SynchedSource.Count, StringFormat={}Selected Machines({0})}">
+ </Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding SelectedMachines.SynchedSource.Count}" Value="0">
+ <Setter Property="Text" Value="All machines"/>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </TextBlock.Style>
+ </TextBlock>
+ </DockPanel>
+ </Border>
+ <Popup StaysOpen="False" IsOpen="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=IsChecked }" MinWidth="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=Width}" >
+ <Border Background="{StaticResource Logging.Background}" BorderBrush="{StaticResource AutoCompleteTextBox.Popup.BorderBrush}" CornerRadius="3" BorderThickness="0.5" Padding="2">
+ <ScrollViewer MaxHeight="600" Background="{DynamicResource ComboBox.Floating.Background}">
+ <ItemsControl ItemsSource="{Binding SelectedMachines}" Foreground="{StaticResource MainWindow.Foreground}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <CheckBox VerticalAlignment="Center" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}" >
+ <CheckBox.Content>
+ <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Data.SerialNumber}" ToolTip="{Binding Data.SerialNumber}" FontFamily="{StaticResource FontName}"></TextBlock>
+ </CheckBox.Content>
+ </CheckBox>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </ScrollViewer>
+ </Border>
+ </Popup>
+ </Grid>
+ </ControlTemplate>
+ </ToggleButton.Template>
+ </ToggleButton>
+ </StackPanel>
+
+ <StackPanel Margin="50 10 0 0" HorizontalAlignment="Center">
+ <TextBlock FontSize="11">Start Date:</TextBlock>
+ <DatePicker x:Name="startdatePicker" Margin="0 5 0 0" SelectedDate="{Binding StartSelectedDate}" materialDesign:HintAssist.Hint="Pick start date" Width="130" VerticalAlignment="Center" FontSize="11" />
+ </StackPanel>
+ <StackPanel Margin="50 10 0 0" HorizontalAlignment="Center">
+ <TextBlock FontSize="11">End Date:</TextBlock>
+ <DatePicker x:Name="endDatePicker" Margin="0 5 0 0" SelectedDate="{Binding EndSelectedDate}" materialDesign:HintAssist.Hint="Pick end date" Width="130" VerticalAlignment="Center" FontSize="11" />
+ </StackPanel>
+ </StackPanel>
+
+ <StackPanel Orientation="Horizontal" Grid.Row="1">
+ <StackPanel Margin="10 20 0 0" Orientation="Vertical" HorizontalAlignment="Center">
+ <!--<TextBlock Text="Job Name:" VerticalAlignment="Center" FontSize="11"></TextBlock>-->
+ <!--<TextBox Text="{Binding JobName}" VerticalAlignment="Center" FontSize="11" Margin="0 5 0 0" Width="130"></TextBox>-->
+ <autoComplete:AutoCompleteTextBox Provider="{Binding JobsProvider}" Width="130" FontSize="11" LoadingContent="Loading..." SelectedItem="{Binding SelectedJob,Mode=TwoWay}" materialDesign:HintAssist.Hint="Job Name" DisplayMember="Name" materialDesign:HintAssist.IsFloating="True">
+ <autoComplete:AutoCompleteTextBox.ItemTemplate>
+ <DataTemplate>
+ <StackPanel>
+ <TextBlock Text="{Binding Name}" FontWeight="Bold" FontStyle="Italic"></TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </autoComplete:AutoCompleteTextBox.ItemTemplate>
+ </autoComplete:AutoCompleteTextBox>
+ </StackPanel>
+ <StackPanel Margin="40 10 0 0" Orientation="Vertical" HorizontalAlignment="Center">
+ <TextBlock Text="Source:" VerticalAlignment="Center" FontSize="11"></TextBlock>
+ <ToggleButton Width="130" Height="24" Margin="0 10 0 0" x:Name="selectJobRunSources" HorizontalAlignment="Left" FontSize="16" VerticalAlignment="Center">
+ <ToggleButton.Template>
+ <ControlTemplate>
+ <Grid>
+ <Border CornerRadius="3" BorderBrush="{StaticResource borderBrush}" BorderThickness="1" TextElement.Foreground="Black" >
+ <DockPanel>
+ <Button x:Name="jobRunSourcesButton" Width="18" Padding="0" Height="16" DockPanel.Dock="Right" BorderBrush="{x:Null}" HorizontalAlignment="Left" Click="JobRunSourcesButton_Click" Style="{StaticResource MaterialDesignFlatButton}" Foreground="{StaticResource MainWindow.Foreground}">
+ <materialDesign:PackIcon Width="16" Height="16" Kind="ChevronDown" VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" HorizontalAlignment="Right"/>
+ </Button>
+ <TextBlock VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" FontSize="11" Margin="5" Text="{Binding JobRunSelectedSources.SynchedSource, Converter={StaticResource CollectionConverter}}"/>
+ </DockPanel>
+ </Border>
+ <Popup StaysOpen="False" IsOpen="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=IsChecked }" Width="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=Width}">
+ <Border Background="{DynamicResource ComboBox.Floating.Background}" BorderBrush="{StaticResource AutoCompleteTextBox.Popup.BorderBrush}" >
+ <ItemsControl ItemsSource="{Binding JobRunSelectedSources}" Foreground="{StaticResource MainWindow.Foreground}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <CheckBox VerticalAlignment="Center" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}">
+ <CheckBox.Content>
+ <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Data}"></TextBlock>
+ </CheckBox.Content>
+ </CheckBox>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </Border>
+ </Popup>
+ </Grid>
+ </ControlTemplate>
+ </ToggleButton.Template>
+ </ToggleButton>
+ </StackPanel>
+ <StackPanel Margin="40 10 0 0" Orientation="Vertical" HorizontalAlignment="Center">
+ <TextBlock Text="Gradient:" VerticalAlignment="Center" FontSize="11"></TextBlock>
+ <ToggleButton Height="24" Width="130" Margin="0 10 0 0" x:Name="selectIsGradient" HorizontalAlignment="Left" FontSize="16" VerticalAlignment="Center">
+ <ToggleButton.Template>
+ <ControlTemplate>
+ <Grid>
+ <Border CornerRadius="3" BorderBrush="{StaticResource borderBrush}" BorderThickness="1" TextElement.Foreground="Black" >
+ <DockPanel>
+ <Button x:Name="isGradientButton" Width="18" Padding="0" Height="16" DockPanel.Dock="Right" BorderBrush="{x:Null}" HorizontalAlignment="Left" Click="IsGradientButton_Click" Style="{StaticResource MaterialDesignFlatButton}" Foreground="{StaticResource MainWindow.Foreground}">
+ <materialDesign:PackIcon Width="16" Height="16" Kind="ChevronDown" VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" HorizontalAlignment="Right"/>
+ </Button>
+ <TextBlock VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" FontSize="11" Margin="5 0 2 0">
+ <Run Text="{Binding IsGradientSelection.SynchedSource, Converter={StaticResource CollectionConverter}}"></Run>
+ </TextBlock>
+ </DockPanel>
+ </Border>
+ <Popup StaysOpen="False" IsOpen="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=IsChecked }" Width="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=Width}">
+ <Border Padding="5" Background="{DynamicResource ComboBox.Floating.Background}" BorderBrush="{StaticResource AutoCompleteTextBox.Popup.BorderBrush}">
+ <ItemsControl ItemsSource="{Binding IsGradientSelection}" Foreground="{StaticResource MainWindow.Foreground}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <CheckBox VerticalAlignment="Center" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}">
+ <CheckBox.Content>
+ <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Data, Converter={StaticResource BooleanToYesNoConverter}}"/>
+ </CheckBox.Content>
+ </CheckBox>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </Border>
+ </Popup>
+ </Grid>
+ </ControlTemplate>
+ </ToggleButton.Template>
+ </ToggleButton>
+ </StackPanel>
+ <StackPanel Margin="40 10 0 0" Orientation="Vertical" HorizontalAlignment="Center">
+ <TextBlock Text="Length:" VerticalAlignment="Center" FontSize="11"></TextBlock>
+ <Border MinWidth="200" BorderThickness="1" CornerRadius="3" BorderBrush="{StaticResource borderBrush}" Margin="0 5 0 0" Height="40">
+ <StackPanel Orientation="Horizontal" Width="200" Margin="2 0 2 0">
+ <TextBlock Text="{Binding LengthLowerValue, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" FontSize="11"></TextBlock>
+ <mahapps:RangeSlider Height="40" Margin="5 5 5 5" Minimum="0" Maximum="5000" Width="140"
+ LowerValue="{Binding LengthLowerValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Delay=100}"
+ UpperValue="{Binding LengthUpperValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Delay=100}"
+ VerticalAlignment="Center" IsSnapToTickEnabled="True" FontSize="8"/>
+ <TextBlock Text="{Binding LengthUpperValue}" VerticalAlignment="Center" FontSize="11"></TextBlock>
+ </StackPanel>
+ </Border>
+ </StackPanel>
+ <StackPanel Margin="40 10 0 0" Orientation="Vertical" HorizontalAlignment="Center">
+ <TextBlock Text="Status:" VerticalAlignment="Center" FontSize="11"></TextBlock>
+ <ToggleButton Height="24" Width="170" Margin="0 10 0 0" x:Name="selectJobRunStatus" HorizontalAlignment="Left" FontSize="16" VerticalAlignment="Center">
+ <ToggleButton.Template>
+ <ControlTemplate>
+ <Grid>
+ <Border CornerRadius="3" BorderBrush="{StaticResource borderBrush}" BorderThickness="1" TextElement.Foreground="Black" >
+ <DockPanel>
+ <Button x:Name="jobRunStatusButton" Width="18" Padding="0" Height="16" DockPanel.Dock="Right" BorderBrush="{x:Null}" HorizontalAlignment="Left" Click="JobRunStatusButton_Click" Style="{StaticResource MaterialDesignFlatButton}" Foreground="{StaticResource MainWindow.Foreground}">
+ <materialDesign:PackIcon Width="16" Height="16" Kind="ChevronDown" VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" HorizontalAlignment="Right"/>
+ </Button>
+ <TextBlock VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" FontSize="11" Margin="5" Text="{Binding JobRunSelectedStatuses.SynchedSource, Converter={StaticResource CollectionConverter}}"/>
+ </DockPanel>
+ </Border>
+ <Popup StaysOpen="False" IsOpen="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=IsChecked }" MinWidth="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=Width}">
+ <Border Padding="5" Background="{DynamicResource ComboBox.Floating.Background}" BorderBrush="{StaticResource AutoCompleteTextBox.Popup.BorderBrush}" >
+ <ItemsControl ItemsSource="{Binding JobRunSelectedStatuses}" Foreground="{StaticResource MainWindow.Foreground}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <CheckBox VerticalAlignment="Center" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}">
+ <CheckBox.Content>
+ <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Data}"/>
+ </CheckBox.Content>
+ </CheckBox>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </Border>
+ </Popup>
+ </Grid>
+ </ControlTemplate>
+ </ToggleButton.Template>
+ </ToggleButton>
+ </StackPanel>
+ <StackPanel Margin="40 10 0 0" Orientation="Vertical" HorizontalAlignment="Center">
+ <TextBlock Text="Threads:" VerticalAlignment="Center" FontSize="11"></TextBlock>
+ <ToggleButton Width="140" Margin="0 10 0 0" x:Name="selectThreadsButton" HorizontalAlignment="Left" FontSize="16" VerticalAlignment="Center">
+ <ToggleButton.Template>
+ <ControlTemplate>
+ <Grid>
+ <Border CornerRadius="3" BorderBrush="{StaticResource borderBrush}" BorderThickness="1" TextElement.Foreground="Black" Height="24">
+ <DockPanel>
+ <Button x:Name="selectThreadButton" Width="18" Padding="0" Height="16" DockPanel.Dock="Right" BorderBrush="{x:Null}" HorizontalAlignment="Left" Click="SelectMachineButton_Click" Style="{StaticResource MaterialDesignFlatButton}" Foreground="{StaticResource MainWindow.Foreground}">
+ <materialDesign:PackIcon Width="16" Height="16" Kind="ChevronDown" VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" HorizontalAlignment="Right"/>
+ </Button>
+ <TextBlock VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" FontSize="11" Margin="5" >
+ <TextBlock.Style>
+ <Style TargetType="{x:Type TextBlock}">
+ <Setter Property="Text" Value="{Binding SelectedThreads.SynchedSource.Count, StringFormat={}Selected Threads({0})}">
+ </Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding SelectedThreads.SynchedSource.Count}" Value="0">
+ <Setter Property="Text" Value="All threads"/>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </TextBlock.Style>
+ </TextBlock>
+ </DockPanel>
+ </Border>
+ <Popup StaysOpen="False" IsOpen="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=IsChecked }" MinWidth="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=Width}" >
+ <Border Background="{DynamicResource ComboBox.Floating.Background}" BorderBrush="{StaticResource AutoCompleteTextBox.Popup.BorderBrush}" CornerRadius="3" BorderThickness="0.5" Padding="2">
+ <ScrollViewer MaxHeight="600" Background="{DynamicResource ComboBox.Floating.Background}">
+ <ItemsControl ItemsSource="{Binding SelectedThreads}" Foreground="{StaticResource MainWindow.Foreground}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <CheckBox VerticalAlignment="Center" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}" >
+ <CheckBox.Content>
+ <TextBlock Margin="5 0 5 0" VerticalAlignment="Center" Text="{Binding Data.Name}" ToolTip="{Binding Data.Name}" FontFamily="{StaticResource FontName}" FontSize="16"></TextBlock>
+ </CheckBox.Content>
+ </CheckBox>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </ScrollViewer>
+ </Border>
+ </Popup>
+ </Grid>
+ </ControlTemplate>
+ </ToggleButton.Template>
+ </ToggleButton>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+ <Button Grid.Column="1" HorizontalAlignment="Right" Command="{Binding LoadJobRunsCommand}" Margin="10" Width="100" VerticalAlignment="Center">GO</Button>
+ </Grid>
+ </Border>
+ </Grid>
+
+ <DataGrid Grid.Row="1" Margin="20 0 0 10" SelectionMode="Single" SelectionUnit="FullRow" BorderBrush="{StaticResource borderBrush}" IsReadOnly="True" BorderThickness="1" RowHeight="80"
+ Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserReorderColumns="True"
+ CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding JobRuns}" HorizontalScrollBarVisibility="Disabled"
+ SelectedItem="{Binding SelectedJobRun}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" FontSize="11">
+
+ <DataGrid.CellStyle>
+ <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
+ <Setter Property="BorderThickness" Value="0"/>
+ <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
+ <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
+ <Setter Property="VerticalAlignment" Value="Stretch"/>
+ <Setter Property="HorizontalAlignment" Value="Left"/>
+ <!--<Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type DataGridCell}">
+ <ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>-->
+ <Style.Triggers>
+ <Trigger Property="IsSelected" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" />
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </DataGrid.CellStyle>
+ <DataGrid.RowStyle>
+ <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}">
+
+ <Style.Triggers>
+ <Trigger Property="IsMouseOver" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" />
+ <Setter Property="Cursor" Value="Hand"></Setter>
+ </Trigger>
+ <Trigger Property="IsSelected" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ </Trigger>
+ <Trigger Property="IsFocused" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </DataGrid.RowStyle>
+
+ <DataGrid.Columns>
+ <DataGridTemplateColumn Header="#">
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <materialDesign:PackIcon Width="24" Height="24" Margin="3 -5 0 0">
+ <materialDesign:PackIcon.Style>
+ <Style TargetType="materialDesign:PackIcon">
+ <Setter Property="Kind" Value="Check"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding JobRun.JobRunStatus}" Value="Completed">
+ <Setter Property="Kind" Value="Check"></Setter>
+ <Setter Property="Foreground" Value="{StaticResource GreenOpenFileBrush}"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding JobRun.JobRunStatus}" Value="Aborted">
+ <Setter Property="Kind" Value="Alert"></Setter>
+ <Setter Property="Foreground" Value="{StaticResource OrangeBrush}"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding JobRun.JobRunStatus}" Value="Failed">
+ <Setter Property="Kind" Value="AlertOctagon"></Setter>
+ <Setter Property="Foreground" Value="{StaticResource RedBrush100}"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </materialDesign:PackIcon.Style>
+ </materialDesign:PackIcon>
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ </DataGridTemplateColumn>
+ <DataGridTextColumn Header="ID" Binding="{Binding JobRun.ID}" MaxWidth="100" ElementStyle="{StaticResource WrapText}"/>
+ <DataGridTextColumn Header="Machine" Binding="{Binding Machine.SerialNumber}" Width="Auto" />
+ <DataGridTextColumn Header="User" Binding="{Binding User.Contact.FullName}" Width="80" ElementStyle="{StaticResource WrapText}"/>
+ <DataGridTextColumn Header="Job Name" Binding="{Binding JobRun.JobName}" MaxWidth="100" ElementStyle="{StaticResource WrapText}"/>
+ <DataGridTextColumn Header="Length" Binding="{Binding JobRun.JobLength, StringFormat={}{0:0.00}}" Width="Auto" />
+ <DataGridTextColumn Header="Source" Binding="{Binding JobRun.Source, Converter={StaticResource EnumToDescriptionConverter}}" Width="Auto" />
+ <DataGridTextColumn Header="Upload &#10;Duration" Binding="{Binding UploadDuration, Converter={StaticResource TimeSpanToTwoDigitsTimeConverter}, FallbackValue=5}" Width="Auto"/>
+ <DataGridTextColumn Header="Heating &#10;Duration" Binding="{Binding HeatingDuration, Converter={StaticResource TimeSpanToTwoDigitsTimeConverter}, FallbackValue=5}" Width="Auto" />
+ <DataGridTextColumn Header="Start Time" Binding="{Binding JobRun.ActualStartDate, Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" />
+ <DataGridTextColumn Header="IsGradient" Binding="{Binding JobRun.IsGradient}" Width="Auto" />
+ <DataGridTextColumn Header="GR" Binding="{Binding JobRun.GradientResolutionCm}" Width="Auto" />
+ <DataGridTextColumn Header="Status" Binding="{Binding JobRun.JobRunStatus, Converter={StaticResource EnumToDescriptionConverter}}" Width="Auto"/>
+ <DataGridTextColumn Header="End Time" Binding="{Binding JobRun.EndDate, Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" />
+ <DataGridTextColumn Header="End &#10;Position" Binding="{Binding JobRun.EndPosition, StringFormat={}{0:0.00}}" Width="Auto" />
+ <DataGridTemplateColumn Header="Liquid Quantities" Width="1*" >
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <ItemsControl ItemsSource="{Binding JobRun.LiquidQuantities,Mode=OneWay}" Margin="0 0 0 0" Height="80" ItemTemplate="{StaticResource LiquidQuantitiesTemplate}">
+ <ItemsControl.ItemContainerStyle>
+ <Style TargetType="ContentPresenter">
+ <Setter Property="Visibility" Value="Visible"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Quantity}" Value="0">
+ <Setter Property="Visibility" Value="Collapsed"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ItemsControl.ItemContainerStyle>
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <UniformGrid Rows="1" IsItemsHost="True"></UniformGrid>
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
+ </ItemsControl>
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ </DataGridTemplateColumn>
+ </DataGrid.Columns>
+ </DataGrid>
+ <Border Grid.Row="1" Grid.Column="1" Margin="20, 0, 20, 10" BorderBrush="{StaticResource borderBrush}" Background="{StaticResource TransparentBackgroundBrush}" BorderThickness="1">
+
+ <StackPanel>
+ <TextBlock Margin="10" Text="{Binding SelectedJobName}"></TextBlock>
+ </StackPanel>
+ </Border>
+ <Border Grid.Row="2" Grid.ColumnSpan="2" Margin="20, 10, 20, 20" BorderBrush="{StaticResource borderBrush}" Background="{StaticResource TransparentBackgroundBrush}" BorderThickness="1">
+ <StackPanel Background="{StaticResource TransparentBackgroundBrush}" >
+ <TextBlock>TOTALS:</TextBlock>
+ <TextBlock>Cyan:</TextBlock>
+ </StackPanel>
+ </Border>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs
new file mode 100644
index 000000000..39b0d2c02
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs
@@ -0,0 +1,67 @@
+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.MachineStudio.Statistics.Views
+{
+ /// <summary>
+ /// Interaction logic for JobRunsView.xaml
+ /// </summary>
+ public partial class JobRunsView : UserControl
+ {
+ public JobRunsView()
+ {
+ InitializeComponent();
+ }
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ selectMachineButton.IsChecked = true;
+ e.Handled = true;
+ }
+
+ private void JobRunSourcesButton_Click(object sender, RoutedEventArgs e)
+ {
+ selectJobRunSources.IsChecked = true;
+ e.Handled = true;
+ }
+ private void IsGradientButton_Click(object sender, RoutedEventArgs e)
+ {
+ selectIsGradient.IsChecked = true;
+ e.Handled = true;
+ }
+ private void JobRunStatusButton_Click(object sender, RoutedEventArgs e)
+ {
+ selectJobRunStatus.IsChecked = true;
+ e.Handled = true;
+ }
+
+ private async void TextBox_GotFocus(object sender, RoutedEventArgs e)
+ {
+ await Task.Delay(200);
+ TextBox txtBox = sender as TextBox;
+ txtBox.SelectAll();
+ }
+
+ private void TextBox_PreviewMouseUp(object sender, MouseButtonEventArgs e)
+ {
+ e.Handled = true;
+ }
+
+ private void SelectMachineButton_Click(object sender, RoutedEventArgs e)
+ {
+ selectThreadsButton.IsChecked = true;
+ e.Handled = true;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml
index 55804c7b3..170d3276a 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml
@@ -11,100 +11,28 @@
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
- <Grid IsEnabled="{Binding IsFree}">
+ <Grid>
<Grid.RowDefinitions>
- <RowDefinition Height="80"/>
- <RowDefinition Height="337*"/>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="20"/>
</Grid.RowDefinitions>
-
- <StackPanel Margin="60 20 0 0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
- <StackPanel>
- <TextBlock FontSize="10">Start Date:</TextBlock>
- <DatePicker DisplayDateStart="{Binding MinDate}" DisplayDateEnd="{Binding MaxDate}" SelectedDate="{Binding StartDate}" materialDesign:HintAssist.Hint="Pick start date" Width="200" VerticalAlignment="Bottom" FontSize="16"></DatePicker>
- </StackPanel>
-
- <StackPanel Margin="40 0 0 0">
- <TextBlock FontSize="10">End Date:</TextBlock>
- <DatePicker DisplayDateStart="{Binding MinDate}" DisplayDateEnd="{Binding MaxDate}" SelectedDate="{Binding EndDate}" materialDesign:HintAssist.Hint="Pick end date" Width="200" VerticalAlignment="Bottom" FontSize="16"></DatePicker>
- </StackPanel>
- </StackPanel>
-
- <UniformGrid Columns="3" Margin="50 20 50 50" Rows="2" Grid.Row="1">
- <Border BorderBrush="{StaticResource Statistics.BorderBrush}" Padding="5" BorderThickness="1" CornerRadius="5" Margin="10">
- <DockPanel>
- <TextBlock DockPanel.Dock="Top" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Padding="10" Text="{Binding TimelineJobStatusSeries.Title}"></TextBlock>
- <lvc:CartesianChart Series="{Binding TimelineJobStatusSeries.SeriesCollection}" LegendLocation="Bottom" SeriesColors="{Binding TimelineJobStatusSeries.SeriesColors}">
- <lvc:CartesianChart.DataTooltip>
- <lvc:DefaultTooltip BulletSize="20" Background="{StaticResource TransparentBackgroundBrush450}" Foreground="{StaticResource Dialog.Foreground}"/>
- </lvc:CartesianChart.DataTooltip>
- <lvc:CartesianChart.AxisX>
- <lvc:Axis Title="{Binding TimelineJobStatusSeries.LabelsTitle}" Labels="{Binding TimelineJobStatusSeries.Labels}" Foreground="{StaticResource DarkGrayBrush200}">
- <lvc:Axis.Separator>
- <lvc:Separator Stroke="#A5A5A5" />
- </lvc:Axis.Separator>
- </lvc:Axis>
- </lvc:CartesianChart.AxisX>
- <lvc:CartesianChart.AxisY>
- <lvc:Axis Title="{Binding TimelineJobStatusSeries.ChartTitle}" MinValue="0" Foreground="{StaticResource DarkGrayBrush200}" >
- <lvc:Axis.Separator>
- <lvc:Separator Stroke="#B0B0B0" />
- </lvc:Axis.Separator>
- </lvc:Axis>
- </lvc:CartesianChart.AxisY>
- </lvc:CartesianChart>
- </DockPanel>
- </Border>
-
- <Border BorderBrush="{StaticResource Statistics.BorderBrush}" Padding="5" BorderThickness="1" CornerRadius="5" Margin="10">
- <DockPanel>
- <TextBlock DockPanel.Dock="Top" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Padding="10" Text="{Binding PieJobFailedReasons.Title}"></TextBlock>
- <UniformGrid Columns="2">
- <lvc:PieChart DataHover="PieChart_DataHover" Series="{Binding PieJobFailedReasons.SeriesCollection}" LegendLocation="None" SeriesColors="{Binding PieJobFailedReasons.SeriesColors}" Background="Transparent">
- <lvc:PieChart.Resources>
- <Style TargetType="lvc:PieSeries">
- <Setter Property="Stroke" Value="#99F9F9F9"></Setter>
- <Setter Property="StrokeThickness" Value="2"/>
- </Style>
- </lvc:PieChart.Resources>
- <lvc:PieChart.DataTooltip>
- <tooltips:PieChartTooltipControl Visibility="Hidden" />
- </lvc:PieChart.DataTooltip>
- </lvc:PieChart>
-
- <TextBlock x:Name="txtPieTitle" TextWrapping="Wrap"></TextBlock>
- </UniformGrid>
- </DockPanel>
- </Border>
-
- <Border BorderBrush="{StaticResource Statistics.BorderBrush}" Padding="5" BorderThickness="1" CornerRadius="5" Margin="10">
- <DockPanel>
- <TextBlock DockPanel.Dock="Top" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Padding="10" Text="{Binding PrintPerWeekSeries.Title}"></TextBlock>
- <lvc:CartesianChart Series="{Binding PrintPerWeekSeries.SeriesCollection}" LegendLocation="Bottom" SeriesColors="{Binding PrintPerWeekSeries.SeriesColors}" >
- <lvc:CartesianChart.Resources>
- <Style TargetType="lvc:ColumnSeries">
- <Setter Property="Foreground" Value="{StaticResource DarkGrayBrush200}"></Setter>
- </Style>
- </lvc:CartesianChart.Resources>
- <lvc:CartesianChart.AxisX>
- <lvc:Axis Title="{Binding PrintPerWeekSeries.LabelsTitle}" Labels="{Binding PrintPerWeekSeries.Labels}" Foreground="{StaticResource DarkGrayBrush200}">
- <lvc:Axis.Separator>
- <lvc:Separator Stroke="#A5A5A5" />
- </lvc:Axis.Separator>
- </lvc:Axis>
- </lvc:CartesianChart.AxisX>
- <lvc:CartesianChart.AxisY>
- <lvc:Axis Title="{Binding PrintPerWeekSeries.ChartTitle}" MinValue="0" Foreground="{StaticResource DarkGrayBrush200}" >
- <lvc:Axis.Separator>
- <lvc:Separator Stroke="#6F6F6F" />
- </lvc:Axis.Separator>
- </lvc:Axis>
- </lvc:CartesianChart.AxisY>
- <lvc:CartesianChart.DataTooltip>
- <lvc:DefaultTooltip BulletSize="20" Background="{StaticResource TransparentBackgroundBrush450}" Foreground="{StaticResource Dialog.Foreground}"/>
- </lvc:CartesianChart.DataTooltip>
- </lvc:CartesianChart>
- </DockPanel>
- </Border>
- </UniformGrid>
+ <Grid Grid.Row="0" IsEnabled="{Binding IsFree}">
+ <TabControl Background="Transparent" Margin="0,40,0,0" x:Name="chartsTabControl" Padding="0 25 0 0">
+ <TabControl.Resources>
+ <Style TargetType="TabPanel">
+ <Setter Property="HorizontalAlignment" Value="Center"/>
+ </Style>
+ <Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
+ <Setter Property="Padding" Value="20,2"></Setter>
+ </Style>
+ </TabControl.Resources>
+ <TabItem Header="STATS" Margin="-100 0 0 0 ">
+ <local:ChartsView x:Name="processParametersView" DataContext="{Binding ChartsViewVM}"/>
+ </TabItem>
+ <TabItem Header="JOB RUNS" Margin="-100 0 0 0 ">
+ <local:JobRunsView x:Name="jobRunsView" DataContext="{Binding JobRunsViewVM}"/>
+ </TabItem>
+ </TabControl>
+ </Grid>
</Grid>
</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml.cs
index 3948c4e5a..f0d1c39a7 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml.cs
@@ -28,10 +28,6 @@ namespace Tango.MachineStudio.Statistics.Views
InitializeComponent();
}
- private void PieChart_DataHover(object sender, ChartPoint chartPoint)
- {
- var tooltip = ((chartPoint.ChartView as PieChart).DataTooltip as Tooltips.PieChartTooltipControl).Title;
- txtPieTitle.Text = tooltip;
- }
+
}
}