Base solution for your next web application

Activities of "SASIMEXICO"

Answer

Hi,

The version of IdentityServer4 is 2.5.0 and IdentityServer4.AccessTokenValidation is 2.7.0.

Regards

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,

Solved.

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

Works fine!

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<Machine> _machineRepository;
    private readonly IAbpSession _session;
    private readonly HubConnection _connection;
    
    #endregion

    #region "Constructor"

    public SignalRExtensionAppService(
        IRepository<Machine> 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<TagDto> Tags { get; set; }
          }
    
  • Model:

     public partial class Machine : FullAuditedEntity, IMayHaveTenant
         {
             public Machine()
             {
                 Events = new HashSet<Event>();
                 MachineAppVersions = new HashSet<MachineAppVersion>();
                 TagMachines = new HashSet<TagMachine>();
             }
    
         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<Event> Events { get; set; }
         public ICollection<MachineAppVersion> MachineAppVersions { get; set; }
         public ICollection<TagMachine> 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

Ok thanks... I try it

Showing 31 to 40 of 45 entries