Base solution for your next web application
Open Closed

We have a problem resetting Features (_tenantManager.ResetAllFeaturesAsync) for a Tenant #8354


User avatar
0
richardghubert created

Hello, We have a problem resetting Features (_tenantManager.ResetAllFeaturesAsync) for a Tenant (Edition is irrelevant here). We are using AspNetZero v6.5.0 .NET-Core 2.2 AspNet-Core MVC & JQuery (see below)

  1. In the first case (see code example below and attached image V1) we Add a feature to the TenantID=1 get the expected result: the new value appears in the DB for TenantID=1 (no Edition associated). Method ChangeEditionV1 activates feature e521b74b-359a-4cd2-b3d7-0eb4034c0483. After method is executed the feature is available in database (ChangeEditionV1.PNG image).
  2. In the second case we set (Add) two features to TenantID=1 and get an unexpected result: only the first of the two features appears correctly in the DB, the second one is “lost”. Method ChangeEditionV2 attempts to activate 2 features: 4b657e3a-9b27-4a32-874b-c72fc610fd01 and e521b74b-359a-4cd2-b3d7-0eb4034c0483. After execution of ChangeEditionV2 method, only one of these feature (4b657e3a-9b27-4a32-874b-c72fc610fd01) is seen in the DB (ChangeEditionV2.PNG image)

EXAMPLES:

// Case 1. Image V1. // This example works. Expected result. See attached Image V1. // [UnitOfWork] public async Task ChangeEditionV1() { try { List featuresData = new List(); // valid feature

featuresData.Add(new NameValue() { Name = "e521b74b-359a-4cd2-b3d7-0eb4034c0483", Value = "true" });

Tenant tenant = await _tenantManager.GetByIdAsync(1); if (tenant == null) throw new UserFriendlyException("Tenant does not exist!?");

await _tenantManager.ResetAllFeaturesAsync(1); // valid edition tenant.EditionId = 10; await _tenantManager.SetFeatureValuesAsync(1, featuresData.ToArray()); } catch(Exception ex) { throw new UserFriendlyException("Error: " + ex.Message); } }

=========================== // Case 2, Image V2. // This example does not work: only one of the two features appears in the DB. The second one is “lost in space”. Why? // [UnitOfWork] public async Task ChangeEditionV2() { try { List`` featuresData = new List``();

<br> // valid features featuresData.Add(new NameValue() { Name = "4b657e3a-9b27-4a32-874b-c72fc610fd01", Value = "true" }); featuresData.Add(new NameValue() { Name = "e521b74b-359a-4cd2-b3d7-0eb4034c0483", Value = "true" });

Tenant tenant = await _tenantManager.GetByIdAsync(1); if (tenant == null) throw new UserFriendlyException("Tenant does not exist!?");

await _tenantManager.ResetAllFeaturesAsync(1); // valid edition tenant.EditionId = 10; await _tenantManager.SetFeatureValuesAsync(1, featuresData.ToArray()); } catch (Exception ex) { throw new UserFriendlyException("Error: " + ex.Message); } }

IMAGE V1: Works.

<br> IMAGE V2: Does Not Work


9 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @richardghubert

    Thank you for your detailed explanation of the problem. We will work on it and get back to you soon.

  • User Avatar
    0
    richardghubert created

    Ping ? :-) Thanks for any help on this.

  • User Avatar
    0
    musa.demir created

    Hi @richardghubert. SetFeatureValueAsync does not store values when:

    • It's already equals to the current value
    • it's equals to default
    • Feature is not exists

    Can you please check these cases. To test it you can override AbpTenantManager.cs->SetFeatureValueAsync(TTenant tenant, string featureName, string value) in TenantManager class and see what is going on.

    https://github.com/aspnetboilerplate/aspnetboilerplate/blob/de57d7c68e411a82a3b5302a79fb6617be3bf8cf/src/Abp.Zero.Common/MultiTenancy/AbpTenantManager.cs#L236-L289

    https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/MultiTenancy/TenantManager.cs

  • User Avatar
    0
    ismcagdas created
    Support Team

    This issue is closed because of no recent activity. Please create a new issue if you are still having this problem.

  • User Avatar
    0
    richardghubert created

    Sincere thanks. We'll take a look and reopen if necessary. Best!

  • User Avatar
    0
    Astech created

    ASP.NET CORE MVC & JQuery v12.0.1 .NET 7

    @ismcagdas - Do you know if there was any task ever completed for this? We are getting very similar behaviour. Edition feature settings (in particular checkboxs) are not correctly updating. Some peculiarities with only updating if a text field setting is also updated.

    I can debug it as far as the EditionManager:

    public virtual Task SetFeatureValueAsync(int editionId, string featureName, string value) { return _featureValueStore.SetEditionFeatureValueAsync(editionId, featureName, value); }

    But then lose the trail into ABP Source code.

    It seems the value is not correctly being inserted into the [AbpFeatures] table.

    Steps to reproduce: 1. Ensure you have a edition feature checkbox setting. 2. Edit an edition and change just the checkbox setting. 3. Save and re-open the edition modal. The value will not be updated

    Thank you

  • User Avatar
    0
    Astech created

    It appears to be something to do with the default value set in AppFeatureProvider: The setting will not update if you are trying to set the checkbox back to it's default value.

  • User Avatar
    0
    Astech created

    Ok, so not just checkboxes. For any setting, when trying to set the value back to it's default value the save does not happen.

    Workaround is to remove all default values in AppFeatureProvider which isn't ideal but will do for now.

    @ismcagdas - can this be looked into and resolved please?

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Astech

    Is it possible for you to create a new question ? Our support team can't see the replies on closed issues.

    Thanks,