예제 #1
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            if (!_currentUserService.HasGroup(UserGroups.ContractManager))
            {
                throw new UnauthorizedAccessException(Resources.InvalidPermissions);
            }

            WorkOrder workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanApproveVariation();

            var variationJobStatus = await _jobStatusUpdateGateway.GetOutstandingVariation(workOrder.Id);

            var authorised = await _authorizationService.AuthorizeAsync(_currentUserService.GetUser(), variationJobStatus, "VarySpendLimit");

            if (!authorised.Succeeded)
            {
                throw new UnauthorizedAccessException(Resources.VariationApprovalAboveSpendLimit);
            }

            await VaryWorkOrder(workOrder, variationJobStatus);

            jobStatusUpdate.Comments = $"{jobStatusUpdate.Comments} Approved By: {_currentUserService.GetHubUser().Name}";

            await _notifier.Notify(new VariationApproved(variationJobStatus, jobStatusUpdate));

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

            workOrder.VerifyCanResumeJob();

            workOrder.StatusCode = WorkStatusCode.Open;

            await _repairsGateway.SaveChangesAsync();
        }
예제 #3
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanMoveToJobIncomplete();

            workOrder.StatusCode = Infrastructure.WorkStatusCode.PendMaterial;

            await _repairsGateway.SaveChangesAsync();
        }
예제 #4
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanMoveToJobIncomplete();

            workOrder.StatusCode = WorkStatusCode.Hold;

            await _repairsGateway.SaveChangesAsync();
        }
        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();
        }
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrderId = int.Parse(jobStatusUpdate.RelatedWorkOrderReference.ID);

            var workOrder = await _repairsGateway.GetWorkOrder(workOrderId);

            var jsu = jobStatusUpdate.ToDb(workOrder);

            await _strategyFactory.ProcessActions(jsu);

            workOrder.IsSplit = jobStatusUpdate.IsSplit ?? workOrder.IsSplit;

            workOrder.IsOvertime = jobStatusUpdate.IsOvertime ?? workOrder.IsOvertime;

            await _repairsGateway.SaveChangesAsync();

            await _jobStatusUpdateGateway.CreateJobStatusUpdate(jsu);
        }
        public async Task <CreateOrderResult> Execute(WorkOrder workOrder)
        {
            using (_logger.BeginScope(Guid.NewGuid()))
            {
                ValidateRequest(workOrder);
                AttachUserInformation(workOrder);
                workOrder.DateRaised = DateTime.UtcNow;

                await SetStatus(workOrder);

                await PopulateRateScheduleItems(workOrder);

                var id = await _repairsGateway.CreateWorkOrder(workOrder);

                _logger.LogInformation(Resources.CreatedWorkOrder);

                var notification = await NotifyHandlers(workOrder);

                var result = new CreateOrderResult(id, workOrder.StatusCode, workOrder.GetStatus());

                _logger.LogInformation("Notification sent successfully for work order {workOrderId}", workOrder.Id);

                if (await workOrder.ContractorUsingDrs(_scheduleOfRatesGateway))
                {
                    _logger.LogInformation("Contractor using DRS: {workOrderId}", workOrder.Id);

                    result.ExternallyManagedAppointment = true;
                    var managementUri = new UriBuilder(_drsOptions.Value.ManagementAddress)
                    {
                        Port  = -1,
                        Query = $"tokenId={notification?.TokenId?.ToString()}"
                    };
                    result.ExternalAppointmentManagementUrl = managementUri.Uri;
                    workOrder.ExternalSchedulerReference    = notification?.TokenId;
                    await _repairsGateway.SaveChangesAsync();
                }

                _logger.LogInformation("Successfully created work order {workOrderId}", workOrder.Id);

                return(result);
            }
        }
예제 #8
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanRejectVariation();

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

            var variationJobStatus = await _jobStatusUpdateGateway.GetOutstandingVariation(workOrder.Id);

            workOrder.StatusCode = WorkStatusCode.VariationRejected;
            jobStatusUpdate.PrefixComments(Resources.RejectedVariationPrepend);

            await _notifier.Notify(new VariationRejected(variationJobStatus, jobStatusUpdate));

            await _repairsGateway.SaveChangesAsync();
        }