This commit is contained in:
@@ -31,13 +31,15 @@ namespace AyaNova.Biz
|
|||||||
//NOTE: agevalue and advanced notice settings here will ensure that direct in app notifications with a future delivery date ("deadman" switch deliveries) set in their
|
//NOTE: agevalue and advanced notice settings here will ensure that direct in app notifications with a future delivery date ("deadman" switch deliveries) set in their
|
||||||
//notifyevent.eventdate will deliver on that date and not immediately to support all the things that are direct built in notifications for future dates
|
//notifyevent.eventdate will deliver on that date and not immediately to support all the things that are direct built in notifications for future dates
|
||||||
//such as for an overdue Review which doesn't have or need it's own notifyeventtype and subscription independently
|
//such as for an overdue Review which doesn't have or need it's own notifyeventtype and subscription independently
|
||||||
|
|
||||||
|
//NEW NOTE: above makes not sense, I'm setting these back to timespan zero
|
||||||
defaultsub = new NotifySubscription()
|
defaultsub = new NotifySubscription()
|
||||||
{
|
{
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
EventType = NotifyEventType.GeneralNotification,
|
EventType = NotifyEventType.GeneralNotification,
|
||||||
DeliveryMethod = NotifyDeliveryMethod.App,
|
DeliveryMethod = NotifyDeliveryMethod.App,
|
||||||
AgeValue = new TimeSpan(0, 0, 1),
|
AgeValue = TimeSpan.Zero,//new TimeSpan(0, 0, 1),
|
||||||
AdvanceNotice = new TimeSpan(0, 0, 1)
|
AdvanceNotice = TimeSpan.Zero//new TimeSpan(0, 0, 1)
|
||||||
};
|
};
|
||||||
await ct.NotifySubscription.AddAsync(defaultsub);
|
await ct.NotifySubscription.AddAsync(defaultsub);
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
@@ -339,7 +341,7 @@ namespace AyaNova.Biz
|
|||||||
var UserName = await ct.User.AsNoTracking().Where(z => z.Id == userId).Select(z => z.Name).FirstOrDefaultAsync();
|
var UserName = await ct.User.AsNoTracking().Where(z => z.Id == userId).Select(z => z.Name).FirstOrDefaultAsync();
|
||||||
|
|
||||||
//if they don't have a regular inapp subscription create one now
|
//if they don't have a regular inapp subscription create one now
|
||||||
await EnsureDefaultInAppUserNotificationSubscriptionExists(userId, ct);
|
await EnsureDefaultInAppUserNotificationSubscriptionExists(userId, ct);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
name = UserName;
|
name = UserName;
|
||||||
|
|||||||
@@ -1222,6 +1222,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
public async Task StateHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task StateHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if (ServerBootConfig.SEEDING) return;
|
if (ServerBootConfig.SEEDING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
@@ -4352,13 +4353,51 @@ namespace AyaNova.Biz
|
|||||||
//do it regardless any time there's an update and then
|
//do it regardless any time there's an update and then
|
||||||
//let this code below handle the refreshing addition that could have changes
|
//let this code below handle the refreshing addition that could have changes
|
||||||
// await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.ContractExpiring);
|
// await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.ContractExpiring);
|
||||||
|
var woId = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, o.WorkOrderItemId, ct);
|
||||||
|
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == woId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
|
||||||
//## CREATED / MODIFIED EVENTS
|
//## CREATED
|
||||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
if (ayaEvent == AyaEvent.Created)
|
||||||
{
|
{
|
||||||
|
|
||||||
//todo: fix etc, tons of shit here incoming
|
//# ScheduledOnWorkorder event
|
||||||
|
if (o.UserId != null)
|
||||||
|
{
|
||||||
|
//Conditions: userid match and tags
|
||||||
|
//delivery is immediate so no need to remove old ones of this kind
|
||||||
|
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ScheduledOnWorkorder && z.UserId == o.UserId).ToListAsync();
|
||||||
|
foreach (var sub in subs)
|
||||||
|
{
|
||||||
|
//not for inactive users
|
||||||
|
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||||
|
|
||||||
|
//Tag match? (will be true if no sub tags so always safe to call this)
|
||||||
|
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags))
|
||||||
|
{
|
||||||
|
NotifyEvent n = new NotifyEvent()
|
||||||
|
{
|
||||||
|
EventType = NotifyEventType.WorkorderStatusChange,
|
||||||
|
UserId = sub.UserId,
|
||||||
|
AyaType = AyaType.WorkOrder,
|
||||||
|
ObjectId = o.WorkOrderId,
|
||||||
|
NotifySubscriptionId = sub.Id,
|
||||||
|
Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}"
|
||||||
|
};
|
||||||
|
await ct.NotifyEvent.AddAsync(n);
|
||||||
|
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||||
|
await ct.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//workorder status change event
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//## MODIFIED
|
||||||
|
if (ayaEvent == AyaEvent.Modified)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,8 +208,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
await m.SendEmailAsync(deliveryAddress, subject, body, ServerGlobalOpsSettingsCache.Notify);
|
await m.SendEmailAsync(deliveryAddress, subject, body, ServerGlobalOpsSettingsCache.Notify);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"Test of general notification system", "Error", null, ne.UserId);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using AyaNova.Util;
|
using AyaNova.Util;
|
||||||
using AyaNova.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
|
|
||||||
namespace AyaNova.Biz
|
namespace AyaNova.Biz
|
||||||
|
|||||||
Reference in New Issue
Block a user