Пример #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory
                              , Microsoft.Extensions.Hosting.IHostApplicationLifetime appLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }



            app.UseHttpsRedirection();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areaRoutev1",
                    template: "{area=v1}/api/{controller=Home}/{action=Get}/{id?}");

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Test API V1");
            });
        }
Пример #2
0
        private void WaitForDBInit(string connectionString, Microsoft.Extensions.Hosting.IHostApplicationLifetime lifetime = null)
        {
            var connection = new MySqlConnection(connectionString);
            int retries    = 1;

            while (retries < 7)
            {
                try
                {
                    Console.WriteLine("Connecting to db. Trial: {0}", retries);
                    connection.Open();
                    connection.Close();
                    break;
                }
                catch (MySqlException e)
                {
                    Console.WriteLine(e.StackTrace);
                    Thread.Sleep((int)Math.Pow(2, retries) * 1000);
                    Console.WriteLine("retrying");
                    retries++;
                }
            }
            if (retries >= 7 && lifetime != null)
            {
                lifetime.StopApplication();
            }
        }
Пример #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.Extensions.Hosting.IHostApplicationLifetime lifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Example.Akka v1"));
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            lifetime.ApplicationStarted.Register(() =>
            {
                app.ApplicationServices.GetService <ActorSystem>(); // start Akka.NET
            });
            lifetime.ApplicationStopping.Register(() =>
            {
                app.ApplicationServices.GetService <ActorSystem>().Terminate().Wait();
            });
        }
Пример #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.Extensions.Hosting.IHostApplicationLifetime appLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor |
                                   ForwardedHeaders.XForwardedProto
            });

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            //REFERENCIA A INTERFACE DE "ServiceContract -> IIntegracaoService" PARA QUE SEJA REFLETIDA COMO SERVIÇOS EM SOAP.
            app.UseSoapEndpoint <IIntegracaoService>("/Integrador.asmx", new BasicHttpBinding(), SoapSerializer.XmlSerializer);
            app.UseSoapEndpoint <IServidorService>("/Servidor.asmx", new BasicHttpBinding(), SoapSerializer.XmlSerializer);
        }
Пример #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.Extensions.Hosting.IHostApplicationLifetime hostApplicationLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGrpcService <LogService>();

                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
                });
            });

            // アプリケーション開始時にLogServiceの初期処理(RabbitMQの接続処理)
            hostApplicationLifetime.ApplicationStarted.Register(() =>
            {
                LogService.Init();
            });

            // アプリケーション終了時にLogServiceの後処理(RabbitMQの切断処理)
            hostApplicationLifetime.ApplicationStopping.Register(() =>
            {
                LogService.ShutdownRabbitMQ();
            });
        }
Пример #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              IApplicationLifetime applicationLifetime,
                              ILogger <Startup> logger,
                              IRedisContext redis)
        {
            _logger = logger;
            _redis  = redis;
            app.UseCors(x =>
            {
                x.AllowAnyHeader();
                x.AllowAnyMethod();
                x.WithOrigins(
                    "http://localhost:8081",
                    "http://localhost:8082",
                    "http://localhost:8083",
                    "http://localhost:8084",
                    "app://."
                    );
                x.AllowCredentials();
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseHangfireDashboard("/job");
            app.UseHangfireServer(new BackgroundJobServerOptions
            {
                ServerName = "docker ui job server"
            });

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapHub <BaseHub>("/pull");
            });

            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("../swagger/v1/swagger.json", "Docker Gui V1");
            });
            if (applicationLifetime == null)
            {
                throw new Exception("applicationLifetime do not null");
            }
            applicationLifetime.ApplicationStarted.Register(OnStarted);
            applicationLifetime.ApplicationStopped.Register(OnStopped);
        }
Пример #7
0
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              ILoggerFactory loggerFctory,
                              Microsoft.Extensions.Hosting.IHostApplicationLifetime applicationLifetime)
        {
            app.UseCors("AllowAll");
#pragma warning disable MVC1005 // Cannot use UseMvc with Endpoint Routing.
            app.UseMvc();
#pragma warning restore MVC1005 // Cannot use UseMvc with Endpoint Routing.

            applicationLifetime.ApplicationStopped.Register(() => container.Dispose());
        }
