Kaynağa Gözat

Added FilterConstant.NULL handling to SQLite provider
Added initial Logikal Support
Fixed missing FilterRow in MultiSelect Dialog
Increased default width of MessageWindow class

frogsoftware 11 ay önce
ebeveyn
işleme
bc6ce5643e

+ 10 - 0
InABox.Logikal/ILogikalApp.cs

@@ -0,0 +1,10 @@
+namespace InABox.Logikal
+{
+    public interface ILogikalApp
+    {
+        LogikalStatus Connect(string path);
+        LogikalStatus Disconnect();
+        LogikalStatus Login(string username, string password);
+        LogikalStatus Logout();
+    }
+}

+ 21 - 0
InABox.Logikal/InABox.Logikal.csproj

@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+    <PropertyGroup>
+        <ImplicitUsings>disable</ImplicitUsings>
+        <Nullable>disable</Nullable>
+        <TargetFramework>netstandard2.0</TargetFramework>
+        <LangVersion>7.3</LangVersion>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <PackageReference Include="H.Formatters.Newtonsoft.Json" Version="13.0.59" />
+      <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
+      <PackageReference Include="Ofcas.Framework.Translation" Version="1.0.0.397" />
+      <PackageReference Include="Ofcas.Lk.Api.Client.Core" Version="3.0.2.8" />
+      <PackageReference Include="Ofcas.Lk.Api.Client.Ui" Version="3.0.2.8" />
+      <PackageReference Include="Ofcas.Lk.Api.Core" Version="3.0.0.98" />
+      <PackageReference Include="Ofcas.Lk.Api.Ui" Version="3.0.0.98" />
+      <PackageReference Include="System.ServiceModel.Primitives" Version="4.10.3" />
+    </ItemGroup>
+
+</Project>

+ 10 - 0
InABox.Logikal/LogikalConnectRequest.cs

@@ -0,0 +1,10 @@
+namespace InABox.Logikal
+{
+    public class LogikalConnectRequest : LogikalRequest
+    {
+        public override LogikalMethod Method() => LogikalMethod.Connect;
+        
+        public string Path { get; set; }
+        
+    }
+}

+ 8 - 0
InABox.Logikal/LogikalConnectResponse.cs

@@ -0,0 +1,8 @@
+namespace InABox.Logikal
+{
+    public class LogikalConnectResponse : LogikalResponse
+    {
+        public override LogikalMethod Method() => LogikalMethod.Connect;
+        
+    }
+}

+ 7 - 0
InABox.Logikal/LogikalDisconnectRequest.cs

@@ -0,0 +1,7 @@
+namespace InABox.Logikal
+{
+    public class LogikalDisconnectRequest : LogikalRequest
+    {
+        public override LogikalMethod Method() => LogikalMethod.Disconnect;
+    }
+}

+ 7 - 0
InABox.Logikal/LogikalDisconnectResponse.cs

@@ -0,0 +1,7 @@
+namespace InABox.Logikal
+{
+    public class LogikalDisconnectResponse : LogikalResponse
+    {
+        public override LogikalMethod Method() => LogikalMethod.Disconnect;
+    }
+}

+ 10 - 0
InABox.Logikal/LogikalLoginRequest.cs

@@ -0,0 +1,10 @@
+namespace InABox.Logikal
+{
+    public class LogikalLoginRequest : LogikalRequest
+    {
+        public override LogikalMethod Method() => LogikalMethod.Login;
+        
+        public string UserID { get; set; }
+        public string Password { get; set; }
+    }
+}

+ 8 - 0
InABox.Logikal/LogikalLoginResponse.cs

@@ -0,0 +1,8 @@
+namespace InABox.Logikal
+{
+    public class LogikalLoginResponse : LogikalResponse
+    {
+        public override LogikalMethod Method() => LogikalMethod.Login;
+        
+    }
+}

+ 7 - 0
InABox.Logikal/LogikalLogoutRequest.cs

