From 8e875c7d05720f92ead97b75f3367555a5153dff Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Tue, 24 Dec 2019 13:49:20 +0200 Subject: Implementing the new Machine Studio ActionLogs module. Related Work Items: #2213 --- .../Tango.MachineStudio.ActionLogs/App.xaml | 12 ++ .../Tango.MachineStudio.ActionLogs.csproj | 4 + .../ViewModels/MainViewVM.cs | 75 +++++-- .../Views/MainView.xaml | 215 ++++++++++++++------- .../Themes/LightThemeColors.xaml | 118 +++++------ 5 files changed, 284 insertions(+), 140 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/App.xaml (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/App.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/App.xaml new file mode 100644 index 000000000..3ab646c7c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/App.xaml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Tango.MachineStudio.ActionLogs.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Tango.MachineStudio.ActionLogs.csproj index 1a5d06616..0d6fa213c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Tango.MachineStudio.ActionLogs.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Tango.MachineStudio.ActionLogs.csproj @@ -82,6 +82,10 @@ MainView.xaml + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs index a550a1911..5f2d86b40 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs @@ -2,14 +2,18 @@ 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 System.Windows; using Tango.BL; using Tango.BL.Builders; using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.BL.ValueObjects; using Tango.Core.Commands; +using Tango.Core.ExtensionMethods; using Tango.MachineStudio.Common; using Tango.SharedUI.Components; @@ -17,6 +21,8 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels { public class MainViewVM : StudioViewModel { + #region properties + private DateTime _startSelectedDate; public DateTime StartSelectedDate { @@ -49,48 +55,83 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels public SelectedObjectCollection SelectedActionLogTypes { get { return _selectedActionLogTypes; } - set { _selectedActionLogTypes = value; RaisePropertyChanged(nameof(SelectedActionLogTypes)); } + set { _selectedActionLogTypes = value; + RaisePropertyChanged(nameof(SelectedActionLogTypes)); } } + private ActionLog _selectedActionLog = null; + public ActionLog SelectedActionLog + { + get { return _selectedActionLog; } + set { _selectedActionLog = value; + SelectedItemChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } + } + + private ActionLogDifference _differenceObject; + public ActionLogDifference DifferenceObject + { + get { return _differenceObject; } + set { _differenceObject = value; RaisePropertyChangedAuto(); } + } + + + private bool _isRunning; + public bool IsRunning + { + get { return _isRunning; } + set { _isRunning = value; } + } + + #endregion + public RelayCommand SearchCommand { get; set; } public RelayCommand CopyToClipBoardCommand { get; set; } public MainViewVM() { ActionLogs = new ObservableCollection(); - SearchCommand = new RelayCommand(Search); - CopyToClipBoardCommand = new RelayCommand(CopyToClipBoard); - DateTime now = DateTime.Now; ; + SearchCommand = new RelayCommand(GetActionLogs, ()=> !IsRunning); + CopyToClipBoardCommand = new RelayCommand(CopyToClipBoard, () => SelectedActionLog != null && SelectedActionLog.DifferenceObject != null); + DateTime now = DateTime.Now; StartSelectedDate = now.AddMonths(-1); EndSelectedDate = now; - + _isRunning = false; var source = Enum.GetValues(typeof(ActionLogType)).Cast().ToObservableCollection(); var syncedSource = Enum.GetValues(typeof(ActionLogType)).Cast().ToObservableCollection(); SelectedActionLogTypes = new SelectedObjectCollection(source, syncedSource); - - //SelectedActionLogTypes.ToList().ForEach(x => x.IsSelected = true); } public override void OnApplicationReady() { } - - private void Search() - { - GetActionLogs(); - } + private void CopyToClipBoard() { + DataObject data = new DataObject(SelectedActionLog.DifferenceObject.ToJsonString()); + System.Windows.Clipboard.SetDataObject(data); + } + + /// + /// New Database Query with search parameters. Initialization ActionLogs property. + /// private async void GetActionLogs() { string filter = SearchFilter?.ToLower(); + if (String.IsNullOrWhiteSpace(filter)) filter = null; + using (ObservablesContext db = ObservablesContext.CreateDefault()) { - ActionLogs = await new ActionLogsCollectionBuilder(db).Set(x => x.LastUpdated < EndSelectedDate && x.LastUpdated >= StartSelectedDate) + DateTime startUtc = StartSelectedDate.ToUniversalTime(); + DateTime endUtc = EndSelectedDate.ToUniversalTime() + DateTime.Now.TimeOfDay; + IsRunning = true; + ActionLogs = await new ActionLogsCollectionBuilder(db).Set(x => x.LastUpdated <= DbFunctions.TruncateTime(endUtc) && x.LastUpdated >= DbFunctions.TruncateTime(startUtc.Date)) .WithUsers() .WithActionType(SelectedActionLogTypes.SynchedSource.ToArray()) .Query(y => y.Where @@ -99,7 +140,15 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels || (x.RelatedObjectName != null && x.RelatedObjectName.ToLower().StartsWith(filter)) || (x.User != null && x.User.Contact != null && x.User.Contact.FullName.ToLower().StartsWith(filter))))) .BuildAsync(); + IsRunning = false; } } + + private void SelectedItemChanged() + { + if (SelectedActionLog == null || SelectedActionLog.DifferenceObject== null) + return; + DifferenceObject = SelectedActionLog.DifferenceObject; + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml index 53db8c11d..60ce2560c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml @@ -3,19 +3,19 @@ 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:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:local="clr-namespace:Tango.MachineStudio.ActionLogs.Views" xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:vm="clr-namespace:Tango.MachineStudio.ActionLogs.ViewModels" xmlns:global="clr-namespace:Tango.MachineStudio.ActionLogs" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" - xmlns:localConverters="clr-namespace:Tango.MachineStudio.ActionLogs.Converters" + xmlns:diff="clr-namespace:Tango.BL.ValueObjects;assembly=Tango.BL" 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}"> - + - @@ -23,70 +23,80 @@ - + - + - - + + - - - Start Date: - - - - End Date: - - - - - - - - - - - - Select Actions - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + Start Date: + + + + End Date: + + + + + + + + + + + + + + () + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + SelectedItem="{Binding SelectedActionLog}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" FontSize="11"> + + + - - - + + + - - + + + - - - - + + + + + + + + + + + + Object Changes + + + + + + + + + + + + + + + + + + : + + | + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Themes/LightThemeColors.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Themes/LightThemeColors.xaml index 0f5727e5b..4ad992e67 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Themes/LightThemeColors.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Themes/LightThemeColors.xaml @@ -9,20 +9,20 @@ 1 - - + + - + - + - - - + + + @@ -40,72 +40,72 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - - + + - - - + + + @@ -161,7 +161,7 @@ - + @@ -216,5 +216,5 @@ - + \ No newline at end of file -- cgit v1.3.1