Activities of "p.j.keukens"

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v5.3.0 (Commercial)
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

Hi,

We have created an entity with a field where we store a JSON object. On this entity we also use AuditLogging which is very important to us. The field where we store the JSON object is of type VARCHAR(MAX). When a change is written in the audit log the JSON is capped to 512 characters as the field "OriginalValue" and "NewValue" in the table "AbpEntityPropertyChanges" are only VARCHAR(512).

We changed the entity configuration to the config below, created a migration and applied changes to the database:

        builder.Entity< Volo.Abp.AuditLogging.EntityPropertyChange >().Property(x => x.OriginalValue).Metadata.RemoveAnnotation("MaxLength");
        builder.Entity< Volo.Abp.AuditLogging.EntityPropertyChange >().Property(x => x.NewValue).Metadata.RemoveAnnotation("MaxLength");
        builder.Entity< Volo.Abp.AuditLogging.EntityPropertyChange >().Property(x => x.OriginalValue).HasColumnType("nvarchar(max)");
        builder.Entity< Volo.Abp.AuditLogging.EntityPropertyChange >().Property(x => x.NewValue).HasColumnType("nvarchar(max)");

Also we changed the MaxNewValueLength and MaxOriginalValueLength to 1.000.000

        EntityPropertyChangeConsts.MaxNewValueLength = 1000000;
        EntityPropertyChangeConsts.MaxOriginalValueLength = 1000000;

In the Constructor (shown in codeblock below) of the EntityPropertyChange it truncates the value based upon MaxNewValueLength and MaxOriginalValueLength so setting it to 1000000 should store all info but in the database the original and new value are still 512 characters. Is there another place where the data is truncated? How can I fix this so that the full JSON object can be stored in the audit log?

public EntityPropertyChange(
        IGuidGenerator guidGenerator,
        Guid entityChangeId,
        EntityPropertyChangeInfo entityChangeInfo,
        Guid? tenantId = null)
    {
        Id = guidGenerator.Create();
        TenantId = tenantId;
        EntityChangeId = entityChangeId;
        NewValue = entityChangeInfo.NewValue.Truncate(EntityPropertyChangeConsts.MaxNewValueLength);
        OriginalValue = entityChangeInfo.OriginalValue.Truncate(EntityPropertyChangeConsts.MaxOriginalValueLength);
        PropertyName = entityChangeInfo.PropertyName.TruncateFromBeginning(EntityPropertyChangeConsts.MaxPropertyNameLength);
        PropertyTypeFullName = entityChangeInfo.PropertyTypeFullName.TruncateFromBeginning(EntityPropertyChangeConsts.MaxPropertyTypeFullNameLength);
    }

Also on the AuditLog we have a form which is multipart/form-data, this form is posted to the razorpage. In the audit log of the post we don't see all the data that is posted to the razorpage. Is there a way to show all the posted data in the audit log? We need this as 'proof' of what someone has posted. I see that when the ApplicationService is called it logs all data that is send to the ApplicationService method but we would like to log the posted data (without the posted files...)

Hi,

EntityPropertyChangeInfo.MaxValueLength is not a static property so I can't change it.

any other way to solve this problem?

Hi,

Yeah I see that realLiangshiwei has changed it yesterday from const to static. In which release will these changes be available?

Thanks.

Hi,

I have overridden the EntityHistoryHelper and that works, larger JSON is now stored in the table. There is still one weird thing and that is that the Created event on the entity is not audited.

I do see the updated event when I change it (in a webpage) but the created not so much.

Could this be because the created is in a Hangfirejob?

Job definition:

public class InformationWorker : HangfireBackgroundWorkerBase

Entity:

[Audited]
public class InformationResponse : FullAuditedEntity

Repository:

public class EfCoreInformationResponseRepository : EfCoreRepository<InformationDbContext, InformationResponse>, IInformationResponseRepository

Insert action:

await informationResponseRepository.InsertAsync(new InformationResponse(details.Id, jsonData));

