This commit is contained in:
2022-03-09 15:13:37 +00:00
parent 8645463641
commit 66c059beeb
8 changed files with 45 additions and 322 deletions

View File

@@ -462,7 +462,7 @@ namespace AyaNova.Api.Controllers
TranslationKeysToFetch.Add("NotifyEventUnitMeterReadingMultipleExceeded");
TranslationKeysToFetch.Add("NotifyEventServerOperationsProblem");
TranslationKeysToFetch.Add("NotifyEventGeneralNotification");
TranslationKeysToFetch.Add("NotifyEventCopyOfCustomerNotification");
//TranslationKeysToFetch.Add("NotifyEventCopyOfCustomerNotification");
TranslationKeysToFetch.Add("NotifyEventWorkorderCreatedForCustomer");
TranslationKeysToFetch.Add("NotifyEventPMGenerationFailed");
TranslationKeysToFetch.Add("NotifyEventPMInsufficientInventory");
@@ -501,7 +501,7 @@ namespace AyaNova.Api.Controllers
ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventServerOperationsProblem"], Id = (long)NotifyEventType.ServerOperationsProblem });
ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventGeneralNotification"], Id = (long)NotifyEventType.GeneralNotification });
ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventCopyOfCustomerNotification"], Id = (long)NotifyEventType.CopyOfCustomerNotification });
// ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventCopyOfCustomerNotification"], Id = (long)NotifyEventType.CopyOfCustomerNotification });
ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventWorkorderCreatedForCustomer"], Id = (long)NotifyEventType.WorkorderCreatedForCustomer });
ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventPMGenerationFailed"], Id = (long)NotifyEventType.PMGenerationFailed });

View File

