no erros in console. the Admin user alreday has the permission Pages_Administration_HangfireDashboard.
So when i directly go to the below link,
http://localhost:22742/hangfire
how does the user be authenticated to the dashboard since there is no prompt for any username and password?
I have enabled this. But i cannot navigate to the dashboard.
http://localhost:22742/hangfire
It says that site cannot be reached. However if i use the below line,
app.UseHangfireDashboard();
the dashboard loads. How can i authorize a user into the dashboard?
I am using single database. so i think i will not run into a problem.
Thanks All for the support.
I managed to get this to work. I disabled the filters in the unit of work manager. Then it returned the user.
_unitOfWorkManager.Current.DisableFilter("MayHaveTenant", "MustHaveTenant"); //get the tenant id for the payment User user = await _userManager.Users.Where(u=>u.Id == payment.Loan.UserId).FirstOrDefaultAsync();
Please let me know any issues in the above solution.
Hi,
I got the code to work partially. i was able to set the tenant using the _abpSession.Use(2, null) hardcoding 2 as the tenant id for debugging. and it worked.
I can get the Tenant id from the User table. The Payment entity has a loan mapped to it. The Loan has the User. So now when i want to get the user using usermanager, since it is outside the unit of work manager (i guess), I am getting a error stating that the user id is not found. But user id is available in the table.
//get the tenant id for the payment User user = await _userManager.GetUserByIdAsync(payment.Loan.UserId);
Is there a way i can include the User as well when i am getting the payment detiails. There is a navigation property to User table from the loan object.
Payment -> Loan -> User
Any help is highly appriciated.
[UnitOfWork] public virtual async Task SendDeviceUnlockNotification() { try { //get the device unlock requests from the db IList<Payment> payments = _paymentRepository.GetAllIncluding(p => p.Loan).Where(p => p.DeviceUnlockStatus == "Requested").ToList(); //loop through the payments and check the device unlock status foreach (Payment payment in payments) { //get the tenant id for the payment User user = await _userManager.GetUserByIdAsync(payment.Loan.UserId);
using (_abpSession.Use(user.TenantId, null))
{
using (_unitOfWorkManager.Current.SetTenantId(_abpSession.TenantId))
{
string status = await _passtimeDomainService.GetDeviceStatus(payment.Loan.VIN);
if (status.ToLower() == "enabled")
{
//update the device unlock status
payment.DeviceUnlockStatus = "Unlocked";
await _paymentRepository.UpdateAsync(payment);
//send push notification
NotificationData notificationData = new NotificationData
{
UserName = user.UserName,
Name = "Vehicle Unlocked Notification",
Title = "Vehicle Unlocked",
Body = "Your vehicle has been unlocked"
};
await _appCentre.NotifyAsync(notificationData);
}
}
}
}
_unitOfWorkManager.Current.SaveChanges();
}
catch (Exception ex)
{
//log any exception
}
}
Yes there is a setting. still the setting is not returned
I hardcoded the tenant id for testing as below,
_unitOfWorkManager.Current.SetTenantId(2)
but still the setting value is empty.
No. The external service does not have the tenant id.
This function should run periodically and check the database for device unlock requests. When a record is found, the job should pick it up and call a external service to unlock the device. The parameters for the request is stored tenant wise. (e.g. the dealer no is chaning from tenant to tenant).
If the device is unlocked, then a push notification is sent via App center to the mobile.
Below is the App setting code,
public static class PasstimeManagement { public const string PasstimeAddress = "PasstimeAddress"; public const string Password = "App.Passtime.Password"; public const string UserName = "App.Passtime.UserName"; public const string DealerNo = "App.Passtime.DealerNo"; }
Below is the App settings provider code,
private IEnumerable<SettingDefinition> GetPasstimeSettings() { return new[] { new SettingDefinition(AppSettings.PasstimeManagement.PasstimeAddress, GetFromAppSettings(AppSettings.PasstimeManagement.PasstimeAddress)), new SettingDefinition(AppSettings.PasstimeManagement.Password, GetFromAppSettings(AppSettings.PasstimeManagement.Password, ""), scopes: SettingScopes.Tenant), new SettingDefinition(AppSettings.PasstimeManagement.UserName, GetFromAppSettings(AppSettings.PasstimeManagement.UserName, ""), scopes: SettingScopes.Tenant), new SettingDefinition(AppSettings.PasstimeManagement.DealerNo, GetFromAppSettings(AppSettings.PasstimeManagement.DealerNo, ""), scopes: SettingScopes.Tenant) }; }
Below is the code in the job,
[UnitOfWork] public virtual async Task SendDeviceUnlockNotification() { using (_unitOfWorkManager.Current.SetTenantId(_abpSession.TenantId)) { string dealerNo = await _settingManager.GetSettingValueAsync(PasstimeManagement.DealerNo); ///more lines below } }