Base solution for your next web application

Activities of "daws"

.net core, angular, aspnetzero 8.8

We have a full audited entity :

[Audited]
public class MyEntity : FullAuditedEntity<short>, IExtendableObject, IPassivable, IValidityRange

When we load it like this in a manager :

[UnitOfWork]
public async Task<List<MyEntity>> GetAllActiveAsync(Expression<Func<MyEntity, bool>> predicate)
{
    return await _MyEntityRepository.GetAll().Where(x => x.IsActive).Where(predicate).ToListAsync();
}

Soft deleted entities are also loaded whereas they should not. We did not override GetAll in the repository.

We currently have a workaround but it's not clean :

public class MyDbContext : AbpZeroDbContext<Tenant, Role, User, MyDbContext>, IAbpPersistedGrantDbContext
{
    ...
    modelBuilder.Entity<MyEntity>().HasQueryFilter(p =>
        !p.IsDeleted
    );
}

How can we solve this ?

  • What is your product version? 10.3
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? ?Net Core
  • What is ABP Framework version? 6.3.1

Hi,

I want to embed my angular aspnetzero application in an iframe on a customer website. To be able for them to access the data, I match my angular routes with tenant and language parameters. Example here

If you open the console, you see the tenancy and language (parsed from the url) and the user id (a public user is automatically created and logged in to store user preferences).

However, when I embed this page in an iframe on a website which is on a different URL, I can't get the user id with SessionService or abp.session.userId. Without a user id, my code will keep trying to login a new public user and reload the page in an infinite loop.

How can I get the user id when the page is embedded in an iframe ?

  • What is your product version? 10.3
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? ?Net Core
  • What is ABP Framework version? 6.3.1

Dear support, I am injecting objects through an IRepository, and the CreatorUserId is filled with my current UserId = 2 (auto detected by ABPSession) when inserted into DB.

I want to modify the UserId of the object, to set it to null. Following your documentation, I use the session.Use (allowing a "long?" parameter) method but when I set the 2nd parameter as null, the UserId is still equals to "2".

If I use a non null value (e.g. "10"), this new value will correctly inserted into db.

Is there any info related to the null, that I am not aware of ?

public void InsertOrUpdateAreas(IList areas)
{
using (_session.Use(_session.TenantId, null))

        {
            var tenantId = _session.TenantId; //2
            var userId = _session.UserId; //2 ==> abp gives "2" instead of null

            foreach (var area in areas)
                    _areaRepository.Insert(area);

            CurrentUnitOfWork.SaveChanges();
        }
    }

Angular .net core. We are currently migrating from aspnetzero 8.8 to 10.3.

In the RoleAppService there's this method :

public async Task <ListResultDto> GetRoles(GetRolesInput input)

When we query the swagger endpoint, we get this :

"/api/services/app/Role/GetRoles": {
      "get": {
        "tags": [
          "Role"
        ],
        "operationId": "ApiServicesAppRoleGetrolesGet",
        "parameters": [
          {
            "name": "Permissions",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ListResultDtoOfRoleListDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResultDtoOfRoleListDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResultDtoOfRoleListDto"
                }
              }
            }
          }
        }
      }
    },

Why does swagger reduce GetRolesInput to Permissions (which is its only Property) ? In the frontend, it triggers compilation errors in the roles.component which doesn't know what a GetRolesInput object is anymore.

I checked in your code and there it's generated just fine. I tried adding other properties to the class, they all seem to be split by swagger. I copied the service.config.nswag from aspnetzero and I also double checked the Startup file in the Web.Host project.

Did I miss a swagger config option somewhere ?

Thanks

.net core, angular, aspnetzero 8.8

In a manager, we read and update a serialized json from/to an abpsetting. We do this several times in a for loop over entity objects. At some point in the loop, the retrieved setting will be truncated (to a variable length), thus crashing the json parser. At the same time, in the database, the setting has been correctly set to a valid json value.

Here's our code :

The loop :

foreach (var entity in entities) 
    _myManager.UpdateEntityAsync(entity).GetAwaiter().GetResult();``