Any ideas on why the created event is not in the audit log?

Okay so I created my own audited scope

    using (var informationScope = auditingManager.BeginScope())
    {
        auditingManager.Current.Log.Url = "InformationWorker";
        auditingManager.Current.Log.UserName = "Hangfire";
        auditingManager.Current.Log.HttpStatusCode = 200;

        ..... get entities .....        
        ..... update entity .....
        ..... create entity .....
        
        await informationScope.SaveAsync(); 
    }       

Now this shows one action which is fine, then it shows the entity changes but only the insert has properties. The entitities that are updated don't show the changed properties, the entitychange is empty. Do I need to log them manually?

You can either log them manually or add to EntityHistorySelectors in AbpAuditingOptions.

@gterdem I have decorated the classes with [Audited] which should be the same as with the entityhistoryselectors isn't it?

Hi,

You guys said that the change underneath would be merged in abp 6.0.0 but I have upgraded my project to 6.0.0 and the property

EntityPropertyChangeInfo.MaxValueLength is still a const int instead of a static int

https://github.com/abpframework/abp/blob/745d374a5a433a12d45e2ef591e6c85265a785cb/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs#L18

As I have my entities marked as audited the changed properties should show up but the audit log and the database only show the action not the properties. So the problem is still there, we need to be able to rely on the audit log.

  • ABP Framework version: v7.0.3

  • UI type: MVC

  • DB provider: EF Core

  • Tiered (MVC) or Identity Server Separated (Angular): yes / no

  • Exception message and stack trace:

  • Autofac.Core.DependencyResolutionException HResult=0x80131500 Message=An exception was thrown while activating Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionEndpointDataSourceFactory -> Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider -> λ:Microsoft.AspNetCore.Mvc.Abstractions.IActionDescriptorProvider[] -> Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider -> Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelFactory -> λ:Microsoft.AspNetCore.Mvc.ApplicationModels.IApplicationModelProvider[] -> Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultApplicationModelProvider -> Microsoft.Extensions.Options.UnnamedOptionsManager1[[Microsoft.AspNetCore.Mvc.MvcOptions, Microsoft.AspNetCore.Mvc.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]] -> Microsoft.Extensions.Options.OptionsFactory1[[Microsoft.AspNetCore.Mvc.MvcOptions, Microsoft.AspNetCore.Mvc.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]] -> λ:Microsoft.Extensions.Options.IConfigureOptions1[[Microsoft.AspNetCore.Mvc.MvcOptions, Microsoft.AspNetCore.Mvc.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]][] -> Microsoft.Extensions.DependencyInjection.MvcDataAnnotationsMvcOptionsSetup -> Volo.Abp.Localization.AbpStringLocalizerFactory -> Volo.Abp.LanguageManagement.External.ExternalLocalizationStore. Source=Autofac StackTrace: at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.SharingMiddleware.<>c__DisplayClass5_0.<Execute>b__0() at Autofac.Core.Lifetime.LifetimeScope.CreateSharedInstance(Guid id, Func1 creator) at Autofac.Core.Lifetime.LifetimeScope.CreateSharedInstance(Guid primaryId, Nullable1 qualifyingId, Func1 creator) at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt) at Autofac.Core.Resolving.ResolveOperation.InvokePipeline(ResolveRequest request, DefaultResolveRequestContext requestContext) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request) at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request) at Autofac.Core.Container.ResolveComponent(ResolveRequest request) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType) at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.GetOrCreateDataSource(IEndpointRouteBuilder endpoints) at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.MapControllerRoute(IEndpointRouteBuilder endpoints, String name, String pattern, Object defaults, Object constraints, Object dataTokens) at Volo.Abp.AspNetCore.Mvc.AbpAspNetCoreMvcModule.<>c.<ConfigureServices>b__1_10(EndpointRouteBuilderContext endpointContext) at Microsoft.AspNetCore.Builder.AbpAspNetCoreApplicationBuilderExtensions.<>c__DisplayClass0_0.<UseConfiguredEndpoints>b__0(IEndpointRouteBuilder endpoints) at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action1 configure) at Microsoft.AspNetCore.Builder.AbpAspNetCoreApplicationBuilderExtensions.UseConfiguredEndpoints(IApplicationBuilder app, Action`1 additionalConfigurationAction) at Nico.Web.NicoWebModule.OnApplicationInitialization(ApplicationInitializationContext context) in C:\SERVER\Innoview\Projects\VS2022\Nico7\Application\src\Nico.Web\NicoWebModule.cs:line 605 at Volo.Abp.Modularity.AbpModule.OnApplicationInitializationAsync(ApplicationInitializationContext context) at Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.

    This exception was originally thrown at this call stack: [External Code]

Inner Exception 1: DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptions`1[Volo.Abp.Localization.AbpLocalizationOptions], Volo.Abp.LanguageManagement.External.ILocalizationResourceRecordRepository, Volo.Abp.LanguageManagement.External.IExternalLocalizationStoreCache)' on type 'ExternalLocalizationStore'.

