Ejemplo n.º 1
0
        private async void button_NotifReport_Click(object sender, RoutedEventArgs e)
        {
            WriteResponseLine(string.Format("Sending OTA_NotifReportRQ..."));

            foreach (HotelReservationType hotelReservation in reservationList.Items)
            {
                //
                // Get the pmsXchange reservation reference.
                //

                UniqueID_Type[] uniqueIDs = hotelReservation.UniqueID;
                string          resType   = uniqueIDs[0].Type;
                string          resIDPMS  = uniqueIDs[0].ID;

                string msgType = uniqueIDs[1].Type;
                string msgID   = uniqueIDs[1].ID;

                string   resStatusText = hotelReservation.ResStatus;
                DateTime dateTimeStamp = resStatusText == "Book" ? hotelReservation.CreateDateTime : hotelReservation.LastModifyDateTime;

                //
                // Send a reservation confirmation.
                //

                NotifReportRQResponse confirmResponse = null;

                if (checkBox_Conf_Errror.IsChecked == false)
                {
                    confirmResponse = await OTA_NotifReportRQ(username, password, null, resStatusText, dateTimeStamp, msgID, resIDPMS);
                }
                else
                {
                    ReservationError resError = new ReservationError((OTA_EWT)comboBox_OTA_EWT.SelectedValue, (OTA_ERR)comboBox_OTA_ERR.SelectedValue, null);
                    confirmResponse = await OTA_NotifReportRQ(username, password, null, resStatusText, dateTimeStamp, msgID, resIDPMS);
                }

                //
                // Make sure that no errors were generated during confirmation!
                //

                if (confirmResponse.OTA_NotifReportRS.Items[0].GetType() == typeof(SuccessType))
                {
                    //
                    // Confirmation was processed correctly.
                    //

                    WriteResponseLine(string.Format("Reservation resID: {0} confirmed successfully.", resIDPMS));
                    button_NotifReport.IsEnabled = false;
                }
                else
                {
                    //
                    // Confirmation error.
                    //

                    string     timestamp = confirmResponse.OTA_NotifReportRS.TimeStamp.ToString();
                    ErrorsType errors    = (ErrorsType)confirmResponse.OTA_NotifReportRS.Items[0];

                    foreach (var error in errors.Error)
                    {
                        WriteResponseLine(string.Format("OTA_NotifReportRS error - Timestamp: {2},  Type: {0},  Value: {1}", error.Type, error.Value, timestamp));
                    }
                }
            }

            WriteResponseLine(string.Format(""));
        }
Ejemplo n.º 2
0
        static public async Task <NotifReportRQResponse> OTA_NotifReportRQ(string usernameAuthenticate, string passwordAuthenticate, ReservationError resError, string resStatus, DateTime dateTimeStamp, string msgID, string resIDPMS)
        {
            NotifReportRQResponse response = null;

            try
            {
                PmsXchangeServiceClient service = new AsyncServiceConnection().service;

                OTA_NotifReportRQ body = new OTA_NotifReportRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.            */, TimeStamp = DateTime.Now, TimeStampSpecified = true
                };
                if (resError == null)
                {
                    body.Items = new object[] { new SuccessType() };
                }
                else
                {
                    ErrorType errorType = API.CreateErrorType(resError.err, resError.ewt, resError.errorText);

                    ErrorsType  errors = new ErrorsType();
                    ErrorType[] error  = { errorType };
                    errors.Error = error;

                    body.Items = new object[] { errors };
                }

                body.NotifDetails = new OTA_NotifReportRQNotifDetails();
                body.NotifDetails.HotelNotifReport = new OTA_NotifReportRQNotifDetailsHotelNotifReport();
                OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservations hotelReservations = new OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservations();
                body.NotifDetails.HotelNotifReport.Item = hotelReservations;

                OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservationsHotelReservation[] hotelReservationList = new OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservationsHotelReservation[1];
                hotelReservationList[0] = new OTA_NotifReportRQNotifDetailsHotelNotifReportHotelReservationsHotelReservation();

                hotelReservations.HotelReservation = hotelReservationList;

                hotelReservations.HotelReservation[0].ResStatus = resStatus;
                if (resStatus == "Book")
                {
                    hotelReservations.HotelReservation[0].CreateDateTime = dateTimeStamp;
                }
                else
                {
                    hotelReservations.HotelReservation[0].LastModifyDateTime = dateTimeStamp;
                }
                hotelReservations.HotelReservation[0].UniqueID         = new UniqueID_Type[1];
                hotelReservations.HotelReservation[0].UniqueID[0]      = new UniqueID_Type();
                hotelReservations.HotelReservation[0].UniqueID[0].Type = OTA_ID_Type.Reference.ToString("d");
                hotelReservations.HotelReservation[0].UniqueID[0].ID   = msgID;

                //
                // Only include the reservation ID info if there was no error processin this reservation.
                //

                if (resError == null)
                {
                    hotelReservations.HotelReservation[0].ResGlobalInfo = new ResGlobalInfoType();
                    hotelReservations.HotelReservation[0].ResGlobalInfo.HotelReservationIDs                = new HotelReservationIDsTypeHotelReservationID[1];
                    hotelReservations.HotelReservation[0].ResGlobalInfo.HotelReservationIDs[0]             = new HotelReservationIDsTypeHotelReservationID();
                    hotelReservations.HotelReservation[0].ResGlobalInfo.HotelReservationIDs[0].ResID_Type  = OTA_ID_Type.Reservation.ToString("d");
                    hotelReservations.HotelReservation[0].ResGlobalInfo.HotelReservationIDs[0].ResID_Value = resIDPMS;
                }

                body.NotifDetails.HotelNotifReport.Item = hotelReservations;
                response = await service.NotifReportRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false);
            }
            catch (NullReferenceException)
            {
                Exception exSetup = new Exception("OTA_NotifReportRQ arguments were not set up properly causing a null reference exception.");
                response = new NotifReportRQResponse();
                response.OTA_NotifReportRS       = new MessageAcknowledgementType();
                response.OTA_NotifReportRS.Items = new object[] { ProcessingException(exSetup) };
            }
            catch (Exception ex)
            {
                response = new NotifReportRQResponse();
                response.OTA_NotifReportRS       = new MessageAcknowledgementType();
                response.OTA_NotifReportRS.Items = new object[] { ProcessingException(ex) };
            }

            return(response);
        }