This commit is contained in:
2020-10-23 20:37:57 +00:00
parent 5f440184ce
commit a4da926733
2 changed files with 36 additions and 26 deletions

2
.vscode/launch.json vendored
View File

@@ -52,7 +52,7 @@
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
"AYANOVA_SERVER_TEST_MODE": "true", "AYANOVA_SERVER_TEST_MODE": "false",
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\" "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\"

View File

@@ -170,37 +170,44 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Bulk remove tags to list of object id's specified /// Bulk remove tags to list of object id's specified
/// </summary> /// </summary>
/// <param name="ayaType"></param>
/// <param name="tag"></param> /// <param name="tag"></param>
/// <param name="idList"></param> /// <param name="dataListSelection"></param>
/// <returns>Job Id</returns> /// <returns>Job Id</returns>
[HttpPost("bulk-remove/{ayaType}/{tag}")] [HttpPost("bulk-remove/{tag}")]
public async Task<IActionResult> BulkRemove([FromRoute] AyaType ayaType, [FromRoute] string tag, [FromBody] List<long> idList) public async Task<IActionResult> BulkRemove([FromRoute] string tag, [FromBody] DataListSelection dataListSelection)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute)))
if (dataListSelection.IsEmpty)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
if (!dataListSelection.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type"));
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) if (!Authorized.HasModifyRole(HttpContext.Items, dataListSelection.ObjectType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
if (idList.Count == 0)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
tag = TagBiz.NormalizeTag(tag); tag = TagBiz.NormalizeTag(tag);
if (string.IsNullOrWhiteSpace(tag)) if (string.IsNullOrWhiteSpace(tag))
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag")); return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag"));
var JobName = $"Bulk operation: Remove tag \"{tag}\" from {ayaType} ({idList.Count} specified)"; await dataListSelection.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log);
if (dataListSelection.SelectedRowIds.Length == 0)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
var JobName = $"Bulk operation: Remove tag \"{tag}\" from {dataListSelection.ObjectType} ({dataListSelection.SelectedRowIds.LongLength} specified)";
JObject o = JObject.FromObject(new JObject o = JObject.FromObject(new
{ {
idList = idList, idList = dataListSelection.SelectedRowIds,
tag = tag tag = tag
}); });
OpsJob j = new OpsJob(); OpsJob j = new OpsJob();
j.Name = JobName; j.Name = JobName;
j.ObjectType = ayaType; j.ObjectType = dataListSelection.ObjectType;
j.JobType = JobType.BulkCoreBizObjectOperation; j.JobType = JobType.BulkCoreBizObjectOperation;
j.SubType = JobSubType.TagRemove; j.SubType = JobSubType.TagRemove;
j.Exclusive = false; j.Exclusive = false;
@@ -255,40 +262,43 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Bulk replace tags to list of object id's specified /// Bulk replace tags to list of object id's specified
/// </summary> /// </summary>
/// <param name="ayaType"></param>
/// <param name="fromTag"></param> /// <param name="fromTag"></param>
/// <param name="toTag"></param> /// <param name="toTag"></param>
/// <param name="idList"></param> /// <param name="dataListSelection"></param>
/// <returns>Job Id</returns> /// <returns>Job Id</returns>
[HttpPost("bulk-replace/{ayaType}/{fromTag}")] [HttpPost("bulk-replace/{fromTag}")]
public async Task<IActionResult> BulkReplace([FromRoute] AyaType ayaType, [FromRoute] string fromTag, [FromQuery] string toTag, [FromBody] List<long> idList) public async Task<IActionResult> BulkReplace([FromRoute] string fromTag, [FromQuery] string toTag, [FromBody] DataListSelection dataListSelection)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) if (dataListSelection.IsEmpty)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
if (!dataListSelection.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type"));
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) if (!Authorized.HasModifyRole(HttpContext.Items, dataListSelection.ObjectType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
if (idList.Count == 0)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
fromTag = TagBiz.NormalizeTag(fromTag); fromTag = TagBiz.NormalizeTag(fromTag);
if (string.IsNullOrWhiteSpace(fromTag)) if (string.IsNullOrWhiteSpace(fromTag))
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "fromTag")); return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "fromTag"));
toTag = TagBiz.NormalizeTag(toTag); toTag = TagBiz.NormalizeTag(toTag);
if (string.IsNullOrWhiteSpace(toTag)) if (string.IsNullOrWhiteSpace(toTag))
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "toTag")); return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "toTag"));
var JobName = $"Bulk operation: Replace tag \"{fromTag}\" with tag \"{toTag}\" on {ayaType} ({idList.Count} specified)"; await dataListSelection.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log);
if (dataListSelection.SelectedRowIds.Length == 0)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
var JobName = $"Bulk operation: Replace tag \"{fromTag}\" with tag \"{toTag}\" on {dataListSelection.ObjectType} ({dataListSelection.SelectedRowIds.LongLength} specified)";
JObject o = JObject.FromObject(new JObject o = JObject.FromObject(new
{ {
idList = idList, idList = dataListSelection.SelectedRowIds,
tag = fromTag, tag = fromTag,
toTag = toTag toTag = toTag
}); });
OpsJob j = new OpsJob(); OpsJob j = new OpsJob();
j.ObjectType = ayaType; j.ObjectType = dataListSelection.ObjectType;
j.Name = JobName; j.Name = JobName;
j.JobType = JobType.BulkCoreBizObjectOperation; j.JobType = JobType.BulkCoreBizObjectOperation;
j.SubType = JobSubType.TagReplace; j.SubType = JobSubType.TagReplace;