Inner Exception 2: MissingMethodException: Method not found: 'Volo.Abp.Localization.LocalizationResource Volo.Abp.Localization.LocalizationResourceExtensions.AddVirtualJson(Volo.Abp.Localization.LocalizationResource, System.String)'.

  • Steps to reproduce the issue:" Upgraded abp from version 6.0 to 7.0.3

In your documentation I can see that there were changes to the LocalizationResource and that it could be a breaking change. The application crashes on app.UseConfigureEndpoints() in my main webmodule. I did create a migration and updated the database after the update to abp version 7.0.3.

So it broke my application but I don't see what I need to do to resolve it, can you help? Kind Regards,

Patrick

I've found the problem and solved it, thanks.

  • ABP Framework version: v7.0.3
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC): yes / no
  • Exception message and stack trace:
  • An exception was thrown while activating Castle.Proxies.ReferenceDataProxy. Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.ReferenceDataProxy. ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Castle.Proxies.ReferenceDataProxy' can be invoked with the available services and parameters: Cannot resolve parameter 'ReferenceData.IReferenceDataRepository referenceDataRepository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], ReferenceData.IReferenceDataRepository)'.
  • Steps to reproduce the issue: Steps to reproduce:
  1. Have a tiered application using MVC and Ef-Core based on the application template
  2. Add a module and reference is from the main project
  3. In the EntityFrameworkCore project of the module add an entity and a repository class
  4. In the Domain project of the module add an interface
  5. In the Application module of the module create an AppService where the custom repository is injected
  6. Some how it cannot resolve the repository and I can't find the problem, if I use IRepository&lt;ReferenceData, string> directly in the AppService that works. But what am I missing that the custom repository isn't registered in the dependency Injection?

Here are the code definitions used:

//Repository in EntityFrameworkCore project of application module
public class EfCoreReferenceDataRepository : EfCoreRepository<ReferenceDbContext, ReferenceData, string>, IReferenceDataRepository
{
	public EfCoreReferenceDataRepository(IDbContextProvider<ReferenceDbContext> dbContextProvider)
		: base(dbContextProvider)
	{
	}
}

//Interface in Domain module of application module (Also tried IRepository<ReferenceData, string> also tried adding ITransientDependency)
public interface IReferenceDataRepository : IBasicRepository<ReferenceData, string>

// Dependency injection in AppService of application module
public ReferenceDataAppService(IReferenceDataRepository referenceDataRepository)

In other modules in the project this works fine, these modules have been upgraded from version 6.0.5 to 7.0.3. The module with the problem is added to the application as a new v7.0.3 module.

I do not use: SkipAutoServiceRegistration

Documentation says: Some specific types are registered to dependency injection by default. Examples:

Repositories (implement BasicRepositoryBase class or its subclasses) are registered as transient.
Showing 1 to 10 of 14 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11