Activities of "jlavallet"

Hi Alper.

I’ve already solved my problem. I would appreciate it if you would credit me that support ticket and add to your error message that elements of code submitted may result in an unauthorized exception - giving a list of the probable reasons and how to fix them. I know I’m not doing any SQL in that block so it’s not SQL injection. Perhaps it’s the URLs in the comments?

Because I wasn’t unable to post a response back to maliming, I spent the first two days of this week reading the documentation and trying every way I could think to solve the problem. In the end I poured over the support website and finally found something that suggested that I could get rid of the dependence on the modal behavior entirely – which I wanted to do – so I replaced the following line of code:

<abp-modal-footer buttons="@(AbpModalButtons.Save)"></abp-modal-footer>

With the following line of code:

<abp-button button-type="Primary" type="submit">Save Order and Proceed to Payment</abp-button>

I changed my POST handler like this – I never could get the redirect to work:

And I changed my JavaScript like this:

I don’t like the client-side redirect so if you can tell me how to do it with server-side redirect, I would prefer that.

That and, possibly other edits - sorry I have to move on – made things work for me.

In an effort to help others with the same problem, I will post my solution as an image. If I only had time to contribute to the documentation… I will try to do so at some point. The support site really needs work on the search functionality. I am aware of the options, but I rarely get good results. I only find them later by manually browsing posts. This is a problem because I am sure my problems have been encountered many times before. That means that my only recourse is to create a new post and since I am in Central Standard Time (Chicago), even the smallest clarifying question from your moderators cost me an entire day. Have you ever considered employing a moderator on the night shift? Obviously, I don’t know the geographical distribution of your customer base, but I would imagine there is a large representation here in the United States. I am a huge fan of framework and modular structure. I have learned a lot from you. I just hope in the future there will be an easier way to get support or find answers. The Discord option does not seem to be actively moderated, and my questions are ignored there.

Thanks, Jack

  • ABP Framework version: v5.3.5
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: N/A
  • Steps to reproduce the issue:"

I am having the exact same problem as the OP in this post: https://support.abp.io/QA/Questions/1765/Instead-of-opening-edit-popup-modal-screen--how-to-redirect-to-page

I have a razor page called SignUp on the public website that contains a form for a user to sign up for a service offered through our product. When the Save button is clicked, it successfully POSTs to the OnPostAsync handler in my SignUp.cshtml.cs controller. The problem is, no matter what I try, I cannot redirect successfully to my Payment page after the order is created in that handler.

Here is my handler:

  public async Task<IActionResult> OnPostAsync()
  {
    //https://github.com/maliming/reCAPTCHA
    var response = await _siteVerify.Verify(new reCAPTCHASiteVerifyRequest
    {
      Response = Order.Token,
      RemoteIp = HttpContext.Connection.RemoteIpAddress?.ToString()
    });

    if (!response.Success)
    {
      Alerts.Danger("Please check the \"I am not a robot\" checkbox and complete the captcha.");
      return Page();
    }

    var order = await _ordersAppService.CreateAsync(Order);

    //var selfBaseUrl = _configuration["App:SelfUrl"] ?? "~"; // Try 2
    //var payment = selfBaseUrl.EnsureEndsWith('/') + $"Payment?orderId={order.Id}"; // Try 2
    
    var payment = $"/Payment?orderId={order.Id}"; // Try 3

    //var result = RedirectToPage("Payment", new { orderId = order.Id }); // Try 1
    //var result = Redirect(payment); // Try 2
    var result = LocalRedirect(payment); //Try 3 
    
    return result; 
  }

Note that the captcha works just fine, my order is created, and then I actually redirect to the Payment page. That is, my OnGetAsync handler in my Payment.cshtml.cs controller gets called, my order gets looked up and set on my Order property and and then I try to return the Page.

  [HiddenInput]
  [BindProperty(SupportsGet = true)]
  public Guid OrderId { get; set; }

  [BindProperty] public OrderUpdateDto Order { get; set; }


  public async Task<IActionResult> OnGetAsync()
  {
    var order = await _ordersAppService.GetAsync(OrderId);
    Order = ObjectMapper.Map<OrderDto, OrderUpdateDto>(order);

    return Page();
  }

