HI, I have an clinic entity which is an extension of OrganizationUnit
public class Clinic : OrganizationUnit {...}
All works fine, but when i call this repository from a periodicbackgroundworker this repository is empty!
`protected override void DoWork()
{
var utcNow = Clock.Now.ToUniversalTime();
var clinics = _clinicRepository.GetAllList();
`
when i call other normal repositories there not empty.
Please advice
8 Answer(s)
-
0
Did you insert any?
-
0
:-) ofcourse
-
0
In host?
-
0
I have about 75 clinics in my database, clinic is an extension of organizationunit. i have added Address, Phone etc. All crud operations work from application layer.
` public class ClinicClosedCheckWorker : PeriodicBackgroundWorkerBase, ISingletonDependency { private const int CheckPeriodAsMilliseconds = 1 * 60 * 60 * 24 * 1000; //1 day
private readonly IRepository<Clinic, long> _clinicRepository; private readonly OrganizationUnitManager _organizationUnitManager; public ClinicClosedCheckWorker( AbpTimer timer, IRepository<Clinic, long> clinicRepository, OrganizationUnitManager organizationUnitManager ) : base(timer) { _clinicRepository = clinicRepository; _organizationUnitManager = organizationUnitManager; Timer.Period = CheckPeriodAsMilliseconds; Timer.RunOnStart = true; LocalizationSourceName = PhoogleConsts.LocalizationSourceName; } protected override void DoWork() { var utcNow = Clock.Now.ToUniversalTime(); var closedClinics = _clinicRepository.GetAllList( clinic => clinic.ClosingDate != null); foreach (var clinic in closedClinics) { try { if (clinic.ClosingDate <= utcNow) { _organizationUnitManager.Delete(clinic.Id); } } catch (Exception exception) { Logger.Error($"Clinic is gesloten maar kan niet worden verwijderd"); Logger.Error(exception.Message, exception); } } } }
`
-
0
Did you insert any in host?
-
0
I'm sorry, but i don't know what you mean? You mean live database?
-
0
Hi @rvanwoezik
In background job, _clinicRepository.GetAllList will return the clinics of the Host. If you want to retrieve clinics of a specific tenant, you need to switch to the tenant context, https://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy#switching-between-host-and-tenants.
If you want to retrieve all records, you can disable MayHaveTenant filter https://aspnetboilerplate.com/Pages/Documents/Data-Filters#disable-filters but it will fail if you are using at least one separate database for a tenant.
-
0
Thnx! you are the best!