asadullahrifat89 / readme-test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ecap-server-core-backendframework-netcore

Backbone of selise in-house .net core framework
Build your own ECAP Microservices



Need anything? Swagger / Request Feature or Report bug

Table of Contents

Introduction

Some introduction of backend ecap-server-core-backendframework-netcore will be provided here.

Ecosystem

Nuget Status Description
Selise.Ecap.Framework Selise.Ecap.Framework-Status Framework for CommandHandlers, EventHandlers, Repository etc
Selise.Ecap.WepApi.Netcore Selise.Ecap.WepApi.Netcore-Status WebApi project dependency
Selise.Ecap.Hosting Selise.Ecap.Hosting-Status Background service dependency
Selise.Ecap.RowLevelSecurity Selise.Ecap.RowLevelSecurity-Status Use to maintain RowLevelSecurity
Selise.Ecap.Bus.Esb Selise.Ecap.Bus.Esb-Status English framework support

Prerequisite

To install the first nuget go to the WebService project of you solution and go to the Nuget Manager. Install the following Nuget

$ Install nuget Selise.Ecap.WebApi.NetCore

The go to the Background service project of you solution and go to the Nuget Manager. Install the following Nuget

$ Install nuget Selise.Ecap.Hosting

Finally, go to the Services project of you solution and go to the Nuget Manager. Install the following Nuget

$ Install nuget Selise.Ecap.Framework

After installing the dependencies above go to the Usage section

Usage

Step 1: Initialize your WebService project with boilerplate code inside the Main method of Program.cs

var ecapWebApiPipelineBuilderOptions = new EcapWebApiPipelineBuilderOptions
            {
                UseFileLogging = true,
                UseConsoleLogging = true,
                CommandLineArguments = args,
                UseAuditLoggerMiddleware = true,
                AddApplicationServices = AddApplicationServices,
                UseJwtBearerAuthentication = true,
                AddRequiredQueues = AddRequiredQueues,
                AddRequiredExchanges = AddRequiredExchanges
            };

            ecapWebApiPipelineBuilderOptions.AddRoutes = (appSettings, routeBuilder) =>
            {
                routeBuilder.MapRoute("Default", $"{appSettings.ServiceName}" + "/{controller}/{action}/{id?}");
            };

            var webHostBuilder = EcapWebApiPipelineBuilder.BuildEcapWebApiPipeline(ecapWebApiPipelineBuilderOptions);

            await webHostBuilder.Build().RunAsync();

Step 2: Add these methods inside the WebService Program.cs file

private static IEnumerable<string> AddRequiredExchanges(IAppSettings appSettings)
        {
            return EventExchanges.GetExchangeNames();
        }

        private static IEnumerable<string> AddRequiredQueues(IAppSettings appSettings)
        {
            return new[] { ... };
        }

        private static void AddApplicationServices(IServiceCollection serviceCollection, IAppSettings appSettings)
        {
            serviceCollection.RegisterCollection(typeof(ICommandHandler<,>), new[] { typeof(...).Assembly });
        }

Step 3: Initialize the Background service in a similar fasion

 public static async Task Main(string[] args)
        {
            var rabbitMqHostBuilderOptions = new RabbitMqHostBuilderOptions
            {
                UseFileLogging = true,
                UseConsoleLogging = true,
                CommandLineArguments = args,
                AddApplicationServices = AddApplicationServices,
                AddAmpqMessageConsumerOptions = (appSettings) =>
                {
                    var ampqMessageConsumerOptions = new AmpqMessageConsumerOptions();

                    ampqMessageConsumerOptions.ConsumerSubscriptions.ListenOn(..., 5);

                    return ampqMessageConsumerOptions;
                }
            };

            var hostBuilder = RabbitMqHostBuilder.BuildRabbitMqHost(rabbitMqHostBuilderOptions);

            await hostBuilder.Build().RunAsync();
        }

        private static void AddApplicationServices(IServiceCollection serviceCollection, IAppSettings appSettings)
        {
            serviceCollection.RegisterCollection(typeof(ICommandHandler<,>), new[] { typeof(...).Assembly });
        }

Documentation

Swagger Documentation https://api-documentation.selise.biz/

Changelog

Detailed changes for each release are documented in the release notes.

Authors

License

Secure Link Service Ltd

Copyright (c) 2012-present, SELISE

About

License:Other