Răsfoiți Sursa

fix error handling in AbstractPostCommand

add versions
Dalibor Votruba 4 ani în urmă
părinte
comite
b5ffb6078b

+ 1 - 0
AppServer/Business/Services/CatalogueService.cs

@@ -58,6 +58,7 @@ namespace BO.AppServer.Business.Services
 
         public async Task<ResultValueDto<MimeTypeRDto>> CreateMimeTypeAsync(MimeTypeCDto mimeType)
         {
+
             // Validation
             var exists = _repoMimeType.Query(new Paging())
                 .Any(x => x.IsEnabled && x.Mimetype1 == mimeType.Mimetype1.ToLower());

+ 1 - 1
AppServer/Connector/AbstractConnection.cs

@@ -167,7 +167,7 @@ namespace BO.Connector
                         foreach (var key in headerAttributes.Keys)
                             req.Headers.Add(key,headerAttributes[key]);
                     req.Headers.ContentType = new MediaTypeHeaderValue("application/json");
-                    resp = await CreateClient().PostAsync(relativeUrlApiCall, req);
+                    resp = await _client.PostAsync(relativeUrlApiCall, req);
                     break;
                 case RestCallTypeEnum.Put:
                     req = new StringContent(_binder.SaveToString(data));

+ 7 - 0
AppServer/Directory.Build.props

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project>
+
+  <!-- version and copyright information -->
+  <Import Project="$(MSBuildThisFileDirectory)Version.props" />
+
+</Project>

+ 14 - 0
AppServer/Version.props

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project>
+
+  <!-- version and copyright information -->
+  <PropertyGroup>
+    <Description>BlueprintOptimizer (Main application server) - software provides automatic service of massive 3D model transformations</Description>
+    <Company>Foo INC</Company>
+    <Product>BlueprintOptimizer</Product>
+    <Copyright>Copyright © 2020–2021 Foo INC</Copyright>
+    <AssemblyVersion>0.0.0.1</AssemblyVersion>
+    <FileVersion>0.0.0.1</FileVersion>	 
+  </PropertyGroup>
+
+</Project>

+ 1 - 1
AppServer/Web/Services/Base.cs

@@ -62,7 +62,7 @@ namespace BO.AppServer.Web.Services
                 ProcessException(result, e);
             }
 
-            return await new Task<TResult>(() => result);
+            return result;
         }
 
         protected void ProcessException(ResultDto result, Exception exception)

+ 20 - 0
Common/qdr.fnd.core.qconsole/Command/Base/AbstractCommand.cs

@@ -242,6 +242,26 @@ namespace Quadarax.Foundation.Core.QConsole.Command.Base
                 WriteLine(writer, WriteTextSeverity.Error, text);
         }
 
+        protected void WriteError(Exception e)
+        {
+            if (e is AggregateException aggr)
+            {
+                foreach (var ex in aggr.InnerExceptions)
+                    DumpException(ex, "- ");
+            }
+            else
+                DumpException(e, string.Empty);
+        }
+
+        private void DumpException(Exception e, string prefix)
+        {
+            while (e != null)
+            {                                         
+                WriteError(prefix + e.Message);
+                e = e.InnerException;
+            }
+        }
+
         protected virtual void WriteLine(ConsoleWriter writer, WriteTextSeverity severity, string text)
         {
             writer.WriteLine(text);

+ 2 - 2
Console/Commands/Base/AbstractPostCommand.cs

@@ -92,7 +92,7 @@ namespace BO.Console.Commands.Base
                             errors.AddRange(exception.InnerExceptions);
                         else
                             errors.Add(e);
-                        //WriteError(e.Message); 
+                        WriteError(e); 
                         return new TIterationResult();
                     }
                 });
@@ -102,7 +102,7 @@ namespace BO.Console.Commands.Base
             }
             Task.WaitAll(tasks.ToArray());
             
-            return new Result(new AggregateException(errors));
+            return errors.Count == 0 ? new Result() : new Result(new Exception("Operation failed!"));
         }
 
         protected abstract TIterationResult IterationExecute(TData data);

+ 7 - 0
Console/Directory.Build.props

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project>
+
+  <!-- version and copyright information -->
+  <Import Project="$(MSBuildThisFileDirectory)Version.props" />
+
+</Project>

+ 2 - 0
Console/Program.cs

@@ -6,6 +6,7 @@ using Quadarax.Foundation.Core.Json;
 using Quadarax.Foundation.Core.QConsole;
 using Quadarax.Foundation.Core.QConsole.Configuration;
 using Quadarax.Foundation.Core.QConsole.Context;
+using Quadarax.Foundation.Core.Reflection.Extensions;
 using Binder = Quadarax.Foundation.Core.Json.Binder;
 
 namespace BO.Console
@@ -48,6 +49,7 @@ namespace BO.Console
             */
 
             var config = new StartupConfiguration("BO Console", Assembly.GetExecutingAssembly().GetName().Version);
+            config.ConsoleCopyright = Assembly.GetExecutingAssembly().GetCopyright();
             config.AllowInteractive = false;
             config.WaitOnKeyInNonInteractiveMode = false;
             config.CommandDefinitionAssebmly = new Assembly[]{Assembly.GetEntryAssembly()};

+ 14 - 0
Console/Version.props

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project>
+
+  <!-- version and copyright information -->
+  <PropertyGroup>
+    <Description>BlueprintOptimizer (Administration console) - software provides automatic service of massive 3D model transformations</Description>
+    <Company>Foo INC</Company>
+    <Product>BlueprintOptimizer</Product>
+    <Copyright>Copyright © 2020–2021 Foo INC</Copyright>
+    <AssemblyVersion>0.0.0.1</AssemblyVersion>
+    <FileVersion>0.0.0.1</FileVersion>	 
+  </PropertyGroup>
+
+</Project>