Bläddra i källkod

qdr-temporary-shared-storage: fix bugs and test

Dalibor Votruba 1 år sedan
förälder
incheckning
1b7b03755f

+ 1 - 1
qdr-temporary-shared-storage/@client/qdr.app.tss.client/qdr.app.tss.client.console/Commands/BaseCmd.cs

@@ -24,7 +24,7 @@ namespace qdr.app.qbstack.Commands
         #endregion
 
         #region *** Properties ***
-        protected IFileSystem FileSystem => GetContext<CommandContext>().FileSystem;
+        protected IFileSystem FileSystem => GetContext<TssCommandContext>().FileSystem;
         protected Uri Url {get; private set;} = new Uri("https://example.com/");
         protected string ApiKey {get; private set;} = string.Empty;
         #endregion

+ 4 - 5
qdr-temporary-shared-storage/@client/qdr.app.tss.client/qdr.app.tss.client.console/Commands/CmdUpload.cs

@@ -1,6 +1,5 @@
 using Quadarax.Application.TemporarySharedStorage.Client.Dtos.Request;
 using Quadarax.Application.TemporarySharedStorage.Client.Services;
-using Quadarax.Foundation.Core.Value.Extensions;
 using Quadarax.Foundation.Core.Logging;
 using Quadarax.Foundation.Core.QConsole;
 using Quadarax.Foundation.Core.QConsole.Argument;
@@ -18,8 +17,8 @@ namespace qdr.app.qbstack.Commands
         private const string CS_CMD_NAME = "upload";
         private const string CS_CMD_DESCR = "Upload a file to QDR Temporary Shared Storage.";
 
-        private const string ARG_FILE_NAME = "filePath";
-        private const string ARG_FILE_HINT = "file_path";
+        private const string ARG_FILE_NAME = "file";
+        private const string ARG_FILE_HINT = "file";
         private const string ARG_FILE_DESCR = "Path to the file to upload.";
 
         private const string ARG_DESCR_NAME = "descr";
@@ -63,7 +62,7 @@ namespace qdr.app.qbstack.Commands
         protected string Message {get;private set;} = string.Empty;
         protected string Password {get;private set;} = string.Empty;
         protected string Reference {get;private set;} = string.Empty;
-        protected int ChunckSize {get;private set;} = 1048576;
+        protected int ChunckSize {get;private set;} = 0;
         protected DateTime ActiveFrom {get;private set;} = DateTime.MinValue;
         protected DateTime ActiveTo {get;private set;} = DateTime.MinValue;
 
@@ -113,7 +112,7 @@ namespace qdr.app.qbstack.Commands
             list.Add(new NamedArgument(ARG_AFROM_NAME, ARG_AFROM_DESCR, ARG_AFROM_HINT, TypeValuesEnum.DateTime, string.Empty, true));
             list.Add(new NamedArgument(ARG_ATO_NAME, ARG_ATO_DESCR, ARG_ATO_HINT, TypeValuesEnum.DateTime, string.Empty, true));
             list.Add(new NamedArgument(ARG_MSG_NAME, ARG_MSG_DESCR, ARG_MSG_HINT, TypeValuesEnum.String, string.Empty, true));
-            list.Add(new NamedArgument(ARG_CHSIZE_NAME, ARG_CHSIZE_DESCR, ARG_CHSIZE_HINT, TypeValuesEnum.Integer, "0", false));
+            list.Add(new NamedArgument(ARG_CHSIZE_NAME, ARG_CHSIZE_DESCR, ARG_CHSIZE_HINT, TypeValuesEnum.Integer, "1048576", false));
             return list;
         }
 

+ 4 - 2
qdr-temporary-shared-storage/@client/qdr.app.tss.client/qdr.app.tss.client.console/Program.cs

@@ -1,9 +1,11 @@
 // See https://aka.ms/new-console-template for more information
-using System.Reflection;
+using qdr.app.tss.client.console;
 using Quadarax.Foundation.Core.QConsole;
 using Quadarax.Foundation.Core.QConsole.Configuration;
 using Quadarax.Foundation.Core.QConsole.Context;
 using Quadarax.Foundation.Core.Reflection.Extensions;
+using System.IO.Abstractions;
+using System.Reflection;
 
 var consoleVersion = Assembly.GetExecutingAssembly()?.GetName()?.Version;
 if (consoleVersion != null)
@@ -19,6 +21,6 @@ if (consoleVersion != null)
     config.ShowStatusOnEveryCommand = false;
     config.IsConsoleDebug = false;
 
-    var console = new Engine(config, new DefualtEngineContext(), args);
+    var console = new Engine(config, new TssEngineContext(new FileSystem()), args);
     console.Start();
 }

+ 15 - 0
qdr-temporary-shared-storage/@client/qdr.app.tss.client/qdr.app.tss.client.console/Properties/launchSettings.json

@@ -0,0 +1,15 @@
+{
+  "profiles": {
+    "WSL": {
+      "commandName": "WSL2",
+      "distributionName": ""
+    },
+    "empty": {
+      "commandName": "Project"
+    },
+    "upload small test": {
+      "commandName": "Project",
+      "commandLineArgs": "upload -url:\"https://www.studiou.cz/\" -apiKey:\"riyeVPRvz9QF1YmrhdSz9rgiVzhy3mSb\" -activeFrom:\"20.5.2025\" -activeTo:\"6.6.2025\" -descr:\"this is a test file\" -msg:\"please enjoy\" -pwd:\"12345\" -ref:\"ref0001\" -file:\"..\\..\\..\\..\\test.pdf\""
+    }
+  }
+}

+ 2 - 2
qdr-temporary-shared-storage/@client/qdr.app.tss.client/qdr.app.tss.client.console/CommandContext.cs → qdr-temporary-shared-storage/@client/qdr.app.tss.client/qdr.app.tss.client.console/TssCommandContext.cs

@@ -4,7 +4,7 @@ using System.IO.Abstractions;
 
 namespace qdr.app.tss.client.console
 {
-    internal class CommandContext : DisposableObject, ICommandContext
+    internal class TssCommandContext : DisposableObject, ICommandContext
     {
 
         private IFileSystem? _fileSystem;
@@ -13,7 +13,7 @@ namespace qdr.app.tss.client.console
 
         public string Status => "READY";
 
-        public CommandContext(IFileSystem fileSystem)
+        public TssCommandContext(IFileSystem fileSystem)
         {
             _fileSystem = fileSystem;
         }

+ 31 - 0
qdr-temporary-shared-storage/@client/qdr.app.tss.client/qdr.app.tss.client.console/TssEngineContext.cs

@@ -0,0 +1,31 @@
+using Quadarax.Foundation.Core.Object;
+using Quadarax.Foundation.Core.QConsole.Context;
+using System.IO.Abstractions;
+
+namespace qdr.app.tss.client.console
+{
+    internal class TssEngineContext : DisposableObject, IEngineContext
+    {
+
+        private IFileSystem? _fileSystem;
+
+        public string Status => throw new NotImplementedException();
+
+
+        public TssEngineContext(IFileSystem fileSystem)
+        {
+            _fileSystem = fileSystem;
+        }
+
+
+        public ICommandContext CreateCommandContext()
+        {
+            return new TssCommandContext(_fileSystem ?? new FileSystem());
+        }
+
+        protected override void OnDisposing()
+        {
+            _fileSystem = null;
+        }
+    }
+}

BIN
qdr-temporary-shared-storage/@client/qdr.app.tss.client/test.pdf