예제 #1
0
        internal async Task <object> GetAppointmentForWorksOrder(string workOrderReference)
        {
            _logger.LogInformation($"Getting booked appointment for work order reference {workOrderReference}");
            //Get DRS sessionId
            var sessionId = await OpenDrsServiceSession();

            // get the work order details and pass it to the request builder
            var workOrder = await _repairsService.GetWorkOrderDetails(workOrderReference);

            if (string.IsNullOrEmpty(workOrder.wo_ref))
            {
                _logger.LogError($"could not find the work order in UH with reference {workOrderReference}");
                throw new InvalidWorkOrderInUHException();
            }
            // Get booking id & order id for the primary order reference
            var orderResponse = await GetOrderFromDrs(workOrderReference, sessionId);

            // close session
            await CloseDrsServiceSession(sessionId);

            var returnResponse = orderResponse.@return;

            if ([email protected] != responseStatus.success)
            {
                _logger.LogError(returnResponse.errorMsg);
                throw new AppointmentServiceException();
            }
            return(new
            {
                beginDate = DateTimeFormatter.FormatDateTimeToUtc([email protected][0].theBookings[0].assignedStart),
                endDate = DateTimeFormatter.FormatDateTimeToUtc([email protected][0].theBookings[0].assignedEnd)
            });
        }
예제 #2
0
        public void returns_a_formatted_postcode()
        {
            var formattedDateTime = DateTimeFormatter.FormatDateTimeToUtc(new DateTime(2017, 10, 18, 12, 00, 00));

            Assert.Equal(formattedDateTime, "2017-10-18T12:00:00Z");
        }
예제 #3
0
        public async Task <object> BookAppointment(string workOrderReference, DateTime beginDate, DateTime endDate)
        {
            _logger.LogInformation($"Booking appointment for work order reference {workOrderReference} with {beginDate} and {endDate}");
            //Get DRS sessionId
            var sessionId = await OpenDrsServiceSession();

            // get the work order details and pass it to the request builder
            var workOrder = await _repairsService.GetWorkOrderDetails(workOrderReference);

            if (string.IsNullOrEmpty(workOrder.wo_ref))
            {
                _logger.LogError($"could not find the work order in UH with reference {workOrderReference}");
                throw new InvalidWorkOrderInUHException();
            }
            var request = _appointmentsServiceRequestBuilder.BuildXmbScheduleBookingRequest(workOrderReference, sessionId, beginDate, endDate, workOrder);

            // Get booking id & order id for the primary order reference
            var orderResponse = await GetOrderFromDrs(workOrderReference, sessionId);

            request.theBooking.orderId   = [email protected][0].orderId;
            request.theBooking.bookingId = [email protected][0].theBookings[0].bookingId;
            var response = await _appointmentsService.ScheduleBookingAsync(request);

            // close session
            await CloseDrsServiceSession(sessionId);

            var returnResponse = response.@return;

            if ([email protected] != responseStatus.success)
            {
                _logger.LogError(returnResponse.errorMsg);
                throw new AppointmentServiceException();
            }
            //update UHT with the order and populate the u_sentToAppointmentSys table
            var order_id = await _repairsService.UpdateUHTVisitAndBlockTrigger(workOrderReference, beginDate, endDate,
                                                                               request.theBooking.orderId, request.theBooking.bookingId, BuildSlotDetail(beginDate, endDate));

            //attach the process (running Andrey's stored procedure)
            _logger.LogInformation($"Updating UH documents for workorder {workOrderReference}");
            if (order_id != null)
            {
                await _repairsService.AddOrderDocumentAsync(ConfigurationManager.AppSettings["RepairRequestDocTypeCode"],
                                                            workOrderReference, order_id.Value, ConfigurationManager.AppSettings["UHDocUploadResponseMessage"]);
            }
            //Issue Order

            _logger.LogInformation($"Issuing order for workorder {workOrderReference}");
            var worksOrderRequest  = _repairsServiceRequestBuilder.BuildWorksOrderRequest(workOrderReference);
            var issueOrderResponse = await _repairsService.IssueOrderAsync(worksOrderRequest);

            if (!issueOrderResponse.Success)
            {
                _logger.LogError(issueOrderResponse.ErrorMessage);
                throw new AppointmentServiceException();
            }
            _logger.LogInformation($"Successfully issued workorder {workOrderReference}");
            //End Issue Order
            var json = new
            {
                beginDate = DateTimeFormatter.FormatDateTimeToUtc(beginDate),
                endDate   = DateTimeFormatter.FormatDateTimeToUtc(endDate)
            };

            return(json);
        }