Dalibor Votruba 4 жил өмнө
parent
commit
1596663b10

+ 2 - 0
@Database/bo_create_schema.sql

@@ -1086,6 +1086,8 @@ CREATE TABLE [dbo].[Registration]
     [Id] [bigint] NOT NULL IDENTITY (1, 1),
     [Id] [bigint] NOT NULL IDENTITY (1, 1),
     [PSInstance] [varchar] (100) NULL,
     [PSInstance] [varchar] (100) NULL,
     [LocationIP] [varchar] (100) NULL,
     [LocationIP] [varchar] (100) NULL,
+	[PoolSize] [int] NOT NULL DEFAULT (0),
+	[Denided] [bit] NOT NULL DEFAULT (0),
     [LastActivity] [datetime] NULL,
     [LastActivity] [datetime] NULL,
     [DocumentProcessedCnt] [int] NOT NULL,
     [DocumentProcessedCnt] [int] NOT NULL,
     [DocumentFailedCnt] [int] NOT NULL,
     [DocumentFailedCnt] [int] NOT NULL,

+ 7 - 5
@Documentation/BlueprintOptimizer.simp

@@ -147,7 +147,7 @@
     <entity-ids>
     <entity-ids>
       <counter>
       <counter>
         <item-type type-id="group" type="Group" />
         <item-type type-id="group" type="Group" />
-        <value>4165</value>
+        <value>4169</value>
       </counter>
       </counter>
       <counter>
       <counter>
         <item-type type-id="erd-entity" type="Entity" />
         <item-type type-id="erd-entity" type="Entity" />
@@ -367,7 +367,7 @@
     <fields>
     <fields>
       <counter>
       <counter>
         <type>SoftwareIdeasModeler.Core.DiagramItems.Erd.ErdEntityAttribute</type>
         <type>SoftwareIdeasModeler.Core.DiagramItems.Erd.ErdEntityAttribute</type>
-        <value>247</value>
+        <value>249</value>
       </counter>
       </counter>
       <counter>
       <counter>
         <type>SoftwareIdeasModeler.Core.DiagramItems.Erd.ErdEntityIndex</type>
         <type>SoftwareIdeasModeler.Core.DiagramItems.Erd.ErdEntityIndex</type>
@@ -752,7 +752,7 @@
           </documentation>
           </documentation>
           <abstract-items />
           <abstract-items />
           <sub-models />
           <sub-models />
-          <diagram type="entity-relationship" id="pca974f586cd54eb2957d89ec61c4843d_762498462" name="BOServer" order-index="0" uid="" show-id="false" show-name="true" show-parent-name="false" name-style="local-auto-parents" show-stereotypes="true" show-tagged-values="false" show-template-parameters="true" show-fields="true" show-field-tags="true" show-empty-compartments="true" show-special-indicators="false" show-rules="true" show-attributes="true" show-attribute-visibility="true" show-operations="true" show-operation-parameters="true" show-operation-visibility="true" show-visibility-sign="true" show-nullability="true" show-sequence-number="false" show-extension-points="false" show-relationship-texts="true" show-data="true" show-description="false" show-field-description="false" auto-routed-paths="false" default-line-style="default" default-type-set="MSSQL" view-location="445,-258">
+          <diagram type="entity-relationship" id="pca974f586cd54eb2957d89ec61c4843d_762498462" name="BOServer" order-index="0" uid="" show-id="false" show-name="true" show-parent-name="false" name-style="local-auto-parents" show-stereotypes="true" show-tagged-values="false" show-template-parameters="true" show-fields="true" show-field-tags="true" show-empty-compartments="true" show-special-indicators="false" show-rules="true" show-attributes="true" show-attribute-visibility="true" show-operations="true" show-operation-parameters="true" show-operation-visibility="true" show-visibility-sign="true" show-nullability="true" show-sequence-number="false" show-extension-points="false" show-relationship-texts="true" show-data="true" show-description="false" show-field-description="false" auto-routed-paths="false" default-line-style="default" default-type-set="MSSQL" view-location="2562,1586">
             <style>
             <style>
               <background-color index="1" color="#FFFFFFFF" />
               <background-color index="1" color="#FFFFFFFF" />
               <background-color index="2" color="#FFFFFFFF" />
               <background-color index="2" color="#FFFFFFFF" />
