Batch is the new Bulk
This commit is contained in:
@@ -233,137 +233,6 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
//NOTE: In DB schema only name and serial are not nullable
|
||||
|
||||
//run validation and biz rules
|
||||
|
||||
// //Name required
|
||||
// if (string.IsNullOrWhiteSpace(proposedObj.Name))
|
||||
// AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");
|
||||
|
||||
|
||||
// //If name is otherwise OK, check that name is unique
|
||||
// if (!PropertyHasErrors("Name"))
|
||||
// {
|
||||
// //Use Any command is efficient way to check existance, it doesn't return the record, just a true or false
|
||||
// if (await ct.NotifySubscription.AnyAsync(z => z.Name == proposedObj.Name && z.Id != proposedObj.Id))
|
||||
// {
|
||||
// AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name");
|
||||
// }
|
||||
// }
|
||||
|
||||
// //Start date AND end date must both be null or both contain values
|
||||
// if (proposedObj.StartDate == null && proposedObj.EndDate != null)
|
||||
// AddError(ApiErrorCode.VALIDATION_REQUIRED, "StartDate");
|
||||
|
||||
// if (proposedObj.StartDate != null && proposedObj.EndDate == null)
|
||||
// AddError(ApiErrorCode.VALIDATION_REQUIRED, "EndDate");
|
||||
|
||||
// //Start date before end date
|
||||
// if (proposedObj.StartDate != null && proposedObj.EndDate != null)
|
||||
// if (proposedObj.StartDate > proposedObj.EndDate)
|
||||
// AddError(ApiErrorCode.VALIDATION_STARTDATE_AFTER_ENDDATE, "StartDate");
|
||||
|
||||
// //Enum is valid value
|
||||
// if (!proposedObj.UserType.IsValid())
|
||||
// {
|
||||
// AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UserType");
|
||||
// }
|
||||
|
||||
// //Any form customizations to validate?
|
||||
// var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.NotifySubscription.ToString());
|
||||
// if (FormCustomization != null)
|
||||
// {
|
||||
// //Yeppers, do the validation, there are two, the custom fields and the regular fields that might be set to required
|
||||
|
||||
// //validate users choices for required non custom fields
|
||||
// RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);
|
||||
|
||||
// //validate custom fields
|
||||
// CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields);
|
||||
// }
|
||||
}
|
||||
|
||||
// private void ValidateCanDelete(NotifySubscription inObj)
|
||||
// {
|
||||
// //whatever needs to be check to delete this object
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //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.BulkCoreBizObjectOperation:
|
||||
// await ProcessBulkJobAsync(job);
|
||||
// break;
|
||||
// default:
|
||||
// throw new System.ArgumentOutOfRangeException($"NotifySubscriptionBiz.HandleJob-> Invalid job type{job.JobType.ToString()}");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// private async Task ProcessBulkJobAsync(OpsJob job)
|
||||
// {
|
||||
// await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running);
|
||||
// await JobsBiz.LogJobAsync(job.GId, $"Batch job {job.SubType} started...");
|
||||
// List<long> idList = new List<long>();
|
||||
// long ProcessedObjectCount = 0;
|
||||
// JObject jobData = JObject.Parse(job.JobInfo);
|
||||
// if (jobData.ContainsKey("idList"))
|
||||
// idList = ((JArray)jobData["idList"]).ToObject<List<long>>();
|
||||
// else
|
||||
// idList = await ct.NotifySubscription.Select(z => z.Id).ToListAsync();
|
||||
// bool SaveIt = false;
|
||||
// foreach (long id in idList)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// SaveIt = false;
|
||||
// ClearErrors();
|
||||
// var o = await GetAsync(id, false);
|
||||
// switch (job.SubType)
|
||||
// {
|
||||
// case JobSubType.TagAddAny:
|
||||
// case JobSubType.TagAdd:
|
||||
// case JobSubType.TagRemoveAny:
|
||||
// case JobSubType.TagRemove:
|
||||
// case JobSubType.TagReplaceAny:
|
||||
// case JobSubType.TagReplace:
|
||||
// SaveIt = TagBiz.ProcessBulkTagOperation(o.Tags, (string)jobData["tag"], jobData.ContainsKey("toTag") ? (string)jobData["toTag"] : null, job.SubType);
|
||||
// break;
|
||||
// default:
|
||||
// throw new System.ArgumentOutOfRangeException($"ProcessBulkJob -> Invalid job Subtype{job.SubType}");
|
||||
// }
|
||||
// if (SaveIt)
|
||||
// {
|
||||
// o = await PutAsync(o);
|
||||
// if (o == null)
|
||||
// await JobsBiz.LogJobAsync(job.GId, $"Error processing item {id}: {GetErrorsAsString()}");
|
||||
// else
|
||||
// ProcessedObjectCount++;
|
||||
// }
|
||||
// else
|
||||
// ProcessedObjectCount++;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await JobsBiz.LogJobAsync(job.GId, $"Error processing item {id}");
|
||||
// await JobsBiz.LogJobAsync(job.GId, ExceptionUtil.ExtractAllExceptionMessages(ex));
|
||||
// }
|
||||
// }
|
||||
// await JobsBiz.LogJobAsync(job.GId, $"Batch job {job.SubType} processed {ProcessedObjectCount} of {idList.Count}");
|
||||
// await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed);
|
||||
// }
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user