Example #1
0
        public IHttpActionResult UpdateJobResultStatus(UpdateJobResultStatusModel updateJobResultStatusModel)
        {
            var processResult = jobQueueService.UpdateJobResultStatus(updateJobResultStatusModel);
            if (processResult.HasError())
            {
                return BadRequest(string.Join(";", processResult.Errors));
            }

            return Ok(processResult);
        }
        public ProcessResult UpdateJobResultStatus(UpdateJobResultStatusModel model)
        {
            var result = new ProcessResult();

            try
            {
                var job = MyDbContext.Jobs.Find(new Guid(model.Id));

                if (job == null)
                {
                    result.Errors.Add("Invalid Job Id");
                    return result;
                }

                job.ResultStatus = model.ResultStatus;

                MyDbContext.SaveChanges();

            }
            catch (Exception e)
            {
                result.Errors.Add("Fail to update job: " + e.Message);
            }

            return result;
        }
        private void UpdateJobStatus(string jobId, string url, ResultStatus status)
        {
            var updateJobResultStatus = new UpdateJobResultStatusModel()
            {
                ResultStatus = status,
                Id = jobId
            };

            var updateResult = PostManager.PostRequest(url, JsonConvert.SerializeObject(updateJobResultStatus));

            if (!updateResult.Success)
            {
                var msg = GetBadResultMessage(updateResult.Result);

                _consumerEventLog.WriteEntry("Fail to update job status (" + jobId + "): " + msg);
            }
            else
            {
                _consumerEventLog.WriteEntry("Successful to update job status (" + jobId + ").");
            }
        }