コード例 #1
0
        public async Task <IActionResult> JobStatusUpdate([FromBody] JobStatusUpdate request)
        {
            _diagnosticContext.SetWorkOrderId(int.Parse(request.RelatedWorkOrderReference.ID));
            await _updateJobStatusUseCase.Execute(request);

            return(Ok());
        }
コード例 #2
0
        private async Task HandleCustomType(WorkOrder workOrder, JobStatusUpdate update)
        {
            switch (update.OtherType)
            {
            case CustomJobStatusUpdates.Completed:
                await VerifyCanComplete(workOrder);

                await _repairsGateway.UpdateWorkOrderStatus(workOrder.Id, WorkStatusCode.Complete);

                var prefix = Resources.WorkOrderCompletedPrefix;
                if (update.EventTime != null)
                {
                    prefix += $"{update.EventTime:dd MMMM yyyy HH:mm} ";
                }
                update.PrefixComments(prefix);
                update.EventTime = DateTime.Now;
                await _notifier.Notify(new WorkOrderCompleted(workOrder, update));

                break;

            case CustomJobStatusUpdates.Cancelled:
                VerifyCanCancel(workOrder);

                update.PrefixComments(Resources.WorkOrderCancelledPrefix);
                await _repairsGateway.UpdateWorkOrderStatus(workOrder.Id, WorkStatusCode.Canceled);

                await _notifier.Notify(new WorkOrderCancelled(workOrder));

                break;

            default: throw new NotSupportedException(Resources.UnsupportedWorkOrderUpdate);
            }
        }
コード例 #3
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            WorkOrder workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanVary();

            var workElement = jobStatusUpdate.MoreSpecificSORCode;

            await AddCodeCosts(workElement.RateScheduleItem, workOrder.AssignedToPrimary?.ContractorReference);

            // check the user has the require vary spend limit
            var authorised = await _authorizationService.AuthorizeAsync(_currentUserService.GetUser(), jobStatusUpdate, "VarySpendLimit");

            if (await _featureManager.IsEnabledAsync(FeatureFlags.SpendLimits) && !authorised.Succeeded)
            {
                workOrder.StatusCode     = WorkStatusCode.VariationPendingApproval;
                jobStatusUpdate.TypeCode = JobStatusUpdateTypeCode.ContractManagerApprovalNeeded_180;
                await _notifier.Notify(new HighCostVariationCreated(workOrder));
            }
            else
            {
                await _updateSorCodesUseCase.Execute(workOrder, workElement.DeepClone());
            }

            jobStatusUpdate.PrefixComments(Resources.VariationReason);
        }
 private IJobStatusUpdateStrategy ProcessOtherCode(JobStatusUpdate jobStatusUpdate)
 {
     return(jobStatusUpdate.OtherType switch
     {
         CustomJobStatusUpdates.Resume => _activator.CreateInstance <ResumeJobStrategy>(),
         CustomJobStatusUpdates.AddNote => null,
         _ => throw new NotSupportedException($"This type code is not supported: {jobStatusUpdate.TypeCode} - {jobStatusUpdate.OtherType}"),
     });
コード例 #5
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanMoveToJobIncomplete();

            workOrder.StatusCode = Infrastructure.WorkStatusCode.PendMaterial;

            await _repairsGateway.SaveChangesAsync();
        }
コード例 #6
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanMoveToJobIncomplete();

            workOrder.StatusCode = WorkStatusCode.Hold;

            await _repairsGateway.SaveChangesAsync();
        }
コード例 #7
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanResumeJob();

            workOrder.StatusCode = WorkStatusCode.Open;

            await _repairsGateway.SaveChangesAsync();
        }
コード例 #8
0
        public async Task <int> CreateJobStatusUpdate(JobStatusUpdate update)
        {
            update.AuthorName  = _currentUserService.GetUser().Name();
            update.AuthorEmail = _currentUserService.GetUser().Email();
            await _repairsContext.JobStatusUpdates.AddAsync(update);

            await _repairsContext.SaveChangesAsync();

            return(update.Id);
        }
コード例 #9
0
 public static void PrefixComments(this JobStatusUpdate jobStatusUpdate, string prefix)
 {
     if (string.IsNullOrEmpty(jobStatusUpdate.Comments))
     {
         jobStatusUpdate.Comments = string.Empty;
     }
     else if (!jobStatusUpdate.Comments.StartsWith(prefix))
     {
         jobStatusUpdate.Comments = $"{prefix}{jobStatusUpdate.Comments}";
     }
 }
コード例 #10
0
        public JobWorker(Job job, IActorRef jobTrackingMaster)
        {
            _logger           = Context.GetLogger();
            Job               = job;
            RunningStatus     = new JobStatusUpdate(Job);
            TotalStats        = new JobStats(Job);
            JobTrackingMaster = jobTrackingMaster;

            // Make the JobTrackingMaster a default subscriber so that it receives all updates.
            Subscribers.Add(JobTrackingMaster);

            BecomeReady();
        }
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanAcknowledgeVariation();

            if (!_currentUserService.HasGroup(UserGroups.Contractor))
            {
                throw new UnauthorizedAccessException(Resources.InvalidPermissions);
            }

            workOrder.StatusCode = WorkStatusCode.Open;
            await _repairsGateway.SaveChangesAsync();
        }
