This commit is contained in:
@@ -85,7 +85,8 @@ SERVER
|
||||
- This object will be replicated repeatedly so it always pays to clean it up more and more
|
||||
- WidgetBiz Put/Patch also share nearly the same process keywords code, so move to common method!!
|
||||
|
||||
|
||||
- Delete user should delete private datafilters
|
||||
- Did I code how to handle implications of user delete anywhere yet??
|
||||
|
||||
|
||||
- Stage 2 AFTER POSTED TEST ROUND COMPLETED
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Get full DataFilter object
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited, TechFull, TechLimited, Accounting
|
||||
/// Any (for public filter), owned only for private filter
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>A single DataFilter</returns>
|
||||
@@ -85,7 +85,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Required roles: Any
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Paged id/name collection of DataFilters with paging data</returns>
|
||||
/// <returns>List of public or owned data filters for listKey provided</returns>
|
||||
[HttpGet("PickList", Name = nameof(DataFilterPickList))]
|
||||
public async Task<IActionResult> DataFilterPickList([FromQuery] string ListKey)
|
||||
{
|
||||
@@ -108,8 +108,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Put (update) DataFilter
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// TechFull (owned only)
|
||||
/// Any (public filter) or owned only (private filter)
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
@@ -189,8 +188,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Delete DataFilter
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// TechFull (owned only)
|
||||
/// Any if public otherwise creator only
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
|
||||
|
||||
internal class DataFilterBiz : BizObject, IJobObject
|
||||
internal class DataFilterBiz : BizObject
|
||||
{
|
||||
|
||||
internal DataFilterBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles)
|
||||
@@ -129,26 +129,6 @@ namespace AyaNova.Biz
|
||||
return ret;
|
||||
}
|
||||
|
||||
// //get many (paged)
|
||||
// internal async Task<ApiPagedResponse<DataFilter>> GetManyAsync(IUrlHelper Url, string routeName, PagingOptions pagingOptions)
|
||||
// {
|
||||
|
||||
// pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
||||
// pagingOptions.Limit = pagingOptions.Limit ?? PagingOptions.DefaultLimit;
|
||||
|
||||
// var items = await ct.DataFilter
|
||||
// .OrderBy(m => m.Id)
|
||||
// .Skip(pagingOptions.Offset.Value)
|
||||
// .Take(pagingOptions.Limit.Value)
|
||||
// .ToArrayAsync();
|
||||
|
||||
// var totalRecordCount = await ct.DataFilter.CountAsync();
|
||||
// var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, totalRecordCount).PagingLinksObject();
|
||||
|
||||
// ApiPagedResponse<DataFilter> pr = new ApiPagedResponse<DataFilter>(items, pageLinks);
|
||||
// return pr;
|
||||
// }
|
||||
|
||||
|
||||
//get picklist (NOT PAGED)
|
||||
internal async Task<List<NameIdItem>> GetPickListAsync(string listKey)
|
||||
@@ -222,9 +202,6 @@ namespace AyaNova.Biz
|
||||
//Delete search index
|
||||
Search.ProcessDeletedObjectKeywords(dbObj.Id, BizType);
|
||||
|
||||
//TAGS
|
||||
TagMapBiz.DeleteAllForObject(new AyaTypeId(BizType, dbObj.Id), ct);
|
||||
ct.SaveChanges();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -236,15 +213,6 @@ namespace AyaNova.Biz
|
||||
//Can save or update?
|
||||
private void Validate(DataFilter inObj, bool isNew)
|
||||
{
|
||||
//run validation and biz rules
|
||||
if (isNew)
|
||||
{
|
||||
//NEW datafilters must be active
|
||||
if (inObj.Active == null || ((bool)inObj.Active) == false)
|
||||
{
|
||||
AddError(ValidationErrorType.InvalidValue, "Active", "New datafilter must be active");
|
||||
}
|
||||
}
|
||||
|
||||
//OwnerId required
|
||||
if (!isNew)
|
||||
@@ -253,6 +221,10 @@ namespace AyaNova.Biz
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "OwnerId");
|
||||
}
|
||||
|
||||
//Owner must be current user, there are no exceptions
|
||||
if (inObj.OwnerId != UserId)
|
||||
AddError(ValidationErrorType.InvalidValue, "OwnerId", "OwnerId must be current user Id");
|
||||
|
||||
//Name required
|
||||
if (string.IsNullOrWhiteSpace(inObj.Name))
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "Name");
|
||||
@@ -271,25 +243,11 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
//Start date AND end date must both be null or both contain values
|
||||
if (inObj.StartDate == null && inObj.EndDate != null)
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "StartDate");
|
||||
|
||||
if (inObj.StartDate != null && inObj.EndDate == null)
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "EndDate");
|
||||
|
||||
//Start date before end date
|
||||
if (inObj.StartDate != null && inObj.EndDate != null)
|
||||
if (inObj.StartDate > inObj.EndDate)
|
||||
AddError(ValidationErrorType.StartDateMustComeBeforeEndDate, "StartDate");
|
||||
|
||||
//Enum is valid value
|
||||
|
||||
if (!inObj.Roles.IsValid())
|
||||
{
|
||||
AddError(ValidationErrorType.InvalidValue, "Roles");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(inObj.ListKey))
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "ListKey");
|
||||
|
||||
if (inObj.ListKey.Length > 255)
|
||||
AddError(ValidationErrorType.LengthExceeded, "ListKey", "255 max");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -298,48 +256,30 @@ namespace AyaNova.Biz
|
||||
//Can delete?
|
||||
private void ValidateCanDelete(DataFilter inObj)
|
||||
{
|
||||
//whatever needs to be check to delete this object
|
||||
//Leaving this off for now
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//JOB / OPERATIONS
|
||||
//
|
||||
public async Task HandleJobAsync(OpsJob job)
|
||||
{
|
||||
//Hand off the particular job to the corresponding processing code
|
||||
//NOTE: If this code throws an exception the caller (JobsBiz::ProcessJobsAsync) will automatically set the job to failed and log the exeption so
|
||||
//basically any error condition during job processing should throw up an exception if it can't be handled
|
||||
switch (job.JobType)
|
||||
{
|
||||
case JobType.TestDataFilterJob:
|
||||
await ProcessTestJobAsync(job);
|
||||
break;
|
||||
default:
|
||||
throw new System.ArgumentOutOfRangeException($"DataFilterBiz.HandleJob-> Invalid job type{job.JobType.ToString()}");
|
||||
}
|
||||
}
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //JOB / OPERATIONS
|
||||
// //
|
||||
// public async Task HandleJobAsync(OpsJob job)
|
||||
// {
|
||||
// //Hand off the particular job to the corresponding processing code
|
||||
// //NOTE: If this code throws an exception the caller (JobsBiz::ProcessJobsAsync) will automatically set the job to failed and log the exeption so
|
||||
// //basically any error condition during job processing should throw up an exception if it can't be handled
|
||||
// switch (job.JobType)
|
||||
// {
|
||||
// case JobType.TestDataFilterJob:
|
||||
// await ProcessTestJobAsync(job);
|
||||
// break;
|
||||
// default:
|
||||
// throw new System.ArgumentOutOfRangeException($"DataFilterBiz.HandleJob-> Invalid job type{job.JobType.ToString()}");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// /// Handle the test job
|
||||
/// </summary>
|
||||
/// <param name="job"></param>
|
||||
private async Task ProcessTestJobAsync(OpsJob job)
|
||||
{
|
||||
var sleepTime = 30 * 1000;
|
||||
//Simulate a long running job here
|
||||
JobsBiz.UpdateJobStatus(job.GId, JobStatus.Running, ct);
|
||||
JobsBiz.LogJob(job.GId, $"DataFilterBiz::ProcessTestJob started, sleeping for {sleepTime} seconds...", ct);
|
||||
//Uncomment this to test if the job prevents other routes from running
|
||||
//result is NO it doesn't prevent other requests, so we are a-ok for now
|
||||
await Task.Delay(sleepTime);
|
||||
JobsBiz.LogJob(job.GId, "DataFilterBiz::ProcessTestJob done sleeping setting job to finished", ct);
|
||||
JobsBiz.UpdateJobStatus(job.GId, JobStatus.Completed, ct);
|
||||
|
||||
}
|
||||
|
||||
//Other job handlers here...
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user