@@ -2557,6 +2557,8 @@
                   <attribute uid="a1767a774d3ed49f7bf7f6b697d958d9c422" cid="ELEM238" name="Id" type="bigint" type-id="MsSql.bigint" type-size="" foreign-key="false" primary-key="true" nullable="false" description="Primary key of Registration record" default-value="" auto-increment="true" creation-date="08/17/2021 09:27:33" />
                   <attribute uid="a1767a774d3ed49f7bf7f6b697d958d9c422" cid="ELEM238" name="Id" type="bigint" type-id="MsSql.bigint" type-size="" foreign-key="false" primary-key="true" nullable="false" description="Primary key of Registration record" default-value="" auto-increment="true" creation-date="08/17/2021 09:27:33" />
                   <attribute uid="afb4231a7494547d781d070ff32800205191" cid="ELEM241" name="PSInstance" type="varchar" type-id="MsSql.varchar" type-size="100" foreign-key="false" primary-key="false" nullable="true" description="Process server instance identifier" default-value="" auto-increment="false" creation-date="08/17/2021 09:30:33" />
                   <attribute uid="afb4231a7494547d781d070ff32800205191" cid="ELEM241" name="PSInstance" type="varchar" type-id="MsSql.varchar" type-size="100" foreign-key="false" primary-key="false" nullable="true" description="Process server instance identifier" default-value="" auto-increment="false" creation-date="08/17/2021 09:30:33" />
                   <attribute uid="a2428945f5b7f4db8be24fcfc69e0a2d9529" cid="ELEM245" name="LocationIP" type="varchar" type-id="MsSql.varchar" type-size="100" foreign-key="false" primary-key="false" nullable="true" description="Process server instance identifier" default-value="" auto-increment="false" creation-date="08/17/2021 09:47:08" />
                   <attribute uid="a2428945f5b7f4db8be24fcfc69e0a2d9529" cid="ELEM245" name="LocationIP" type="varchar" type-id="MsSql.varchar" type-size="100" foreign-key="false" primary-key="false" nullable="true" description="Process server instance identifier" default-value="" auto-increment="false" creation-date="08/17/2021 09:47:08" />
+                  <attribute uid="a4af362de9c694cbdb2d4a990400fa7e3415" cid="EA247" name="PoolSize" type="int" type-id="MsSql.int" type-size="" foreign-key="false" primary-key="false" nullable="false" description="Defines how many documents can be reserved for processing at once." default-value="0" auto-increment="false" creation-date="12/22/2021 08:56:53" />
+                  <attribute uid="a2d70f289a93d44b596dd0cb2e6cbe7ac430" cid="EA248" name="Denided" type="bit" type-id="MsSql.bit" type-size="" foreign-key="false" primary-key="false" nullable="false" description="Defines if instance is denided to connect" default-value="0" auto-increment="false" creation-date="12/22/2021 08:56:58" />
                   <attribute uid="a43ee7873d3ad4cb0ab9dd2d18082ee72109" cid="ELEM242" name="LastActivity" type="datetime" type-id="MsSql.datetime" type-size="" foreign-key="false" primary-key="false" nullable="true" description="Timestamp latest activity" default-value="" auto-increment="false" creation-date="08/17/2021 09:30:33" />
                   <attribute uid="a43ee7873d3ad4cb0ab9dd2d18082ee72109" cid="ELEM242" name="LastActivity" type="datetime" type-id="MsSql.datetime" type-size="" foreign-key="false" primary-key="false" nullable="true" description="Timestamp latest activity" default-value="" auto-increment="false" creation-date="08/17/2021 09:30:33" />
                   <attribute uid="a561e1497aa4b46468e856418d9c2c20a879" cid="ELEM243" name="DocumentProcessedCnt" type="int" type-id="MsSql.int" type-size="" foreign-key="false" primary-key="false" nullable="false" description="# of new processed documents" default-value="" auto-increment="false" creation-date="08/17/2021 09:32:33" />
                   <attribute uid="a561e1497aa4b46468e856418d9c2c20a879" cid="ELEM243" name="DocumentProcessedCnt" type="int" type-id="MsSql.int" type-size="" foreign-key="false" primary-key="false" nullable="false" description="# of new processed documents" default-value="" auto-increment="false" creation-date="08/17/2021 09:32:33" />
                   <attribute uid="a16ba37593de641e0a1b3ed0644c19bd9880" cid="ELEM244" name="DocumentFailedCnt" type="int" type-id="MsSql.int" type-size="" foreign-key="false" primary-key="false" nullable="false" description="# of failed documents" default-value="" auto-increment="false" creation-date="08/17/2021 09:32:33" />
                   <attribute uid="a16ba37593de641e0a1b3ed0644c19bd9880" cid="ELEM244" name="DocumentFailedCnt" type="int" type-id="MsSql.int" type-size="" foreign-key="false" primary-key="false" nullable="false" description="# of failed documents" default-value="" auto-increment="false" creation-date="08/17/2021 09:32:33" />
