aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-15 15:46:03 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-15 15:46:03 +0200
commitb188d7bfd91062f65474bd139bb8a434694f117b (patch)
treeb75e5628482d4f96fc4236beaf854152d83292a4 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs
parent47d63f4b155318d674a891a6586433f41881a3b1 (diff)
downloadTango-b188d7bfd91062f65474bd139bb8a434694f117b.tar.gz
Tango-b188d7bfd91062f65474bd139bb8a434694f117b.zip
Fixed issue with job run start date.
Fixed issue with ActionLogs busy indication.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs67
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml2
2 files changed, 39 insertions, 30 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 534bb364f..df2643d88 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
@@ -16,12 +16,15 @@ using Tango.BL.ValueObjects;
using Tango.Core.Commands;
using Tango.Core.ExtensionMethods;
using Tango.MachineStudio.Common;
+using Tango.MachineStudio.Common.Notifications;
using Tango.SharedUI.Components;
namespace Tango.MachineStudio.ActionLogs.ViewModels
{
public class MainViewVM : StudioViewModel
{
+ private INotificationProvider _notification;
+
#region Properties
private DateTime _startSelectedDate;
@@ -83,30 +86,23 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels
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 RelayCommand CopyRelateObjectIDCommand { get; set; }
- public MainViewVM()
+ public MainViewVM(INotificationProvider notification)
{
+ _notification = notification;
+
ActionLogs = new ObservableCollection<ActionLog>();
- SearchCommand = new RelayCommand(GetActionLogs, () => !IsRunning);
+ SearchCommand = new RelayCommand(GetActionLogs, () => IsFree);
CopyRelateObjectIDCommand = new RelayCommand(CopyRelateObjectID);
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<ActionLogType>().ToObservableCollection();
var syncedSource = Enum.GetValues(typeof(ActionLogType)).Cast<ActionLogType>().ToObservableCollection();
@@ -139,27 +135,40 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels
if (String.IsNullOrWhiteSpace(filter)) filter = null;
- using (ObservablesContext db = ObservablesContext.CreateDefault())
+ try
{
-
- DateTime startUtc = new DateTime(StartSelectedDate.Date.Ticks, DateTimeKind.Utc);
- TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(24, 0, 0);
- DateTime endUtc = new DateTime(EndSelectedDate.Date.Ticks + offsetTime.Ticks, DateTimeKind.Utc);
+ IsFree = false;
- Debug.Write($"TEST TIME {startUtc} from {endUtc} " + System.Environment.NewLine);
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
- IsRunning = true;
- ActionLogs = await new ActionLogsCollectionBuilder(db).Set(x => x.LastUpdated <= DbFunctions.TruncateTime(endUtc) && x.LastUpdated >= DbFunctions.TruncateTime(startUtc))
- .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.RelatedObjectGuid != null && x.RelatedObjectGuid.ToLower().StartsWith(filter))
- || (x.User != null && x.User.Contact != null && x.User.Contact.FullName.ToLower().StartsWith(filter)))))
- .BuildAsync();
- IsRunning = false;
+ DateTime startUtc = new DateTime(StartSelectedDate.Date.Ticks, DateTimeKind.Utc);
+ TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(24, 0, 0);
+ DateTime endUtc = new DateTime(EndSelectedDate.Date.Ticks + offsetTime.Ticks, DateTimeKind.Utc);
+
+ Debug.Write($"TEST TIME {startUtc} from {endUtc} " + System.Environment.NewLine);
+
+ ActionLogs = await new ActionLogsCollectionBuilder(db).Set(x => x.LastUpdated <= DbFunctions.TruncateTime(endUtc) && x.LastUpdated >= DbFunctions.TruncateTime(startUtc))
+ .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.RelatedObjectGuid != null && x.RelatedObjectGuid.ToLower().StartsWith(filter))
+ || (x.User != null && x.User.Contact != null && x.User.Contact.FullName.ToLower().StartsWith(filter)))))
+ .BuildAsync();
+ }
+ }
+ catch (Exception ex)
+ {
+ IsFree = true;
+ LogManager.Log(ex, "Error getting action logs.");
+ _notification.ShowError($"Error occurred while trying to retrieve the action logs.\n{ex.Message}");
+ }
+ finally
+ {
+ IsFree = true;
}
}
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 3a7eaa802..fd640bae5 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
@@ -207,7 +207,7 @@
</DataGrid.Columns>
</DataGrid>
</Grid>
- <Grid Grid.Row="1" Grid.Column="0" Visibility="{Binding IsRunning,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <Grid Grid.Row="1" Grid.Column="0" Visibility="{Binding IsBusy,Converter={StaticResource BooleanToVisibilityConverter}}">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<mahapps:ProgressRing Margin="20 60 20 40" Width="80" Height="80" IsActive="{Binding IsRunning}"></mahapps:ProgressRing>
<TextBlock Text="Loading..." HorizontalAlignment="Center" FontSize="20" FontStyle="Italic" VerticalAlignment="Center" Margin="0 20 0 0"></TextBlock>