Пример #8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStatusCodePagesWithReExecute("/NotFound", "?statusCode={0}");

            app.UseStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                // endpoints.MapControllers();
                endpoints.MapRazorPages();

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");

                endpoints.MapHub <LogHub>("/loghub");

                // endpoints.MapFallbackToController("Index", "Home");
            });

            app.Use(async(context, next) =>
            {
                var url = context.Request.Path.Value ?? "";
                if (url.ToLower().EndsWith("/home"))
                {
                    context.Response.Redirect("/");
                    return;
                }

                await next();
            });

            appLifetime.ApplicationStarted.Register(() => {
                Settings.GetSettings().AppUrl = app.ServerFeatures.Get <IServerAddressesFeature>().Addresses.ToList().First();
                if (Settings.GetSettings().AppSettings.OpenBrowserOnLaunch)
                {
                    UrlOpener.Open(Settings.GetSettings().AppUrl);
                }
            });
        }
Пример #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              Microsoft.Extensions.Hosting.IHostApplicationLifetime lifetime)
        {
            if (env.IsDevelopment())
            {
                //app.UseDeveloperExceptionPage();
            }

            //global error handler
            app.UseExceptionHandler(a => a.Run(async context =>
            {
                var exceptionHandlerPathFeature = context.Features.Get <Microsoft.AspNetCore.Diagnostics.IExceptionHandlerPathFeature>();
                var exception = exceptionHandlerPathFeature.Error;

                var result = System.Text.Json.JsonSerializer.Serialize(new { error = "unhandled exception" });
                if (env.IsDevelopment())
                {
                    result = System.Text.Json.JsonSerializer.Serialize(new { error = exception.Message });
                }
                context.Response.ContentType = "application/json";

                context.Response.StatusCode = 500;
                await context.Response.Body.WriteAsync(System.Text.Encoding.ASCII.GetBytes(result));
            }));

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            if (Configuration["init"] != "true")
            {
                return;
            }

            //run via --init, so we init db and exit
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetRequiredService <PatientContext>();
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
            }
            lifetime.StopApplication();
        }
Пример #10
0
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.Extensions.Hosting.IHostApplicationLifetime lifetime,
                       IPipeline pipeline)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     app.UseRouting();
     app.UseEndpoints(endpoints =>
     {
         endpoints.MapGrpcService <StorageService>();
     });
     UpdateDatabase(app);
     pipeline.Open();
 }
Пример #11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.Extensions.Hosting.IHostApplicationLifetime lifetime)
        {
            lifetime.ApplicationStopping.Register(OnShutdown);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub <CollierHub>("/miner");
            });
        }
Пример #12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              Microsoft.Extensions.Hosting.IHostApplicationLifetime applicationLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseCors("AllowFromAll");
            //#if (AddSwagger)
            app.UseSwagger();

            app.UseReDoc(c =>
            {
                c.RoutePrefix = "swagger";
            });
            //#endif

            //#if (AddSerilog)
            app.UseSerilogRequestLogging();
            //#endif

            app.UseHttpsRedirection();

            //#if (AddPromethus)
            app.UseMetricServer();
            //#endif
            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                //#if (AddHealthCheck)
                // for doing deep health check
                endpoints.MapHealthChecks("/health", new HealthCheckOptions()
                {
                    ResponseWriter = WriteResponse
                });
                // for doing only basic health check
                endpoints.MapHealthChecks("/liveness", new HealthCheckOptions()
                {
                    Predicate = r => r.Name.Contains("self")
                });
                //#endif
            });
        }
Пример #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.Extensions.Hosting.IHostApplicationLifetime lifetime)
        {
            try {
                app.ApplicationServices.GetService(typeof(RedirectService));
            }
            catch (MongoDB.Driver.MongoConfigurationException)
            {
                lifetime.StopApplication();
            }
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });
        }
Пример #14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.Extensions.Hosting.IHostApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();
            app.UseAuthorization();

            applicationLifetime.ApplicationStarted.Register(OnApplicationStarted);
            applicationLifetime.ApplicationStopping.Register(OnApplicationStopping);
            applicationLifetime.ApplicationStopped.Register(OnApplicationStopped);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Пример #15
0
    public void Configure(IApplicationBuilder app, Microsoft.Extensions.Hosting.IHostApplicationLifetime lifeTime)
    {
        var serverAddressesFeature =
            app.ServerFeatures.Get <IServerAddressesFeature>();

        app.UseStaticFiles();

        app.Run(async(context) =>
        {
            context.Response.ContentType = "text/html";
            string url      = context.Request.GetDisplayUrl();
            Uri response    = new Uri(url);
            string query    = response.Query;
            string htmlFile = "%RESPONSE%";
            try
            {
                htmlFile = System.IO.File.ReadAllText("index.html");
            }
            catch (Exception)
            {
            }

            if (query.StartsWith("?code="))
            {
                bool success = await Server.RequestToken(query);
                if (success)
                {
                    await context.Response.WriteAsync(htmlFile.Replace("%RESPONSE%", "<span>Authorization Complete!</span><h3>Return to 3ds Max to begin your export!</h3>"));
                }
                else
                {
                    await context.Response.WriteAsync(htmlFile.Replace("%RESPONSE%", "<h2>Authorization Denied!</h2>"));
                }
            }
            else
            {
                await context.Response.WriteAsync(htmlFile.Replace("%RESPONSE%", "<h2>Authorization Denied!</h2>"));
            }

            lifeTime.StopApplication();
        });
    }
