Coder Social home page Coder Social logo

Comments (11)

 avatar commented on May 23, 2024 2

Yes it's working. Thanks

from beatpulse.

lurumad avatar lurumad commented on May 23, 2024 1

Hi @sorcer1

Yes, we have an issue in BeatPulse, because we haven't parametrized LivenessDb context constructor. So you are register another DbContext and the error is clear.

public LivenessDb(DbContextOptions options) : base(options) { }

Should be

public LivenessDb(DbContextOptions<LivenessDb> options) : base(options) { }

We are going to fix it!

from beatpulse.

unaizorrilla avatar unaizorrilla commented on May 23, 2024

Hi @sorcer1

Are you trying to enable UI in your Web API? ( UI is intended to be a different project)
You need also UseBeatPulseUI in your Configure method.

Can you post your code on a gist in order to check? or sendus a copy, git uri etc..

from beatpulse.

 avatar commented on May 23, 2024

Yes, i want to have UI in my Web API.

The UseBeatPulseUI is already in my Configure method.
The UI is shown but with an error : Could not retrieve liveness data

from beatpulse.

lurumad avatar lurumad commented on May 23, 2024

Hi @sorcer1 ,

Can you share with us your Startup.cs?

Regards!

from beatpulse.

unaizorrilla avatar unaizorrilla commented on May 23, 2024

Hi @sorcer1

I create a sample app with your scenario and is working, can you send me a repro of the problem?

from beatpulse.

 avatar commented on May 23, 2024
using BeatPulse;
using BeatPulse.UI;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using MovieSystem.Api.Core.Extensions;
using MovieSystem.Api.Core.Middlewares;
using MovieSystem.Api.Core.Swagger;
using MovieSystem.Infrastructures.Interfaces;
using MovieSystem.Infrastructures.Security;
using MovieSystem.Server.Config;
using MovieSystem.Server.Config.Interfaces;
using MovieSystemV4.Data;
using MovieSystemV4.Data.Interfaces;
using MovieSystemV4.Data.Models;
using MovieSystemV4.Repositories;
using MovieSystemV4.Repositories.Interfaces;
using MovieSystemV4.Services;
using MovieSystemV4.Services.Interfaces;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace MovieSystemV4.Api
{
    public class Startup
    {
        public static IHostingEnvironment HostingEnvironment;

        public Startup(IHostingEnvironment hostingEnvironment)
        {
            HostingEnvironment = hostingEnvironment;
        }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOptions();

            // Configure health checks
            ConfigureHealthChecks(services);

            // Configures the service authentification
            ConfigureServiceAuthentication(services);

            // Config the database context
            ConfigureServiceDbContext(services);

            // Add services by Dependency Injection
            ConfigureServicesByDependencyInjection(services);

            // Add CORS to enable security
            services.AddCors();

            // Config compression for https
            services.AddResponseCompression(options => { options.EnableForHttps = true; });

            // Config the cache
            ConfigureCache(services);

            services.AddMvc()
                // Add JSON options to MVC rendering
                .AddJsonOptions(jsonOptions =>
                {
                    jsonOptions.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                    jsonOptions.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                });
                
            // Configure API Versioning
            ConfigureApiVersioning(services);

            // TODO : ajout de la gestion des profils 
            // x-profile-id: 50

            // Configure swagger api documentation
            ConfigureSwagger(services);
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            app.UseBeatPulseUI();

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

            if (HostingEnvironment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            // Enable middleware to serve generated Swagger as a JSON endpoint
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "MOVIESYSTEM API V1");
                c.DocumentTitle = "MovieSystem API Documentation";
            });

            app.UseAuthentication();
            app.UseResponseCompression();
            app.UseRequestResponseLogging();
            app.UseMvc();
        }

        private static void ConfigureSwagger(IServiceCollection services)
        {
           //...
        }

        private static void ConfigureApiVersioning(IServiceCollection services)
        {
           //...
        }

        private static void ConfigureServiceDbContext(IServiceCollection services)
        {
            //...
        }

        private static void ConfigureCache(IServiceCollection services)
        {
            //...
        }

        private static void ConfigureHealthChecks(IServiceCollection services)
        {
            services.AddBeatPulseUI();

            services.AddBeatPulse(setup =>
            {
                setup.AddSqlServer("myConnectionString");
            });
        }

        private static void ConfigureServiceAuthentication(IServiceCollection services)
        {
           //...
        }

        private static void ConfigureServicesByDependencyInjection(IServiceCollection services)
        {
            //...
        }
    }
}

from beatpulse.

 avatar commented on May 23, 2024

More details about the error :

MovieSystemV4.Api> [14:20:43 ERR] Connection id "0HLEGBRB1HRQM", Request id "0HLEGBRB1HRQM:00000002": An unhandled exception was thrown by the application.
MovieSystemV4.Api> System.InvalidOperationException: The DbContextOptions passed to the LivenessDb constructor must be a DbContextOptions<LivenessDb>. When registering multiple DbContext types make sure that the constructor for each context type has a DbContextOptions<TContext> parameter rather than a non-generic DbContextOptions parameter.
MovieSystemV4.Api>    at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
MovieSystemV4.Api>    at lambda_method(Closure , ServiceProviderEngineScope )
MovieSystemV4.Api>    at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
MovieSystemV4.Api>    at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
MovieSystemV4.Api>    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
MovieSystemV4.Api>    at BeatPulse.UI.Middleware.UIApiEndpointMiddleware.InvokeAsync(HttpContext context, IServiceScopeFactory serviceScopeFactory)
MovieSystemV4.Api>    at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
MovieSystemV4.Api>    at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
MovieSystemV4.Api>    at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext)
MovieSystemV4.Api>    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

from beatpulse.

 avatar commented on May 23, 2024

good

from beatpulse.

lurumad avatar lurumad commented on May 23, 2024

Fixed!

Version 2.1.1 BeatPulseUI.

from beatpulse.

unaizorrilla avatar unaizorrilla commented on May 23, 2024

@sorcer1 Is working?

from beatpulse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.