This commit is contained in:
2020-07-10 21:39:17 +00:00
parent 920ccf7250
commit e2e38b62c7
4 changed files with 66 additions and 6 deletions

View File

@@ -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

View File

@@ -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
{

View File

@@ -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
/// <summary>
/// Duplicate NotifySubscription
/// (Wiki and Attachments are not duplicated)
/// </summary>
/// <param name="id">Source object id</param>
/// <param name="apiVersion">From route path</param>

View File

@@ -101,6 +101,8 @@ namespace AyaNova.Biz
//
internal async Task<NotifySubscription> 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