示例#1
0
        private async Task NotifyHandlers(Infrastructure.WorkOrder workOrder)
        {
            var notification = new WorkOrderOpened(workOrder);
            await _notifier.Notify(notification);

            await _notifier.Notify(new WorkOrderApproved(workOrder));
        }
示例#2
0
        public static WorkOrderResponse ToResponse(this Infrastructure.WorkOrder workOrder, Infrastructure.AppointmentDetails appointment, Uri drsManagementAddress, bool canAssignOperative)
        {
            Log.Logger.Information("Calling ResponseFactory.WorkOrder.ToResponse");

            Infrastructure.PropertyClass propertyClass = workOrder.Site?.PropertyClass?.FirstOrDefault();
            string addressLine   = propertyClass?.Address?.AddressLine;
            var    managementUri = workOrder.ExternalSchedulerReference is null ? null : new UriBuilder(drsManagementAddress)
            {
                Port  = -1,
                Query = $"tokenId={workOrder.ExternalSchedulerReference}"
            }.Uri;

            return(new WorkOrderResponse
            {
                Reference = workOrder.Id,
                Description = workOrder.DescriptionOfWork,
                Priority = workOrder.WorkPriority?.PriorityDescription,
                Property = addressLine,
                DateRaised = workOrder.DateRaised,
                PropertyReference = workOrder.Site?.PropertyClass?.FirstOrDefault()?.PropertyReference,
                Target = workOrder.WorkPriority?.RequiredCompletionDateTime,
                PriorityCode = workOrder.WorkPriority?.PriorityCode,
                LastUpdated = null,
                Owner = workOrder.AssignedToPrimary?.Name,
                RaisedBy = workOrder.AgentName,
                CallerName = workOrder.Customer?.Person?.Name?.Full,
                CallerNumber = workOrder.Customer?.Person?.Communication?.Where(cc => cc.Channel?.Medium == Generated.CommunicationMediumCode._20 /* Audio */).FirstOrDefault()
                               ?.Value,
                Status = workOrder.GetStatus(),
                Action = workOrder.GetAction(),
                ContractorReference = workOrder.AssignedToPrimary?.ContractorReference,
                TradeCode = workOrder.WorkElements.FirstOrDefault()?.Trade.FirstOrDefault()?.CustomCode,
                TradeDescription = workOrder.WorkElements.FirstOrDefault()?.Trade.FirstOrDefault()?.CustomName,
                Appointment = appointment is null ? null : new AppointmentResponse
                {
                    Date = appointment.Date.Date.ToDate(),
                    Description = appointment.Description,
                    Start = appointment.Start.ToTime(),
                    End = appointment.End.ToTime(),
                    Reason = appointment.AppointmentReason,
                    Note = appointment.AppointmentNote
                },
                ExternalAppointmentManagementUrl = managementUri,
                Operatives = workOrder.WorkOrderOperatives.MapList(o => o.ToResponse()),
                CanAssignOperative = canAssignOperative,
                ClosedDated = workOrder.ClosedDate,
                PlannerComments = workOrder.PlannerComments,
                IsSplit = workOrder.IsSplit,
                IsOvertime = workOrder.IsOvertime
            });
 private static string GetContractor(Infrastructure.WorkOrder workOrder)
 {
     return(workOrder.AssignedToPrimary?.ContractorReference);
 }