소스 검색

Improving some things

Kenric Nugteren 1 년 전
부모
커밋
2a1dd501ff

+ 1 - 1
InABox.Client.RPC/RPCClient.cs

@@ -145,7 +145,7 @@ namespace InABox.Rpc
 
 
         protected override TEntity[] DoLoad(Filter<TEntity>? filter = null, SortOrder<TEntity>? sort = null)
         protected override TEntity[] DoLoad(Filter<TEntity>? filter = null, SortOrder<TEntity>? sort = null)
         {
         {
-            return DoQuery(filter, null, sort)?.ToObjects<TEntity>().ToArray() ?? new TEntity[] { };
+            return DoQuery(filter, null, sort)?.ToArray<TEntity>() ?? new TEntity[] { };
         }
         }
         
         
         
         

+ 8 - 4
InABox.Core/Configuration/UserConfiguration.cs

@@ -54,7 +54,8 @@ namespace InABox.Configuration
                     .And(x => x.UserID).IsEqualTo(ClientFactory.UserID);
                     .And(x => x.UserID).IsEqualTo(ClientFactory.UserID);
 
 
 
 
-                result = client.Load(filter).FirstOrDefault(x => string.Equals(x.UserID, ClientFactory.UserID));
+                result = client.Query(filter, Columns.All<UserSettings>())
+                    .ToObjects<UserSettings>().FirstOrDefault();
             }
             }
             return result ?? NewSettings();
             return result ?? NewSettings();
         }
         }
@@ -126,9 +127,12 @@ namespace InABox.Configuration
             var client = new Client<UserSettings>();
             var client = new Client<UserSettings>();
             var data = reset 
             var data = reset 
                 ? new Dictionary<string,UserSettings>() 
                 ? new Dictionary<string,UserSettings>() 
-                : client.Load(new Filter<UserSettings>(x => x.Section).IsEqualTo(typeof(T).Name)
-                    .And(x => x.Key).InList(objs.Keys.ToArray())
-                    .And(x => x.UserID).IsEqualTo(ClientFactory.UserID))
+                : client.Query(
+                    new Filter<UserSettings>(x => x.Section).IsEqualTo(typeof(T).Name)
+                        .And(x => x.Key).InList(objs.Keys.ToArray())
+                        .And(x => x.UserID).IsEqualTo(ClientFactory.UserID),
+                    Columns.All<UserSettings>())
+                .ToObjects<UserSettings>()
                 .ToDictionary(x => x.Key, x => x);
                 .ToDictionary(x => x.Key, x => x);
 
 
             var settings = new List<UserSettings>(objs.Count);
             var settings = new List<UserSettings>(objs.Count);

+ 12 - 18
InABox.Core/Security/Security.cs

@@ -108,24 +108,18 @@ namespace InABox.Core
 
 
         public static void CheckTokens()
         public static void CheckTokens()
         {
         {
-            var tasks = new Task[] {
-                Task.Run(() =>
-                {
-                    _usertokens ??= new Client<UserSecurityToken>().Load(
-                        new Filter<UserSecurityToken>(x => x.User.ID).IsEqualTo(ClientFactory.UserGuid)
-                    );
-                }),
-                Task.Run(() =>
-                {
-                    _grouptokens ??= new Client<SecurityToken>().Load(
-                        new Filter<SecurityToken>(x => x.Group.ID).IsEqualTo(ClientFactory.UserSecurityID));
-                }),
-                Task.Run(() =>
-                {
-                    _globaltokens ??= new Client<GlobalSecurityToken>().Load();
-                }),
-            };
-            Task.WaitAll(tasks);
+            _usertokens ??= Client.Query(
+                new Filter<UserSecurityToken>(x => x.User.ID).IsEqualTo(ClientFactory.UserGuid),
+                Columns.None<UserSecurityToken>().Add(x => x.Descriptor).Add(x => x.Enabled)
+            ).ToArray<UserSecurityToken>();
+            _grouptokens ??= Client.Query(
+                new Filter<SecurityToken>(x => x.Group.ID).IsEqualTo(ClientFactory.UserSecurityID),
+                Columns.None<SecurityToken>().Add(x => x.Descriptor).Add(x => x.Enabled)
+            ).ToArray<SecurityToken>();
+            _globaltokens ??= Client.Query(
+                null,
+                Columns.None<GlobalSecurityToken>().Add(x => x.Descriptor).Add(x => x.Enabled))
+            .ToArray<GlobalSecurityToken>();
         }
         }
         
         
         private static void CheckAutoToken(Type _class, Type type)
         private static void CheckAutoToken(Type _class, Type type)

