Forráskód Böngészése

Introduce ProcessServer solution

Add Service user
Dalibor Votruba 4 éve
szülő
commit
96bb39916d

+ 8 - 0
AppServer/Business/Services/ConfigurationService.cs

@@ -80,6 +80,14 @@ namespace BO.AppServer.Business.Services
                         RoleEnum.SuperAdmin
                     });
 
+                await EnsureUser(srvUsers, Configuration.System.AccountProcess.Name,
+                    Configuration.System.AccountProcess.Password,
+                    Configuration.System.AccountProcess.Email,
+                    Configuration.System.AccountProcess.CultureLcid, new[]
+                    {
+                        RoleEnum.System,
+                        RoleEnum.Service
+                    });
             }
             return new ResultPlain();
         }

+ 1 - 0
AppServer/Metadata/Configuration/Configuration.cs

@@ -27,6 +27,7 @@ namespace BO.AppServer.Metadata.Configuration
             public CfgSystemAccount AccountSystem { get; set; }
             public CfgSystemAccount AccountConsole { get; set; }
             public CfgSystemAccount AccountAdmin { get; set; }
+            public CfgSystemAccount AccountProcess { get; set; }
             public string SessionIdleTimeout { get; set; }
             public CfgSystemStorage Storage { get; set; }
             public bool UseSSL { get; set; }

+ 6 - 0
AppServer/Web/appsettings.json

@@ -33,6 +33,12 @@
         "Email": "admin@bo.com",
         "Culture": "en-US"
       },
