rename all variants of naming that hold an AyaType value to "aType" (parameter) / "AType" (not parameter) everywhere front and back; "ayType", "objectType", "oType" all are used in various areas

This commit is contained in:
2021-03-23 17:06:05 +00:00
parent dfef3f7934
commit dde1b8bb8c
113 changed files with 450 additions and 450 deletions

View File

@@ -86,7 +86,7 @@ namespace AyaNova.Api.Controllers
long UserId = UserIdFromContext.Id(HttpContext.Items);
if (!Authorized.HasModifyRole(HttpContext.Items, dbObject.AttachToObjectType))
if (!Authorized.HasModifyRole(HttpContext.Items, dbObject.AttachToAType))
{
return StatusCode(403, new ApiNotAuthorizedResponse());
}
@@ -115,7 +115,7 @@ namespace AyaNova.Api.Controllers
ct.Entry(dbObject).OriginalValues["Concurrency"] = inObj.Concurrency;
//Log event and save context
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.AttachToObjectId, dbObject.AttachToObjectType, AyaEvent.AttachmentModified, ChangeTextra), ct);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.AttachToObjectId, dbObject.AttachToAType, AyaEvent.AttachmentModified, ChangeTextra), ct);
@@ -133,7 +133,7 @@ namespace AyaNova.Api.Controllers
}
//Normallyh wouldn't return a whole list but in this case the UI demands it because of reactivity issues
var ret = await GetFileListForObjectAsync(dbObject.AttachToObjectType, dbObject.AttachToObjectId);
var ret = await GetFileListForObjectAsync(dbObject.AttachToAType, dbObject.AttachToObjectId);
return Ok(ApiOkResponse.Response(ret));
}
@@ -189,7 +189,7 @@ namespace AyaNova.Api.Controllers
return NotFound();
return Ok(ApiOkResponse.Response(new { id = at.AttachToObjectId, type = at.AttachToObjectType }));
return Ok(ApiOkResponse.Response(new { id = at.AttachToObjectId, type = at.AttachToAType }));
}
@@ -224,7 +224,7 @@ namespace AyaNova.Api.Controllers
bool badRequest = false;
string AttachToObjectType = string.Empty;
string AttachToAType = string.Empty;
string AttachToObjectId = string.Empty;
string errorMessage = string.Empty;
string Notes = string.Empty;
@@ -239,15 +239,15 @@ namespace AyaNova.Api.Controllers
if (!badRequest
&& (!uploadFormData.FormFieldData.ContainsKey("FileData")
|| !uploadFormData.FormFieldData.ContainsKey("AttachToObjectType")
|| !uploadFormData.FormFieldData.ContainsKey("AttachToAType")
|| !uploadFormData.FormFieldData.ContainsKey("AttachToObjectId")))
{
badRequest = true;
errorMessage = "Missing one or more required FormFieldData values: AttachToObjectType, AttachToObjectId, FileData";
errorMessage = "Missing one or more required FormFieldData values: AttachToAType, AttachToObjectId, FileData";
}
if (!badRequest)
{
AttachToObjectType = uploadFormData.FormFieldData["AttachToObjectType"].ToString();
AttachToAType = uploadFormData.FormFieldData["AttachToAType"].ToString();
AttachToObjectId = uploadFormData.FormFieldData["AttachToObjectId"].ToString();
if (uploadFormData.FormFieldData.ContainsKey("Notes"))
Notes = uploadFormData.FormFieldData["Notes"].ToString();
@@ -255,10 +255,10 @@ namespace AyaNova.Api.Controllers
//"[{\"name\":\"Client.csv\",\"lastModified\":1582822079618},{\"name\":\"wmi4fu06nrs41.jpg\",\"lastModified\":1586900220990}]"
FileData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UploadFileData>>(uploadFormData.FormFieldData["FileData"].ToString());
if (string.IsNullOrWhiteSpace(AttachToObjectType) || string.IsNullOrWhiteSpace(AttachToObjectId))
if (string.IsNullOrWhiteSpace(AttachToAType) || string.IsNullOrWhiteSpace(AttachToObjectId))
{
badRequest = true;
errorMessage = "AttachToObjectType and / or AttachToObjectId are empty and are required";
errorMessage = "AttachToAType and / or AttachToObjectId are empty and are required";
}
}
@@ -267,11 +267,11 @@ namespace AyaNova.Api.Controllers
if (!badRequest)
{
attachToObject = new AyaTypeId(AttachToObjectType, AttachToObjectId);
attachToObject = new AyaTypeId(AttachToAType, AttachToObjectId);
if (attachToObject.IsEmpty)
{
badRequest = true;
errorMessage = "AttachToObjectType and / or AttachToObjectId are not valid and are required";
errorMessage = "AttachToAType and / or AttachToObjectId are not valid and are required";
}
}
@@ -281,7 +281,7 @@ namespace AyaNova.Api.Controllers
if (!attachToObject.IsCoreBizObject)
{
badRequest = true;
errorMessage = attachToObject.ObjectType.ToString() + " - AttachToObjectType does not support attachments";
errorMessage = attachToObject.AType.ToString() + " - AttachToAType does not support attachments";
}
}
@@ -290,7 +290,7 @@ namespace AyaNova.Api.Controllers
if (!badRequest)
{
//check if object exists
if (!await BizObjectExistsInDatabase.ExistsAsync(attachToObject.ObjectType, attachToObject.ObjectId, ct))
if (!await BizObjectExistsInDatabase.ExistsAsync(attachToObject.AType, attachToObject.ObjectId, ct))
{
badRequest = true;
errorMessage = "Invalid attach object";
@@ -298,7 +298,7 @@ namespace AyaNova.Api.Controllers
else
{
// User needs modify rights to the object type in question
if (!Authorized.HasModifyRole(HttpContext.Items, attachToObject.ObjectType))
if (!Authorized.HasModifyRole(HttpContext.Items, attachToObject.AType))
{
//delete temp files
ApiUploadProcessor.DeleteTempUploadFile(uploadFormData);
@@ -354,7 +354,7 @@ namespace AyaNova.Api.Controllers
var v = await FileUtil.StoreFileAttachmentAsync(a.InitialUploadedPathName, a.MimeType, a.OriginalFileName, theDate, attachToObject, Notes, ct);
//EVENT LOG
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, attachToObject.ObjectId, attachToObject.ObjectType, AyaEvent.AttachmentCreate, v.DisplayFileName), ct);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, attachToObject.ObjectId, attachToObject.AType, AyaEvent.AttachmentCreate, v.DisplayFileName), ct);
//SEARCH INDEXING
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserTranslationIdFromContext.Id(HttpContext.Items), v.Id, AyaType.FileAttachment);
@@ -363,7 +363,7 @@ namespace AyaNova.Api.Controllers
}
}
ret = await GetFileListForObjectAsync(attachToObject.ObjectType, attachToObject.ObjectId);
ret = await GetFileListForObjectAsync(attachToObject.AType, attachToObject.ObjectId);
}
catch (InvalidDataException ex)
{
@@ -415,7 +415,7 @@ namespace AyaNova.Api.Controllers
long UserId = UserIdFromContext.Id(HttpContext.Items);
if (!Authorized.HasDeleteRole(HttpContext.Items, dbObject.AttachToObjectType))
if (!Authorized.HasDeleteRole(HttpContext.Items, dbObject.AttachToAType))
{
return StatusCode(403, new ApiNotAuthorizedResponse());
}
@@ -425,7 +425,7 @@ namespace AyaNova.Api.Controllers
await FileUtil.DeleteFileAttachmentAsync(dbObject, ct);
//Event log process delete
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.AttachToObjectId, dbObject.AttachToObjectType, AyaEvent.AttachmentDelete, dbObject.DisplayFileName), ct);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.AttachToObjectId, dbObject.AttachToAType, AyaEvent.AttachmentDelete, dbObject.DisplayFileName), ct);
//Delete search index
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.FileAttachment, ct);
@@ -461,7 +461,7 @@ namespace AyaNova.Api.Controllers
await FileUtil.DeleteFileAttachmentAsync(dbObject, ct);
//Event log process delete
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.AttachToObjectId, dbObject.AttachToObjectType, AyaEvent.AttachmentDelete, dbObject.DisplayFileName), ct);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.AttachToObjectId, dbObject.AttachToAType, AyaEvent.AttachmentDelete, dbObject.DisplayFileName), ct);
//Delete search index
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.FileAttachment, ct);
@@ -495,13 +495,13 @@ namespace AyaNova.Api.Controllers
continue;
//do the move
var msg = $"{dbObject.DisplayFileName} moved from {dbObject.AttachToObjectType}-{dbObject.AttachToObjectId} to {dt.ToType}-{dt.ToId} ";
var msg = $"{dbObject.DisplayFileName} moved from {dbObject.AttachToAType}-{dbObject.AttachToObjectId} to {dt.ToType}-{dt.ToId} ";
dbObject.AttachToObjectId = dt.ToId;
dbObject.AttachToObjectType = dt.ToType;
dbObject.AttachToAType = dt.ToType;
await ct.SaveChangesAsync();
//Event log process move
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.AttachToObjectId, dbObject.AttachToObjectType, AyaEvent.AttachmentModified, msg), ct);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.AttachToObjectId, dbObject.AttachToAType, AyaEvent.AttachmentModified, msg), ct);
}
return NoContent();
@@ -546,7 +546,7 @@ namespace AyaNova.Api.Controllers
}
//is this allowed?
if (!Authorized.HasReadFullRole(DownloadUser.Roles, dbObject.AttachToObjectType))
if (!Authorized.HasReadFullRole(DownloadUser.Roles, dbObject.AttachToAType))
{
await Task.Delay(AyaNova.Util.ServerBootConfig.FAILED_AUTH_DELAY);//DOS protection
return StatusCode(403, new ApiNotAuthorizedResponse());
@@ -568,7 +568,7 @@ namespace AyaNova.Api.Controllers
}
//Log
await EventLogProcessor.LogEventToDatabaseAsync(new Event(DownloadUser.Id, dbObject.AttachToObjectId, dbObject.AttachToObjectType, AyaEvent.AttachmentDownload, dbObject.DisplayFileName), ct);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(DownloadUser.Id, dbObject.AttachToObjectId, dbObject.AttachToAType, AyaEvent.AttachmentDownload, dbObject.DisplayFileName), ct);
return PhysicalFile(filePath, mimetype, dbObject.DisplayFileName);
@@ -579,7 +579,7 @@ namespace AyaNova.Api.Controllers
async private Task<object> GetFileListForObjectAsync(AyaType ayaType, long ayaId)
{
return await ct.FileAttachment.AsNoTracking().Where(z => z.AttachToObjectId == ayaId && z.AttachToObjectType == ayaType).OrderBy(z => z.DisplayFileName)
return await ct.FileAttachment.AsNoTracking().Where(z => z.AttachToObjectId == ayaId && z.AttachToAType == ayaType).OrderBy(z => z.DisplayFileName)
.Select(z => new { z.Id, z.Concurrency, z.ContentType, z.DisplayFileName, z.LastModified, z.Notes })
.ToArrayAsync();
// var v = l.OrderBy(z => z.DisplayFileName);
@@ -604,7 +604,7 @@ namespace AyaNova.Api.Controllers
var JobName = $"Attachment maintenance (demand) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
OpsJob j = new OpsJob();
j.Name = JobName;
j.ObjectType = AyaType.FileAttachment;
j.AType = AyaType.FileAttachment;
j.JobType = JobType.AttachmentMaintenance;
j.SubType = JobSubType.NotSet;
j.Exclusive = true;