Base solution for your next web application

Activities of "SASIMEXICO"

Answer

Hi,

Yes, when disable Identity Server in appsettings.json it works correctly. But if I do this, I can't use Identity, no?

Thanks,

Question

Hi,

I have performed the steps indicated on the web (https://aspnetboilerplate.com/Pages/Documents/EF-Core-PostgreSql-Integration) to make the change to PosgreSql with version 4.8.1 so far everything is right. But when I login, I have an error -> MissingMethodException: Method not found: 'System.String IdentityModel.CryptoRandom.CreateUniqueId (Int32)'.

Error:

MissingMethodException: Method not found: 'System.String IdentityModel.CryptoRandom.CreateUniqueId(Int32)'. IdentityServer4.Services.DefaultUserSession.CreateSessionIdAsync(ClaimsPrincipal principal, AuthenticationProperties properties) System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<TStateMachine>(ref TStateMachine stateMachine) IdentityServer4.Services.DefaultUserSession.CreateSessionIdAsync(ClaimsPrincipal principal, AuthenticationProperties properties) IdentityServer4.Hosting.IdentityServerAuthenticationService.SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties) in IdentityServerAuthenticationService.cs Microsoft.AspNetCore.Identity.SignInManager<TUser>.SignInAsync(TUser user, AuthenticationProperties authenticationProperties, string authenticationMethod) Abp.Threading.InternalAsyncHelper.AwaitTaskWithPostActionAndFinally(Task actualReturnValue, Func<Task> postAction, Action<Exception> finalAction) in InternalAsyncHelper.cs Abp.Authorization.AbpSignInManager<TTenant, TRole, TUser>.SignInOrTwoFactorAsync(AbpLoginResult<TTenant, TUser> loginResult, bool isPersistent, Nullable<bool> rememberBrowser, string loginProvider, bool bypassTwoFactor) in AbpSignInManager.cs GenTime.Web.Controllers.UiController.Login(LoginModel model) in UiController.cs + var signInResult = await _signInManager.SignInOrTwoFactorAsync(loginResult, model.RememberMe); Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ExceptionContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in IdentityServerMiddleware.cs IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes) in MtlsTokenEndpointMiddleware.cs Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.InvokeCore(HttpContext context) IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in BaseUrlMiddleware.cs Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware+<>c__DisplayClass0_0+<<UseJwtTokenMiddleware>b__0>d.MoveNext() Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware+<>c__DisplayClass0_0+<<UseJwtTokenMiddleware>b__0>d.MoveNext() Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.InvokeCore(HttpContext context) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Any idea of the reason?

Regards.

Solved.

Just add "--mono:framework" in mtouch additional arguments, uncheck PNG optimization and "don't link" in the routing.

Works fine!

Hi,

this is the error ever appear when try to debug in my iPhone 6. In iOS Simulator works fine, but not in device (never run):

/Users/...................../src/GenTime.Mobile.iOS/MTOUCH: Error MT2101: Can't resolve the reference '!!0 Castle.Windsor.IWindsorContainer::Resolve(System.Object)', referenced from the method 'T Abp.Dependency.IocManager::Resolve(System.Object)' in 'Castle.Windsor, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'. (MT2101) (GenTime.Mobile.iOS)

Working with Mac. All SDK and libraries up to date. Xamarin.Forms 3.6 Xamarin.Forms.Maps 3.6 Essentials 1.0

Any solution?

Thanks

Great It's working fine!!

Very, very thanks.

Regards

The TenantId and UserId of the AbpSession is null.

How do I inject the AbpSession?

I do the following:

    private readonly IRepository&lt;Machine&gt; _machineRepository;
    private readonly IAbpSession _session;
    private readonly HubConnection _connection;
    
    #endregion

    #region "Constructor"

    public SignalRExtensionAppService(
        IRepository&lt;Machine&gt; machineRepository,
        IAbpSession session,
        HubConnection connection
        )
    {
        _machineRepository = machineRepository;
        _connection = connection;
        _session = session;
        //_sampleDbContextProvider = sampleDbContextProvider;

        log = NullLogger.Instance;

        InvokedOn();
    }
  • Dto

      [AutoMapTo(typeof(Machine))]
              public class CreateMachineDto
              {
                  public int? Id { get; set; }
                  [Required]
                  [StringLength(AbpTenantBase.MaxNameLength)]
                  public string Name { get; set; }
                  public string Description { get; set; }
                  public bool? Active { get; set; }
    
              public int? TenantId { get; set; }
    
              public DateTime InstallDate { get; set; }
              public DateTime LastLogin { get; set; }
              public DateTime? LastLogout { get; set; }
              public bool? IsBlocked { get; set; }
              public string ReasonIsBlocked { get; set; }
    
              // OperatingSystem
              public string OperationSystem { get; set; }
              public string OSVersion { get; set; }
              public string OSArchitecture { get; set; }
              public string OSSerialNumber { get; set; }
              public string OSLanguage { get; set; }
              public string OSTotalVisibleMemorySize { get; set; }
              public string OSSystemDrive { get; set; }
              //ComputerSystem
              public string CSNumberOfLogicalProcessors { get; set; }
              public string CSManufacturer { get; set; }
              public string CSModel { get; set; }
              //LogicalDisk
              public string LDDiskSize { get; set; }
              public string LDFreeSpaceDisk { get; set; }
    
              public DateTime? DateWasBlocked { get; set; }
              public int? LicenseId { get; set; }
    
              public CreateApplicationDto Application { get; set; }
              public ICollection&lt;TagDto&gt; Tags { get; set; }
          }
    
  • Model:

     public partial class Machine : FullAuditedEntity, IMayHaveTenant
         {
             public Machine()
             {
                 Events = new HashSet&lt;Event&gt;();
                 MachineAppVersions = new HashSet&lt;MachineAppVersion&gt;();
                 TagMachines = new HashSet&lt;TagMachine&gt;();
             }
    
         public string Name { get; set; }
         public string Description { get; set; }
         public bool? Active { get; set; }
         public DateTime? InstallDate { get; set; }
         public DateTime? LastLogin { get; set; }
         public DateTime? LastLogout { get; set; }
         public bool? IsBlocked { get; set; }
         public string ReasonIsBlocked { get; set; }
         public DateTime? DateWasBlocked { get; set; }
    
         // OperatingSystem
         public string OperationSystem { get; set; }
         public string OSVersion { get; set; }
         public string OSArchitecture { get; set; }
         public string OSSerialNumber { get; set; }
         public string OSLanguage { get; set; }
         public string OSTotalVisibleMemorySize { get; set; }
         public string OSSystemDrive { get; set; }
         //ComputerSystem
         public string CSNumberOfLogicalProcessors { get; set; }
         public string CSManufacturer { get; set; }
         public string CSModel { get; set; }
         //LogicalDisk
         public string LDDiskSize { get; set; }
         public string LDFreeSpaceDisk { get; set; }
    
         public int? TenantId { get; set; }
         public int? LicenseId { get; set; }
    
         public License License { get; set; }
         public ICollection&lt;Event&gt; Events { get; set; }
         public ICollection&lt;MachineAppVersion&gt; MachineAppVersions { get; set; }
         public ICollection&lt;TagMachine&gt; TagMachines { get; set; }
     }
    