The manager :

    [UnitOfWork]
    public async Task UpdateEntityAsync(MyEntity entity)
    {
        await _myEntityRepository.UpdateAsync(entity);
        AddDateRangeToReprocess(entity.Id, new DateRange(entity.Start, entity.End));
    }
    [UnitOfWork]
    public void AddDateRangeToReprocess(short id, DateRange range)
    {
        var existingDateRanges = GetDateRangesToReprocess();

        if (existingDateRanges == null)
        {
            existingDateRanges = new Dictionary<short, List<DateRange>>();
        }

        if (!existingDateRanges.ContainsKey(id) || existingDateRanges[id] == null)
        {
            existingDateRanges.AddOrUpdateIfExist(id, new List<DateRange>());
        }

        if (!existingDateRanges[id].Any(x => x == range))
        {
            existingDateRanges[id].Add(range);
        }

        if (_tenantManager.AbpSession.TenantId.HasValue)
        {
            _settingManager.ChangeSettingForTenant(_tenantManager.AbpSession.TenantId.Value, "EntityRanges", JsonConvert.SerializeObject(existingDateRanges));
        }
    }
    [UnitOfWork]
    public Dictionary<short, List<DateRange>> GetDateRangesToReprocess()
    {
        return JsonConvert.DeserializeObject<Dictionary<short, List<DateRange>>>(_settingManager.GetSettingValue("EntityRanges"));
    }

Output example :

//Value of the setting in the database :
{"14":[{"Start":"2021-03-01T05:39:00Z","End":"2021-03-01T05:39:44Z","Duration":"00:00:44"},{"Start":"2021-03-08T16:51:45Z","End":"2021-03-08T16:52:05Z","Duration":"00:00:20"}]}

//Value of the setting when debugging in the manager (GetDateRangesToReprocess) :
{"14":[{"Start":"2021-03-01T05:39:00Z","End":"2021-03-01T05:39:44Z","Duration":"00:00:44"},{"Start":"2021-03-08T16:51:45Z","End":"2021-03-08T16:52:05Z",

There does not seem to be a specific length to which our setting is truncated.

We figured that maybe it had to do with the cache that was not invalidated properly ?

Question

Hello,

Is it possible to have my users at the host level so that they're shared across tenants ?

So when I edit a user (or its permissions, or anything else), changes would be echoed to other tenants.

We're on Aspnetzero V8.8.0 angular + .net core

  • What is your product version? ABP 8.8.0
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .net core
  • What is ABP Framework version? abp 5.8

Hello !

The issue is that i try to send emails from abp framework through an anonymous SMTP server and it does not work via ABP. When I send it from SMTP Prober or directly from one c# smtp client, it works fine.

But from abp, I have set these parameters but it does not seems to work.

do you have any idea if I made some erros in the abpsettings ?

thanks

Aspnetzero 8.8 (Angular + .NET Core)

We create "public" users on the fly who have access to a limited set of features.

For these users, the default language (french) is ignored, even when we set it as a user setting before authenticating.

Here's the workflow :

  • The user access the page : www.oursite.com/public
  • From this page we call a custom method in the tokenAuthService to create a new temporary user and return his accesstoken :
var publicUser = Authorization.Users.User.CreateTenantAdminUser(AbpSession.TenantId.Value, $"{userName}@public.com");
  • We then Authenticate the user and return the AuthenticateResultModel back to the frontend
  • Now that our user is authenticated, in the login.service.ts we redirect the user to a landing page
this.processAuthenticateResult(result, 'publiclanding');

Problem : the language is English even though the tenant default language setting is set to french.

And we tried to override the default setting for the user as follows (in tokenAuthService, right before authenticating) :

_settingManager.ChangeSettingForUser(publicUser.ToUserIdentifier(), LocalizationSettingNames.DefaultLanguage, "fr");

but it doesn't work either.

From what I can read from this page : https://aspnetboilerplate.com/Pages/Documents/Localization#asp-net-core, the user setting should be preferred over other settings, right ?

I have an AppService method which returns a very large array of int? (nullable int).

Most values in this array are null.

Currently, when calling the method via Web api, the response array is formatted like this in JSON :

[null,null,null, ..., 3, 4, 8, 11, 12, null, null, null, ...]

In order to spare network bandwith, I want my array to be like this :

[,,, ..., 3, 4, 8, 11, 12,,,, ...]

Is it doable without bypassing the service-proxies JSON parsing functions ?

(Using Aspnetcore 7.2.3 with angular)

How can I format localized text in html ?

Example : {{l('MyTextKey')}}

Would return (in English for instance) : <span><b>MyText</b><br/>is formatted in the current language</span>

Which would render on screen :

MyText is formatted in the current language

We're using abp 7.2.3 with angular

Showing 1 to 10 of 43 entries