Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "Ricavir"

Sorry, error on this post title. Title is "Notification not sent"

Hi,

I'm testing a new feature that needs to notify every user of current tenant. I've added my notification definition to the notification provider.

I've got following exception when sending it :

ERROR 2017-11-23 08:45:50,525 [10 ] Mvc.ExceptionHandling.AbpExceptionFilter - Can not set TenantId to 0 for IMustHaveTenant entities! Abp.AbpException: Can not set TenantId to 0 for IMustHaveTenant entities!

I try to set tenantId with _unitOfWorkManager.Current.SetTenantId(x) but same exception

I try to launch the notification from different locations : from AppService (Exception raised) and from BackgroundWorker (Exception not raised but notification not sent as well)

I try with existing notification "SendMessageAsync" (existing on your template project for test purpose) and I've got same exception.

I must miss something because when I create a new User, the welcome notification is sent and received by this new user.

Any idea ?

Ok, tks for your clarification @aaron

Hi,

I'm implementing a background worker class to schedule some tasks automatically. I took as code example the class "SubscriptionExpirationCheckWorker" on MultiTenancy namespace.

I'm able to search for tenants

var tenantsForEventSchedule = _tenantRepository.GetAllList(tenant => tenant.IsActive);

and also to get some tenant settings.

But when I try to search for other entities, an exception is raised with message "cannot access a disposed object" relative to the db context. The system try to access the database but the connection ha been disposed before.

I've read aspnetboilerplate documentation about UnitOfWork ; therefore, I've added [UnitOfWork] attribute before DoWork method I still have the same exception.

How can I fix this ?

Here is an extract of the code :

public class EventSchedulerWorker : PeriodicBackgroundWorkerBase, ISingletonDependency
    {
        private const int CheckPeriodAsMilliseconds = 1 * 60 * 60 * 100; // demo 6 minutes

        private readonly IRepository<Tenant> _tenantRepository;
        private readonly IRepository<ContractSchedule, long> _contractScheduleRepository;
        private readonly TenantManager _tenantManager;
        private readonly IAppNotifier _appNotifier;

        public EventSchedulerWorker(
            AbpTimer timer,
            IRepository<Tenant> tenantRepository,
            IRepository<ContractSchedule, long> contractScheduleRepository,
            TenantManager tenantManager,
            IAppNotifier appNotifier)
            : base(timer)
        {
            _tenantRepository = tenantRepository;
            _contractScheduleRepository = contractScheduleRepository;
            _tenantManager = tenantManager;
            _appNotifier = appNotifier;

            Timer.Period = CheckPeriodAsMilliseconds;
            Timer.RunOnStart = true;

            LocalizationSourceName = LogisavConsts.LocalizationSourceName;
        }

        [UnitOfWork]
        protected override async void DoWork()
        {
            var tenantsForEventSchedule = _tenantRepository.GetAllList(tenant => tenant.IsActive);

            foreach (var tenant in tenantsForEventSchedule)
            {
                try
                {
                    if (await SettingManager.GetSettingValueForTenantAsync<bool>(AppSettings.TenantEvent.Scheduler_Activated, tenant.Id) == true)
                    {
                        //define period to search contracts
                        var today = Clock.Now.Date;
                        int dayCountBeforeEventCreation = await SettingManager.GetSettingValueForTenantAsync<int>(AppSettings.TenantEvent.Scheduler_DayCount_BeforeEventCreation, tenant.Id);
                        var startDate = today.AddDays(-dayCountBeforeEventCreation);
                        bool includeSuspendedContracts = await SettingManager.GetSettingValueForTenantAsync<bool>(AppSettings.TenantEvent.Scheduler_SuspendedContractIncluded, tenant.Id);                        

                        var contractsFound = _contractScheduleRepository
                            .GetAll()
                            .Include(c => c.Contract)
                            .Where(cs => cs.Contract.IsActive == true)
                            .WhereIf(!includeSuspendedContracts, cs => cs.Contract.IsSuspended == false)
                            .Where(cs => cs.ScheduleDate >= startDate && cs.ScheduleDate <= today)
                            .ToList();

             >>>>>>>>>>>> EXCEPTION HERE : "cannot access a disposed object"

thank you for clarification @ismcagdas

Hi @ismcagdas,

I just saw that github issue 945 has been closed. In fact, I just deactivate IdentityServer from my appseetings file and this solve my problem.

But, I have to ask something that I didn't catch : how aspnetzero can authenticate users without IdentityServer ? I was thinking that it was a must have... Right now, in my current project, JwtBearer is the only authentication setting that is enable... If IdentityServer is not in charge of that, who is doing it ? an ASP.NET CORE package ?

That said, what is the benefit to add IdentityServer4 if we already have somehow an authentication module that is also able to authenticate angular client and third party application (like mobile apps) ?

Thanks @ismcagdas

Hi,

I want to retrieve users that are included in, at least, one organization unit. I've looked to abp docs but didn't found.

Right now, I'm using following code :

//Find users in OU
            foreach(var user in await UserManager.Users.ToListAsync())
            {
                if((await UserManager.GetOrganizationUnitsAsync(user)).Count() > 0)
                {
                    employeeIds.Add(user.Id);
                }
            }

Can I achieve that in a more efficient way ?

Coming back from the field : After publishing application in FDD way, I tranfered it in FTP to the hosting provider. The library is then runned by ASP.NET CORE installed on shared server.

Unfortunately, we had some errors :

  • "ErrorCode = 0x80004005 : 80008083."
  • "A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found"

I didn't found the way to generate hostpolicy.dll.

This was the main issues but other ones must be managed when hosting on a shared server (file access, some appservices not working...)

As we want to go fast and don't have more time to spend on it right now, we decided to switch to an Azure plan. The App is now running on Azure like a charm.

We put this task in our backlog for now and will update this post when we'll have more time. If anyone using aspnetzero have more information on FDD, feel free to share here ;)

Hi,

thanks for your answer. I've been hardly working on this issue.

Actually, you can build a dll as output file instead of EXE (in this case, it is a FDD : framework dependent deployment) You just need to change OutputType from "EXE" to "LIBRARY". All hosting provides will request this kind of deployment for security reasons.

Right now, I'm trying to find the right config to tell IIS to launch this library instead of old EXE file.

I'll keep you informed when I will reach my goal ;)

Cheers

Showing 261 to 270 of 325 entries