No restrict to get the service of ITenantRepository?
Can I get the ITenantRepository anywhere especially in backgroun worker class?
Oh...
ITenantRepository tenantRepository = this.LazyServiceProvider.LazyGetRequiredService<ITenantRepository>();
tenantRepository is null
2022-11-17 11:10:23.791 +08:00 [INF] Starting: 【扫码关注】积分发放... 2022-11-17 11:10:46.619 +08:00 [ERR] Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at Yee.Change.AdminBlazorUI.WorkItems.FansJoinedNotifierWorkItem.FansSubscribedPoint() in D:\dev\abp\change\admin-blazor-ui\src\Yee.Change.AdminBlazorUI.Application\WorkItems\FansJoinedNotifierWorkItem.cs:line 97 at Yee.Change.AdminBlazorUI.WorkItems.FansJoinedNotifierWorkItem.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) in D:\dev\abp\change\admin-blazor-ui\src\Yee.Change.AdminBlazorUI.Application\WorkItems\FansJoinedNotifierWorkItem.cs:line 56 at Volo.Abp.BackgroundWorkers.AsyncPeriodicBackgroundWorkerBase.DoWorkAsync(CancellationToken cancellationToken) 2022-11-17 11:10:51.016 +08:00 [INF] Initialized all ABP modules.
and I try another way,
ICurrentTenant currentTenant = this.LazyServiceProvider.LazyGetRequiredService<ICurrentTenant>();
ITenantRepository tenantRepository = this.LazyServiceProvider.LazyGetRequiredService<ITenantRepository>();
if (allTenants == null)
{
using (currentTenant.Change(null))
{
allTenants = await tenantRepository.GetListAsync();
}
}
got the same error again: Object reference not set to an instance of an object.
public class FansJoinedNotifierWorkItem : AsyncPeriodicBackgroundWorkerBase
{
public FansJoinedNotifierWorkItem(AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory) : base(timer, serviceScopeFactory)
{
this.Timer.Period = 60 * 1000;
}
protected async override Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
{
this.Timer.Period = 1440 * 60 * 1000;
扫码关注送积分 subscribPoint = new 扫码关注送积分();
subscribPoint.LazyServiceProvider = this.LazyServiceProvider;
await this.FansSubscribedPoint();
this.Timer.Period = siteOptions.Value.UserFollowNotifyIntervalMinutes * 60 * 1000;
}
static List<Tenant> allTenants;
public async Task FansSubscribedPoint()
{
Log.Information("Starting: 【扫码关注】积分发放...");
IDataFilter dataFilter = this.LazyServiceProvider.LazyGetRequiredService<IDataFilter>();
if (allTenants == null)
{
using (dataFilter.Disable<IMultiTenant>())
{
ITenantRepository tenantRepository = this.LazyServiceProvider.LazyGetRequiredService<ITenantRepository>();
allTenants = await tenantRepository.GetListAsync();
}
}
……
Log.Information("Completed: 【扫码关注】积分发放...");
}
}
Volo.Abp.Identity.Pro.Domain need standard 2.1?
So I must change all of my projects with Domain from NET Standard 2.0 to NET Standard 2.1.
/builds/change/account/src/Yee.Change.Account.Domain.Shared/Yee.Change.Account.Domain.Shared.csproj : error NU1103: Unable to find a stable package Volo.Abp.Identity.Pro.Domain.Shared with version (>= 5.3.0)
The newest stable version of above package is 5.0.2?
var query = dbContext.Where(p => p.ItemKey == input.ItemKey && p.ItemType == input.ItemType).DistinctBy(p => p.EventTypeId);
I can not change the color of the text.
tks a lot!
thank you! all my questions have been resolved.