@@ -0,0 +1,7 @@
+namespace InABox.Logikal
+{
+    public class LogikalLogoutRequest : LogikalRequest
+    {
+        public override LogikalMethod Method() => LogikalMethod.Logout;
+    }
+}

+ 8 - 0
InABox.Logikal/LogikalLogoutResponse.cs

@@ -0,0 +1,8 @@
+namespace InABox.Logikal
+{
+    public class LogikalLogoutResponse : LogikalResponse
+    {
+        public override LogikalMethod Method() => LogikalMethod.Logout;
+        
+    }
+}

+ 27 - 0
InABox.Logikal/LogikalMessage.cs

@@ -0,0 +1,27 @@
+using System;
+using Newtonsoft.Json;
+
+namespace InABox.Logikal
+{
+    public class LogikalMessage
+    {
+        public Guid ID { get; set; }
+        public LogikalMethod Method { get; set; }
+        public String Payload { get; set; }
+        
+        public static LogikalMessage Error(string message)
+        {
+            return new LogikalMessage()
+            {
+                ID = Guid.NewGuid(), 
+                Method = LogikalMethod.Error,
+                Payload = JsonConvert.SerializeObject(new LogikalErrorResponse()
+                {
+                    Message = message
+                })
+                
+            };
+        }
+
+    }
+}

+ 11 - 0
InABox.Logikal/LogikalMethod.cs

@@ -0,0 +1,11 @@
+namespace InABox.Logikal
+{
+    public enum LogikalMethod
+    {
+        Error = -1,
+        Connect = 0,
+        Login = 1,
+        Logout = 998,
+        Disconnect = 999
+    }
+}

+ 19 - 0
InABox.Logikal/LogikalObject.cs

@@ -0,0 +1,19 @@
+using Newtonsoft.Json;
+
+namespace InABox.Logikal
+{
+    public abstract class LogikalObject
+    {
+        public abstract LogikalMethod Method();
+        
+        public LogikalMessage ToMessage()
+        {
+            return new LogikalMessage()
+            {
+                Method = Method(),
+                Payload = JsonConvert.SerializeObject(this)
+            };
+        }
+
+    }
+}

+ 24 - 0
InABox.Logikal/LogikalRequest.cs

@@ -0,0 +1,24 @@
+using System;
+using Newtonsoft.Json;
+
+namespace InABox.Logikal
+{
+    public abstract class LogikalRequest : LogikalObject
+    {
+        
+        public static LogikalRequest FromMessage(LogikalMessage message)
+        {
+            if (message.Method == LogikalMethod.Connect)
+                return JsonConvert.DeserializeObject<LogikalConnectRequest>(message.Payload);
+            if (message.Method == LogikalMethod.Login)
+                return JsonConvert.DeserializeObject<LogikalLoginRequest>(message.Payload);
+            if (message.Method == LogikalMethod.Logout)
+                return JsonConvert.DeserializeObject<LogikalLogoutRequest>(message.Payload);
+            if (message.Method == LogikalMethod.Disconnect)
+                return JsonConvert.DeserializeObject<LogikalDisconnectRequest>(message.Payload);
+            throw new Exception($"Invalid Message Method: {message.Method}: {message.Payload}");
+        }
+        
+        
+    }
+}

+ 38 - 0
InABox.Logikal/LogikalResponse.cs

