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:
@@ -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;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace AyaNova.Api.Controllers
|
||||
var JobName = $"LT:BackupNow LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
OpsJob j = new OpsJob();
|
||||
j.Name = JobName;
|
||||
j.ObjectType = AyaType.NoType;
|
||||
j.AType = AyaType.NoType;
|
||||
j.JobType = JobType.Backup;
|
||||
j.SubType = JobSubType.NotSet;
|
||||
j.Exclusive = true;
|
||||
|
||||
@@ -184,9 +184,9 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
public sealed class UserEventLogItem
|
||||
{
|
||||
//DateTime, ObjectType, ObjectId, Event, Textra
|
||||
//DateTime, AType, ObjectId, Event, Textra
|
||||
public DateTime Date { get; set; }
|
||||
public AyaType ObjectType { get; set; }
|
||||
public AyaType AType { get; set; }
|
||||
public long ObjectId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public AyaEvent Event { get; set; }
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace AyaNova.Api.Controllers
|
||||
if (selectedRequest == null)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelectedRequest is required"));
|
||||
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, selectedRequest.ObjectType))
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, selectedRequest.AType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
if (string.IsNullOrWhiteSpace(format))
|
||||
@@ -86,12 +86,12 @@ namespace AyaNova.Api.Controllers
|
||||
UserTranslationId);
|
||||
|
||||
|
||||
log.LogDebug($"Instantiating biz object handler for {selectedRequest.ObjectType}");
|
||||
var biz = BizObjectFactory.GetBizObject(selectedRequest.ObjectType, ct, UserId, UserRoles, UserTranslationId);
|
||||
log.LogDebug($"Fetching data for {selectedRequest.SelectedRowIds.Length} {selectedRequest.ObjectType} items");
|
||||
log.LogDebug($"Instantiating biz object handler for {selectedRequest.AType}");
|
||||
var biz = BizObjectFactory.GetBizObject(selectedRequest.AType, ct, UserId, UserRoles, UserTranslationId);
|
||||
log.LogDebug($"Fetching data for {selectedRequest.SelectedRowIds.Length} {selectedRequest.AType} items");
|
||||
// var TheData = await ((IExportAbleObject)biz).GetJSONExportData(dataListSelection.SelectedRowIds);
|
||||
|
||||
string baseFileName = FileUtil.StringToSafeFileName($"{selectedRequest.ObjectType.ToString().ToLowerInvariant()}-{format}-{FileUtil.GetSafeDateFileName()}");
|
||||
string baseFileName = FileUtil.StringToSafeFileName($"{selectedRequest.AType.ToString().ToLowerInvariant()}-{format}-{FileUtil.GetSafeDateFileName()}");
|
||||
|
||||
// string outputRandomFileNameNoExtension = StringUtil.ReplaceLastOccurrence(FileUtil.NewRandomFileName, ".", "");
|
||||
string outputSourceFileName = baseFileName + "." + format;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace AyaNova.Api.Controllers
|
||||
// uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);xx
|
||||
|
||||
|
||||
string UploadObjectType = string.Empty;
|
||||
string UploadAType = string.Empty;
|
||||
|
||||
string errorMessage = string.Empty;
|
||||
string Notes = string.Empty;
|
||||
@@ -100,10 +100,10 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Missing required FormFieldData value: FileData"));
|
||||
|
||||
|
||||
if (uploadFormData.FormFieldData.ContainsKey("ObjectType"))
|
||||
UploadObjectType = uploadFormData.FormFieldData["ObjectType"].ToString();
|
||||
if (uploadFormData.FormFieldData.ContainsKey("AType"))
|
||||
UploadAType = uploadFormData.FormFieldData["AType"].ToString();
|
||||
else
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Missing required FormFieldData value: ObjectType"));
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Missing required FormFieldData value: AType"));
|
||||
|
||||
//fileData in JSON stringify format which contains the actual last modified dates etc
|
||||
//"[{\"name\":\"Client.csv\",\"lastModified\":1582822079618},{\"name\":\"wmi4fu06nrs41.jpg\",\"lastModified\":1586900220990}]"
|
||||
@@ -112,7 +112,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
|
||||
//Instantiate the business object handler
|
||||
AyaType TheType = System.Enum.Parse<AyaType>(UploadObjectType, true);
|
||||
AyaType TheType = System.Enum.Parse<AyaType>(UploadAType, true);
|
||||
log.LogDebug($"Instantiating biz object handler for {TheType}");
|
||||
var biz = BizObjectFactory.GetBizObject(TheType, ct);
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelectedRequest is required"));
|
||||
|
||||
|
||||
if (!Authorized.HasDeleteRole(HttpContext.Items, selectedRequest.ObjectType))
|
||||
if (!Authorized.HasDeleteRole(HttpContext.Items, selectedRequest.AType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
//Rehydrate id list if necessary
|
||||
@@ -220,7 +220,7 @@ namespace AyaNova.Api.Controllers
|
||||
UserIdFromContext.Id(HttpContext.Items),
|
||||
UserTranslationIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
var JobName = $"LT:BatchDeleteJob - LT:{selectedRequest.ObjectType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
var JobName = $"LT:BatchDeleteJob - LT:{selectedRequest.AType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
JObject o = JObject.FromObject(new
|
||||
{
|
||||
idList = selectedRequest.SelectedRowIds
|
||||
@@ -228,7 +228,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
OpsJob j = new OpsJob();
|
||||
j.Name = JobName;
|
||||
j.ObjectType = selectedRequest.ObjectType;
|
||||
j.AType = selectedRequest.AType;
|
||||
j.JobType = JobType.BatchCoreObjectOperation;
|
||||
j.SubType = JobSubType.Delete;
|
||||
j.Exclusive = false;
|
||||
|
||||
@@ -40,22 +40,22 @@ namespace AyaNova.Api.Controllers
|
||||
/// not all business objects have names some may return '-' or simply the type name
|
||||
/// if that is the case
|
||||
/// </summary>
|
||||
/// <param name="ayType">AyaType</param>
|
||||
/// <param name="aType">AyaType</param>
|
||||
/// <param name="id">Non zero id, if zero returns type name</param>
|
||||
/// <returns>Name</returns>
|
||||
[HttpGet("{ayType}/{id}")]
|
||||
public ActionResult GetName([FromRoute] AyaType ayType, [FromRoute] long id)
|
||||
[HttpGet("{aType}/{id}")]
|
||||
public ActionResult GetName([FromRoute] AyaType aType, [FromRoute] long id)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!Authorized.HasSelectRole(HttpContext.Items, ayType))
|
||||
if (!Authorized.HasSelectRole(HttpContext.Items, aType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
if (id == 0)
|
||||
return Ok(ApiOkResponse.Response(ayType.ToString()));
|
||||
return Ok(ApiOkResponse.Response(aType.ToString()));
|
||||
|
||||
return Ok(ApiOkResponse.Response(BizObjectNameFetcherDirect.Name(ayType, id, ct)));
|
||||
return Ok(ApiOkResponse.Response(BizObjectNameFetcherDirect.Name(aType, id, ct)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -160,10 +160,10 @@ namespace AyaNova.Api.Controllers
|
||||
/// <summary>
|
||||
/// Get Report list for object
|
||||
/// </summary>
|
||||
/// <param name="ayType">Type of object</param>
|
||||
/// <param name="aType">Type of object</param>
|
||||
/// <returns>Name / id report list of allowed reports for role of requester</returns>
|
||||
[HttpGet("list/{ayType}")]
|
||||
public async Task<IActionResult> GetReportList([FromRoute] AyaType ayType)
|
||||
[HttpGet("list/{aType}")]
|
||||
public async Task<IActionResult> GetReportList([FromRoute] AyaType aType)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -171,11 +171,11 @@ namespace AyaNova.Api.Controllers
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
//extra check if they have rights to the type of object in question, this nips it in the bud before they even get to the fetch data stage later
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, ayType))
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, aType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
var o = await biz.GetReportListAsync(ayType);
|
||||
var o = await biz.GetReportListAsync(aType);
|
||||
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace AyaNova.Api.Controllers
|
||||
case AyaType.WorkOrderItemTask:
|
||||
case AyaType.WorkOrderItemTravel:
|
||||
AyaTypeId TypeId = await WorkOrderBiz.GetAncestor(ayaType, id, ct);
|
||||
return Ok(ApiOkResponse.Response(new { AyaType = TypeId.ObjectTypeAsInt, Id = TypeId.ObjectId }));
|
||||
return Ok(ApiOkResponse.Response(new { AyaType = TypeId.ATypeAsInt, Id = TypeId.ObjectId }));
|
||||
default:
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Only types with ancestors are valid"));
|
||||
|
||||
|
||||
@@ -90,10 +90,10 @@ namespace AyaNova.Api.Controllers
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
if (!selectedRequest.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
if (!selectedRequest.AType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type"));
|
||||
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, selectedRequest.ObjectType))
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, selectedRequest.AType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
tag = TagBiz.NormalizeTag(tag);
|
||||
@@ -110,7 +110,7 @@ namespace AyaNova.Api.Controllers
|
||||
UserIdFromContext.Id(HttpContext.Items),
|
||||
UserTranslationIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
var JobName = $"LT:BatchJob LT:Add LT:Tag \"{tag}\" LT:{selectedRequest.ObjectType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
var JobName = $"LT:BatchJob LT:Add LT:Tag \"{tag}\" LT:{selectedRequest.AType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
JObject o = JObject.FromObject(new
|
||||
{
|
||||
idList = selectedRequest.SelectedRowIds,
|
||||
@@ -119,7 +119,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
OpsJob j = new OpsJob();
|
||||
j.Name = JobName;
|
||||
j.ObjectType = selectedRequest.ObjectType;
|
||||
j.AType = selectedRequest.AType;
|
||||
j.JobType = JobType.BatchCoreObjectOperation;
|
||||
j.SubType = JobSubType.TagAdd;
|
||||
j.Exclusive = false;
|
||||
@@ -159,7 +159,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
OpsJob j = new OpsJob();
|
||||
j.Name = JobName;
|
||||
j.ObjectType = ayaType;
|
||||
j.AType = ayaType;
|
||||
j.JobType = JobType.BatchCoreObjectOperation;
|
||||
j.SubType = JobSubType.TagAddAny;
|
||||
j.Exclusive = false;
|
||||
@@ -183,9 +183,9 @@ namespace AyaNova.Api.Controllers
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
if (!selectedRequest.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
if (!selectedRequest.AType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type"));
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, selectedRequest.ObjectType))
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, selectedRequest.AType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
tag = TagBiz.NormalizeTag(tag);
|
||||
@@ -202,7 +202,7 @@ namespace AyaNova.Api.Controllers
|
||||
UserIdFromContext.Id(HttpContext.Items),
|
||||
UserTranslationIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
var JobName = $"LT:BatchJob LT:Remove LT:Tag \"{tag}\" LT:{selectedRequest.ObjectType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
var JobName = $"LT:BatchJob LT:Remove LT:Tag \"{tag}\" LT:{selectedRequest.AType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
JObject o = JObject.FromObject(new
|
||||
{
|
||||
idList = selectedRequest.SelectedRowIds,
|
||||
@@ -211,7 +211,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
OpsJob j = new OpsJob();
|
||||
j.Name = JobName;
|
||||
j.ObjectType = selectedRequest.ObjectType;
|
||||
j.AType = selectedRequest.AType;
|
||||
j.JobType = JobType.BatchCoreObjectOperation;
|
||||
j.SubType = JobSubType.TagRemove;
|
||||
j.Exclusive = false;
|
||||
@@ -252,7 +252,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
OpsJob j = new OpsJob();
|
||||
j.Name = JobName;
|
||||
j.ObjectType = ayaType;
|
||||
j.AType = ayaType;
|
||||
j.SubType = JobSubType.TagRemoveAny;
|
||||
j.JobType = JobType.BatchCoreObjectOperation;
|
||||
j.Exclusive = false;
|
||||
@@ -278,9 +278,9 @@ namespace AyaNova.Api.Controllers
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
if (!selectedRequest.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
if (!selectedRequest.AType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type"));
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, selectedRequest.ObjectType))
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, selectedRequest.AType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
fromTag = TagBiz.NormalizeTag(fromTag);
|
||||
if (string.IsNullOrWhiteSpace(fromTag))
|
||||
@@ -299,7 +299,7 @@ namespace AyaNova.Api.Controllers
|
||||
UserIdFromContext.Id(HttpContext.Items),
|
||||
UserTranslationIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
var JobName = $"LT:BatchJob LT:Replace LT:Tag \"{fromTag}\" -> LT:Tag \"{toTag}\" LT:{selectedRequest.ObjectType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
var JobName = $"LT:BatchJob LT:Replace LT:Tag \"{fromTag}\" -> LT:Tag \"{toTag}\" LT:{selectedRequest.AType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
JObject o = JObject.FromObject(new
|
||||
{
|
||||
idList = selectedRequest.SelectedRowIds,
|
||||
@@ -308,7 +308,7 @@ namespace AyaNova.Api.Controllers
|
||||
});
|
||||
|
||||
OpsJob j = new OpsJob();
|
||||
j.ObjectType = selectedRequest.ObjectType;
|
||||
j.AType = selectedRequest.AType;
|
||||
j.Name = JobName;
|
||||
j.JobType = JobType.BatchCoreObjectOperation;
|
||||
j.SubType = JobSubType.TagReplace;
|
||||
@@ -355,7 +355,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
OpsJob j = new OpsJob();
|
||||
j.Name = JobName;
|
||||
j.ObjectType = ayaType;
|
||||
j.AType = ayaType;
|
||||
j.JobType = JobType.BatchCoreObjectOperation;
|
||||
j.SubType = JobSubType.TagReplaceAny;
|
||||
j.Exclusive = false;
|
||||
|
||||
@@ -336,7 +336,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
|
||||
bool badRequest = false;
|
||||
string UploadObjectType = string.Empty;
|
||||
string UploadAType = string.Empty;
|
||||
string UploadObjectId = string.Empty;
|
||||
string errorMessage = string.Empty;
|
||||
string Notes = string.Empty;
|
||||
@@ -371,8 +371,8 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
if (!badRequest)
|
||||
{
|
||||
if (uploadFormData.FormFieldData.ContainsKey("ObjectType"))
|
||||
UploadObjectType = uploadFormData.FormFieldData["ObjectType"].ToString();
|
||||
if (uploadFormData.FormFieldData.ContainsKey("AType"))
|
||||
UploadAType = uploadFormData.FormFieldData["AType"].ToString();
|
||||
if (uploadFormData.FormFieldData.ContainsKey("ObjectId"))
|
||||
UploadObjectId = uploadFormData.FormFieldData["ObjectId"].ToString();
|
||||
if (uploadFormData.FormFieldData.ContainsKey("Notes"))
|
||||
|
||||
Reference in New Issue
Block a user