Activities of "liangshiwei"

Could you explain the problem in detail?

Please following : https://github.com/abpframework/abp/issues/4089 and https://github.com/abpframework/abp/issues/4089. Available in the next version.

Update Volo.Abp.Commercial.SuiteTemplates to 2.8.0.

Note: Please do not update abp suite unless you update your solution. Abp suite may not be compatible with your old version.

Try:

await this._accountAppService.SendPasswordResetCodeAsync(new SendPasswordResetCodeDto { Email=identityUser.Email, "Angular" });

Hi @roop.yekollu@atlasair.com

I use the project you provided, but can't reproduce this problem. Just one thing, you use automapper map object, but you did not initialize the collection in the parameterless constructor.null reference exception will be thrown when adding.

In addition, some boundary condition checks are missing in your code, like:

private async Task<bool> AddToSubEventsAsync(Alert alert, IEnumerable<string> subEvents)
{
    Check.NotNull(alert, nameof(alert));
    Check.NotNull(subEvents, nameof(subEvents));

    var EventTypesMasterList = await _eventTypeRepository.GetListAsync();

    foreach (var subEvent in subEvents)
    {
        var eventType = EventTypesMasterList.FirstOrDefault(e => e.Name == subEvent);
        alert.AddSubEvent(eventType.Id);  // If eventType object is null, you will get null reference exception.
    }

    return true;
}

Hi @roop.yekollu@atlasair.com

I suggest you delete the repository on github, because your commercial license is included in the project.

The cause of the error is not because of the AlertSubEventType entity, I think your code has wrong.

If you want to implement soft delete for AlertSubEventType entity, you should use b.HasIndex(ae => new { ae.EventTypeId, ae.AlertId }).HasFilter("[IsDeleted] != 1"); see https://github.com/abpframework/abp/issues/1181.

If you can provide a sample project that reproduce this problem, I can quickly help you find the problem.

I do n’t know much about FluentValidation, you can maybe inject repository to validator class and check duplicate entities. But I suggest you Check Duplicate Entities in the domain layer.

I see that you use alertRepository query in SetSubEventsAsync method,I don't know your implementation, I assume it queries from the database.so changes need to be saved.

var currentSubEventNames = await _alertRepository.GetSubEventTypes(alert);

I see that you call the RemoveFromSubEventsAsync method to delete the existing record, but the id value of the current alert entity is 0. I think you should make the following changes:

public virtual async Task<AlertDto> CreateAsync(AlertCreateDto input)
{
    var newAlert = new Alert()
    {
        Subject = input.Subject,
        FlightRegistrationNumber = input.FlightRegistrationNumber
    };

    var alert = await _alertRepository.InsertAsync(newAlert);

    await UpdateAlertByInput(alert, input);

    await CurrentUnitOfWork.SaveChangesAsync();
    return ObjectMapper.Map<Alert, AlertDto>(alert);
}

protected virtual async Task UpdateAlertByInput(Alert alert, AlertCreateOrUpdateDtoBase input)
{
    alert.Subject = input.Subject;
    alert.FlightRegistrationNumber = input.FlightRegistrationNumber;


    if (input.SubEventNames != null)
    {
        await SetSubEventsAsync(alert, input.SubEventNames);
    }
}

private async Task SetSubEventsAsync([NotNull] Alert alert, [NotNull] IEnumerable<string> subEventNames)
{
    Check.NotNull(alert, nameof(alert));
    Check.NotNull(subEventNames, nameof(subEventNames));

    if (alert.Id != 0)
    {
        await RemoveFromSubEventsAsync(alert);
    }

    await AddToSubEventsAsync(alert, subEventNames.Distinct());

}

private async Task<bool> RemoveFromSubEventsAsync(Alert alert)
{
    Check.NotNull(alert, nameof(alert));

    alert.SubEvents.Clear();

    return true;
}

private async Task<bool> AddToSubEventsAsync(Alert alert, IEnumerable<string> subEvents)
{
    Check.NotNull(alert, nameof(alert));
    var enumerable = subEvents as string[] ?? subEvents.ToArray();
    Check.NotNull(enumerable, nameof(subEvents));

    var EventTypesMasterList = await _alertEventTypeRepository.GetListAsync();

    foreach (var subEvent in enumerable)
    {
        var eventType = EventTypesMasterList.FirstOrDefault(e => e.Name == subEvent);
        alert.AddSubEvent(eventType.Id);
    }

    return true;
}

In addition, you configured a soft delete for the AlertSubEventType entity, but the entity uses a combined index, you need to remove soft delete:

 public class AlertSubEventType : Entity
{
    public long AlertId { get; set; }

    public int EventTypeId { get; set; }


    public AlertSubEventType()
    {
    }

    public AlertSubEventType(long alertId, int eventTypeId)
    {
        AlertId = alertId;
        EventTypeId = eventTypeId;
    }

    public override object[] GetKeys()
    {
        return new object[] {AlertId, EventTypeId};
    }
}

I tried to use your code, but did not reproduce the problem.

I didn't customize the alert repository for simplicity, After inserting the alert entity, I called the save change method of the unit of work, because the code you provided uses the repository to query the alert entity.

Showing 6291 to 6300 of 6377 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07