Пример #16
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApplicationLifetime applicationLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();
            app.UseErrorHandler();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
            SeedData(app);
            applicationLifetime.ApplicationStopped.Register(() => Conteiner.Dispose());
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.Extensions.Hosting.IHostApplicationLifetime appLifetime)
        {
            TrackingCircuitHandler.Instance.AppLifetime = appLifetime;
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            //app.UseHttpsRedirection();
            app.UseStaticFiles();

            //Tips: for embedded mode
            var ass = Assembly.GetEntryAssembly();
            var resourceAssemblyName = ass.GetName().Name;

            app.UseStaticFiles(new StaticFileOptions
            {
                //[Tips] resourceAssemblyName is something like project name?
                FileProvider = new EmbeddedFileProvider(ass, $"{resourceAssemblyName}.wwwroot"),
                RequestPath  = "/embeded"
            }
                               );

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
            });

            appLifetime.ApplicationStarted.Register(() => OpenBrowser(
                                                        app.ServerFeatures.Get <Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature>().Addresses.First()));
        }
Пример #18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.Extensions.Hosting.IHostApplicationLifetime applicationLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            Program.ApplicationLifetime = applicationLifetime;

            app.UseHttpsRedirection();

            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(
                    Path.Combine(env.ContentRootPath, "replays")),
                RequestPath = "/replays"
            });

            app.UseRouting();

            // global cors policy
            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            app.UseAuthentication();
            app.UseAuthorization();

            //add the Swagger generator and the Swagger UI middle wares
            app.UseOpenApi();
            app.UseSwaggerUi3();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Пример #19
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, Microsoft.Extensions.Hosting.IHostApplicationLifetime appLifetime)
        {
            if (_env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "api/{controller=Home}/{action=Index}/{id?}");
            });

            appLifetime.ApplicationStopped.Register(() => ApplicationContainer.Dispose());
        }
        //public void ConfigureContainer(ContainerBuilder builder)
        //{
        //    //添加依赖注入关系
        //    builder.RegisterModule(new AutofacModuleRegister());
        //    var controllerBaseType = typeof(ControllerBase);
        //    //在控制器中使用依赖注入
        //    builder.RegisterAssemblyTypes(typeof(Program).Assembly)
        //        .Where(t => controllerBaseType.IsAssignableFrom(t) && t != controllerBaseType)
        //        .PropertiesAutowired();
        //}
        //public void ConfigureContainer(ContainerBuilder builder)
        //{
        //    var serviceAssembly = Assembly.Load("LZ.Service");
        //    builder.RegisterAssemblyTypes(serviceAssembly).Where(o => o.Name.Contains("Service")).AsImplementedInterfaces().PropertiesAutowired();
        //    var repositoryAssembly = Assembly.Load("LZ.Repository");
        //    builder.RegisterAssemblyTypes(repositoryAssembly).Where(o => o.Name.Contains("Repository")).AsImplementedInterfaces().PropertiesAutowired();
        //    //builder.RegisterAssemblyTypes(typeof(Program).Assembly).
        //    //    Where(x => x.Name.EndsWith("service", StringComparison.OrdinalIgnoreCase)).AsImplementedInterfaces();
        //    //builder.Register(c => new TokenAuthorizeAttribute(c.Resolve<IUserRoleActionAuthorityRepository>(), c.Resolve<IUserRepository>(), c.Resolve<IRoleViewService>())).InstancePerRequest().PropertiesAutowired();

        //    //    builder.RegisterAssemblyTypes(typeof(Program).Assembly).
        //    //Where(x => x.Name.EndsWith("service", StringComparison.OrdinalIgnoreCase)).AsImplementedInterfaces();
        //    //    builder.RegisterDynamicProxy();

        //    //    builder.RegisterAssemblyTypes(this.GetType().Assembly)
        //    //.AsImplementedInterfaces()
        //    //.PropertiesAutowired();
        //}
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHost host, Microsoft.Extensions.Hosting.IHostApplicationLifetime appLitetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseRouting();

            app.UseCors("default");//跨域管道

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

            appLitetime.ApplicationStopped.Register(() => { AutofacContainer.Dispose(); });
        }
