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

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.

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.

That certainly fixed that. Thank you. I suppose the important thing was to change the requiresNew parameters to false.

requiresNew (bool): Set true to ignore the surrounding unit of work and start a new UOW with the provided options. Default value is false. If it is false and there is a surrounding UOW, Begin method doesn't actually begin a new UOW, but silently participates to the existing UOW.

https://docs.abp.io/en/abp/4.3/Unit-Of-Work#begin-a-new-unit-of-work

Just a little bit more information…

I think it was picking up my production connection string instead of my local development connection string. When I excluded the appsettings.Production.json file from the project everything worked fine.

Thanks for your help!

Showing 1 to 10 of 30 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11