This commit is contained in:
11
server/AyaNova/ControllerHelpers/ImportModeFromContext.cs
Normal file
11
server/AyaNova/ControllerHelpers/ImportModeFromContext.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
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,6 +463,11 @@ 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?
|
||||||
|
|
||||||
|
context.Request.HttpContext.Items["AY_IMPORT_MODE"]= context.Request.Headers.ContainsKey("X-AY-Import-Mode");
|
||||||
|
|
||||||
|
|
||||||
//CHECK JWT
|
//CHECK JWT
|
||||||
if (
|
if (
|
||||||
!context.Request.Path.Value.EndsWith("/auth") &&
|
!context.Request.Path.Value.EndsWith("/auth") &&
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
public BizObject()
|
public BizObject()
|
||||||
{
|
{
|
||||||
|
//default
|
||||||
|
ImportMode=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
internal static BizObject GetBizObject(AyaType ayaType, AyContext ct, long userId = 1, AuthorizationRoles roles = AuthorizationRoles.All, bool InImportMode=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (ayaType)
|
switch (ayaType)
|
||||||
@@ -33,7 +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);
|
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles, InImportMode);
|
||||||
case AyaType.CustomerNote:
|
case AyaType.CustomerNote:
|
||||||
return new CustomerNoteBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new CustomerNoteBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.User:
|
case AyaType.User:
|
||||||
|
|||||||
@@ -13,21 +13,22 @@ 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)
|
internal CustomerBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles, bool InImportMode)
|
||||||
{
|
{
|
||||||
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));
|
return new CustomerBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items), ImportModeFromContext.ImportMode(httpContext.Items));
|
||||||
else
|
else
|
||||||
return new CustomerBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdminFull);
|
return new CustomerBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdminFull, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ namespace AyaNova.Util
|
|||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
// Erase all user entered data from the db
|
// Erase all user entered data from the db
|
||||||
// This is called by seeder for trial seeding purposes
|
// This is called by seeder for trial seeding purposes
|
||||||
//
|
// and by v8 migrate v7 exporter
|
||||||
internal static async Task EmptyBizDataFromDatabaseForSeedingOrImportingAsync(ILogger _log)
|
internal static async Task EmptyBizDataFromDatabaseForSeedingOrImportingAsync(ILogger _log)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user