This commit is contained in:
@@ -1083,7 +1083,7 @@ namespace AyaNova.Biz
|
||||
#endregion
|
||||
|
||||
|
||||
#region CustomerServiceImminent
|
||||
#region CustomerServiceImminent "Service Reminder"
|
||||
if (ayaEvent == AyaEvent.Created && oProposed.ServiceDate != null && oProposed.ServiceDate > DateTime.UtcNow)
|
||||
{
|
||||
|
||||
@@ -1093,8 +1093,36 @@ namespace AyaNova.Biz
|
||||
//not for inactive users
|
||||
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||
|
||||
//No tag match for this one
|
||||
//Customer User?
|
||||
var UserInfo = await ct.User.AsNoTracking().Where(x => x.Id == sub.UserId).Select(x => new { x.CustomerId, x.UserType, x.HeadOfficeId }).FirstOrDefaultAsync();
|
||||
if (UserInfo.UserType == UserType.Customer || UserInfo.UserType == UserType.HeadOffice)
|
||||
{
|
||||
//CUSTOMER USER
|
||||
|
||||
//Quick short circuit: if workorder doesn't have a customer id then it's not going to match no matter what
|
||||
if (oProposed.CustomerId == 0) continue;
|
||||
|
||||
var customerUserRights = await UserBiz.CustomerUserEffectiveRightsAsync(sub.UserId);
|
||||
|
||||
//Are they allowed right now to use this type of notification?
|
||||
if (!customerUserRights.NotifyWOCreated) continue;
|
||||
|
||||
//is this their related work order?
|
||||
if (UserInfo.CustomerId != oProposed.CustomerId)
|
||||
{
|
||||
//not the same customer but might be a head office user and this is one of their customers so check for that
|
||||
if (UserInfo.HeadOfficeId == null) continue;//can't match any head office so no need to go further
|
||||
|
||||
//see if workorder customer's head office is the same id as the user's headofficeid (note that a customer user with the same head office as a *different* customer workorder doesn't qualify)
|
||||
var CustomerInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == oProposed.CustomerId).Select(x => new { x.HeadOfficeId, x.BillHeadOffice }).FirstOrDefaultAsync();
|
||||
if (!CustomerInfo.BillHeadOffice) continue;//can't possibly match so no need to go further
|
||||
if (UserInfo.HeadOfficeId != CustomerInfo.HeadOfficeId) continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
continue;//only customers can subscribe to this particular notification
|
||||
|
||||
//No tag match for this one
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.CustomerServiceImminent,
|
||||
@@ -1111,10 +1139,10 @@ namespace AyaNova.Biz
|
||||
|
||||
}
|
||||
|
||||
}//CustomerServiceImminent
|
||||
}//CustomerServiceImminent "Service Reminder"
|
||||
|
||||
if (ayaEvent == AyaEvent.Modified)
|
||||
{// CustomerServiceImminent
|
||||
{// CustomerServiceImminent "Service Reminder"
|
||||
|
||||
//differences requiring re-processing of notification
|
||||
if (oProposed.ServiceDate != oCurrent.ServiceDate)
|
||||
@@ -1131,6 +1159,35 @@ namespace AyaNova.Biz
|
||||
//not for inactive users
|
||||
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||
|
||||
//Customer User?
|
||||
var UserInfo = await ct.User.AsNoTracking().Where(x => x.Id == sub.UserId).Select(x => new { x.CustomerId, x.UserType, x.HeadOfficeId }).FirstOrDefaultAsync();
|
||||
if (UserInfo.UserType == UserType.Customer || UserInfo.UserType == UserType.HeadOffice)
|
||||
{
|
||||
//CUSTOMER USER
|
||||
|
||||
//Quick short circuit: if workorder doesn't have a customer id then it's not going to match no matter what
|
||||
if (oProposed.CustomerId == 0) continue;
|
||||
|
||||
var customerUserRights = await UserBiz.CustomerUserEffectiveRightsAsync(sub.UserId);
|
||||
|
||||
//Are they allowed right now to use this type of notification?
|
||||
if (!customerUserRights.NotifyWOCreated) continue;
|
||||
|
||||
//is this their related work order?
|
||||
if (UserInfo.CustomerId != oProposed.CustomerId)
|
||||
{
|
||||
//not the same customer but might be a head office user and this is one of their customers so check for that
|
||||
if (UserInfo.HeadOfficeId == null) continue;//can't match any head office so no need to go further
|
||||
|
||||
//see if workorder customer's head office is the same id as the user's headofficeid (note that a customer user with the same head office as a *different* customer workorder doesn't qualify)
|
||||
var CustomerInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == oProposed.CustomerId).Select(x => new { x.HeadOfficeId, x.BillHeadOffice }).FirstOrDefaultAsync();
|
||||
if (!CustomerInfo.BillHeadOffice) continue;//can't possibly match so no need to go further
|
||||
if (UserInfo.HeadOfficeId != CustomerInfo.HeadOfficeId) continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
continue;//only customers can subscribe to this particular notification
|
||||
|
||||
//No tag match for this one
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
@@ -1150,7 +1207,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
}//CustomerServiceImminent
|
||||
}//CustomerServiceImminent "Service Reminder"
|
||||
|
||||
//# WorkorderCreatedForCustomer - Customer / headoffice notification
|
||||
if (oProposed.CustomerId != 0 && (ayaEvent == AyaEvent.Created
|
||||
|
||||
Reference in New Issue
Block a user