+      "AccountProcess": {
+        "Name": "Process",
+        "Password": "SmRAd1avKA",
+        "Email": "process@bo.com",
+        "Culture": "en-US"
+      },
       "Storage": {
         "InputPath": "C:\\BOFiles\\Input",
         "OutputPath": "C:\\BOFiles\\Output",

+ 95 - 0
ProcessServer/Commands/Base/BaseLocalCommand.cs

@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.IO.Abstractions;
+using System.Linq;
+using System.Text.Json;
+using BO.AppServer.Metadata.Configuration;
+using Quadarax.Foundation.Core.Console;
+using Quadarax.Foundation.Core.Data.Interface.Entity;
+using Quadarax.Foundation.Core.Logging;
+using Quadarax.Foundation.Core.Object.Extensions;
+using Quadarax.Foundation.Core.QConsole;
+using Quadarax.Foundation.Core.QConsole.Argument;
+using Quadarax.Foundation.Core.QConsole.Command.Base;
+
+namespace BO.ProcessServer.Commands.Base
+{
+    internal abstract class BaseLocalCommand : AbstractCommand, ILogHandler
+    {
+        #region *** Constants ***
+
+        protected const string CS_ARG_NAME_DUMP = "dump";
+        private const string CS_ARG_HINT_DUMP = "<is_dump_reponses>";
+        private const string CS_ARG_DESC_DUMP = "Flag if set dumps incomming json messages.";
+
+        protected const string CS_ARG_NAME_DEBUG = "dbg";
+        private const string CS_ARG_HINT_DEBUG = "<is_debug_mode>";
+        private const string CS_ARG_DESC_DEBUG = "Flag if set writes debug messages.";
+
+        #endregion
+
+        protected Configuration Configuration { get; private set; }
+
+        protected bool? IsForce { get; private set; }
+
+        protected bool IsDebug { get; private set; }
+
+        protected IFileSystem FileSystem { get; private set; }
+
+        protected BaseLocalCommand(Engine engine) : base(engine)
+        {
+
+        }
+
+        protected override void OnInitialize()
+        {
+            base.OnInitialize();
+            Configuration = JsonSerializer.Deserialize<Configuration>(FileSystem.File.ReadAllText(Constants.CS_CONFIGURATION_FILE));
+        }
+
+        protected override void OnValidateArguments()
+        {
+            base.OnValidateArguments();
+            
+            IsDebug = WasArgumentSpecified(CS_ARG_NAME_DEBUG);
+
+            if (IsDebug)
+                DebugConsoleWriter.IsWriteDebugEnabled = true;
+        }
+
+        protected override IEnumerable<AbstractArgument> OnSetupArguments()
+        {
+            FileSystem = new FileSystem();
+            var args = base.OnSetupArguments().ToList();
+            args.Add(new FlagArgument(CS_ARG_NAME_DUMP, CS_ARG_DESC_DUMP, CS_ARG_HINT_DUMP, false));
+            args.Add(new FlagArgument(CS_ARG_NAME_DEBUG, CS_ARG_DESC_DEBUG, CS_ARG_HINT_DEBUG, false));
+            return args;
+        }
+
+
+        public void Log(LogSeverityEnum type, string message, Exception e = null)
+        {
+            if ((type == LogSeverityEnum.Trace || type == LogSeverityEnum.Debug) && !IsDebug)
+                return;
+            WriteInfo($"{type}: {message}" + (e == null ? "" : e.Message));
+        }
+
+        protected void WriteDtoToConsole(IDto dto)
+        {
+            var props = dto.GetAllPropertyValues();
+            using (var wName = new ConsoleWriter(ConsoleColor.White))
+            {
+                using (var wValue = new ConsoleWriter(ConsoleColor.Yellow))
+                {
+                    var maxKeyLength = props.Keys.Max(x => x.Length);
+                    foreach (var prop in props)
+                    {
+                        wName.Write(prop.Key);
+                        wName.Write(new string(' ', maxKeyLength - prop.Key.Length) + " :\t");
+                        wValue.WriteLine(prop.Value?.ToString());
+                    }
+                }
+            }
+        }
+    }
+}

+ 44 - 0
ProcessServer/Commands/RunCommand.cs

@@ -0,0 +1,44 @@
+using System;
+using BO.ProcessServer.Commands.Base;
+using Quadarax.Foundation.Core.QConsole;
+using Quadarax.Foundation.Core.Value;
+// ReSharper disable InconsistentNaming
+
+namespace BO.ProcessServer.Commands
+{
+    internal class RunCommand : BaseLocalCommand
+    {
+        #region *** Constants ***
+        private const string CS_CMD_RUN_NAME = "run";
+        private const string CS_CMD_RUN_DESCR = "Runs entire ProcessServer instance.";
+        #endregion
+
+        #region *** Properties ***
+        public override string Name => CS_CMD_RUN_NAME;
+        public override string Description => CS_CMD_RUN_DESCR;
+        #endregion
+
+        #region *** Private fields ***
+        #endregion
+
+
+        #region *** Constructors ***
+        public RunCommand(Engine engine) : base(engine)
+        {
+        }
+        #endregion
+
+        #region *** EXECUTE ***
+
+        protected override Result OnExecute()
+        {
+            throw new NotImplementedException();
+        }
+        #endregion
+
+        #region *** Private operations ***
+        #endregion
+
+
+    }
+}

+ 8 - 0
ProcessServer/Constants.cs

@@ -0,0 +1,8 @@
+namespace BO.ProcessServer
+{
+    // ReSharper disable  InconsistentNaming
+    internal class Constants
+    {
+        public const string CS_CONFIGURATION_FILE = "processserver.json";
+    }
+}

+ 16 - 0
ProcessServer/Options/Configuration.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Text.Json.Serialization;
+
+namespace BO.ProcessServer.Options
+{
+    internal class Configuration
+    {
+        [JsonPropertyName("api-base-url")] public Uri ApiBaseUrl { get; set; }
+        [JsonPropertyName("api-user")] public string ApiUser { get; set; }
+        [JsonPropertyName("api-pwd")] public string ApiUserPwd { get; set; }
+        [JsonPropertyName("api-magic")] public string ApiMagic { get; set; }
+        [JsonPropertyName("api-timeout")] public string ApiTimeoutRaw { get; set; }
+        public TimeSpan ApiTimeout => TimeSpan.Parse(ApiTimeoutRaw);
+    }
+
+}

+ 27 - 0
ProcessServer/ProcessServer.csproj

@@ -0,0 +1,27 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <ApplicationIcon>bo_procsrv.ico</ApplicationIcon>
+    <RootNamespace>BO.ProcessServer</RootNamespace>
+    <AssemblyName>BO.ProcessServer</AssemblyName>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\AppServer\Connector.PS\Connector.PS.csproj" />
+    <ProjectReference Include="..\Common\qdr.fnd.core.qconsole\qdr.fnd.core.qconsole.csproj" />
+    <ProjectReference Include="..\Common\qdr.fnd.core\qdr.fnd.core.csproj" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Folder Include="Commands\Base\" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <None Update="processServer.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+
+</Project>

+ 73 - 0
ProcessServer/ProcessServer.sln

@@ -0,0 +1,73 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32002.261
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessServer", "ProcessServer.csproj", "{4AA6E6D4-D619-46E8-9211-E4863F65A492}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{86FAB9A1-4A29-4C77-984D-6BB615E70466}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "qdr.fnd.core.qconsole", "..\Common\qdr.fnd.core.qconsole\qdr.fnd.core.qconsole.csproj", "{46C7CE5F-7F86-4469-A112-13796582BEFE}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "qdr.fnd.core", "..\Common\qdr.fnd.core\qdr.fnd.core.csproj", "{78735C63-2EC1-4689-8F04-BE6F774AFA91}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connector.PS", "..\AppServer\Connector.PS\Connector.PS.csproj", "{66275D7A-1AE4-4810-A7EF-3D6562817C84}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "qdr.fnd.core.data.itfc", "..\Common\qdr.fnd.core.data.itfc\qdr.fnd.core.data.itfc.csproj", "{21857816-CD4F-4F46-9C8F-9EC7491CD8A9}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Connector", "Connector", "{BBFD1410-90B2-4C40-970A-D19FB35DFE7A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Metadata", "..\AppServer\Metadata\Metadata.csproj", "{7723EB63-8B98-462B-8BC7-580CDDA3815D}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connector", "..\AppServer\Connector\Connector.csproj", "{7249C7C1-4A69-40C1-882B-993788B961DE}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{4AA6E6D4-D619-46E8-9211-E4863F65A492}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4AA6E6D4-D619-46E8-9211-E4863F65A492}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4AA6E6D4-D619-46E8-9211-E4863F65A492}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4AA6E6D4-D619-46E8-9211-E4863F65A492}.Release|Any CPU.Build.0 = Release|Any CPU
+		{46C7CE5F-7F86-4469-A112-13796582BEFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{46C7CE5F-7F86-4469-A112-13796582BEFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{46C7CE5F-7F86-4469-A112-13796582BEFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{46C7CE5F-7F86-4469-A112-13796582BEFE}.Release|Any CPU.Build.0 = Release|Any CPU
+		{78735C63-2EC1-4689-8F04-BE6F774AFA91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{78735C63-2EC1-4689-8F04-BE6F774AFA91}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{78735C63-2EC1-4689-8F04-BE6F774AFA91}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{78735C63-2EC1-4689-8F04-BE6F774AFA91}.Release|Any CPU.Build.0 = Release|Any CPU
+		{66275D7A-1AE4-4810-A7EF-3D6562817C84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{66275D7A-1AE4-4810-A7EF-3D6562817C84}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{66275D7A-1AE4-4810-A7EF-3D6562817C84}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{66275D7A-1AE4-4810-A7EF-3D6562817C84}.Release|Any CPU.Build.0 = Release|Any CPU
+		{21857816-CD4F-4F46-9C8F-9EC7491CD8A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{21857816-CD4F-4F46-9C8F-9EC7491CD8A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{21857816-CD4F-4F46-9C8F-9EC7491CD8A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{21857816-CD4F-4F46-9C8F-9EC7491CD8A9}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7723EB63-8B98-462B-8BC7-580CDDA3815D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7723EB63-8B98-462B-8BC7-580CDDA3815D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7723EB63-8B98-462B-8BC7-580CDDA3815D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7723EB63-8B98-462B-8BC7-580CDDA3815D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7249C7C1-4A69-40C1-882B-993788B961DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7249C7C1-4A69-40C1-882B-993788B961DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7249C7C1-4A69-40C1-882B-993788B961DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7249C7C1-4A69-40C1-882B-993788B961DE}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{46C7CE5F-7F86-4469-A112-13796582BEFE} = {86FAB9A1-4A29-4C77-984D-6BB615E70466}
+		{78735C63-2EC1-4689-8F04-BE6F774AFA91} = {86FAB9A1-4A29-4C77-984D-6BB615E70466}
+		{66275D7A-1AE4-4810-A7EF-3D6562817C84} = {BBFD1410-90B2-4C40-970A-D19FB35DFE7A}
+		{21857816-CD4F-4F46-9C8F-9EC7491CD8A9} = {86FAB9A1-4A29-4C77-984D-6BB615E70466}
+		{7723EB63-8B98-462B-8BC7-580CDDA3815D} = {BBFD1410-90B2-4C40-970A-D19FB35DFE7A}
+		{7249C7C1-4A69-40C1-882B-993788B961DE} = {BBFD1410-90B2-4C40-970A-D19FB35DFE7A}
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {1E109E7F-8E32-4A46-982B-F8FC763EB73D}
+	EndGlobalSection
+EndGlobal

+ 26 - 0
ProcessServer/Program.cs

@@ -0,0 +1,26 @@
+using System.Reflection;
+using Quadarax.Foundation.Core.QConsole;
+using Quadarax.Foundation.Core.QConsole.Configuration;
+using Quadarax.Foundation.Core.QConsole.Context;
+using Quadarax.Foundation.Core.Reflection.Extensions;
+
+namespace BO.ProcessServer
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            var config = new StartupConfiguration("BO ProcessServer", Assembly.GetExecutingAssembly().GetName().Version);
+            config.ConsoleCopyright = Assembly.GetExecutingAssembly().GetCopyright();
+            config.AllowInteractive = false;
+            config.WaitOnKeyInNonInteractiveMode = false;
+            config.CommandDefinitionAssebmly = new Assembly[] { Assembly.GetEntryAssembly() };
+            config.DisableDefaultCommands();
+            config.ShowStatusOnEveryCommand = false;
+            config.IsConsoleDebug = false;
+
+            var console = new Engine(config, new DefualtEngineContext(), args);
+            console.Start();
+        }
+    }
+}

+ 14 - 0
ProcessServer/Version.props

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project>
+
+  <!-- version and copyright information -->
+  <PropertyGroup>
+    <Description>BlueprintOptimizer (Process 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>

BIN
ProcessServer/bo_procsrv.ico


+ 7 - 0
ProcessServer/processServer.json

@@ -0,0 +1,7 @@
+{
+	"api-base-url": "http://localhost:5000/api/",
+	"api-user": "Console",
+	"api-pwd": "A1Abastr0vA",
+	"api-magic": "6DEC4167-57A6-4333-92DA-ADE009A97DE9",
+	"api-timeout": "00:10:00",
+}