I can step through this method and everything is working, but when it returns, it stays on my SignUp page and does not render my Payment page. As you can see above, I've tried three different ways of redirecting (actually more) and each of them redirect but the rendering my Payment.cshtml page never happens.

Just a note – I can navigate directly to my Payment page by entering /Payment?orderd=… in the address bar of my browser. Everything works great with that page. I'm not getting any kind of error response.

So, what could be going wrong? Why would my SignUp page not redirect fully? Do I need some kind of special JavaScript handler? I've tried playing around with the following code in my SignUp.js file which is included in the script tag on my page:

$(function () {
  console.log('loaded')
  $("#order-form").abpAjaxForm().on('abp-ajax-success', function () {
    //window.location.href = '/Success;
  });

  //$("#order-form").abpAjaxForm().on('abp-ajax-fail', function () {
  //  window.location.href = '/Error';
  //});
});

I could do a client-side redirect, but I really don't want to do that as I might have other clients in the future. Again, why would the redirect not complete?

  • ABP Framework version: v 5.3.5
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: N/A
  • Steps to reproduce the issue:" We have noticed that the CreateTenant.cshtml, EditTenant.cshtml, CreateUser.cshtml, and EditUser.cshtml files are rendering in strange ways. One example of what we're seeing is the following:

When the Extra Properties are rendered for our New Tenant, and (1) we click the State abp-select, (2) the select expands as expected (albeit without much contrast around its edges to differentiate it from the modal dialog). As long as we have plenty of real estate, the select renders as it should.

However, if the view is constrained, as is shown below, the rendering begins to be problematic:

When the Extra Properties are rendered for our New Tenant, and (1) we click the State abp-select, (2) the select expands at the top of the view.

And when the view is constrained further, as is shown below, the expanded select control is not shown at all:

(1) We click the State abp-select… Nothing is rendered!

What can be done about this?

Also, as is visible in all three screenshots above, the StateId property is rendered as a StateId_Text label and a useless text field.

Why is that?

Is it possible for me to get the cshtml files without the models, etc.?

https://centurycorporation-my.sharepoint.com/:u:/p/jlavallet/EcMPpnAcCJZJjYWscoCsSlYBUukgDLOGlP4Slu0F46YU7g?e=lepKQV

I've Included a link to the logs after incorporating that change. I'm getting a foreign key constraint violation with the database. Please see the BlueSpot.HttpApi.Host\logs.txt file. It appears to have some kind of conflict with the CMS module.

Again, everything compiles fine. The migration was created just fine - although I didn't need it because there weren't any schema changes. The DbMigrator seemed to run fine - although I did see some red output lines when it ran, there was nothing in its log. The problem manifested itself when I tried to create a new tenant.

Related With this problem, I'm also having a problem when I try to programmatically create a Tenet. I am trying to do this using the _tenantManager.CreateAsync(string name, Guid? editionId) method:

      if (!_currentTenant.IsAvailable &&
          await _tenantRepository.FindByNameAsync(TenantConsts.ShelbyCoTenantName) == null)
      {
        var editions = await _editionRepository.GetListAsync();
        var edition = editions.FirstOrDefault(edition => edition.DisplayName == "Standard");
        var tenant = await _tenantManager.CreateAsync(TenantConsts.ShelbyCoTenantName, edition.Id);

        //await _tenantRepository.UpdateAsync(tenant);
      }

      else if (_currentTenant.IsAvailable && _currentTenant.Name == TenantConsts.ShelbyCoTenantName)
      {
        var tenant = await _tenantRepository.FindByIdAsync(_currentTenant.Id.Value);
        var alState = await _stateRepository.GetAsync(state => state.Code == "AL");

        tenant.ExtraProperties[TenantConsts.AddressLine1PropertyName] = "P.O. Box 1095";
        tenant.ExtraProperties[TenantConsts.CityPropertyName] = "Columbiana";
        tenant.ExtraProperties[TenantConsts.StateIdPropertyName] = alState.Id;
        tenant.ExtraProperties[TenantConsts.ZipCodePropertyName] = "35051";

        await _tenantRepository.UpdateAsync(tenant);
      }

