From fc6bdc8ec79ccb6b45b80a8608a6f3d360244fa4 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 21 Nov 2018 11:27:26 +0200 Subject: Added component type name in hardware versions module. --- .../ViewModels/MainViewVM.cs | 40 ++++++++++++++++++++++ .../Views/MainView.xaml | 7 +++- 2 files changed, 46 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index c46b1dec1..5e087cd02 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -43,6 +43,46 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels { _selectedHardwareObject = value; RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(SelectedHardwareObjectTypeName)); + } + } + + public String SelectedHardwareObjectTypeName + { + get + { + String name = String.Empty; + + if (SelectedHardwareObject is HardwareMotor) + { + name = (SelectedHardwareObject as HardwareMotor).HardwareMotorType.Description; + } + else if (SelectedHardwareObject is HardwareDancer) + { + name = (SelectedHardwareObject as HardwareDancer).HardwareDancerType.Description; + } + else if (SelectedHardwareObject is HardwareBlower) + { + name = (SelectedHardwareObject as HardwareBlower).HardwareBlowerType.Description; + } + else if (SelectedHardwareObject is HardwareBreakSensor) + { + name = (SelectedHardwareObject as HardwareBreakSensor).HardwareBreakSensorType.Description; + } + else if (SelectedHardwareObject is HardwarePidControl) + { + name = (SelectedHardwareObject as HardwarePidControl).HardwarePidControlType.Description; + } + else if (SelectedHardwareObject is HardwareSpeedSensor) + { + name = (SelectedHardwareObject as HardwareSpeedSensor).HardwareSpeedSensorType.Description; + } + else if (SelectedHardwareObject is HardwareWinder) + { + name = (SelectedHardwareObject as HardwareWinder).HardwareWinderType.Description; + } + + return name; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml index 293b947f0..121e6e45c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml @@ -371,7 +371,12 @@ - + + + + + + -- cgit v1.3.1 From 81311d321be26ccad433143290ddf5b8ee1bbafb Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 22 Nov 2018 16:54:38 +0200 Subject: Working on Stats. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 20578304 bytes .../Build/Shortcuts/Machine Emulator.lnk | Bin 1471 -> 1455 bytes .../Build/Shortcuts/Machine Studio.lnk | Bin 1532 -> 1516 bytes .../Build/Shortcuts/Proto Compiler GUI.lnk | Bin 1464 -> 1448 bytes .../Models/LabeledSeriesCollection.cs | 7 + .../ViewModels/MainViewVM.cs | 172 +++++++++++++++------ .../Views/MainView.xaml | 48 ++++-- .../Tango.BL/Builders/MachineBuilder.cs | 8 + Software/Visual_Studio/Tango.sln | 43 ++++++ .../Utilities/Tango.JobRunsGenerator/App.config | 16 ++ .../Utilities/Tango.JobRunsGenerator/Program.cs | 88 +++++++++++ .../Properties/AssemblyInfo.cs | 7 + .../Tango.JobRunsGenerator.csproj | 74 +++++++++ .../Tango.JobRunsGenerator/packages.config | 4 + 15 files changed, 407 insertions(+), 60 deletions(-) create mode 100644 Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/App.config create mode 100644 Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Tango.JobRunsGenerator.csproj create mode 100644 Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/packages.config (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index c6d13c91b..d0ab60a89 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 292366f4b..6c60faaea 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk index 9afe2c39c..ed9cce877 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index 9777e06c8..290f7d1b7 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk index c20fa96d6..565a15760 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk and b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/LabeledSeriesCollection.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/LabeledSeriesCollection.cs index b29c74127..4d3bf5eac 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/LabeledSeriesCollection.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/LabeledSeriesCollection.cs @@ -12,6 +12,13 @@ namespace Tango.MachineStudio.Statistics.Models { public class LabeledSeriesCollection : ExtendedObject { + private String _title; + public String Title + { + get { return _title; } + set { _title = value; RaisePropertyChangedAuto(); } + } + private String _charTitle; public String ChartTitle { 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 f09ed2e0d..82e47052b 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 @@ -7,7 +7,9 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Media; using Tango.BL; +using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.Core.Helpers; using Tango.MachineStudio.Common; using Tango.MachineStudio.Statistics.Models; @@ -16,6 +18,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels public class MainViewVM : StudioViewModel { private ObservablesContext _context; + private List _job_runs; + private bool rendered; private LabeledSeriesCollection _timelineJobStatusSeries; public LabeledSeriesCollection TimelineJobStatusSeries @@ -24,19 +28,16 @@ namespace Tango.MachineStudio.Statistics.ViewModels set { _timelineJobStatusSeries = value; RaisePropertyChangedAuto(); } } + private LabeledSeriesCollection _pieJobFailedReasons; + public LabeledSeriesCollection PieJobFailedReasons + { + get { return _pieJobFailedReasons; } + set { _pieJobFailedReasons = value; RaisePropertyChangedAuto(); } + } + public MainViewVM() { - TimelineJobStatusSeries = new LabeledSeriesCollection() - { - ChartTitle = "Monthly Job Runs", - LabelsTitle = "Date", - SeriesColors = new List() - { - Colors.Green, - Colors.Orange, - Colors.Red, - }, - }; + } public override void OnApplicationReady() @@ -45,43 +46,128 @@ namespace Tango.MachineStudio.Statistics.ViewModels { _context = ObservablesContext.CreateDefault(); DateTime start_date = DateTime.UtcNow.AddMonths(-1); - var jobs_runs = _context.JobRuns.Where(x => x.StartDate > start_date).OrderBy(x => x.StartDate).ToList(); + _job_runs = _context.JobRuns.OrderBy(x => x.StartDate).ToList(); + }); + } - InvokeUIOnIdle(() => - { - var completed_job_runs = new ColumnSeries() - { - Title = "Completed", - Values = new ChartValues(), - Fill = Brushes.Green, - }; - var aborted_job_runs = new ColumnSeries() - { - Title = "Aborted", - Values = new ChartValues(), - Fill = Brushes.Orange, - }; - var failed_job_runs = new ColumnSeries() - { - Title = "Failed", - Values = new ChartValues(), - Fill = Brushes.Red, - }; + private List GetJobRunsByStartDate(DateTime startDate, JobRunStatus? status = null) + { + return _job_runs.Where(x => x.StartDate.ToLocalTime() >= startDate && (status == null || x.JobRunStatus == status)).ToList(); + } - for (DateTime date = DateTime.Now.AddMonths(-1); date.Date <= DateTime.Now.Date; date = date.AddDays(1)) - { - completed_job_runs.Values.Add(jobs_runs.Where(x => x.StartDate.ToLocalTime().Date == date.Date && x.JobRunStatus == JobRunStatus.Completed).Count()); - aborted_job_runs.Values.Add(jobs_runs.Where(x => x.StartDate.ToLocalTime().Date == date.Date && x.JobRunStatus == JobRunStatus.Aborted).Count()); - failed_job_runs.Values.Add(jobs_runs.Where(x => x.StartDate.ToLocalTime().Date == date.Date && x.JobRunStatus == JobRunStatus.Failed).Count()); + private List 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 CreateDates(DateTime start, DateTime end) + { + for (DateTime date = start.Date; date.Date <= end.Date; date = date.AddDays(1)) + { + yield return date; + } + } - TimelineJobStatusSeries.Labels.Add(date.ToShortDateString()); - } + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (rendered) return; - TimelineJobStatusSeries.SeriesCollection.Add(completed_job_runs); - TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs); - TimelineJobStatusSeries.SeriesCollection.Add(failed_job_runs); - }); + rendered = true; + + InvokeUIOnIdle(() => + { + GenerateTimelineJobStatusChart(); + GeneratePieFailedReasonsChart(); }); } + + private void GenerateTimelineJobStatusChart() + { + TimelineJobStatusSeries = new LabeledSeriesCollection() + { + Title = "This Month Job Runs Status", + ChartTitle = "Number Of Runs", + LabelsTitle = "Date", + SeriesColors = new List() + { + Colors.Green, + Colors.Orange, + Colors.Red, + }, + }; + + var completed_job_runs = new ColumnSeries() + { + Title = "Completed", + Values = new ChartValues(), + Fill = Brushes.Green, + }; + var aborted_job_runs = new ColumnSeries() + { + Title = "Aborted", + Values = new ChartValues(), + Fill = Brushes.Orange, + }; + var failed_job_runs = new ColumnSeries() + { + Title = "Failed", + Values = new ChartValues(), + Fill = Brushes.Red, + }; + + foreach (var date in CreateDates(DateTime.Now.AddMonths(-1), DateTime.Now)) + { + 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(completed_job_runs); + TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs); + TimelineJobStatusSeries.SeriesCollection.Add(failed_job_runs); + } + + private void GeneratePieFailedReasonsChart() + { + var groups = GetJobRunsByStartDate(DateTime.Now.AddMonths(-1), JobRunStatus.Failed).GroupBy(x => x.FailedMessage); + + List colors = new List(); + + int max = groups.Max(x => x.Count()); + + 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 = "This Month 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() { count }, + Fill = new SolidColorBrush(colors[index++]), + DataLabels = true, + }; + + PieJobFailedReasons.SeriesCollection.Add(series); + } + } } } 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 c1c3a39b6..56a16770a 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 @@ -10,23 +10,37 @@ 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}"> - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs index fa18a9f3b..35770b6b4 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs @@ -36,5 +36,13 @@ namespace Tango.BL.Builders .Build(); }); } + + public virtual MachineBuilder WithJobs() + { + return AddStep(3, () => + { + new JobsCollectionBuilder(Context).Set(x => x.MachineGuid == Entity.Guid).WithSegments().Build(); + }); + } } } diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index cd4b7121f..490ea56b3 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -234,6 +234,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.Statist EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Explorer", "Tango.Explorer\Tango.Explorer.csproj", "{4399AF76-DB52-4CFB-8020-6F85BDB29FD5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.JobRunsGenerator", "Utilities\Tango.JobRunsGenerator\Tango.JobRunsGenerator.csproj", "{4EDCF067-E377-42CB-A18C-8368CF484577}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AppVeyor|Any CPU = AppVeyor|Any CPU @@ -4157,6 +4159,46 @@ Global {4399AF76-DB52-4CFB-8020-6F85BDB29FD5}.Release|x64.Build.0 = Release|Any CPU {4399AF76-DB52-4CFB-8020-6F85BDB29FD5}.Release|x86.ActiveCfg = Release|Any CPU {4399AF76-DB52-4CFB-8020-6F85BDB29FD5}.Release|x86.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|Any CPU.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|ARM.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|ARM.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|ARM64.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|ARM64.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|x64.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|x64.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|x86.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.AppVeyor|x86.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|ARM.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|ARM.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|ARM64.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|x64.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|x64.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|x86.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Debug|x86.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|Any CPU.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|ARM.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|ARM.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|ARM64.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|ARM64.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|x64.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|x64.Build.0 = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|x86.ActiveCfg = Release|Any CPU + {4EDCF067-E377-42CB-A18C-8368CF484577}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4228,6 +4270,7 @@ Global {99D233C5-FEE7-418E-9C25-D4584CB52E28} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} {72E591D6-8F83-4D8C-8F67-9C325E623234} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} {8A65AD6A-A9B4-48C0-9301-4B7434B712F8} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} + {4EDCF067-E377-42CB-A18C-8368CF484577} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} diff --git a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/App.config b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/App.config new file mode 100644 index 000000000..f05da3520 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/App.config @@ -0,0 +1,16 @@ + + + + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs new file mode 100644 index 000000000..6c3c62606 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; + +namespace Tango.JobRunsGenerator +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Job Runs Generator Started..."); + + DateTime now = DateTime.UtcNow; + DateTime yearago = DateTime.UtcNow.AddYears(-1); + Random rnd = new Random(); + List messages = new List() + { + "Timeout failure", + "Thread Break", + "Application Exception", + "Over Temperature", + "Communication Error" + }; + + int count = 0; + + using (ObservablesContext db = ObservablesContext.CreateDefault("localhost\\SQLEXPRESS")) + { + var machines = db.Machines.ToList(); + + foreach (var machine in machines) + { + new MachineBuilder(db).Set(machine).WithJobs().Build(); + + foreach (var job in machine.Jobs) + { + using (ObservablesContext db2 = ObservablesContext.CreateDefault("localhost\\SQLEXPRESS")) + { + for (DateTime date = yearago; date < now; date = date.AddDays(1)) + { + Console.WriteLine($"Adding job runs for machine '{machine.SerialNumber}' job '{job.Name}' date {date.ToShortDateString()}..."); + + for (int i = 0; i < rnd.Next(0, 9); i++) + { + int status = rnd.Next(0, 3); + String message = messages[rnd.Next(0, messages.Count)]; + + db2.JobRuns.Add(new JobRun() + { + StartDate = date, + EndDate = date.AddMinutes(rnd.Next(10, 61)), + JobGuid = job.Guid, + EndPosition = job.Length / rnd.Next(1, 11), + Status = status, + FailedMessage = status == 2 ? message : null, + }); + + count++; + } + } + + db2.SaveChanges(); + } + } + } + + Console.WriteLine($"The generator is about to insert {count} job runs to the database are you sure? [Y/N]:"); + var key = Console.ReadKey().Key; + + if (key == ConsoleKey.Y) + { + Console.WriteLine("Saving changes to database..."); + Console.WriteLine("Done!"); + Console.ReadLine(); + } + else + { + return; + } + } + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..3be693fff --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Job Runs Generator")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Tango.JobRunsGenerator.csproj b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Tango.JobRunsGenerator.csproj new file mode 100644 index 000000000..a5426e3fd --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Tango.JobRunsGenerator.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {4EDCF067-E377-42CB-A18C-8368CF484577} + Exe + Tango.JobRunsGenerator + Tango.JobRunsGenerator + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + ..\..\Build\Utilities\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + ..\..\Build\Utilities\Debug\ + TRACE + prompt + 4 + + + + ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + GlobalVersionInfo.cs + + + + + + + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/packages.config b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/packages.config new file mode 100644 index 000000000..eb315b1dc --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.3.1 From 96d935cdfdc4d0d6c4dd0e3d2bd9d5d436bf9a05 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 22 Nov 2018 17:17:32 +0200 Subject: Fixed issue hardware designer copy parameters. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../ViewModels/MainViewVM.cs | 4 +++- 3 files changed, 3 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index d0ab60a89..ef4007771 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 6c60faaea..128bbfbfb 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index 5e087cd02..73ba02435 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -134,7 +134,9 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels (prop) => !prop.PropertyType.IsEnum && - !prop.Name.ToLower().Contains("guid")); + prop.Name.ToLower() != "guid" + && + prop.Name.ToLower() != "id"); } private void CreateDefaultView() -- cgit v1.3.1