+ 3 - 3
inabox.wpf/ProgressWindow/Progress.cs

@@ -68,12 +68,12 @@ namespace InABox.WPF
             {
             {
                 DisplayImage = DisplayImage
                 DisplayImage = DisplayImage
             };
             };
-            progress.Progress.Content = message;
+            progress.Message = message;
 
 
             progress.Loaded += (_, args) =>
             progress.Loaded += (_, args) =>
             {
             {
                 var worker = new BackgroundWorker();
                 var worker = new BackgroundWorker();
-                var update = new Progress<string>(data => progress.Progress.Content = data);
+                var update = new Progress<string>(data => progress.Message = data);
 
 
                 progress.OnCancelled += () =>
                 progress.OnCancelled += () =>
                 {
                 {
@@ -104,7 +104,7 @@ namespace InABox.WPF
             progress.Loaded += (_, args) =>
             progress.Loaded += (_, args) =>
             {
             {
                 var worker = new BackgroundWorker();
                 var worker = new BackgroundWorker();
-                var update = new Progress<string>(data => progress.Progress.Content = data);
+                var update = new Progress<string>(data => progress.Message = data);
 
 
                 progress.OnCancelled += () =>
                 progress.OnCancelled += () =>
                 {
                 {

+ 1 - 1
inabox.wpf/ProgressWindow/ProgressForm.xaml

@@ -44,7 +44,7 @@
                 FontSize="14"
                 FontSize="14"
                 FontStyle="Oblique"
                 FontStyle="Oblique"
                 x:Name="Progress"
                 x:Name="Progress"
-                Content="Please wait.."
+                Content="Please wait..."
                 Margin="0"
                 Margin="0"
                 HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                 HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                 HorizontalContentAlignment="Center"
                 HorizontalContentAlignment="Center"

+ 23 - 4
inabox.wpf/ProgressWindow/ProgressForm.xaml.cs

@@ -1,5 +1,7 @@
 using InABox.Wpf;
 using InABox.Wpf;
 using System;
 using System;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
 using System.Windows;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using System.Windows.Media;
 using System.Windows.Media;
@@ -10,7 +12,7 @@ namespace InABox.WPF
     /// <summary>
     /// <summary>
     ///     Interaction logic for ProgressForm.xaml
     ///     Interaction logic for ProgressForm.xaml
     /// </summary>
     /// </summary>
-    public partial class ProgressForm : ThemableWindow
+    public partial class ProgressForm : ThemableWindow, INotifyPropertyChanged
     {
     {
         private ImageSource? _image = null;
         private ImageSource? _image = null;
 
 
@@ -25,6 +27,17 @@ namespace InABox.WPF
 
 
         public Visibility CancelButtonVisibility => HasCancelButton ? Visibility.Visible : Visibility.Collapsed;
         public Visibility CancelButtonVisibility => HasCancelButton ? Visibility.Visible : Visibility.Collapsed;
 
 
+        private string _message;
+        public string Message
+        {
+            get => _message;
+            set
+            {
+                _message = value;
+                Progress.Content = _message;
+            }
+        }
+
         private ProgressForm(string cancelText, bool hasCancelButton)
         private ProgressForm(string cancelText, bool hasCancelButton)
         {
         {
             CancelText = cancelText;
             CancelText = cancelText;
@@ -52,9 +65,9 @@ namespace InABox.WPF
         public void UpdateWindow(string message)
         public void UpdateWindow(string message)
         {
         {
             if (Progress.Dispatcher.CheckAccess())
             if (Progress.Dispatcher.CheckAccess())
-                Progress.Content = message;
+                Message = message;
             else
             else
-                Progress.Dispatcher.Invoke(() => { Progress.Content = message; });
+                Progress.Dispatcher.Invoke(() => { Message = message; });
         }
         }
 
 
         public void CloseWindow()
         public void CloseWindow()
@@ -67,7 +80,7 @@ namespace InABox.WPF
 
 
         public string GetMessage()
         public string GetMessage()
         {
         {
-            return Progress.Content as string;
+            return Message;
         }
         }
 
 
         private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
         private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
@@ -82,5 +95,11 @@ namespace InABox.WPF
         {
         {
             OnCancelled?.Invoke();
             OnCancelled?.Invoke();
         }
         }
+
+        public event PropertyChangedEventHandler? PropertyChanged;
+        protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        }
     }
     }
 }
 }