@@ -3398,11 +3400,11 @@
                 <relation from="4629c8efe5764821a4f2ffb806413d2d" from-iid="a8224407a4be49b9a96cdea96c056054" to="e80985e7fce14193b34889876668ff81" to-iid="aed881e5e9074359a10bd1cac19d9d0e" to-field="a1037ef123e2f4e5bba8993964bafcb81218" />
                 <relation from="4629c8efe5764821a4f2ffb806413d2d" from-iid="a8224407a4be49b9a96cdea96c056054" to="e80985e7fce14193b34889876668ff81" to-iid="aed881e5e9074359a10bd1cac19d9d0e" to-field="a1037ef123e2f4e5bba8993964bafcb81218" />
               </item>
               </item>
               <item id="3a5d239825ed496b9e4a88608b4d49ba" iid="f83b50caf747406bac8a3fd15e53d170" creation-date="08/17/2021 09:26:32" order-index="64" type="entity">
               <item id="3a5d239825ed496b9e4a88608b4d49ba" iid="f83b50caf747406bac8a3fd15e53d170" creation-date="08/17/2021 09:26:32" order-index="64" type="entity">
-                <layout ax="3369" ay="1768" awidth="264" aheight="247" x="3369" y="1768" width="264" height="247" rotation-center="0,107.5" />
+                <layout ax="3369" ay="1768" awidth="264" aheight="276" x="3369" y="1768" width="264" height="247" rotation-center="0,107.5" />
                 <erd-entity show-nullability="true" show-description="true" />
                 <erd-entity show-nullability="true" show-description="true" />
               </item>
               </item>
               <item id="42f0a2f9fa4f4357aade2b5b1da1f821" iid="1bf79993c0b3444c9d3ec04a5998841c" creation-date="12/21/2021 14:38:05" order-index="65" type="relation">
               <item id="42f0a2f9fa4f4357aade2b5b1da1f821" iid="1bf79993c0b3444c9d3ec04a5998841c" creation-date="12/21/2021 14:38:05" order-index="65" type="relation">
-                <layout start-role-position="25,15" end-role-position="25,-15" line-style="oblique" lock-to-fields="true" auto-path="" x1="2981" y1="1774" x2="3369" y2="1854" start-border-pos="0.358076923076923" end-border-pos="0.913461538461538" start-local-pos="141" end-local-pos="86" name-position="0,20">
+                <layout start-role-position="25,15" end-role-position="25,-15" line-style="oblique" lock-to-fields="true" auto-path="" x1="2981" y1="1774" x2="3369" y2="1854" start-border-pos="0.358076923076923" end-border-pos="0.922554347826087" start-local-pos="141" end-local-pos="86" name-position="0,20">
                   <points>
                   <points>
                     <point x="2981" y="1774" />
                     <point x="2981" y="1774" />
                     <point x="3369" y="1854" />
                     <point x="3369" y="1854" />

+ 14 - 3
AppServer/Business/Mapper/MapperLong.cs

