示例#1
0
        public ProcessResult UpdateJobProcessStatus(UpdateJobProcessStatusModel 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.ProcessStatus     = model.ProcessStatus;
                job.CompletedDateTime = DateTime.Now;

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

            return(result);
        }
示例#2
0
        public IHttpActionResult UpdateJobProcessStatus(UpdateJobProcessStatusModel updateJobProcessStatusModel)
        {
            var processResult = jobQueueService.UpdateJobProcessStatus(updateJobProcessStatusModel);

            if (processResult.HasError())
            {
                return(BadRequest(string.Join(";", processResult.Errors)));
            }
            return(Ok(processResult));
        }
        private void CompleteJob(string jobId, string url)
        {
            var compleJobModel = new UpdateJobProcessStatusModel()
            {
                Id            = jobId,
                ProcessStatus = ProcessStatus.Completed
            };

            var completeResult = PostManager.PostRequest(url, JsonConvert.SerializeObject(compleJobModel));

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

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