This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
namespace AyaNova.Api.ControllerHelpers
|
||||
{
|
||||
internal static class ImportModeFromContext
|
||||
{
|
||||
internal static bool ImportMode(IDictionary<object, object> HttpContextItems)
|
||||
{
|
||||
return HttpContextItems["AY_IMPORT_MODE"] != null;
|
||||
}
|
||||
}
|
||||
}//eons
|
||||
@@ -463,9 +463,10 @@ namespace AyaNova
|
||||
context.Request.HttpContext.Items["AY_USER_ID"] = u.id;
|
||||
context.Request.HttpContext.Items["AY_TRANSLATION_ID"] = u.translationId;
|
||||
|
||||
//Is import mode header set?
|
||||
if (context.Request.Headers.ContainsKey("X-AY-Import-Mode"))
|
||||
context.Request.HttpContext.Items["AY_IMPORT_MODE"] = true;
|
||||
//turned out didn't need this for v8 migrate so far, but keeping in case it turns out to be handy down the road
|
||||
// //Is import mode header set?
|
||||
// if (context.Request.Headers.ContainsKey("X-AY-Import-Mode"))
|
||||
// context.Request.HttpContext.Items["AY_IMPORT_MODE"] = true;
|
||||
|
||||
|
||||
//CHECK JWT
|
||||
|
||||
@@ -13,8 +13,7 @@ namespace AyaNova.Biz
|
||||
|
||||
public BizObject()
|
||||
{
|
||||
//default
|
||||
ImportMode=false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +27,6 @@ namespace AyaNova.Biz
|
||||
internal long UserId { get; set; }
|
||||
internal long UserTranslationId { get; set; }
|
||||
internal AuthorizationRoles CurrentUserRoles { get; set; }
|
||||
internal bool ImportMode { get; set; }//mostly for v8 migrate notification disabling purposes but could be used for other things D.T.R. (down the road)
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//Returns the biz object class that corresponds to the type presented
|
||||
//Used by SEARCH and objects with JOBS
|
||||
internal static BizObject GetBizObject(AyaType ayaType, AyContext ct, long userId = 1, AuthorizationRoles roles = AuthorizationRoles.All, bool InImportMode=false)
|
||||
internal static BizObject GetBizObject(AyaType ayaType, AyContext ct, long userId = 1, AuthorizationRoles roles = AuthorizationRoles.All)
|
||||
{
|
||||
|
||||
switch (ayaType)
|
||||
@@ -33,9 +33,7 @@ namespace AyaNova.Biz
|
||||
case AyaType.FileAttachment:
|
||||
return new AttachmentBiz(ct, userId, roles);
|
||||
case AyaType.Customer:
|
||||
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles, InImportMode);
|
||||
case AyaType.CustomerNote:
|
||||
return new CustomerNoteBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.User:
|
||||
return new UserBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
|
||||
|
||||
@@ -13,22 +13,21 @@ namespace AyaNova.Biz
|
||||
{
|
||||
internal class CustomerBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject, IExportAbleObject, IImportAbleObject
|
||||
{
|
||||
internal CustomerBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles, bool InImportMode)
|
||||
internal CustomerBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles)
|
||||
{
|
||||
ct = dbcontext;
|
||||
UserId = currentUserId;
|
||||
UserTranslationId = userTranslationId;
|
||||
CurrentUserRoles = UserRoles;
|
||||
BizType = AyaType.Customer;
|
||||
ImportMode = InImportMode;
|
||||
}
|
||||
|
||||
internal static CustomerBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
|
||||
{
|
||||
if (httpContext != null)
|
||||
return new CustomerBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items), ImportModeFromContext.ImportMode(httpContext.Items));
|
||||
return new CustomerBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
||||
else
|
||||
return new CustomerBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdminFull, false);
|
||||
return new CustomerBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdminFull);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -55,10 +54,7 @@ namespace AyaNova.Biz
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
await SearchIndexAsync(newObject, true);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||
if (!ImportMode)
|
||||
await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
else
|
||||
newObject.TechNotes+="*";
|
||||
await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
return newObject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//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
|
||||
@@ -141,10 +141,12 @@ namespace AyaNova.Biz
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user