diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-12-15 13:12:20 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-12-15 13:12:20 +0200 |
| commit | 13c57f7ccabadd3ed75ffaef195d35c15c2a8c68 (patch) | |
| tree | 938bd6dd844cf2645510aa3d42f3bfbe24e52a7e /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs | |
| parent | d1859415972bb991cba6639482c1cd2a9e19e8d8 (diff) | |
| parent | 957ca86b8e899eb488626c456d9c37dd4545bd80 (diff) | |
| download | Tango-13c57f7ccabadd3ed75ffaef195d35c15c2a8c68.tar.gz Tango-13c57f7ccabadd3ed75ffaef195d35c15c2a8c68.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs | 48 |
1 files changed, 43 insertions, 5 deletions
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 c3c3baa70..c1f87b3bb 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 @@ -8,6 +8,7 @@ using System.Windows.Data; using Tango.BL; using Tango.BL.Builders; using Tango.BL.Entities; +using Tango.Core.Commands; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.MachineDesigner.Views; using Tango.SharedUI; @@ -17,6 +18,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public class MachineUpdatesViewVM : ViewModel { private INotificationProvider _notification; + private ObservablesContext _context; #region Properties @@ -70,6 +72,19 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _displayDatabaseUpdates = value; RaisePropertyChangedAuto(); OnFilterChanged(); } } + private bool _displaySynchronizations; + public bool DisplaySynchronizations + { + get { return _displaySynchronizations; } + set { _displaySynchronizations = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + #endregion + + #region Commands + + public RelayCommand RefreshCommand { get; set; } + #endregion #region Constructors @@ -79,6 +94,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels DisplayApplicationUpdates = true; DisplayMachineSetups = true; DisplayDatabaseUpdates = true; + DisplaySynchronizations = true; + + RefreshCommand = new RelayCommand(Refresh, () => IsFree); } public MachineUpdatesViewVM(INotificationProvider notificationProvider) : this() @@ -92,17 +110,36 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public async Task Init(Machine machine, ObservablesContext context) { - Machine = machine; - Updates = (await new TangoUpdatesCollectionBuilder(context).Set(x => x.MachineGuid == machine.Guid).BuildAsync()).OrderByDescending(x => x.StartDate).ToList(); - UpdatesView = CollectionViewSource.GetDefaultView(Updates); - UpdatesView.Filter = UpdatesFilter; - OnFilterChanged(); + try + { + _context = context; + Machine = machine; + Updates = (await new TangoUpdatesCollectionBuilder(context).Set(x => x.MachineGuid == machine.Guid).BuildAsync()).OrderByDescending(x => x.StartDate).ToList(); + UpdatesView = CollectionViewSource.GetDefaultView(Updates); + UpdatesView.Filter = UpdatesFilter; + OnFilterChanged(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading machine updates."); + _notification.ShowError($"An error occurred while loading the history of machine updates.\n{ex.FlattenMessage()}"); + } } #endregion #region Private Methods + private async void Refresh() + { + IsFree = false; + using (_notification.PushTaskItem("Refreshing machine updates...")) + { + await Init(Machine, _context); + } + IsFree = true; + } + private void OnFilterChanged() { if (UpdatesView != null) @@ -119,6 +156,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels if (!DisplayMachineSetups && update.IsSetup) return false; if (!DisplayApplicationUpdates && update.IsUpdate) return false; if (!DisplayDatabaseUpdates && update.IsDataBase) return false; + if (!DisplaySynchronizations && update.IsSynchronization) return false; return true; } else |
