This commit is contained in:
2018-09-26 19:40:18 +00:00
parent fbd6b249ab
commit e0fb8b916c
4 changed files with 60 additions and 61 deletions

View File

@@ -18,6 +18,7 @@ namespace AyaNova.Biz
internal class UserBiz : BizObject, IJobObject, IImportAyaNova7Object
{
public static AyaType BizType = AyaType.User;
private readonly AyContext ct;
public readonly long UserId;
public readonly long UserLocaleId;
@@ -81,11 +82,11 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync();
//Log event
EventLogProcessor.AddEntry(new Event(UserId, outObj.Id, AyaType.User, AyaEvent.Created), ct);
EventLogProcessor.AddEntry(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
await ct.SaveChangesAsync();
//SEARCH INDEXING
Search.ProcessNewObjectKeywords(ct, UserLocaleId, outObj.Id, AyaType.User, outObj.Name, outObj.EmployeeNumber, outObj.Notes, outObj.Name);
Search.ProcessNewObjectKeywords(ct, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.EmployeeNumber, outObj.Notes, outObj.Name);
return outObj;
@@ -218,10 +219,10 @@ namespace AyaNova.Biz
//Log modification
EventLogProcessor.AddEntry(new Event(UserId, dbObj.Id, AyaType.User, AyaEvent.Modified), ct);
EventLogProcessor.AddEntry(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
ct.SaveChanges();
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, AyaType.User, dbObj.Name, dbObj.EmployeeNumber, dbObj.Notes, dbObj.Name);
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.EmployeeNumber, dbObj.Notes, dbObj.Name);
return true;
}
@@ -252,10 +253,10 @@ namespace AyaNova.Biz
return false;
//Log modification
EventLogProcessor.AddEntry(new Event(UserId, dbObj.Id, AyaType.User, AyaEvent.Modified), ct);
EventLogProcessor.AddEntry(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
ct.SaveChanges();
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, AyaType.User, dbObj.Name, dbObj.EmployeeNumber, dbObj.Notes, dbObj.Name);
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.EmployeeNumber, dbObj.Notes, dbObj.Name);
return true;
}
@@ -280,14 +281,14 @@ namespace AyaNova.Biz
ct.Database.ExecuteSqlCommand($"delete from auseroptions where userid={dbObj.Id}");
//Event log process delete
EventLogProcessor.DeleteObject(UserId, AyaType.User, dbObj.Id, dbObj.Name, ct);
EventLogProcessor.DeleteObject(UserId, BizType, dbObj.Id, dbObj.Name, ct);
ct.SaveChanges();
//Delete search index
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, AyaType.User);
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, BizType);
//TAGS
TagMapBiz.DeleteAllForObject(new AyaTypeId(AyaType.User, dbObj.Id), ct);
TagMapBiz.DeleteAllForObject(new AyaTypeId(BizType, dbObj.Id), ct);
ct.SaveChanges();
return true;
@@ -671,7 +672,7 @@ namespace AyaNova.Biz
//skip the administrator account but add it to the map for all the other import code that requires it
if (V7Id == new Guid("2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed"))
{
var mapItem = new ImportAyaNova7MapItem(V7Id, AyaType.User, 1);
var mapItem = new ImportAyaNova7MapItem(V7Id, BizType, 1);
importMap.Add(mapItem);
return true;
}
@@ -718,7 +719,7 @@ namespace AyaNova.Biz
else
{
await ct.SaveChangesAsync();
var mapItem = new ImportAyaNova7MapItem(V7Id, AyaType.User, o.Id);
var mapItem = new ImportAyaNova7MapItem(V7Id, BizType, o.Id);
importMap.Add(mapItem);
@@ -728,7 +729,7 @@ namespace AyaNova.Biz
break;
case "eventlog":
{
await ImportAyaNova7Biz.LogEventCreatedModifiedEvents(j, importMap, AyaType.User, ct);
await ImportAyaNova7Biz.LogEventCreatedModifiedEvents(j, importMap, BizType, ct);
}
break;
case "locale":
@@ -813,22 +814,7 @@ namespace AyaNova.Biz
}
// private static async Task LogEventCreatedModifiedEvents(JObject j, List<ImportAyaNova7MapItem> importMap, AyaType ayaType, AyContext ct)
// {
// var V7Id = new Guid(j["ID"].Value<string>());
// var RavenUserId = importMap.Where(m => m.V7ObjectId == V7Id).First().NewObjectAyaTypeId.ObjectId;
// var Creator = importMap.Where(m => m.V7ObjectId == new Guid(j["Creator"].Value<string>())).First().NewObjectAyaTypeId.ObjectId;
// var Modifier = importMap.Where(m => m.V7ObjectId == new Guid(j["Modifier"].Value<string>())).First().NewObjectAyaTypeId.ObjectId;
// var Created = j["Created"].Value<DateTime>();
// var Modified = j["Modified"].Value<DateTime>();
// //handle EventLog entries for users now that we have the user's created
// //Created
// EventLogProcessor.AddEntry(new Event(Creator, RavenUserId, AyaType.User, AyaEvent.Created, Created), ct);
// //MODIFIED
// EventLogProcessor.AddEntry(new Event(Modifier, RavenUserId, AyaType.User, AyaEvent.Modified, Modified), ct);
// await ct.SaveChangesAsync();
// }
//Other job handlers here...

View File

@@ -16,18 +16,30 @@ namespace AyaNova.Biz
internal class WidgetBiz : BizObject, IJobObject
{
public static AyaType BizType = AyaType.Widget;
private readonly AyContext ct;
public readonly long userId;
public readonly long UserLocaleId;
private readonly AuthorizationRoles userRoles;
internal WidgetBiz(AyContext dbcontext, long currentUserId, AuthorizationRoles UserRoles)
internal WidgetBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles)
{
ct = dbcontext;
userId = currentUserId;
userRoles = UserRoles;
}
internal static WidgetBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
{
return new WidgetBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
}
//Version for internal use
internal static WidgetBiz GetBizInternal(AyContext ct)
{
return new WidgetBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull);
}
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
@@ -41,7 +53,7 @@ namespace AyaNova.Biz
//do stuff with widget
Widget outObj = inObj;
outObj.OwnerId = userId;
//TagHelper(collection of tags??)
await ct.Widget.AddAsync(outObj);
return outObj;
@@ -191,7 +203,7 @@ namespace AyaNova.Biz
internal void DeleteChildren(Widget dbObj)
{
//TAGS
TagMapBiz.DeleteAllForObject(new AyaTypeId(AyaType.Widget, dbObj.Id), ct);
TagMapBiz.DeleteAllForObject(new AyaTypeId(BizType, dbObj.Id), ct);
}
////////////////////////////////////////////////////////////////////////////////////////////////