Пример #21
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, Microsoft.Extensions.Hosting.IHostApplicationLifetime applicationLifetime)
        {
            loggerFactory.AddLog4Net();

            app.UseMiddleware <ErrorHandlerMiddleware>();
            app.UseMiddleware <LoggingMiddleware>();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            app.UseResponseCompression();
            app.UseHttpsRedirection();
            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/BlotterAPISpec/swagger.json", "Blotter API");
                options.RoutePrefix = string.Empty;
            });

            //app.UseExceptionHandler(errorApp =>
            //{
            //    errorApp.Run(async context =>
            //    {
            //        context.Response.StatusCode = 500; // or another Status accordingly to Exception Type
            //        context.Response.ContentType = "application/json";

            //        var error = context.Features.Get<IExceptionHandlerFeature>();
            //        if (error != null)
            //        {
            //            var ex = error.Error;

            //            await context.Response.WriteAsync(new ErrorModel()
            //            {
            //                HttpStatusCode = 500,
            //                Message = ex.Message
            //            }.ToString(), Encoding.UTF8);
            //        }
            //    });
            //});



            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });


            //Task.Run(async () =>
            //{
            //    using (var client = new HttpClient())
            //    {
            //        client.BaseAddress = new Uri(Configuration.GetSection("BaseUrl").Value);
            //        var resp = await client.GetAsync("api/v1/healthcheck");
            //    }
            //});

            var scope = app.ApplicationServices.CreateScope();

            _autoSyncservice = scope.ServiceProvider.GetService <IAutoSyncService>();
            _autoSyncservice.StartAutoSyncFromSource();

            applicationLifetime.ApplicationStopping.Register(OnShutDown);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              Microsoft.Extensions.Hosting.IHostApplicationLifetime applicationLifetime,
                              IWebHostEnvironment env,
                              ILoggerFactory loggerFactory,
                              IConfiguration config)
        {
            // initialize logger
            loggerFactory.AddLog4Net();
            Forge.Logging.LogManager.LOGGER = Forge.Logging.Log4net.Log4NetManager.Instance;
            Forge.Logging.LogUtils.LogAll();
            LOGGER = LogManager.GetLogger(typeof(Startup));

            // bind configuration to POCO
            SesameConfiguration.Instance = config.GetSection("SesameConfiguration").Get <SesameConfiguration>();

            // create wcf binding and endpoint address
            ClientProxyBase.SourceId = ClientIdGenerator.GenerateId(ClientTypeEnum.External);
            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

            binding.Name                   = "TcpEndpoint";
            binding.OpenTimeout            = TimeSpan.FromMinutes(1);
            binding.CloseTimeout           = TimeSpan.FromMinutes(1);
            binding.ReceiveTimeout         = TimeSpan.FromMinutes(10);
            binding.SendTimeout            = TimeSpan.FromMinutes(10);
            binding.MaxBufferSize          = 2147483647;
            binding.MaxReceivedMessageSize = 2147483647;
            binding.TransferMode           = TransferMode.Buffered;
            binding.ReaderQuotas.MaxDepth  = 2147483647;
            binding.ReaderQuotas.MaxStringContentLength = 2147483647;
            binding.ReaderQuotas.MaxArrayLength         = 2147483647;
            binding.ReaderQuotas.MaxBytesPerRead        = 2147483647;
            binding.ReaderQuotas.MaxNameTableCharCount  = 2147483647;
            binding.Security.Mode = SecurityMode.None;
            binding.Security.Message.ClientCredentialType   = MessageCredentialType.None;
            binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;

            EndpointAddress endpoint = new EndpointAddress(SesameConfiguration.Instance.SesameServiceUrl);

            // initialize communication system
            ClientProxyBase.ConfigureClientProxyForCallback(new ConfigurationForCallback(binding, endpoint));
            ClientProxyBase.Faulted += ClientProxyBase_Faulted;
            try
            {
                ClientProxyBase.Open();
            }
            catch (Exception ex)
            {
                LOGGER.Error(string.Format("Failed to open connection. Reason: {0}", ex.Message));
                mFaultHandlerEvent.Set();
            }
            mFaultHandlerThread      = new Thread(new ThreadStart(FaultHandlerThreadMain));
            mFaultHandlerThread.Name = "FaultHandlerThread";
            mFaultHandlerThread.Start();

            // register shutdown
            applicationLifetime.ApplicationStopping.Register(OnShutdown);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }