Starts in:
2 DAYS
3 HRS
22 MIN
28 SEC
Starts in:
2 D
3 H
22 M
28 S
Open Closed

ExtraProperties EntityChanges in AuditLogs and MaxResultCount. #6318


User avatar
0
thanhlg created

Hi Abp Support Team, How can I retrieve more than 1000 records with MaxResultCount and... I added ScreenUrl to AuditLogs like this: I want to add ScreenUrl and CurrentUser.Id to EntityChanges. How can I do that? Is there any way to retrieve multiple EntityIds on the same page? For example, I have a Customer page. The page has one EntityId of the Customer table, which I have set as DocId in the code. Inside the page, I have a grid that stores data for the CustomerABC table, which will have another EntityId. I have added ScreenUrl to AuditLogs to retrieve the information of the page where the changes were made, but when there are more than 1000 records, retrieving the data is not accurate. I have switched to filtering EntityIds based on the DocId of the currently opened page to narrow down the data. However, using this approach, if the page contains child tables with different entities, I cannot retrieve the data of those tables. Could you provide an example of how to handle this request? Thanks,


14 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sorry, I don't quite understand your question.

    Could you explain it more clearly? Thank you.

  • User Avatar
    0
    thanhlg created

    Hi, I apologize for the complexity of my question. I want to add ScreenUrl and UserId to ExtraProperties of EntityChanges (currently only possible to store in the ExtraProperties of AuditLogs), and I would like to be able to retrieve more than 1000 records because the current MaxResultCount limit is 1000.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I want to add ScreenUrl and UserId to ExtraProperties of EntityChanges

    For example:

    public class MyAuditLogContributor : AuditLogContributor
    {
        public override void PostContribute(AuditLogContributionContext context)
        {
            foreach (var change in context.AuditInfo.EntityChanges)
            {
                change.SetProperty()
            }
            
        }
    }
    

    and I would like to be able to retrieve more than 1000 records because the current MaxResultCount limit is 1000.

    You can try:

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        ExtensibleLimitedResultRequestDto.MaxMaxResultCount = int.MaxValue;
    }
    
    
  • User Avatar
    0
    thanhlg created

    Thank you very much.

    Could you please clarify if it is possible to filter data when retrieving a list of EntityChanges using ExtraProperties? I would like to retrieve a list of data where ScreenUrl in ExtraProperties is equal to the URL of the currently opened page. Additionally, I need to filter multiple EntityIds within the same page. How can this be achieved? Could you provide me with some suggestions?

  • User Avatar
    0
    thanhlg created

    and I would like to be able to retrieve more than 1000 records because the current MaxResultCount limit is 1000.

    You can try:

    public override void ConfigureServices(ServiceConfigurationContext context) 
    { 
        ExtensibleLimitedResultRequestDto.MaxMaxResultCount = int.MaxValue; 
    } 
     
    

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sorry, will it work if you try this?

    public override void ConfigureServices(ServiceConfigurationContext context) 
    { 
        LimitedResultRequestDto.MaxMaxResultCount = int.MaxValue; 
        ExtensibleLimitedResultRequestDto.MaxMaxResultCount = int.MaxValue; 
    } 
     
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Could you please clarify if it is possible to filter data when retrieving a list of EntityChanges using ExtraProperties

    No, it will not work.

    You need to override the service.

    First: https://docs.abp.io/en/abp/latest/Entity-Framework-Core#mapefcoreproperty Then, you can filter data via shadow-properties : https://learn.microsoft.com/en-us/ef/core/modeling/shadow-properties#accessing-shadow-properties

  • User Avatar
    0
    thanhlg created
    public override void ConfigureServices(ServiceConfigurationContext context)  
    {  
        LimitedResultRequestDto.MaxMaxResultCount = int.MaxValue;  
        ExtensibleLimitedResultRequestDto.MaxMaxResultCount = int.MaxValue;  
    }  
      
    

    Thanks for the support, but if I don't use this configuration, can you help me rewrite the 'GetEntityChanges' method without using pagination and without limiting the number of results?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sure.

    [ExposeServices(typeof(IAuditLogsAppService))]
    public class MyAuditLogsAppService : AuditLogsAppService
    {
        public MyAuditLogsAppService(IAuditLogRepository auditLogRepository, IJsonSerializer jsonSerializer, IPermissionChecker permissionChecker, IPermissionDefinitionManager permissionDefinitionManager) : base(auditLogRepository, jsonSerializer, permissionChecker, permissionDefinitionManager)
        {
        }
    }
    

  • User Avatar
    0
    thanhlg created
    [ExposeServices(typeof(IAuditLogsAppService))] 
    public class MyAuditLogsAppService : AuditLogsAppService 
    { 
        public MyAuditLogsAppService(IAuditLogRepository auditLogRepository, IJsonSerializer jsonSerializer, IPermissionChecker permissionChecker, IPermissionDefinitionManager permissionDefinitionManager) : base(auditLogRepository, jsonSerializer, permissionChecker, permissionDefinitionManager) 
        { 
        } 
    } 
    

    Can you help me write the GetEntityChangesAsync(GetEntityChangesDto input) method without being limited by MaxResultCount?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I have shown how to replace the AuditLogsAppService service, you can override any method you want : )

    For example:

    [ExposeServices(typeof(IAuditLogsAppService))] 
    public class MyAuditLogsAppService : AuditLogsAppService 
    { 
        public MyAuditLogsAppService(IAuditLogRepository auditLogRepository, IJsonSerializer jsonSerializer, IPermissionChecker permissionChecker, IPermissionDefinitionManager permissionDefinitionManager) : base(auditLogRepository, jsonSerializer, permissionChecker, permissionDefinitionManager) 
        { 
        }
    
        public override Task<PagedResultDto<EntityChangeDto>> GetEntityChangesAsync(GetEntityChangesDto input)
        {
            input.MaxResultCount = int.MaxValue;
            return base.GetEntityChangesAsync(input);
        }
    
    } 
    
    
  • User Avatar
    0
    thanhlg created

    What if the data exceeds int.MaxValue?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    https://learn.microsoft.com/en-us/dotnet/api/system.int32.maxvalue?view=net-8.0

    Int.MaxValue is 2147483647. I don't know why you have to return so much data. You may need to reconsider your use cases. : )

  • User Avatar
    -1
    liangshiwei created
    Support Team Fullstack Developer

    if used for multiple years, the data will inevitably become very large. Is there a better alternative?

    No, as I said, you should rethink your use cases. you can consider using data range to filter data.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06