@@ -0,0 +1,38 @@
+using System;
+using Newtonsoft.Json;
+
+namespace InABox.Logikal
+{
+    public abstract class LogikalResponse : LogikalObject
+    {
+        public LogikalStatus Status { get; set; } = LogikalStatus.Unknown;
+        
+        public static LogikalResponse FromMessage(LogikalMessage message)
+        {
+            if (message.Method == LogikalMethod.Connect)
+                return JsonConvert.DeserializeObject<LogikalConnectResponse>(message.Payload);
+            if (message.Method == LogikalMethod.Login)
+                return JsonConvert.DeserializeObject<LogikalLoginResponse>(message.Payload);
+            if (message.Method == LogikalMethod.Logout)
+                return JsonConvert.DeserializeObject<LogikalLogoutResponse>(message.Payload);
+            if (message.Method == LogikalMethod.Disconnect)
+                return JsonConvert.DeserializeObject<LogikalDisconnectResponse>(message.Payload);
+            if (message.Method == LogikalMethod.Error)
+                return JsonConvert.DeserializeObject<LogikalErrorResponse>(message.Payload);
+            throw new Exception("Unknown Message ID");
+        }
+        
+    }
+
+    public class LogikalErrorResponse : LogikalResponse
+    {
+        public override LogikalMethod Method() => LogikalMethod.Error;
+        
+        public String Message { get; set; }
+
+        public LogikalErrorResponse()
+        {
+            Status = LogikalStatus.Error;
+        }
+    }
+}

+ 11 - 0
InABox.Logikal/LogikalStatus.cs

@@ -0,0 +1,11 @@
+namespace InABox.Logikal
+{
+    public enum LogikalStatus
+    {
+        Ok,
+        Restricted,
+        Error,
+        Failed,
+        Unknown,
+    }
+}

+ 16 - 2
inabox.database.sqlite/SQLiteProvider.cs

@@ -1393,6 +1393,8 @@ namespace InABox.Database.SQLite
         {
             return constant switch
             {
+                FilterConstant.Null => "NULL",
+                
                 FilterConstant.Now => "datetime()",
                 FilterConstant.Today => "datetime(date())",
                 FilterConstant.Zero => "0",
@@ -1437,7 +1439,8 @@ namespace InABox.Database.SQLite
                 FilterConstant.EndOfThisFinancialYear => "datetime(date(), '-6 months', 'start of year', '+18 months', '-000.0001 seconds')",
                 FilterConstant.StartOfNextFinancialYear => "datetime(date(), '+6 months', 'start of year', '+6 months')",
                 FilterConstant.EndOfNextFinancialYear => "datetime(date(), '+6 months', 'start of year', '+18 months', '-000.0001 seconds')",
-                
+
+                    
                 _ => throw new Exception($"FilterConstant.{constant} is not implemented!"),
             };
         }
@@ -1523,7 +1526,18 @@ namespace InABox.Database.SQLite
                 else
                 {
                     if (filter.Value is FilterConstant constant)
-                        result = string.Format("(" + operators[filter.Operator] + ")", prop, GetFilterConstant(constant));
+                    {
+                        if (constant == FilterConstant.Null)
+                        {
+                            result = string.Format("({0} {1} NULL)", prop,
+                                filter.Operator == Operator.IsEqualTo 
+                                    ? "IS"
+                                    : "IS NOT");
+                        }
+                        else
+                            result = string.Format("(" + operators[filter.Operator] + ")", prop,
+                                GetFilterConstant(constant));
+                    }
                     else
                     {
                         var value = Encode(filter.Value, mexp.Type);

+ 3 - 0
inabox.wpf/DynamicGrid/MultiSelectDialog.cs

@@ -58,12 +58,15 @@ namespace InABox.DynamicGrid
 
             datagrid.Reconfigure(options =>
             {
+                options.BeginUpdate();
                 options.Clear();
                 options.SelectColumns = true;
                 options.FilterRows = true;
                 if (multiselect)
                     options.MultiSelect = true;
+                options.EndUpdate();
             });
+            datagrid.Reconfigure();
 
             datagrid.OnReload += Grid_OnReload;
             datagrid.OnDoubleClick += Grid_DoubleClick;

+ 2 - 2
inabox.wpf/Forms/MessageWindow.xaml

@@ -5,8 +5,8 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:InABox.Wpf"
         mc:Ignorable="d"
-        Width="280"
-        MinWidth="280"
+        Width="350"
+        MinWidth="350"
         SizeToContent="Height"
         x:Name="Window"
         WindowStartupLocation="CenterScreen"