From 621230afe9d9040536b43241e63117c9bb34beaa Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 11 Dec 2019 20:57:30 +0200 Subject: Implemented Jobs, JobRuns & Machine Events Synchronization. Added synchronizations to Updates view on Machine Designer. Removed request response events logging from machine studio. Fixed issue with exception throwing from machine service. Implemented "New jobs synchronized" notification item to PPC. Added synchronization to PPC settings. Added Synchronization view to technician module. Implemented PPC Schema synchronizer utility. Added custom query support to EntityCollectionBuilder. Added synchronization status to TangoUpdate. Removed FK from Jobs and Job runs. --- .../Views/MachineUpdateDetailsDialog.xaml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml index 9d60d36f8..804ee456c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml @@ -40,6 +40,9 @@ + + + -- cgit v1.3.1 From d99c80d6633d2932cf67fc7013100a639882c6dc Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 17 Dec 2019 02:08:31 +0200 Subject: Implemented PPC Updates/Synchronization View. Refactored database updates to be deleted if no differences. Updated MS and PPC with Offline Updates. Refactored Machine Designer Updates View to take only last 100 update entries. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/TCC/TCC.mdf | Bin 8388608 -> 8388608 bytes Software/DB/TCC/TCC_log.ldf | Bin 8388608 -> 8388608 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../ViewModels/MachineUpdatesViewVM.cs | 3 +- .../Views/MachineUpdateDetailsDialog.xaml | 3 + .../Views/MachineUpdatesView.xaml | 3 + .../Tango.PPC.Technician.csproj | 8 +- .../Tango.PPC.Technician/ViewModelLocator.cs | 6 +- .../ViewModels/SynchronizationViewVM.cs | 41 ---- .../ViewModels/UpdatesViewVM.cs | 75 +++++++ .../Tango.PPC.Technician/Views/CatalogView.xaml | 6 +- .../Tango.PPC.Technician/Views/MainView.xaml | 2 +- .../Views/SynchronizationView.xaml | 133 ------------ .../Views/SynchronizationView.xaml.cs | 28 --- .../Tango.PPC.Technician/Views/UpdatesView.xaml | 237 +++++++++++++++++++++ .../Tango.PPC.Technician/Views/UpdatesView.xaml.cs | 28 +++ .../MachineSetup/MachineSetupManager.cs | 3 - .../MachineUpdate/MachineUpdateManager.cs | 40 ++-- .../PPC/Tango.PPC.Common/Resources/Merged.xaml | 1 + .../DefaultMachineDataSynchronizer.cs | 4 +- .../Web/MachineUpdateCompletedRequest.cs | 1 + .../Controllers/PPCController.cs | 5 + 25 files changed, 393 insertions(+), 234 deletions(-) delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SynchronizationViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/UpdatesViewVM.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SynchronizationView.xaml delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SynchronizationView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/UpdatesView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/UpdatesView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 8ad9bc103..41603a45f 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 9bce4a9c4..12b0bd50c 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf index 3540a7786..5746eb81e 100644 Binary files a/Software/DB/TCC/TCC.mdf and b/Software/DB/TCC/TCC.mdf differ diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf index 94b99ac61..bb7c5c203 100644 Binary files a/Software/DB/TCC/TCC_log.ldf and b/Software/DB/TCC/TCC_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index e70e0e6e3..5d5ff5ddb 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 e65b718bb..4ff9f3fd3 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.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs index c1f87b3bb..e1e9ee561 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs @@ -19,6 +19,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { private INotificationProvider _notification; private ObservablesContext _context; + private const int MAX_UPDATE_ITEMS = 100; #region Properties @@ -114,7 +115,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { _context = context; Machine = machine; - Updates = (await new TangoUpdatesCollectionBuilder(context).Set(x => x.MachineGuid == machine.Guid).BuildAsync()).OrderByDescending(x => x.StartDate).ToList(); + Updates = (await new TangoUpdatesCollectionBuilder(context).Set(x => x.MachineGuid == machine.Guid).Query(x => x.OrderByDescending(y => y.StartDate).Take(MAX_UPDATE_ITEMS)).BuildAsync()).ToList(); UpdatesView = CollectionViewSource.GetDefaultView(Updates); UpdatesView.Filter = UpdatesFilter; OnFilterChanged(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml index 804ee456c..1e7b03fed 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml @@ -43,6 +43,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml index 8d1ff8ec8..65a5a569f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml @@ -74,6 +74,9 @@ + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj index e11e34298..b6502e417 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj @@ -98,13 +98,13 @@ - + CatalogView.xaml - - SynchronizationView.xaml + + UpdatesView.xaml PackagesView.xaml @@ -199,7 +199,7 @@ Designer MSBuild:Compile - + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs index 05a04e2a6..d50df6a01 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs @@ -21,7 +21,7 @@ namespace Tango.PPC.Technician TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); - TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } /// @@ -93,11 +93,11 @@ namespace Tango.PPC.Technician /// /// Gets the synchronization view vm. /// - public static SynchronizationViewVM SynchronizationViewVM + public static UpdatesViewVM UpdatesViewVM { get { - return TangoIOC.Default.GetInstance(); + return TangoIOC.Default.GetInstance(); } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SynchronizationViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SynchronizationViewVM.cs deleted file mode 100644 index 8036b99a4..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SynchronizationViewVM.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.Commands; -using Tango.PPC.Common; - -namespace Tango.PPC.Technician.ViewModels -{ - public class SynchronizationViewVM : PPCViewModel - { - public RelayCommand SynchronizeCommand { get; set; } - - public SynchronizationViewVM() - { - SynchronizeCommand = new RelayCommand(Synchronize, () => !MachineDataSynchronizer.IsSynchronizing); - } - - public override void OnApplicationStarted() - { - - } - - public override void OnApplicationReady() - { - base.OnApplicationReady(); - MachineDataSynchronizer.SynchronizationStarted += (_, __) => InvalidateRelayCommands(); - MachineDataSynchronizer.SynchronizationEnded += (_, __) => InvalidateRelayCommands(); - } - - private async void Synchronize() - { - try - { - await MachineDataSynchronizer.Synchronize(); - } - catch { } - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/UpdatesViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/UpdatesViewVM.cs new file mode 100644 index 000000000..91bbcba0e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/UpdatesViewVM.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core.Commands; +using Tango.PPC.Common; +using System.Data.Entity; + +namespace Tango.PPC.Technician.ViewModels +{ + public class UpdatesViewVM : PPCViewModel + { + public RelayCommand SynchronizeCommand { get; set; } + + private List _updates; + public List Updates + { + get { return _updates; } + set { _updates = value; RaisePropertyChangedAuto(); } + } + + public UpdatesViewVM() + { + Updates = new List(); + SynchronizeCommand = new RelayCommand(Synchronize, () => !MachineDataSynchronizer.IsSynchronizing); + } + + public override void OnApplicationStarted() + { + + } + + public override void OnApplicationReady() + { + base.OnApplicationReady(); + MachineDataSynchronizer.SynchronizationStarted += (_, __) => InvalidateRelayCommands(); + MachineDataSynchronizer.SynchronizationEnded += (_, __) => InvalidateRelayCommands(); + } + + private async void Synchronize() + { + try + { + await MachineDataSynchronizer.Synchronize(); + } + catch { } + } + + public async override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + Updates = await db.TangoUpdates.Where(x => + x.Status != (int)TangoUpdateStatuses.SynchronizationCompleted && + x.Status != (int)TangoUpdateStatuses.SynchronizationFailed && + x.Status != (int)TangoUpdateStatuses.SynchronizationStarted + ).OrderByDescending(x => x.StartDate).ToListAsync(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading update history."); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml index b8c74c374..a48c80a52 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml @@ -93,13 +93,13 @@ - + - Synchronization + Updates - View the current status and history of synchronization operations to the machine service. + View the current status and history of update operations. diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml index 2acadb32d..d669de187 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml @@ -18,7 +18,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SynchronizationView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SynchronizationView.xaml deleted file mode 100644 index a0021d40e..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SynchronizationView.xaml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - - - - - - - - Synchronization - - - - - - - - Synchronize Now - Synchronization occurres automatically in the background. You can choose to synchronize now. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SynchronizationView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SynchronizationView.xaml.cs deleted file mode 100644 index 7193d66ff..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SynchronizationView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.PPC.Technician.Views -{ - /// - /// Interaction logic for SynchronizationView.xaml - /// - public partial class SynchronizationView : UserControl - { - public SynchronizationView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/UpdatesView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/UpdatesView.xaml new file mode 100644 index 000000000..fa5db97e9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/UpdatesView.xaml @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + Updates + + + + + + + Software Updates + Synchronization + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Synchronize Now + Synchronization occurres automatically in the background. You can choose to synchronize now. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/UpdatesView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/UpdatesView.xaml.cs new file mode 100644 index 000000000..cdac5cbbb --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/UpdatesView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Technician.Views +{ + /// + /// Interaction logic for UpdatesView.xaml + /// + public partial class UpdatesView : UserControl + { + public UpdatesView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 582eec83b..29daedb4c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -166,10 +166,7 @@ namespace Tango.PPC.Common.MachineSetup { LogManager.Log(xx, "Error notifying setup completed."); } - } - if (response != null) - { try { using (ObservablesContext db = ObservablesContext.CreateDefault()) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index 666b6813c..d0424254b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -473,7 +473,7 @@ namespace Tango.PPC.Common.MachineUpdate _isUpdating = false; } - private void OnCompleted(UpdateDBResponse response) + private void OnCompleted(UpdateDBResponse response, bool completedWithNoDifferences = false) { if (response != null) { @@ -483,6 +483,7 @@ namespace Tango.PPC.Common.MachineUpdate { Token = response.NotifyCompletedToken, Status = BL.Enumerations.TangoUpdateStatuses.DatabaseCompleted, + ReportsAboutDbCheckNoDifferences = completedWithNoDifferences, }).Result; } catch (Exception ex) @@ -490,23 +491,26 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log(ex, "Error notifying database completed."); } - try + if (!completedWithNoDifferences) { - using (ObservablesContext db = ObservablesContext.CreateDefault()) + try { - TangoUpdate update = new TangoUpdate(); - update.ApplicationVersion = _app_manager.Version.ToString(); - update.FirmwareVersion = _app_manager.FirmwareVersion.ToString(); - update.MachineGuid = _machineProvider.Machine.Guid; - update.UpdateStatus = BL.Enumerations.TangoUpdateStatuses.DatabaseCompleted; - update.StartDate = _updateStartDate; - update.EndDate = DateTime.UtcNow; - db.SaveChanges(); + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + TangoUpdate update = new TangoUpdate(); + update.ApplicationVersion = _app_manager.Version.ToString(); + update.FirmwareVersion = _app_manager.FirmwareVersion.ToString(); + update.MachineGuid = _machineProvider.Machine.Guid; + update.UpdateStatus = BL.Enumerations.TangoUpdateStatuses.DatabaseCompleted; + update.StartDate = _updateStartDate; + update.EndDate = DateTime.UtcNow; + db.SaveChanges(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving database update information to database."); } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error saving database update information to database."); } } @@ -1091,12 +1095,18 @@ namespace Tango.PPC.Common.MachineUpdate } catch (Exception ex) { + OnFailed(ex, update_response, false, null, null); throw LogManager.Log(ex, "Update manager error while trying to compare the database."); } } LogManager.Log("Comparison completed successfully."); + if (!has_differences) + { + OnCompleted(update_response, true); + } + return new DbCompareResult() { RequiresUpdate = has_differences, diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index 730066b46..6713fcc1b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -51,6 +51,7 @@ +