The method completes but no Tenant is created. What's up with that? I am using Extra Properties for my Tenant and there is no way to pass in those properties using this method. The else if block above was one attempt I had made to update those properties after the tenant was created but that did not help. I also tried the following code to try and initialize the extra properties:

public class TenantCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<Tenant>>, ITransientDependency
{
  private readonly ICurrentTenant _currentTenant;
  private readonly IStateRepository _stateRepository;
  private readonly ITenantRepository _tenantRepository;
  private readonly IUserDataSeeder _userDataSeeder;

  public TenantCreatedEventHandler(ITenantRepository tenantRepository, IStateRepository stateRepository,
    ICurrentTenant currentTenant, IUserDataSeeder userDataSeeder)
  {
    _tenantRepository = tenantRepository;
    _stateRepository = stateRepository;
    _currentTenant = currentTenant;
    _userDataSeeder = userDataSeeder;
  }

  /// <inheritdoc />
  public async Task HandleEventAsync(EntityCreatedEventData<Tenant> eventData)
  {
    try
    {
      var tenant = eventData.Entity;
      if (tenant.Name == TenantConsts.ShelbyCoTenantName)
      {
        using (_currentTenant.Change(tenant.Id))
        {
          var alState = await _stateRepository.GetAsync(state => state.Code == "AL");

          tenant.ExtraProperties[TenantConsts.AddressLine1PropertyName] = "P.O. Box 1095";
          tenant.ExtraProperties[TenantConsts.CityPropertyName] = "Columbiana";
          tenant.ExtraProperties[TenantConsts.StateIdPropertyName] = alState.Id;
          tenant.ExtraProperties[TenantConsts.ZipCodePropertyName] = "35051";

          await _tenantRepository.UpdateAsync(tenant);

          await _userDataSeeder.CreateUsersAsync();
        }
      }
    }
    catch (Exception e)
    {
      Console.WriteLine(e);
      throw;
    }
  }
}

That code was not called after the programmatic creation attempt.

One more thing As I am using the commercial version of the Identity and Sass modules, I would like access to the following .cshtml files:

Pages\Tenets\CreateModal.cshtml
Pages\Tenets\EditModal.cshtml

I'm not sure about the namespace/Intermediate folders. I need to change some controls and styling. How do I get access to that? I tried getting the framework's TenantManagement files but I quickly determined that that was the framework and not the commercial module pages that I need.

Thankful you guys are okay!