コード例 #12
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanRejectWorkOrder();

            if (!_currentUserService.HasGroup(UserGroups.AuthorisationManager))
            {
                throw new UnauthorizedAccessException(Resources.InvalidPermissions);
            }

            workOrder.StatusCode = WorkStatusCode.Canceled;
            jobStatusUpdate.PrefixComments(Resources.WorkOrderAuthorisationRejected);

            await _notifier.Notify(new WorkOrderRejected(workOrder));
        }
        public async Task HandleVariationApprove()
        {
            var variation = new JobStatusUpdate()
            {
                AuthorEmail = "email"
            };
            var rejection = new JobStatusUpdate()
            {
                RelatedWorkOrder = new WorkOrder
                {
                    Id = 1
                }
            };
            await _classUnderTest.Notify(new VariationApproved(variation, rejection));

            _emailMock.Verify(m => m.SendMailAsync(It.Is <VariationApprovedEmail>(email => email.Address == variation.AuthorEmail)));
        }
コード例 #14
0
        public async Task ProcessActions(JobStatusUpdate jobStatusUpdate)
        {
            IJobStatusUpdateStrategy strategy = jobStatusUpdate.TypeCode switch
            {
                JobStatusUpdateTypeCode.OperativeAssigned_10 => _activator.CreateInstance <AssignOperativesUseCase>(),
                JobStatusUpdateTypeCode.Variation_80 => _activator.CreateInstance <MoreSpecificSorUseCase>(),
                JobStatusUpdateTypeCode.ApproveVariation_10020 => _activator.CreateInstance <ApproveVariationUseCase>(),
                JobStatusUpdateTypeCode.RejectVariation_125 => _activator.CreateInstance <RejectVariationUseCase>(),
                JobStatusUpdateTypeCode.ContractorAcknowledgeVariation_10010 => _activator.CreateInstance <ContractorAcknowledgeVariationUseCase>(),
                JobStatusUpdateTypeCode.Incomplete_120 => _activator.CreateInstance <JobIncompleteStrategy>(),
                JobStatusUpdateTypeCode.JobIncompleteNeedMaterials_12020 => _activator.CreateInstance <JobIncompleteNeedMaterialsStrategy>(),
                JobStatusUpdateTypeCode.Reject_190 => _activator.CreateInstance <RejectWorkOrderStrategy>(),
                JobStatusUpdateTypeCode.Approve_200 => _activator.CreateInstance <ApproveWorkOrderStrategy>(),
                JobStatusUpdateTypeCode.Other_0 => ProcessOtherCode(jobStatusUpdate),
                _ => throw new NotSupportedException($"This type code is not supported: {jobStatusUpdate.TypeCode}"),
            };

            if (strategy != null)
            {
                await strategy.Execute(jobStatusUpdate);
            }
        }
コード例 #15
0
 public VariationApproved(JobStatusUpdate variation, JobStatusUpdate approval)
 {
     Variation = variation;
     Approval  = approval;
 }
コード例 #16
0
 public VariationRejected(JobStatusUpdate variation, JobStatusUpdate rejection)
 {
     Variation = variation;
     Rejection = rejection;
 }
コード例 #17
0
 public WorkOrderCompleted(WorkOrder workOrder, JobStatusUpdate update)
 {
     WorkOrder = workOrder;
     Update    = update;
 }
コード例 #18
0
 public JobComplete(Job job, JobStatusUpdate jobStatusUpdate)
 {
     Job             = job;
     JobStatusUpdate = jobStatusUpdate;
 }
コード例 #19
0
 public ReceivedJobStatus(Job job, JobStatusUpdate runningStatus)
 {
     Job           = job;
     RunningStatus = runningStatus;
 }
コード例 #20
0
        private void Ready()
        {
            // kick off the job
            Receive <IStartJob>(start =>
            {
                _logger.Info("JobWorker.Ready.IStartJob");

                // Need to reset tracking buckets.
                WorkerTracker.Tell(new WorkerTracker.ResetTrackerBuckets());
                RunningStatus = new JobStatusUpdate(Job)
                {
                    Status = JobStatus.Starting
                };
                TotalStats          = new JobStats(Job);
                RunningStatus.Stats = TotalStats;

                if (!Subscribers.Contains(start.Requestor))
                {
                    Subscribers.Add(start.Requestor);
                }

                PublishJobStatus();

                Self.Tell(new JobCanStart(start.Job));
            });

            Receive <JobCanStart>(start =>
            {
                RunningStatus.Status = JobStatus.Running;

                CoordinatorRouter.Tell(new WorkerCoordinator.GetJobData(start.Job.JobInfo));

                Become(Started);
                Stash.UnstashAll();
            });

            Receive <JobCanStart>(start =>
            {
                _logger.Warning("Can't start job yet. No routees.");
            });


            Receive <CheckJobStatus>(start =>
            {
                Sender.Tell(new ReceivedJobStatus(Job, RunningStatus), Self);
            });

            Receive <ReceiveTimeout>(ic =>
            {
                _logger.Error("JobWorker.Ready.ReceiveTimeout: \r\n{0}", ic);
            });

            Receive <ISubscribeToJob>(subscribe =>
            {
                Stash.Stash();
            });

            ReceiveAny(o =>
            {
                _logger.Error("JobWorker.Ready.ReceiveAny and stashing: \r\n{0}", o);
                Stash.Stash();
            });
        }