Pārlūkot izejas kodu

Merging Kenrics Improvements

Frank van den Bos 2 gadi atpakaļ
vecāks
revīzija
ad5d2d2866

+ 0 - 2
InABox.Client.RPC/RPCClient.cs

@@ -22,8 +22,6 @@ namespace InABox.Rpc
         {
             _transport = transport;
             _transport.OnMessage += Transport_Message;
-            if (!_transport.IsConnected())
-                _transport.Connect();
         }
 
         ~RpcClient()

+ 10 - 1
InABox.Client.RPC/Transports/RPCClientTransport.cs

@@ -76,6 +76,9 @@ namespace InABox.Rpc
             where TParameters : IRpcCommandParameters, ISerializeBinary
             where TResult : IRpcCommandResult, ISerializeBinary, new()
         {
+            
+            CheckConnection<TCommand>();
+            
             var request = new RpcMessage()
             {
                 Id = Guid.NewGuid(),
@@ -98,7 +101,13 @@ namespace InABox.Rpc
             
             return result;
         }
-        
+
+        private void CheckConnection<TCommand>() where TCommand : IRpcCommand
+        {
+            if (!IsConnected())
+                throw new RpcException($"Transport Disconnected: {typeof(TCommand).Name}()", RpcError.DISCONNECTED);
+        }
+
 
         public ManualResetEventSlim Queue(Guid id)
         {

+ 4 - 1
InABox.Client.RPC/Transports/Socket/RPCClientSocketTransport.cs

@@ -49,7 +49,10 @@ namespace InABox.Rpc
             
             // Time to wait before disconnect - the default meant that the client disconnected during debugging, since the ping would fail
             socket.WaitTime = TimeSpan.FromSeconds(5);
-            
+            socket.OnOpen -= Socket_OnOpen;
+            socket.OnError -= Socket_OnError;
+            socket.OnClose -= Socket_OnClose;
+            socket.OnMessage -= Socket_OnMessage;
             socket.Connect();
             if (socket.ReadyState == WebSocketState.Open)
             {

+ 0 - 2
InABox.Core/Client/ClientFactory.cs

@@ -231,8 +231,6 @@ namespace InABox.Clients
 
         public static ValidationStatus Validate(Guid session)
         {
-            InvalidateUser();
-
             var result = Client.Validate(session);
 
             if (result.Status != ValidationStatus.INVALID)

+ 3 - 1
InABox.Core/CoreUtils.cs

@@ -1619,7 +1619,7 @@ namespace InABox.Core
         }
         //static readonly Regex StripQuotes = new Regex(@"&quot;", RegexOptions.Compiled);
 
-        public static string StripHTML(string html)
+        public static string StripHTML(this string html)
         {
             if (string.IsNullOrWhiteSpace(html))
                 return "";
@@ -1632,6 +1632,8 @@ namespace InABox.Core
             result = result.Replace("\0", "").Trim();
             return result;
         }
+        
+        
 
         public static string GetCaption(this Type type, bool usedefault = true)
         {

+ 16 - 0
InABox.Core/MultiQuery/MultiQuery.cs

@@ -12,6 +12,14 @@ namespace InABox.Core
 
         public int Count => _queries.Count;
 
+        public Dictionary<object, IQueryDef> Definitions()
+        {
+            Dictionary<object, IQueryDef> result = new Dictionary<object, IQueryDef>();
+            foreach (var query in _queries)
+                result[query.Key] = query.Query;
+            return result;
+        }
+
         public void Clear()
         {
             _queries.Clear();
@@ -88,6 +96,14 @@ namespace InABox.Core
             return query.Result;
         }
 
+        public void Set(object key, CoreTable table)
+        {
+            var query = _queries.FirstOrDefault(x => Equals(x.Key, key));
+            if (query == null)
+                throw new Exception("Key does not exist");
+            query.Result = table;
+        }
+        
         private class InternalQueryDef
         {
             public object Key { get; set; }

+ 6 - 9
InABox.Mobile/Shared/MobileLogging.cs

@@ -23,7 +23,7 @@ namespace InABox.Mobile
 
         private static string _logfilenameincludingpath;
         
-        private static void CheckLogger()
+        private static Logger CheckLogger()
         {
             if (_logger == null)
             {
@@ -46,22 +46,19 @@ namespace InABox.Mobile
                     .WriteTo.File(_logfilenameincludingpath)
                     .CreateLogger();
             }
+            return _logger;
         }
         
         public static void Log(LogType type, string entitytype, string message, string page)
         {
-            CheckLogger();
-            System.Diagnostics.Debug.WriteLine($"[Log] {message}");
-            Console.WriteLine($"[Log] {message}");
-            _logger.Information("{Type} {Entity} {Message} {Page}", type, entitytype, message, page);
+            CheckLogger()
+                .Information("{Type} {Entity} {Message} {Page}", type, entitytype, message, page);
         }
         
         public static void Log(string message)
         {
-            CheckLogger();
-            System.Diagnostics.Debug.WriteLine($"[Log] {message}");
-            Console.WriteLine($"[Log] {message}");
-            _logger.Information("{Log}", message);
+            CheckLogger()
+                .Information("{Log}", message);
         }
 
         public static void Log(Exception exception, String tag = "")

+ 8 - 7
InABox.RPC.Shared/IRPCCommand.cs

@@ -3,14 +3,15 @@ using InABox.Core;
 
 namespace InABox.Rpc
 {
-    /// <summary>
-    /// Flag an <see cref="IRpcCommand{TProperties, TResult}"/> with <see cref="IRpcLogCommand"/> if its execution should be logged.
-    /// </summary>
-    public interface IRpcLogCommand { }
+    public interface IRpcCommand
+    {
+        /// <summary>
+        /// Set to <see langword="true"/> if this command should be logged.
+        /// </summary>
+        bool Log { get; }
+    }
 
-    public interface IRpcCommand<TProperties, TResult>
-        where TProperties : IRpcCommandParameters
-        where TResult : IRpcCommandResult
+    public interface IRpcCommand<TProperties, TResult> : IRpcCommand
     {
     }