diff --git a/PCUT/Http.Core/Constants/HttpConstants.cs b/PCUT/Http.Core/Constants/HttpConstants.cs index da39201..27d3925 100644 --- a/PCUT/Http.Core/Constants/HttpConstants.cs +++ b/PCUT/Http.Core/Constants/HttpConstants.cs @@ -40,6 +40,7 @@ public const string Metadata = "api/metadata"; public const string MetadataById = "api/metadata/{0}"; + public const string Log = "api/logs"; } } } diff --git a/PCUT/Http.Core/Handlers/AuthenticationHandler.cs b/PCUT/Http.Core/Handlers/AuthenticationHandler.cs index e065fad..6dbd947 100644 --- a/PCUT/Http.Core/Handlers/AuthenticationHandler.cs +++ b/PCUT/Http.Core/Handlers/AuthenticationHandler.cs @@ -1,7 +1,6 @@ using Http.Core.Constants; using Http.Core.Contexts; using Http.Core.Extensions; -using Http.Core.Models; using System; using System.Net.Http; using System.Net.Http.Headers; @@ -31,13 +30,13 @@ namespace Http.Core.Handlers return false; var expiredTime = UserContext.Instance.ExpiredTime; - if (expiredTime != null || expiredTime - DateTime.UtcNow < _requiredRefreshTime) + if (expiredTime != null && expiredTime - DateTime.UtcNow < _requiredRefreshTime) { await _refreshSemaphore.WaitAsync(); bool refreshSuccess; { expiredTime = UserContext.Instance.ExpiredTime; - if (expiredTime != null || expiredTime - DateTime.UtcNow < _requiredRefreshTime) + if (expiredTime != null && expiredTime - DateTime.UtcNow < _requiredRefreshTime) refreshSuccess = await RefreshTokenAsync(); else refreshSuccess = true; // Some other thread already refreshed token diff --git a/PCUT/PCUT.Entities/Log.cs b/PCUT/PCUT.Entities/Log.cs new file mode 100644 index 0000000..b0446ac --- /dev/null +++ b/PCUT/PCUT.Entities/Log.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; +using System; + +namespace PCUT.Entities +{ + public class Log + { + [JsonProperty("datetime")] + public DateTime Timestamp { get; set; } + [JsonProperty("content")] + public string Content { get; set; } + } +} diff --git a/PCUT/PCUT/Converters/LogTimestampConverter.cs b/PCUT/PCUT/Converters/LogTimestampConverter.cs new file mode 100644 index 0000000..ae32870 --- /dev/null +++ b/PCUT/PCUT/Converters/LogTimestampConverter.cs @@ -0,0 +1,26 @@ +using System; +using Windows.UI.Xaml.Data; + +namespace PCUT.Converters +{ + internal class LogTimestampConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + switch (value) + { + case DateTime timeValue: + { + return $"[{timeValue.ToString("yyyy-MM-dd HH:mm:ss.fff K")}]"; + } + default: + return string.Empty; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +} diff --git a/PCUT/PCUT/PCUT.csproj b/PCUT/PCUT/PCUT.csproj index b784ee3..b554cb5 100644 --- a/PCUT/PCUT/PCUT.csproj +++ b/PCUT/PCUT/PCUT.csproj @@ -137,6 +137,7 @@ + @@ -246,6 +247,7 @@ UserListPage.xaml + diff --git a/PCUT/PCUT/Pages/AdminCenterPage.xaml b/PCUT/PCUT/Pages/AdminCenterPage.xaml index 3c908ce..7fa2abf 100644 --- a/PCUT/PCUT/Pages/AdminCenterPage.xaml +++ b/PCUT/PCUT/Pages/AdminCenterPage.xaml @@ -29,7 +29,7 @@ - + diff --git a/PCUT/PCUT/Pages/AdminCenterPage.xaml.cs b/PCUT/PCUT/Pages/AdminCenterPage.xaml.cs index 47ecd00..0e7c6c2 100644 --- a/PCUT/PCUT/Pages/AdminCenterPage.xaml.cs +++ b/PCUT/PCUT/Pages/AdminCenterPage.xaml.cs @@ -1,5 +1,4 @@ -using PCUT.Pages.Logs; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/PCUT/PCUT/Pages/Logs/LogInformationPage.xaml b/PCUT/PCUT/Pages/Logs/LogInformationPage.xaml index 6692088..88d8273 100644 --- a/PCUT/PCUT/Pages/Logs/LogInformationPage.xaml +++ b/PCUT/PCUT/Pages/Logs/LogInformationPage.xaml @@ -1,14 +1,66 @@  + xmlns:viewmodels="using:PCUT.ViewModels" + mc:Ignorable="d"> + + + + + + + + + + + + + + + - + + + + + + +