Base solution for your next web application

Activities of "imad"

Question

Hi,

I noticed in the TenantAppService there is an injection for _tenantManager in the constructor although in the base class there is a property called TenantManager, any difference between the two?

Also why CrudAppService/AsyncCrudAppService is not used in the project and all the CRUD are re implemented, any specific reason behind this design? Can TenantAppService inherit AsyncCrudAppService and implement only the missing methods, while providing the appropriate values for the CRUD permission names ?

Thanks

Answer

Thanks.

Question

Hi,

I am trying to achieve something similar to the OU concept called data labeling, where each entity will have some labels assigned to it and the users can only access the entities matching his security settings. Currently the implementation for the organization units doesn't restrict user access for the entities that belongs to the OU that they have access to.

I know that the datafilters concept is a potential solution to handle this kind of controls, do you have any recommendations to point me in the right direction?

Hi,

In my application service, I need to send additional data to the client when I throw UserFriendlyException, so I created my own exception class that inherit UserFriendlyException and added my own custom properties.

However on the client side, when calling the application service method, I am unable to get the new custom properties added, do i need to register my custom exception somewhere?

Also on the client side and based on the error code thrown, i need to provide my own handling and prevent the default error message that appears, how to cancel this behavior based on error code.

ex:

vm.save = function () { vm.saving = true; appService.update(vm.entity) .then(function () { abp.notify.info(app.localize('SavedSuccessfully')); $uibModalInstance.close(); }, function (result) { <ins>//I want to cancel the default error message and show my own handling with the new custom properties</ins> vm.saving = false;
}).finally(function () { vm.saving = false; }); };

Question

Hi,

In my application service i need to connect to an external database using ODBC, this database provider doesn't support transaction, and it causing problem with the default transnational nature of application service methods.

The solution was to add the [UnitOfWork(IsDisabled = true)] attribute and define my own scope for the code part that needs to interact with the SQL server database using UnitOfWorkManager.Begin() method. However the behavior I am getting is different if I execute the SQL server part alone in an application service methods.

What I Have so far:

[UnitOfWork(IsDisabled = true)]
public async Task DeleteObject(DeleteObjectInput input){
    //connect to external engine

    //perform SQL server logic
    var unitOfWorkOptions = new UnitOfWorkOptions() { IsTransactional = true };
    unitOfWorkOptions.FilterOverrides.Add(new DataFilterConfiguration(AbpDataFilters.SoftDelete, false));
    using (var unitOfWork = UnitOfWorkManager.Begin(unitOfWorkOptions))
    {
        var object = await _objectRepository.GetAsync(input.Id);
       //perform some logic
        await _objectRepository.DeleteAsync(object );
        await unitOfWork.CompleteAsync();
    }
}

The object class has a List of other sub-objects and a one to one relation with another extend-object. When i execute the above code only the object is marked as deleted and the dependent objects are intact, while if i execute the same code directly in an application service methods all the dependent object are marked as deleted.

Another point, I assume disabling the SoftDelete filter is enough to completely remove the objects from the database, which is not the case (apparently it works only on the select), do I need to execute a raw SQL query to achieve this behavior?

Thank you.

Answer

Hi,

Changing the scope to RequiresNew, solved the problem and i am getting the same behavior as if i am executing in a default app service methods. My objects are using foreign keys with cascadedelete so the delete is automatically handled by EF.

Is there any possible way to disable the SoftDelete filter while executing a delete to do a physical delete (check the second part of my question)?

Thank you.

Answer

Hi,

I ended up overriding the CancelDeletionForSoftDelete in my dbContext:

protected override void CancelDeletionForSoftDelete(System.Data.Entity.Infrastructure.DbEntityEntry entry)
        {
            if (!this.CurrentUnitOfWorkProvider.Current.IsFilterEnabled(Abp.Domain.Uow.AbpDataFilters.SoftDelete))
            {
                return;
            }

            base.CancelDeletionForSoftDelete(entry);
        }
Question

Hi,

How to achieve Dto inheritence in order for base and derived class map correctly to their correspondent Dto?

in the following example, i am always getting the ProductDto even if the product is a ProductA instance, how to make it map to ProductADto?

public class Product {}
public class ProductA : Product {}

[AutoMap(typeof(Product)]
public class ProductDto {}

[AutoMap(typeof(ProductA)]
public class ProductADto {}

public class GetProductForEditOutput
{
public Product EditProduct { get; set; }
}
Question

Hi,

I need to send a notification from an ApplicationService defined in a custom module, I successfully managed to add a new notification type to the default AppNotificationProvider defined in the core module, but when I try to replicate the same in another module the notification wont show up, even its not save in the database.

So in my custom module i have the following:

  1. Defined a new NotificationProvider and registered it to Configuration.Notifications.Providers in module PreInitialize, its now successfully shown in the list of available notification to the user in Notification Settings. 2.Defined a new AppNotifier similar to the one in the core module that uses the _notificationPublisher.PublishAsync 3.From my custom application service i invoke await _appNotifier.NewDataProjectCreatedAsync(dataProject);

I got no error and yet the notification is not saved in the database and of course not sent to the client, even the user is subscribed to this type of notification.

What i am missing do i need to call _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync before i invoke the method on appNotifier like in the AccountController?

Thank you.

Hi I am using version 2.0.1,

While looking at the profiler, i see the following execution queries:

1.INSERT [dbo].[AbpNotifications] 2.INSERT [dbo].[AbpBackgroundJobs] 3.Select FROM [dbo].[AbpBackgroundJobs] 4.Select FROM [dbo].[AbpNotifications] 5.Select FROM [dbo].[AbpNotificationSubscriptions] (returns 1 row) 6.DELETE [dbo].[AbpNotifications] 7.DELETE [dbo].[AbpBackgroundJobs]

There is no insert into AbpTenantNotifications or AbpUserNotifications where others notifications usually are.

Thank you.

Showing 1 to 10 of 13 entries