Exactly

The error has disappeared ... but the IRepository<Machine> is empty.

What am I doing wrong?

I've tried to do it, but I don't know what I'm doing wrong.

  • WebHostModule

              IocManager.Resolve&lt;AppService.ISignalRExtensionAppService&gt;();
    
  • ISignalRExtensionAppService

      public interface ISignalRExtensionAppService : IApplicationService
      {
          Task Create(CreateMachineDto input);
      }
    
  • SignalRExtensionAppService

      public class SignalRExtensionAppService : ISignalRExtensionAppService
      {
          #region "Members"
    
      public ILogger log { get; set; }
    
      private readonly IDbContextProvider&lt;GenTimeDbContext&gt; _sampleDbContextProvider;
      private readonly IRepository&lt;Machine&gt; _machineRepository;
      private readonly HubConnection _connection;
    
      #endregion
    
      #region "Constructor"
    
      public SignalRExtensionAppService(
          IRepository&lt;Machine&gt; machineRepository,
          IDbContextProvider&lt;GenTimeDbContext&gt; sampleDbContextProvider,
          HubConnection connection
          )
      {
          _machineRepository = machineRepository;
          _connection = connection;
          _sampleDbContextProvider = sampleDbContextProvider;
    
          log = NullLogger.Instance;
    
          InvokedOn();
      }
    
      #endregion
    
      #region "Private Method"
    
      #region "SignalR"
    
      private async Task InvokedOn()
      {
          _connection.On&lt;string, string, string, int&gt;("GetMessage", (from, to, message, type) =>
          {
              Task.Run(async () =>
              {
                  var newMessage = $"{"SIG"}: {message}";
                  log.Info(newMessage);
                  Recieve_SendMessageToUser(from, to, message, type);
              });
          });
      }
    
      private async Task Recieve_SendMessageToUser(string from, string to, string message, int type)
      {
          string action = message.Split('@')[0];
          switch (action)
          {
              case "ActualizeRegisterDB":
                  ActualizeRegisterDB(message.Split('@')[1], message.Split('@')[2], message);
                  break;
              default:
                  break;
          }
      }
    
      private async Task ActualizeRegisterDB(string machineName, string tenant, string message)
      {
          int tenantId = 0;
          try
          {
              var lastLogin = DateTime.ParseExact(message.Split('@')[3], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
              var lastLogout = DateTime.ParseExact(message.Split('@')[4], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
    
              int.TryParse(message.Split('@')[2], out tenantId);
    
              CreateMachineDto createMachine = new CreateMachineDto()
              {
                  Name = message.Split('@')[1],
                  LastLogin = lastLogin,
                  LastLogout = lastLogout,
                  TenantId = tenantId
              };
    
              await Create(createMachine);
          }
          catch (Exception ex)
          {
              log.Error(ex.Message, ex);
          }
      }
    
      #endregion
    
      #endregion
    
      #region "Interface Implementation Method"
    
      public async Task Create(CreateMachineDto input)
      {
          try
          {
              log.Debug(string.Format("Machine: {0} with TenantId is {1} send: {2} - {3}", input.Name, input.TenantId, input.LastLogin, input.LastLogin));
    
              var machine = _machineRepository.GetAll().Where(x => x.Name == input.Name && x.TenantId == input.TenantId).FirstOrDefault();
              machine.LastLogin = input.LastLogin;
              machine.LastLogout = input.LastLogout;
    
              await _machineRepository.InsertOrUpdateAsync(machine);
          }
          catch (Exception ex)
          {
              log.Error(ex.Message, ex);
          }
      }
    
      #endregion
    

    }

SignalR events arrive without problem. But when the "Create" is done, I have the following error:

Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'GenTimeDbContext'.

Thanks for all

Regards

Showing 61 to 70 of 81 entries