@@ -404,283 +404,3 @@ namespace AyaNova.Biz
}//eoc
}//eons
//###DEPRECATED: MOVED EVENT PROCESSING INTO BIZ OBJECTS BUT
// //SPLIT INTO STANDARD EVENT PROCESSING METHODS BELOW
// //AND ANYTHING TYPE SPECIFIC IS IN BIZ OBJECT ITSELF
// //KEEPING THIS AS IT HAS SOME IMPLEMENTATION NOTES IN IT
// //This is told about an event and then determines if there are any subscriptions related to that event and proceses them accordingly
// //todo: this should take some kind of general event type like the AyaEvent types (i.e. which CRUD operation is in effect if relevant)
// //and also a biz object before and after or just before if not a change and also a AyaType
// //then *this* code will go through and look for subscriptions related to that event
// //this way the biz object code can be "dumb" about notifications in general and just let this code handle it as needed
// //will iterate the subscriptions and see if any apply here
// internal static async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel newObject, ICoreBizObjectModel originalObject = null)
// {
// if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
// log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{newObject.AyaType}, AyaEvent:{ayaEvent}]");
// //set to true if any changes are made to the context (NotifyEvent added)
// bool SaveContext = false;
// try
// {
// using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
// {
// //short circuit if there are no subscriptions which would be typical of a v8 migrate scenario or fresh import or just not using notification
// if (!await ct.NotifySubscription.AnyAsync())
// return;
// //switch through AyaEvent then individual Ayatypes as required for event types
// switch (ayaEvent)
// {
// case AyaEvent.Created:
// #region Created processing
// //------------------------------
// // AyaType Specific created related subscriptions
// // Note: these are for specific things only in this block
// // generally being created notifications are further down below
// switch (newObject.AyaType)
// {
// //AyaTypes with their own special notification related events
// case AyaType.WorkOrder:
// {
// //WorkorderStatusChange
// {
// throw new System.NotImplementedException("Awaiting workorder object completion");
// var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.WorkorderStatusChange).ToListAsync();
// foreach (var sub in subs)
// {
// if (TagsMatch(newObject.Tags, sub.Tags))
// {
// NotifyEvent n = new NotifyEvent()
// {
// EventType = NotifyEventType.ObjectAge,
// UserId = sub.UserId,
// ObjectId = newObject.Id,
// NotifySubscriptionId = sub.Id,
// //TODO: IdValue=((WorkOrder)newObject).WorkorderStatusId
// Name = newObject.Name
// };
// await ct.NotifyEvent.AddAsync(n);
// log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
// //Note: in same event but for MODIFY below if need to delete old notifyevent here
// // var deleteEventList = await ct.NotifyEvent.Where(z => z.ObjectId == ev.ObjectId && z.AyaType == ev.AyaType).ToListAsync();
// // ct.NotifyEvent.RemoveRange(deleteEventList);
// SaveContext = true;
// }
// }
// }
// //ScheduledOnWorkorder https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/892
// //ScheduledOnWorkorderImminent https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/892
// //WorkorderCompletedStatusOverdue
// //WorkorderCompleted [USER, CUSTOMER], if customer then also CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// //OutsideServiceOverdue
// //OutsideServiceReceived https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/892
// //PartRequestReceived https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/892
// //CustomerServiceImminent ALSO CopyOfCustomerNotification
// //WorkorderCreatedForCustomer (conditional ID sb customer id) ALSO CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// //PartRequested https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/892
// //WorkorderTotalExceedsThreshold
// //WorkorderStatusAge
// }
// break;
// case AyaType.Quote:
// //QuoteStatusChange [USER, CUSTOMER] / ALSO CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// //QuoteStatusAge
// break;
// case AyaType.Contract:
// //ContractExpiring [CUSTOMER/USER] / ALSO CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// break;
// case AyaType.Reminder:
// //ReminderImminent
// break;
// case AyaType.Unit:
// //UnitWarrantyExpiry
// break;
// case AyaType.UnitMeterReading:
// //UnitMeterReadingMultipleExceeded
// break;
// }
// //------------------------------------------
// //ObjectCreated
// //
// // [USER for any type, CUSTOMER for workorder only] / if customer then CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// // {
// // }
// #endregion created processing
// break;
// case AyaEvent.Modified:
// #region Modified processing
// //######## NOTE: be sure to remove any that are being replaced potentially
// //------------------------------
// // AyaType Specific modified related subscriptions
// //
// switch (newObject.AyaType)
// {
// //AyaTypes with their own special notification related events
// case AyaType.WorkOrder:
// {
// //WorkorderStatusChange [USER, CUSTOMER BOTH] / CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// //
// {
// throw new System.NotImplementedException("Awaiting workorder object completion");
// // if (((WorkOrder)newObject).WorkorderStatusId != ((WorkOrder)dbObject).WorkorderStatusId)
// // {
// // var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.WorkorderStatusChange).ToListAsync();
// // foreach (var sub in subs)
// // {
// // if (TagsMatch(newObject.Tags, sub.Tags))
// // {
// // NotifyEvent n = new NotifyEvent()
// // {
// // EventType = NotifyEventType.ObjectAge,
// // UserId = sub.UserId,
// // ObjectId = newObject.Id,
// // NotifySubscriptionId = sub.Id,
// // //TODO: IdValue=((WorkOrder)newObject).WorkorderStatusId
// // EventDate = DateTime.UtcNow,
// //Name=newObject.Name
// //,
// // Name=newObject.Name
// // };
// // await ct.NotifyEvent.AddAsync(n);
// // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
// // //Note: in same event but for MODIFY below if need to delete old notifyevent here
// // // var deleteEventList = await ct.NotifyEvent.Where(z => z.ObjectId == ev.ObjectId && z.AyaType == ev.AyaType).ToListAsync();
// // // ct.NotifyEvent.RemoveRange(deleteEventList);
// // SaveContext = true;
// // }
// // }
// // }
// }
// //ScheduledOnWorkorder (DELETE OLD, USER / DATE COULD CHANGE)
// //https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/892
// //ScheduledOnWorkorderImminent (DELTE OLD)
// //https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/892
// //WorkorderCompletedStatusOverdue (DELETE OLD)
// //WorkorderCompleted [USER, CUSTOMER] ALSO CopyOfCustomerNotification applies here https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// //OutsideServiceOverdue (ALSO DELETE OLD)
// //OutsideServiceReceived
// //PartRequestReceived
// //CustomerServiceImminent (ALSO DELETE OLD) / ALSO CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// //PartRequested
// //https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/892
// //WorkorderTotalExceedsThreshold
// //WorkorderStatusAge (ALSO DELETE OLD)
// //https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/1137
// //WorkorderCompletedFollowUp (uses AGE after Completed status) [USER]
// }
// break;
// case AyaType.Quote:
// //QuoteStatusChange [USER, CUSTOMER] ALSO CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// //QuoteStatusAge (DELETE OLD)
// break;
// case AyaType.Contract:
// //ContractExpiring (DELETE OLD)
// break;
// case AyaType.Reminder:
// //ReminderImminent (DELETE OLD)
// break;
// case AyaType.Unit:
// //UnitWarrantyExpiry (DELETE OLD)
// break;
// case AyaType.UnitMeterReading:
// //UnitMeterReadingMultipleExceeded
// //case 1254
// // This is as a threshold multiple value, i.e. if it's passing a multiple of 50,000 then notify, or notify every 10,000 or something.
// // In saving code it just checks to see if it has crossed the multiple threshold, i.e. calculate the old multiple, calculate the new multiple if over then send notification immediate.
// break;
// case AyaType.CustomerServiceRequest:
// //CSRAccepted (DELETE OLD might have changed from one to the other) [CUSTOMER] ALSO CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// //CSRRejected (DELETE OLD might have changed from one to the other) [CUSTOMER] ALSO CopyOfCustomerNotification https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3398
// break;
// case AyaType.ServiceBank:
// //ServiceBankDepleted https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/472
// break;
// }
// //------------------------------------------
// //ObjectModified
// //
// // {
// // var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ObjectModified && z.AyaType == newObject.AyaType).ToListAsync();
// // foreach (var sub in subs)
// // {
// // if (TagsMatch(newObject.Tags, sub.Tags))
// // {
// // NotifyEvent n = new NotifyEvent()
// // {
// // EventType = NotifyEventType.ObjectModified,
// // UserId = sub.UserId,
// // AyaType = newObject.AyaType,
// // ObjectId = newObject.Id,
// // NotifySubscriptionId = sub.Id,
// // Name = newObject.Name
// // };
// // await ct.NotifyEvent.AddAsync(n);
// // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
// // SaveContext = true;
// // }
// // }
// // }
// #endregion modified processing
// break;
// case AyaEvent.Deleted:
// #region Deleted processing
// //------------------------------
// // Delete any NotifyEvent records for this exact object
// await ProcessStandardObjectDeletedEvents(newObject, ct);
// #endregion deleted processing
// break;
// default:
// #if (DEBUG)
// throw (new System.NotSupportedException($"NotifyEventProcessor:HandlePotentialNotificationEvent - AyaEvent {ayaEvent} was specified which is unexpected and not supported"));
// #else
// break;
// #endif
// }
// if (SaveContext)
// await ct.SaveChangesAsync();
// }
// }
// catch (Exception ex)
// {
// log.LogError(ex, $"Error processing event");
// }
// finally
// {
// log.LogDebug($"Notify event processing completed");
// }
// }//eom

