public LoginViewModel() { //Login = new RelayCommand(LoginLocal); LoginCommand = new RelayCommand(DoLogin); CleanDBCommand = new RelayCommand(CleanDB); Init(); if (System.Diagnostics.Debugger.IsAttached) { SetPasswordAndUsername(); } _autoSyncService = ObjectFactory.GetInstance<IAutoSyncService>(); }
// 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); }