@@ -1,10 +1,8 @@
-using System;
-using System.Linq;
+using System.Linq;
 using BO.AppServer.Data.Entity;
 using BO.AppServer.Data.Entity;
 using BO.AppServer.Metadata.Dto;
 using BO.AppServer.Metadata.Dto;
 using BO.AppServer.Metadata.Enums;
 using BO.AppServer.Metadata.Enums;
 using Quadarax.Foundation.Core.Data.Interface.Entity;
 using Quadarax.Foundation.Core.Data.Interface.Entity;
-using Quadarax.Foundation.Core.Mapper;
 
 
 namespace BO.AppServer.Business.Mapper
 namespace BO.AppServer.Business.Mapper
 {
 {
@@ -97,6 +95,19 @@ namespace BO.AppServer.Business.Mapper
 
 
             });
             });
 
 
+
+            Define<RegistrationCDto, Registration>();
+            Define<RegistrationUDto, Registration>();
+            Define<Registration, RegistrationRDto>(builder =>
+            {
+                builder.Custom(dest => dest.Audit, src => new BoAuditTimestampDto()
+                {
+                    Created = src.Created,
+                    Changed = null,
+                });
+            });
+
+
         }
         }
         public void DefineBiDirection<TDao, TDto>() 
         public void DefineBiDirection<TDao, TDto>() 
             where TDao : class, IDao<long>, new()
             where TDao : class, IDao<long>, new()

+ 34 - 0
AppServer/Business/Services/RegistrationService.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Security.Principal;
+using BO.AppServer.Business.Services.Base;
+using BO.AppServer.Data.Repository;
+using BO.AppServer.Metadata.Configuration;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+
+namespace BO.AppServer.Business.Services
+{
+    public class RegistrationService : UserContextService
+    {
+
+        #region *** Private fields ***
+
+        private RegistrationRepo _repoRegistration;
+        #endregion
+
+        #region *** Constructors ***
+        public RegistrationService(
+            RegistrationRepo repoRegistration,
+            IOptions<Configuration> config,
+            UserRepo repoUser,
+            UserManager<IdentityUser> userManager,
+            IPrincipal currentPrincipal,
+            ILoggerFactory logger) : base(config, repoUser, userManager, currentPrincipal, logger)
+        {
+            _repoRegistration = repoRegistration ?? throw new ArgumentNullException(nameof(repoRegistration));
+        }
+        #endregion
+
+    }
+}

+ 2 - 0
AppServer/Data/Entity/BOContext.cs

@@ -775,6 +775,8 @@ namespace BO.AppServer.Data.Entity
                 entity.Property(e => e.DocumentFailedCnt).HasComment("# of failed documents");
                 entity.Property(e => e.DocumentFailedCnt).HasComment("# of failed documents");
 
 
                 entity.Property(e => e.DocumentProcessedCnt).HasComment("# of new processed documents");
                 entity.Property(e => e.DocumentProcessedCnt).HasComment("# of new processed documents");
+                entity.Property(e => e.PoolSize).HasComment("Defines how many documents can be reserved for processing at once.");
+                entity.Property(e => e.Denided).HasComment("Defines if instance is denided to connect.");
 
 
                 entity.Property(e => e.LastActivity)
                 entity.Property(e => e.LastActivity)
                     .HasColumnType("datetime")
                     .HasColumnType("datetime")

+ 2 - 0
AppServer/Data/Entity/Registration.cs

@@ -15,6 +15,8 @@ namespace BO.AppServer.Data.Entity
         // public long Id { get; set; }
         // public long Id { get; set; }
         public string Psinstance { get; set; }
         public string Psinstance { get; set; }
         public string LocationIp { get; set; }
         public string LocationIp { get; set; }
+        public int PoolSize { get; set; }
+        public bool Denided { get; set; }
         public DateTime? LastActivity { get; set; }
         public DateTime? LastActivity { get; set; }
         public int DocumentProcessedCnt { get; set; }
         public int DocumentProcessedCnt { get; set; }
         public int DocumentFailedCnt { get; set; }
         public int DocumentFailedCnt { get; set; }

+ 1 - 3
AppServer/Metadata/Dto/BoAuditDto.cs

@@ -3,10 +3,8 @@ using System.Text;
 
 
 namespace BO.AppServer.Metadata.Dto
 namespace BO.AppServer.Metadata.Dto
 {
 {
-    public class BoAuditDto : Dto
+    public class BoAuditDto : BoAuditTimestampDto
     {
     {
-        public DateTime Created { get; set; }
-        public DateTime? Changed { get; set; }
         public string CreatedBy { get; set; }
         public string CreatedBy { get; set; }
         public string ChangedBy { get; set; }
         public string ChangedBy { get; set; }
 
 

+ 10 - 0
AppServer/Metadata/Dto/BoAuditTimestampDto.cs

@@ -0,0 +1,10 @@
+using System;
+
+namespace BO.AppServer.Metadata.Dto
+{
+    public class BoAuditTimestampDto : Dto
+    {
+        public DateTime Created { get; set; }
+        public DateTime? Changed { get; set; }
+    }
+}

+ 10 - 0
AppServer/Metadata/Dto/EmptyDto.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BO.AppServer.Metadata.Dto
+{
+    class EmptyDto
+    {
+    }
+}

+ 53 - 0
AppServer/Metadata/Dto/RegistrationDto.cs

@@ -0,0 +1,53 @@
+using System;
+using Quadarax.Foundation.Core.Data.Interface.Entity;
+
+namespace BO.AppServer.Metadata.Dto
+{
+
+    #region *** Registration - Base ***
+
+    public class RegistrationBaseDto : BoDto
+    {
+        public string Psinstance { get; set; }
+        public string LocationIp { get; set; }
+        public int PoolSize { get; set; }
+    }
+
+    #endregion
+
+    #region *** Registration - Create ***
+
+    public class RegistrationCDto : RegistrationBaseDto, ICreateDto
+    {
+    }
+
+    #endregion
+
+    #region *** Registration - Update ***
+
+    public class RegistrationUDto : RegistrationBaseDto, IUpdateDto
+    {
+    }
+
+    #endregion
+
+    #region *** Registration - Read ***
+
+    public class RegistrationRDto : RegistrationBaseDto, IReadDto
+    {
+        public BoAuditTimestampDto Audit { get; set; }
+        public DateTime? LastActivity { get; set; }
+        public int DocumentProcessedCnt { get; set; }
+        public int DocumentFailedCnt { get; set; }
+    }
+
+    #endregion
+
+    #region *** Registration - Delete ***
+
+    internal class RegistrationDDto : BoDto, IDeleteDto
+    {
+    }
+
+    #endregion
+}

+ 109 - 3
AppServer/Web/Services/PS.cs

@@ -1,10 +1,116 @@
-using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Threading.Tasks;
+using BO.AppServer.Business.Services;
+using BO.AppServer.Metadata.Dto;
+using BO.AppServer.Metadata.Enums;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Quadarax.Foundation.Core.Data.Interface.Entity.Dto;
 
 
 namespace BO.AppServer.Web.Services
 namespace BO.AppServer.Web.Services
 {
 {
+    [Authorize]
     [Route("api/[controller]")]
     [Route("api/[controller]")]
     [ApiController]
     [ApiController]
-    public class PS : ControllerBase
-    {
+    public class PS : Base<PS>
+    {
+        #region *** Properties ***
+        protected override RoleEnum LoginRoleAllowed => RoleEnum.System;
+        #endregion
+
+        #region *** Private fields ***
+        private DocumentService _srvDocument;
+        #endregion
+
+        #region *** Constructors ***
+
+        public PS(ILoggerFactory logger, AccessService srvAccess) : base(logger, srvAccess)
+        {
+        }
+        #endregion
+
+        #region *** Registrations ***
+        [HttpPost("{ticket}/register")]
+        public async Task<ResultValueDto<RegistrationRDto>> Register(string ticket, [FromBody] RegistrationCDto registration)
+        {
+            CheckAccess(ticket);
+            //return await Call(async () => await _srvUsers.CreateUserAsync(user));
+            return null;
+        }
+
+        [HttpPatch("{ticket}/register")]
+        public async Task<ResultValueDto<RegistrationRDto>> Register(string ticket, [FromBody] RegistrationUDto registration)
+        {
+            CheckAccess(ticket);
+            //return await Call(async () => await _srvUsers.CreateUserAsync(user));
+            return null;
+        }
+        #endregion
+
+        #region *** Document gathering ***
+        [HttpGet("{ticket}/ps/{registrationId}/new")]
+        public async Task<ResultsValueDto<DocumentRDto>> GetQueueNew(string ticket, long registrationId)
+        {
+            CheckAccess(ticket);
+            //return await Call(async () => await _srvUsers.CreateUserAsync(user));
+            return null;
+        }
+        [HttpGet("{ticket}/ps/{registrationId}/pending")]
+        public async Task<ResultsValueDto<DocumentRDto>> GetQueuePending(string ticket, long registrationId)
+        {
+            CheckAccess(ticket);
+            //return await Call(async () => await _srvUsers.CreateUserAsync(user));
+            return null;
+        }
+
+        [HttpGet("{ticket}/ps/{registrationId}/document/{documentId}/artifact/{artifactId}")]
+        public async Task<IActionResult> GetDocumentArtifactContent(string ticket, long documentId, long artifactId)
+        {
+            // TODO: May wrap to better way
+            try
+            {
+                CheckAccess(ticket);
+                //var id = await _srvWorkspace.GetWorkspaceIdByAPIAccess(wrkspApiKey, apiKeyPassword, context);
+                //var content = await _srvDocument.GetArtifactAsync(id, documentId, artifactId);
+                //return new FileStreamResult(content.Item1, content.Item2);
+                return null;
+            }
+            catch (Exception e)
+            {
+                return Problem(e.Message);
+            }
+        }
+
+        #endregion
+
+        #region *** Document state operations ***
+        [HttpPatch("{ticket}/ps/{registrationId}/document/{documentId}/status")]
+        public async Task<ResultValueDto<EmptyDto>> SetDocumentProcessingStatus(string ticket, long registrationId, long documentId)
+        {
+            CheckAccess(ticket);
+            //return await Call(async () => await _srvUsers.CreateUserAsync(user));
+            return null;
+        }
+
+        [HttpPatch("{ticket}/ps/{registrationId}/document/{documentId}/free")]
+        public async Task<ResultsValueDto<EmptyDto>> SetFreeDocument(string ticket, long registrationId, long documentId)
+        {
+            CheckAccess(ticket);
+            //return await Call(async () => await _srvUsers.CreateUserAsync(user));
+            return null;
+        }
+        #endregion
+
+        #region *** Document uploading ***
+        [HttpPatch("{ticket}/ps/{registrationId}/document/{documentId}")]
+        public async Task<ResultValueDto<DocumentRDto>> UploadDocumentArtifact(string ticket, long registrationId, long documentId, [FromBody] ArtifactCDto artifact, IFormFile content)
+        {
+            CheckAccess(ticket);
+            //return await Call(async () => await _srvUsers.CreateUserAsync(user));
+            return null;
+        }
+        #endregion
     }
     }
 }
 }

+ 2 - 0
Console/Scripts/bo_create_schema.sql

@@ -1086,6 +1086,8 @@ CREATE TABLE [dbo].[Registration]
     [Id] [bigint] NOT NULL IDENTITY (1, 1),
     [Id] [bigint] NOT NULL IDENTITY (1, 1),
     [PSInstance] [varchar] (100) NULL,
     [PSInstance] [varchar] (100) NULL,
     [LocationIP] [varchar] (100) NULL,
     [LocationIP] [varchar] (100) NULL,
+	[PoolSize] [int] NOT NULL DEFAULT (0),
+	[Denided] [bit] NOT NULL DEFAULT (0),
     [LastActivity] [datetime] NULL,
     [LastActivity] [datetime] NULL,
     [DocumentProcessedCnt] [int] NOT NULL,
     [DocumentProcessedCnt] [int] NOT NULL,
     [DocumentFailedCnt] [int] NOT NULL,
     [DocumentFailedCnt] [int] NOT NULL,