View File

@@ -18,7 +18,13 @@ namespace AyaNova.Biz
ContractExpiring = 5,//* Contract object, aged notification with optional advance notice for expiration date of contract. Customer version and User version deliveries possible.
CSRAccepted = 6,//*CustomerServiceRequest object, saved with ACCEPTED status, delivered to Customer only
CSRRejected = 7,//*CustomerServiceRequest object, saved with REJECTED status, delivered to Customer only
CopyOfCustomerNotification = 8,//*User notification of what was sent to a Customer as a notification. In other words can subscribe to any customer notifications and be sent a copy of them. Tag filter is based on Customer's tags for this one so user can choose which customer group to subscribe to this or all.
//decided against this for initial release but kept the translation keys and event type here and commented out in enumlistcontroller
//CopyOfCustomerNotification = 8,//XXXXX*User notification of what was sent to a Customer as a notification. In other words can subscribe to any customer notifications and be sent a copy of them. Tag filter is based on Customer's tags for this one so user can choose which customer group to subscribe to this or all.
// "NotifyEventCopyOfCustomerNotification": "Kopie der Kundenbenachrichtigung",
// "NotifyEventCopyOfCustomerNotification": "Copy of Customer notification",
// "NotifyEventCopyOfCustomerNotification": "Copia de la notificación al cliente",
// "NotifyEventCopyOfCustomerNotification": "Copie de la notification client",
//
QuoteStatusChange = 9,//* Quote object, any *change* of status including from no status (new) to a specific conditional status ID value
ObjectAge = 10,//* Any object, Age (conditional on AgeValue) after creation event of any object of conditional specific AyaType and optionally conditional tags
PMInsufficientInventory = 11,//Upcoming PM will not have enough inventory to generate without making a part request
@@ -43,11 +49,10 @@ namespace AyaNova.Biz
WorkorderCompleted = 30, //*Service work order is set to any status that is flagged as a "Completed" type of status. Customer & User (Note this is for users that don't want or can't pick status change to completed type)
WorkorderCreatedForCustomer = 31, //*Service work order is created for Customer, only applies to that customer user notify sub for that customer, customer id is in conditional ID value for subscription
PMGenerationFailed = 32, //indicates there was a failure during PM generation with error
SendUserCredentials = 33, // Internal System use only: When user generates new credentials and sends them this is the notification type for that see UserBiz GenerateCredsAndEmailUser
//SendUserCredentials = 33, //XXXXXXX Internal System use only: When user generates new credentials and sends them this is the notification type for that see UserBiz GenerateCredsAndEmailUser
ReviewImminent = 34,//*Review object, Advance notice setting tag conditional
//POTENTIAL OTHER NOTIFICATIONS:
//WorkOrderItemLoan unit is overdue from estimate
//NEW ITEMS REQUIRE translation KEYS

