Beispiel #1
0
        static public async Task <ReadRQResponse> OTA_ReadRQ(string pmsID, string usernameAuthenticate, string passwordAuthenticate, string hotelCode, ResStatus resStatus)
        {
            ReadRQResponse response = null;

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

                OTA_ReadRQ body = new OTA_ReadRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.            */, TimeStamp = DateTime.Now, TimeStampSpecified = true, POS = CreatePOS(pmsID)
                };

                OTA_ReadRQReadRequests readRequests = new OTA_ReadRQReadRequests();
                OTA_ReadRQReadRequestsHotelReadRequest hotelReadRequest = new OTA_ReadRQReadRequestsHotelReadRequest()
                {
                    HotelCode = hotelCode
                };
                readRequests.Items = new object[] { hotelReadRequest };

                OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria selectionCriteria = new OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria()
                {
                    SelectionType = OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType.Undelivered, SelectionTypeSpecified = true                                                                                                                                         /* Must be set to true, or ReadRQ returns an error.*/
                };

                if (resStatus != ResStatus.All)
                {
                    selectionCriteria.ResStatus = resStatus.ToString();
                }

                hotelReadRequest.SelectionCriteria = selectionCriteria;
                body.ReadRequests = readRequests;

                //
                // Send a retrieve reservations request.
                //

                response = await service.ReadRQAsync(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 ReadRQResponse();
                response.OTA_ResRetrieveRS       = new OTA_ResRetrieveRS();
                response.OTA_ResRetrieveRS.Items = new object[] { ProcessingException(exSetup) };
            }
            catch (Exception ex)
            {
                response = new ReadRQResponse();
                response.OTA_ResRetrieveRS       = new OTA_ResRetrieveRS();
                response.OTA_ResRetrieveRS.Items = new object[] { ProcessingException(ex) };
            }

            return(response);
        }
Beispiel #2
0
        private async void button_Read_Click(object sender, RoutedEventArgs e)
        {
            WriteResponseLine(string.Format("Sending OTA_ResRetrieveRQ..."));
            button_NotifReport.IsEnabled = false;

            ResStatus resStatus = ResStatus.All;

            if (radioButton_Modify.IsChecked == true)
            {
                resStatus = ResStatus.Modify;
            }
            if (radioButton_Cancel.IsChecked == true)
            {
                resStatus = ResStatus.Cancel;
            }
            if (radioButton_Book.IsChecked == true)
            {
                resStatus = ResStatus.Book;
            }

            ReadRQResponse reservationsResponse = await OTA_ReadRQ(pmsID, username, password, hotelCode, resStatus);

            if (reservationsResponse.OTA_ResRetrieveRS.Items[0].GetType() == typeof(SuccessType))
            {
                WriteResponseLine(string.Format("OTA_ResRetrieveRS success!"));

                if (reservationsResponse.OTA_ResRetrieveRS.Items.Length > 1)
                {
                    reservationList = (OTA_ResRetrieveRSReservationsList)reservationsResponse.OTA_ResRetrieveRS.Items[1];
                    WriteResponseLine(string.Format("# of reservations: {0} ", reservationList.Items.Length));

                    //
                    // Got the reservation list, so now process it....
                    //

                    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;

                        WriteResponseLine(string.Format("Reservation - resID: {0}, msgID: {1}, Status: {2}, TimeStamp: {3}", resIDPMS, msgID, resStatusText, dateTimeStamp.ToString()));
                        button_NotifReport.IsEnabled = true;
                    }
                }
                else
                {
                    WriteResponseLine("No reservation list available.");
                }
            }
            else
            {
                string     timestamp = reservationsResponse.OTA_ResRetrieveRS.TimeStamp.ToString();
                ErrorsType errors    = (ErrorsType)reservationsResponse.OTA_ResRetrieveRS.Items[0];

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

            WriteResponseLine(string.Format(""));
        }