From e2e38b62c79e8b512095d9852bdda56eafd27b8a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 10 Jul 2020 21:39:17 +0000 Subject: [PATCH] --- devdocs/specs/core-notification.txt | 2 +- .../AyaNova/Controllers/EnumListController.cs | 61 +++++++++++++++++++ .../NotifySubscriptionController.cs | 5 +- server/AyaNova/biz/NotifySubscriptionBiz.cs | 4 +- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/devdocs/specs/core-notification.txt b/devdocs/specs/core-notification.txt index b29b517c..b039334e 100644 --- a/devdocs/specs/core-notification.txt +++ b/devdocs/specs/core-notification.txt @@ -70,7 +70,7 @@ TODO: Translation keys needed: OutTags - +todo: updating subscriptions must clear out old events and notifications if they are affected TODO: check before any thing that might create a dupe todo: have removed the old v7 SMTP retry deliveries for simplification instead, it will now act as if this is always set to true diff --git a/server/AyaNova/Controllers/EnumListController.cs b/server/AyaNova/Controllers/EnumListController.cs index db0f7720..5ca3dd50 100644 --- a/server/AyaNova/Controllers/EnumListController.cs +++ b/server/AyaNova/Controllers/EnumListController.cs @@ -227,6 +227,67 @@ namespace AyaNova.Api.Controllers ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleSalesFull"], Id = (long)AuthorizationRoles.SalesFull }); // ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleAll"], Id = (long)AuthorizationRoles.All }); + } + else if (keyNameInLowerCase == StringUtil.TrimTypeName(typeof(NotifyEventType).ToString()).ToLowerInvariant()) + { + TranslationKeysToFetch.Add("NotifyEventObjectDeleted"); + TranslationKeysToFetch.Add("NotifyEventObjectCreated"); + TranslationKeysToFetch.Add("NotifyEventObjectModified"); + TranslationKeysToFetch.Add("NotifyEventWorkorderStatusChange"); + TranslationKeysToFetch.Add("NotifyEventContractExpiring"); + TranslationKeysToFetch.Add("NotifyEventCSRAccepted"); + TranslationKeysToFetch.Add("NotifyEventCSRRejected"); + TranslationKeysToFetch.Add("NotifyEventWorkorderClosed"); + TranslationKeysToFetch.Add("NotifyEventQuoteStatusChange"); + TranslationKeysToFetch.Add("NotifyEventWorkorderFollowUp"); + TranslationKeysToFetch.Add("NotifyEventServiceBankDepleted"); + TranslationKeysToFetch.Add("NotifyEventReminderImminent"); + TranslationKeysToFetch.Add("NotifyEventScheduledOnWorkorder"); + TranslationKeysToFetch.Add("NotifyEventScheduledOnWorkorderImminent"); + TranslationKeysToFetch.Add("NotifyEventWorkorderCloseByPassed"); + TranslationKeysToFetch.Add("NotifyEventOutsideServiceOverdue"); + TranslationKeysToFetch.Add("NotifyEventOutsideServiceReceived"); + TranslationKeysToFetch.Add("NotifyEventPartRequestReceived"); + TranslationKeysToFetch.Add("NotifyEventNotifyHealthCheck"); + TranslationKeysToFetch.Add("NotifyEventBackupStatus"); + TranslationKeysToFetch.Add("NotifyEventCustomerServiceImminent"); + TranslationKeysToFetch.Add("NotifyEventPartRequested"); + TranslationKeysToFetch.Add("NotifyEventWorkorderTotalExceedsThreshold"); + TranslationKeysToFetch.Add("NotifyEventWorkorderStatusAge"); + TranslationKeysToFetch.Add("NotifyEventUnitWarrantyExpiry"); + TranslationKeysToFetch.Add("NotifyEventUnitMeterReadingMultipleExceeded"); + TranslationKeysToFetch.Add("NotifyEventDefaultNotification"); + + var LT = TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, TranslationId).Result; + + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventObjectDeleted"], Id = (long)NotifyEventType.ObjectDeleted }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventObjectCreated"], Id = (long)NotifyEventType.ObjectCreated }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventObjectModified"], Id = (long)NotifyEventType.ObjectModified }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventWorkorderStatusChange"], Id = (long)NotifyEventType.WorkorderStatusChange }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventContractExpiring"], Id = (long)NotifyEventType.ContractExpiring }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventCSRAccepted"], Id = (long)NotifyEventType.CSRAccepted }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventCSRRejected"], Id = (long)NotifyEventType.CSRRejected }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventWorkorderClosed"], Id = (long)NotifyEventType.WorkorderClosed }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventQuoteStatusChange"], Id = (long)NotifyEventType.QuoteStatusChange }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventWorkorderFollowUp"], Id = (long)NotifyEventType.WorkorderFollowUp }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventServiceBankDepleted"], Id = (long)NotifyEventType.ServiceBankDepleted }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventReminderImminent"], Id = (long)NotifyEventType.ReminderImminent }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventScheduledOnWorkorder"], Id = (long)NotifyEventType.ScheduledOnWorkorder }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventScheduledOnWorkorderImminent"], Id = (long)NotifyEventType.ScheduledOnWorkorderImminent }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventWorkorderCloseByPassed"], Id = (long)NotifyEventType.WorkorderCloseByPassed }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventOutsideServiceOverdue"], Id = (long)NotifyEventType.OutsideServiceOverdue }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventOutsideServiceReceived"], Id = (long)NotifyEventType.OutsideServiceReceived }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventPartRequestReceived"], Id = (long)NotifyEventType.PartRequestReceived }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventNotifyHealthCheck"], Id = (long)NotifyEventType.NotifyHealthCheck }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventBackupStatus"], Id = (long)NotifyEventType.BackupStatus }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventCustomerServiceImminent"], Id = (long)NotifyEventType.CustomerServiceImminent }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventPartRequested"], Id = (long)NotifyEventType.PartRequested }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventWorkorderTotalExceedsThreshold"], Id = (long)NotifyEventType.WorkorderTotalExceedsThreshold }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventWorkorderStatusAge"], Id = (long)NotifyEventType.WorkorderStatusAge }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventUnitWarrantyExpiry"], Id = (long)NotifyEventType.UnitWarrantyExpiry }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventUnitMeterReadingMultipleExceeded"], Id = (long)NotifyEventType.UnitMeterReadingMultipleExceeded }); + ReturnList.Add(new NameIdItem() { Name = LT["NotifyEventDefaultNotification"], Id = (long)NotifyEventType.DefaultNotification }); + } else { diff --git a/server/AyaNova/Controllers/NotifySubscriptionController.cs b/server/AyaNova/Controllers/NotifySubscriptionController.cs index 810d70ba..3c0b4d70 100644 --- a/server/AyaNova/Controllers/NotifySubscriptionController.cs +++ b/server/AyaNova/Controllers/NotifySubscriptionController.cs @@ -6,14 +6,12 @@ using Microsoft.Extensions.Logging; using AyaNova.Models; using AyaNova.Api.ControllerHelpers; using AyaNova.Biz; -using System.Linq; -using Microsoft.EntityFrameworkCore; namespace AyaNova.Api.Controllers { [ApiController] [ApiVersion("8.0")] - [Route("api/v{version:apiVersion}/notify")] + [Route("api/v{version:apiVersion}/notify-subscription")] [Produces("application/json")] [Authorize] public class NotifySubscriptionController : ControllerBase @@ -60,7 +58,6 @@ namespace AyaNova.Api.Controllers /// /// Duplicate NotifySubscription - /// (Wiki and Attachments are not duplicated) /// /// Source object id /// From route path diff --git a/server/AyaNova/biz/NotifySubscriptionBiz.cs b/server/AyaNova/biz/NotifySubscriptionBiz.cs index 1aaa4b3e..46abd0bb 100644 --- a/server/AyaNova/biz/NotifySubscriptionBiz.cs +++ b/server/AyaNova/biz/NotifySubscriptionBiz.cs @@ -101,6 +101,8 @@ namespace AyaNova.Biz // internal async Task PutAsync(NotifySubscription putObject) { + //TODO: Must remove all prior events and replace them + NotifySubscription dbObject = await ct.NotifySubscription.SingleOrDefaultAsync(z => z.Id == putObject.Id); if (dbObject == null) { @@ -187,7 +189,7 @@ namespace AyaNova.Biz //todo: validate subscription is valid //perhaps check if customer type user doesn't have non customer notification etc - + //NOTE: In DB schema only name and serial are not nullable //run validation and biz rules