[ReplaceDbContext(typeof(IIdentityProDbContext))]
[ReplaceDbContext(typeof(ISaasDbContext))]
[ConnectionStringName("Default")]
public class BlueSpotDbContext :
  BlueSpotDbContextBase<BlueSpotDbContext>,
  IIdentityProDbContext,
  ISaasDbContext
{
  public BlueSpotDbContext(DbContextOptions<BlueSpotDbContext> options)
    : base(options) { }

  public DbSet<Locality> Localities { get; set; }
  public DbSet<RejectionReason> RejectionReasons { get; set; }
  public DbSet<State> States { get; set; }
  public DbSet<Violation> Violations { get; set; }
  public DbSet<ViolationStatus> ViolationStatuses { get; set; }
  public DbSet<Photo> Photos { get; set; }

  /// <inheritdoc />
  public DbSet<IdentityUser> Users { get; set; }

  /// <inheritdoc />
  public DbSet<IdentityRole> Roles { get; set; }

  /// <inheritdoc />
  public DbSet<IdentityClaimType> ClaimTypes { get; set; }

  /// <inheritdoc />
  public DbSet<OrganizationUnit> OrganizationUnits { get; set; }

  /// <inheritdoc />
  public DbSet<IdentitySecurityLog> SecurityLogs { get; set; }

  /// <inheritdoc />
  public DbSet<IdentityLinkUser> LinkUsers { get; set; }

  /// <inheritdoc />
  public DbSet<Tenant> Tenants { get; set; }

  /// <inheritdoc />
  public DbSet<Edition> Editions { get; set; }

  /// <inheritdoc />
  public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; }

  protected override void OnModelCreating(ModelBuilder builder)
  {
    builder.SetMultiTenancySide(MultiTenancySides.Both);

    base.OnModelCreating(builder);

    //...
  }

  protected override Expression<Func<TEntity, bool>> CreateFilterExpression<TEntity>()
  {
    if (typeof(TEntity) == typeof(OrganizationUnit))
    {
      using (DataFilter.Disable<IMultiTenant>())
      {
        return base.CreateFilterExpression<TEntity>();
      }
    }

    return base.CreateFilterExpression<TEntity>();
  }
}

Everything compiles but when I do a Add-Migration I get the following:

