This commit is contained in:
2020-11-27 19:55:33 +00:00
parent 54b9455e74
commit f264f012ed
6 changed files with 16 additions and 32 deletions

View File

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

View File

@@ -463,9 +463,10 @@ namespace AyaNova
context.Request.HttpContext.Items["AY_USER_ID"] = u.id; context.Request.HttpContext.Items["AY_USER_ID"] = u.id;
context.Request.HttpContext.Items["AY_TRANSLATION_ID"] = u.translationId; context.Request.HttpContext.Items["AY_TRANSLATION_ID"] = u.translationId;
//Is import mode header set? //turned out didn't need this for v8 migrate so far, but keeping in case it turns out to be handy down the road
if (context.Request.Headers.ContainsKey("X-AY-Import-Mode")) // //Is import mode header set?
context.Request.HttpContext.Items["AY_IMPORT_MODE"] = true; // if (context.Request.Headers.ContainsKey("X-AY-Import-Mode"))
// context.Request.HttpContext.Items["AY_IMPORT_MODE"] = true;
//CHECK JWT //CHECK JWT

View File

@@ -13,8 +13,7 @@ namespace AyaNova.Biz
public BizObject() public BizObject()
{ {
//default
ImportMode=false;
} }
@@ -28,7 +27,6 @@ namespace AyaNova.Biz
internal long UserId { get; set; } internal long UserId { get; set; }
internal long UserTranslationId { get; set; } internal long UserTranslationId { get; set; }
internal AuthorizationRoles CurrentUserRoles { 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 #endregion

View File

@@ -12,7 +12,7 @@ namespace AyaNova.Biz
//Returns the biz object class that corresponds to the type presented //Returns the biz object class that corresponds to the type presented
//Used by SEARCH and objects with JOBS //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) switch (ayaType)
@@ -33,9 +33,7 @@ namespace AyaNova.Biz
case AyaType.FileAttachment: case AyaType.FileAttachment:
return new AttachmentBiz(ct, userId, roles); return new AttachmentBiz(ct, userId, roles);
case AyaType.Customer: case AyaType.Customer:
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles, InImportMode); return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
case AyaType.CustomerNote:
return new CustomerNoteBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
case AyaType.User: case AyaType.User:
return new UserBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles); return new UserBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);

View File

@@ -13,22 +13,21 @@ namespace AyaNova.Biz
{ {
internal class CustomerBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject, IExportAbleObject, IImportAbleObject 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; ct = dbcontext;
UserId = currentUserId; UserId = currentUserId;
UserTranslationId = userTranslationId; UserTranslationId = userTranslationId;
CurrentUserRoles = UserRoles; CurrentUserRoles = UserRoles;
BizType = AyaType.Customer; BizType = AyaType.Customer;
ImportMode = InImportMode;
} }
internal static CustomerBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null) internal static CustomerBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
{ {
if (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 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 EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
await SearchIndexAsync(newObject, true); await SearchIndexAsync(newObject, true);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
if (!ImportMode) await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
else
newObject.TechNotes+="*";
return newObject; return newObject;
} }
} }

View File

@@ -141,10 +141,12 @@ namespace AyaNova.Biz
bool SaveContext = false; bool SaveContext = false;
try try
{ {
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext) 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 through AyaEvent then individual Ayatypes as required for event types
switch (ayaEvent) switch (ayaEvent)
{ {