View File

@@ -611,7 +611,6 @@
"NotifyDeliveryMethodSMTP": "An E-Mail-Adresse liefern",
"NotifyEventBackupStatus": "Status der Sicherung",
"NotifyEventContractExpiring": "Vertrag läuft aus",
"NotifyEventCopyOfCustomerNotification": "Kopie der Kundenbenachrichtigung",
"NotifyEventCSRAccepted": "Kundendienstanfrage angenommen",
"NotifyEventCSRRejected": "Kundendienstanfrage abgelehnt",
"NotifyEventCustomerServiceImminent": "Servicetermin",

View File

@@ -611,7 +611,6 @@
"NotifyDeliveryMethodSMTP": "Deliver to email address",
"NotifyEventBackupStatus": "Backup status",
"NotifyEventContractExpiring": "Contract expiring",
"NotifyEventCopyOfCustomerNotification": "Copy of Customer notification",
"NotifyEventCSRAccepted": "Customer service request accepted",
"NotifyEventCSRRejected": "Customer service request rejected",
"NotifyEventCustomerServiceImminent": "Service reminder",

View File

@@ -611,7 +611,6 @@
"NotifyDeliveryMethodSMTP": "Entregar a la dirección de correo electrónico",
"NotifyEventBackupStatus": "Estado de copia de seguridad",
"NotifyEventContractExpiring": "Vencimiento del contrato",
"NotifyEventCopyOfCustomerNotification": "Copia de la notificación al cliente",
"NotifyEventCSRAccepted": "Solicitud de servicio al cliente aceptada",
"NotifyEventCSRRejected": "Solicitud de servicio al cliente rechazada",
"NotifyEventCustomerServiceImminent": "Cita de servicio",

View File

@@ -611,7 +611,6 @@
"NotifyDeliveryMethodSMTP": "Livrer à l'adresse e-mail",
"NotifyEventBackupStatus": "Statut de sauvegarde",
"NotifyEventContractExpiring": "Contrat expirant",
"NotifyEventCopyOfCustomerNotification": "Copie de la notification client",
"NotifyEventCSRAccepted": "Demande de service client acceptée",
"NotifyEventCSRRejected": "Demande de service client rejetée",
"NotifyEventCustomerServiceImminent": "Rendez-vous de service",