diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs | 37 |
1 files changed, 21 insertions, 16 deletions
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 fb6568df8..408789d9f 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 @@ -23,7 +23,7 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels public class MainViewVM : StudioViewModel { #region Properties - + private DateTime _startSelectedDate; public DateTime StartSelectedDate { @@ -56,15 +56,20 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels public SelectedObjectCollection<ActionLogType> 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; + set + { + _selectedActionLog = value; SelectedItemChanged(); RaisePropertyChangedAuto(); InvalidateRelayCommands(); @@ -78,7 +83,7 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels set { _differenceObject = value; RaisePropertyChangedAuto(); } } - + private bool _isRunning; public bool IsRunning { @@ -87,7 +92,7 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels } #endregion - + public RelayCommand SearchCommand { get; set; } public RelayCommand CopyToClipBoardCommand { get; set; } public RelayCommand CopyRelateObjectIDCommand { get; set; } @@ -95,7 +100,7 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels public MainViewVM() { ActionLogs = new ObservableCollection<ActionLog>(); - SearchCommand = new RelayCommand(GetActionLogs, ()=> !IsRunning); + SearchCommand = new RelayCommand(GetActionLogs, () => !IsRunning); CopyRelateObjectIDCommand = new RelayCommand(CopyRelateObjectID); CopyToClipBoardCommand = new RelayCommand(CopyToClipBoard, () => SelectedActionLog != null && SelectedActionLog.DifferenceObject != null); DateTime now = DateTime.Now; @@ -112,12 +117,12 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels { } - + private void CopyToClipBoard() { DataObject data = new DataObject(SelectedActionLog.DifferenceObject.ToJsonString()); System.Windows.Clipboard.SetDataObject(data); - + } private void CopyRelateObjectID() { @@ -137,26 +142,26 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels using (ObservablesContext 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; + TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(23, 59, 59); + DateTime endUtc = EndSelectedDate.ToUniversalTime() + offsetTime; 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 - (x => filter == null || - (x.ID.ToString().ToLower().StartsWith(filter) - || (x.RelatedObjectName != null && x.RelatedObjectName.ToLower().StartsWith(filter)) + (x => filter == null || + (x.ID.ToString().ToLower().StartsWith(filter) + || (x.RelatedObjectName != null && x.RelatedObjectName.ToLower().StartsWith(filter)) || (x.RelatedObjectGuid != null && x.RelatedObjectGuid.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) + if (SelectedActionLog == null || SelectedActionLog.DifferenceObject == null) return; DifferenceObject = SelectedActionLog.DifferenceObject; } |
