瀏覽代碼

Suppressed socket exception loop.

Kenric Nugteren 1 年之前
父節點
當前提交
4d21660f70

+ 0 - 2
prs.classes/Entities/Assignment/Assignment.cs

@@ -26,8 +26,6 @@ namespace Comal.Classes
     public class Assignment : Entity, IPersistent, IRemotable, INumericAutoIncrement<Assignment>, IOneToMany<Employee>, IOneToMany<Job>,
         IOneToMany<Kanban>, ILicense<SchedulingControlLicense>, IJobActivity, IOneToMany<Invoice>, IJobScopedItem
     {
-        private bool bChanging;
-
         [IntegerEditor(Editable = Editable.Hidden)]
         [EditorSequence(1)]
         public int Number { get; set; }

+ 6 - 11
prs.desktop/Forms/Console.xaml.cs

@@ -13,28 +13,26 @@ namespace PRSDesktop
 {
     public class PropertyChangedBase : INotifyPropertyChanged
     {
-        public event PropertyChangedEventHandler PropertyChanged;
+        public event PropertyChangedEventHandler? PropertyChanged;
 
         protected virtual void OnPropertyChanged(string propertyName)
         {
             Application.Current.Dispatcher.BeginInvoke((Action)(() =>
             {
-                var handler = PropertyChanged;
-                if (handler != null)
-                    handler(this, new PropertyChangedEventArgs(propertyName));
+                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
             }));
         }
     }
 
     public class LogEntry : PropertyChangedBase
     {
-        public string DateTime { get; set; }
+        public string DateTime { get; set; } = "";
 
-        public string Type { get; set; }
+        public string Type { get; set; } = "";
 
-        public string User { get; set; }
+        public string User { get; set; } = "";
 
-        public string Message { get; set; }
+        public string Message { get; set; } = "";
     }
 
     public class CollapsibleLogEntry : LogEntry
@@ -73,12 +71,9 @@ namespace PRSDesktop
         public CollectionViewSource _filtered;
 
         private readonly ObservableCollection<LogEntry> _logentries;
-        private bool _monitoronly = true;
 
         private EventLogger logger;
 
-        private int _msgindex = 1;
-
         public Console()
         {
             InitializeComponent();

+ 9 - 1
prs.desktop/MainWindow.xaml.cs

@@ -465,6 +465,7 @@ namespace PRSDesktop
             {
                 Dispatcher.Invoke(() =>
                 {
+                    var cancelled = false;
                     var success = Progress.ShowModal("Reconnecting", "Exit PRS", (progress, ct) =>
                     {
                         try
@@ -484,6 +485,13 @@ namespace PRSDesktop
                                 catch (System.Exception e1)
                                 {
                                     Logger.Send(LogType.Error, ClientFactory.UserID, $"Reconnect Failed: {e1.Message}");
+
+                                    // TODO: Remove this suppression
+                                    if (e1.Message.StartsWith("The socket is connected, you needn't connect again!"))
+                                    {
+                                        cancelled = true;
+                                        break;
+                                    }
                                 }
                             }
                             if (client.IsConnected())
@@ -498,7 +506,7 @@ namespace PRSDesktop
                             Logger.Send(LogType.Error, ClientFactory.UserID, $"Reconnect Failed: {e.Message}");
                         }
                     });
-                    if (!success)
+                    if (!success || cancelled)
                     {
                         Close();
                     }

+ 32 - 26
prs.desktop/Panels/Security/Global/GlobalTokenGrid.cs

@@ -15,7 +15,7 @@ namespace PRSDesktop
 {
     public class GlobalTokenGrid : DynamicGrid<SecurityDescriptor>
     {
-        private List<SecurityDescriptor> _descriptors;
+        private List<SecurityDescriptor>? _descriptors;
         private static readonly BitmapImage defaultdisabled = PRSDesktop.Resources.disabled.Fade(0.25F).AsBitmapImage();
         private static readonly BitmapImage defaulttick = PRSDesktop.Resources.tick.Fade(0.25F).AsBitmapImage();
         private static readonly BitmapImage disabled = PRSDesktop.Resources.disabled.AsBitmapImage();
@@ -53,10 +53,10 @@ namespace PRSDesktop
 
         public Guid GroupID { get; set; }
 
-        private const String ENABLED_TOKENS = "Enabled";
-        private const String DISABLED_TOKENS = "Disabled";
-        private const String OVERRIDDEN_TOKENS = "Overridden";
-        private const String DEFAULT_TOKENS = "Default";
+        private const string ENABLED_TOKENS = "Enabled";
+        private const string DISABLED_TOKENS = "Disabled";
+        private const string OVERRIDDEN_TOKENS = "Overridden";
+        private const string DEFAULT_TOKENS = "Default";
 
         private static readonly string[] ENABLED_FILTERS = new[] { ENABLED_TOKENS, DISABLED_TOKENS };
         private static readonly string[] OVERRIDDEN_FILTERS = new[] { OVERRIDDEN_TOKENS, DEFAULT_TOKENS };
@@ -64,10 +64,12 @@ namespace PRSDesktop
 
         protected override DynamicGridColumns LoadColumns()
         {
-            var columns = new DynamicGridColumns();
-            columns.Add(new DynamicGridColumn { ColumnName = "Group", Caption = "Group", Width = 150, Alignment = Alignment.MiddleCenter });
-            columns.Add(new DynamicGridColumn { ColumnName = "Description", Caption = "Description", Width = 0, Alignment = Alignment.MiddleLeft });
-            columns.Add(new DynamicGridColumn { ColumnName = "Category", Caption = "Applies To", Width = 200, Alignment = Alignment.MiddleCenter });
+            var columns = new DynamicGridColumns
+            {
+                new DynamicGridColumn { ColumnName = "Group", Caption = "Group", Width = 150, Alignment = Alignment.MiddleCenter },
+                new DynamicGridColumn { ColumnName = "Description", Caption = "Description", Width = 0, Alignment = Alignment.MiddleLeft },
+                new DynamicGridColumn { ColumnName = "Category", Caption = "Applies To", Width = 200, Alignment = Alignment.MiddleCenter }
+            };
 
             ActionColumns.Clear();
 
@@ -184,7 +186,7 @@ namespace PRSDesktop
             if (MatchFilter(filter, ALL_FILTERS))
                 return true;
 
-            String descriptor = row.Get<SecurityDescriptor, String>(c => c.Descriptor);
+            string descriptor = row.Get<SecurityDescriptor, String>(c => c.Descriptor);
             bool globaldefault = row.Get<SecurityDescriptor, bool>(c => c.Default);
             
             if (!MatchFilter(filter, ENABLED_FILTERS))
@@ -235,10 +237,14 @@ namespace PRSDesktop
 
         protected override SecurityDescriptor LoadItem(CoreRow row)
         {
+            if(_descriptors is null)
+            {
+                throw new Exception("LoadItem() called before Reload()");
+            }
             return _descriptors[row.Index];
         }
 
-        private CoreTable _table = null;
+        private CoreTable? _table = null;
         
         protected override void Reload(Filters<SecurityDescriptor> criteria, Columns<SecurityDescriptor> columns,
             ref SortOrder<SecurityDescriptor>? sort,
@@ -313,7 +319,7 @@ namespace PRSDesktop
 
 
 
-        private BitmapImage GlobalImage(CoreRow row)
+        private BitmapImage? GlobalImage(CoreRow? row)
         {
             if (row == null)
                 return null;
@@ -324,7 +330,7 @@ namespace PRSDesktop
             return row.Get<SecurityDescriptor, bool>(c => c.Default) ? defaulttick : defaultdisabled;
         }
 
-        private BitmapImage GroupImage(CoreRow row, Guid groupid)
+        private BitmapImage? GroupImage(CoreRow? row, Guid groupid)
         {
             if (row == null)
                 return null;
@@ -338,7 +344,7 @@ namespace PRSDesktop
                 : defaultdisabled;
         }
 
-        private BitmapImage UserImage(CoreRow row, Guid groupid, Guid userid)
+        private BitmapImage? UserImage(CoreRow? row, Guid groupid, Guid userid)
         {
             if (row == null)
                 return null;
@@ -398,7 +404,7 @@ namespace PRSDesktop
             Reset
         }
 
-        private Dictionary<TokenAction, Tuple<String,String>> _tokennames = new Dictionary<TokenAction, Tuple<String,String>>()
+        private readonly Dictionary<TokenAction, Tuple<String,String>> _tokennames = new()
         {
             { TokenAction.Enable, new("Enable", "Enabling") },
             { TokenAction.Disable, new("Disable", "Enabling")  },
@@ -456,10 +462,10 @@ namespace PRSDesktop
                 resetchildren = confirm == MessageBoxResult.Yes;
             }
             
-            List<String> resetusers = new List<String>();
-            List<String> resetgroups = new List<String>();
-            List<String> resetglobals = new List<String>();
-            List<GlobalSecurityToken> updates = new List<GlobalSecurityToken>();
+            var resetusers = new List<string>();
+            var resetgroups = new List<string>();
+            var resetglobals = new List<string>();
+            var updates = new List<GlobalSecurityToken>();
             
             Progress.ShowModal($"{_tokennames[action].Item2} Tokens", (progress) =>
             {
@@ -471,7 +477,7 @@ namespace PRSDesktop
                     progress.Report($"{_tokennames[action].Item2} Tokens ({(double)(i) * 100.0D / (double)rows.Count:F2}% complete)");
                     i++;
                     
-                    String descriptor = row.Get<SecurityToken, String>(c => c.Descriptor);
+                    string descriptor = row.Get<SecurityToken, String>(c => c.Descriptor);
                     bool defaultvalue = row.Get<SecurityDescriptor, bool>(c => c.Default);
                     bool desiredvalue = action switch
                     {
@@ -572,9 +578,9 @@ namespace PRSDesktop
                 resetchildren = confirm == MessageBoxResult.Yes;
             }
             
-            List<String> resetusers = new List<String>();
-            List<String> resetgroups = new List<String>();
-            List<SecurityToken> updates = new List<SecurityToken>();
+            var resetusers = new List<string>();
+            var resetgroups = new List<string>();
+            var updates = new List<SecurityToken>();
             
             Progress.ShowModal($"{_tokennames[action].Item2} Tokens", (progress) =>
             {
@@ -585,7 +591,7 @@ namespace PRSDesktop
                     progress.Report($"{_tokennames[action].Item2} Tokens ({(double)(i) * 100.0D / (double)rows.Count:F2}% complete)");
                     i++;
                     
-                    String descriptor = row.Get<SecurityDescriptor, String>(c => c.Descriptor);
+                    string descriptor = row.Get<SecurityDescriptor, String>(c => c.Descriptor);
                     bool globaldefault = row.Get<SecurityDescriptor, bool>(c => c.Default);
                     bool defaultvalue = GetGlobalOrDefault(descriptor, globaldefault);
                     var currentvalue = GetGroupOrDefault(descriptor, groupid, globaldefault);
@@ -646,8 +652,8 @@ namespace PRSDesktop
 
             Progress.ShowModal($"{_tokennames[action].Item2} Tokens", (progress) =>
             {
-                List<String> resets = new List<String>();
-                List<UserSecurityToken> updates = new List<UserSecurityToken>();
+                var resets = new List<string>();
+                var updates = new List<UserSecurityToken>();
 
                 int i = 1;
                 foreach (var row in rows)