PM> Add-Migration IdentityAndSassDbContext -Context BlueSpotDbContext
Multiple startup projects set.
Using project 'src\BlueSpot.EntityFrameworkCore' as the startup project.
Build started...
Build succeeded.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.get_DataFilter() in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.EntityFrameworkCore\Volo\Abp\EntityFrameworkCore\AbpDbContext.cs:line 51
   at BlueSpot.EntityFrameworkCore.BlueSpotDbContext.CreateFilterExpression[TEntity]() in D:\Century\Internal\BlueSpot\BlueSpot\src\BlueSpot.EntityFrameworkCore\EntityFrameworkCore\BlueSpotDbContext.cs:line 176
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.ConfigureGlobalFilters[TEntity](ModelBuilder modelBuilder, IMutableEntityType mutableEntityType) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.EntityFrameworkCore\Volo\Abp\EntityFrameworkCore\AbpDbContext.cs:line 604
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.ConfigureBaseProperties[TEntity](ModelBuilder modelBuilder, IMutableEntityType mutableEntityType) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.EntityFrameworkCore\Volo\Abp\EntityFrameworkCore\AbpDbContext.cs:line 596
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.OnModelCreating(ModelBuilder modelBuilder) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.EntityFrameworkCore\Volo\Abp\EntityFrameworkCore\AbpDbContext.cs:line 105
   at BlueSpot.EntityFrameworkCore.BlueSpotDbContextBase`1.OnModelCreating(ModelBuilder builder) in D:\Century\Internal\BlueSpot\BlueSpot\src\BlueSpot.EntityFrameworkCore\EntityFrameworkCore\BlueSpotDbContextBase.cs:line 35
   at BlueSpot.EntityFrameworkCore.BlueSpotDbContext.OnModelCreating(ModelBuilder builder) in D:\Century\Internal\BlueSpot\BlueSpot\src\BlueSpot.EntityFrameworkCore\EntityFrameworkCore\BlueSpotDbContext.cs:line 78
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.Customize(ModelBuilder modelBuilder, DbContext context)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, ModelDependencies modelDependencies)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, ModelCreationDependencies modelCreationDependencies, Boolean designTime)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Boolean designTime)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
   at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__8_4(IServiceProvider p)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.get_ContextServices()
   at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
   at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<System.IServiceProvider>.get_Instance()
   at Microsoft.EntityFrameworkCore.Infrastructure.Internal.InfrastructureExtensions.GetService[TService](IInfrastructure`1 accessor)
   at Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService[TService](IInfrastructure`1 accessor)
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType, String namespace)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.&lt;&gt;c__DisplayClass0_0.&lt;.ctor&gt;b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.&lt;&gt;c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Exception has been thrown by the target of an invocation.

Please advise. I hope you guys are safe out there. The earthquake seems terrible.

Can I disable multi-tenancy for the Organizational Unit entity?

I know how to perform queries by using (_dataFilter.Disable<IMultiTenant>()). I created a utility class to do that:

public static class OuHelper
{
  public static async Task<IEnumerable<OrganizationUnit>> GetHostOusAsync(
    IOrganizationUnitRepository ouRepository,
    IDataFilter dataFilter)
  {
    using (dataFilter.Disable<IMultiTenant>())
    {
      return await ouRepository.GetListAsync();
    }
  }
}

but later when I want to do this:

  public async Task HandleEventAsync(EntityCreatedEventData<IdentityUser> eventData)
  {
    var ous = await OuHelper.GetHostOusAsync(_ouRepository, _dataFilter);
    var adminsOu = ous.FirstOrDefault(ou => ou.DisplayName == OrganizationUnitConsts.Admins);
    var agentsOu = ous.FirstOrDefault(ou => ou.DisplayName == OrganizationUnitConsts.Agents);
    var reportersOu = ous.FirstOrDefault(ou => ou.DisplayName == OrganizationUnitConsts.Reporters);

    var user = eventData.Entity;

    if (adminsOu != null)
    {
      var isInAdminOu = await _userManager.IsInOrganizationUnitAsync(user.Id, adminsOu.Id);
      var isInAdminRole = await _userManager.IsInRoleAsync(user, RoleConsts.Admin);

      if (isInAdminOu && !isInAdminRole)
      {
        await _userManager.AddToRoleAsync(user, RoleConsts.Admin);
      }
      else if (!isInAdminOu && isInAdminRole)
      {
        // THIS FAILS
        await _userManager.AddToOrganizationUnitAsync(user.Id, adminsOu.Id);
      }
    }

    if (agentsOu != null)
    {
      var isInAgentOu = await _userManager.IsInOrganizationUnitAsync(user.Id, agentsOu.Id);
      var isInAgentRole = await _userManager.IsInRoleAsync(user, RoleConsts.Agent);

      if (isInAgentOu && !isInAgentRole)
      {
        await _userManager.AddToRoleAsync(user, RoleConsts.Agent);
      }
      else if (!isInAgentOu && isInAgentRole)
      {
        // THIS FAILS
        await _userManager.AddToOrganizationUnitAsync(user.Id, agentsOu.Id);
      }
    }

    if (reportersOu != null)
    {
      var isInReporterOu = await _userManager.IsInOrganizationUnitAsync(user.Id, reportersOu.Id);
      var isInReporterRole = await _userManager.IsInRoleAsync(user, RoleConsts.Reporter);

      if (isInReporterOu && !isInReporterRole)
      {
        await _userManager.AddToRoleAsync(user, RoleConsts.Reporter);
      }
      else if (!isInReporterOu && isInReporterRole)
      {
        // THIS FAILS
        await _userManager.AddToOrganizationUnitAsync(user.Id, reportersOu.Id);
      }
    }
  }

Since it's not my entity and it's built into the Saas module, i can't remove the IMultiTenant interface. Or can I?

The desired behavior is for the Organizational Units to be application scoped and not tenant scoped.

FYI- I am using the commercial module.

Thanks so much!

Liming,

I figured it out. It came down to calling the wrong resource name in one of javascript files I had copied from another project. Why it manifested itself well after file was included in the project, I have no idea.

var resource = abp.localization.getResource('DonorProject');

After correcting project name to "BlueSpot" the problem went away.

Can you point me to a resource that explains how to debug the ABP Framework code?

I sent you a zip file containing my logs. There are some HTTP 500 responses in them. Any interpretation you can offer would help. Thank you.

Showing 1 to 10 of 43 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07