コード例 #1
0
        private async void button_HotelAvailNotif_Click(object sender, RoutedEventArgs e)
        {
            WriteResponseLine(string.Format("Sending OTA_HotelAvailNotifRQ..."));



            #region AvailStatusMessages setup

            List <AvailStatusMessage> availStatusMessageList = new List <AvailStatusMessage>();

            //
            // Set up one or more AvailStatusMessage.  Just using some random data.
            //

            DateTime start = new DateTime(2016, 8, 15);
            DateTime end   = new DateTime(2016, 8, 18);
            AvailStatusMessage.StatusApplicationControl statusApplicationControl
                = new AvailStatusMessage.StatusApplicationControl(start, end, "S2S", "TR", GetAvailDestList("NYU", "ATL"));
            AvailStatusMessage availStatusMessage = new AvailStatusMessage(statusApplicationControl, Restrictions.Stop_Sold, 1, 30, null);
            availStatusMessageList.Add(availStatusMessage); // Add an AvailStatusMessage to AvailStatusMessages.

            AvailStatusMessages availStatusMessages = new AvailStatusMessages(hotelCode, availStatusMessageList);

            #endregion


            HotelAvailNotifRQResponse availResponse = await OTA_HotelAvailNotifRQ(pmsID, username, password, availStatusMessages);


            if (availResponse.OTA_HotelAvailNotifRS.Items[0].GetType() == typeof(SuccessType))
            {
                WriteResponseLine(string.Format("OTA_HotelAvailNotifRS success!"));
            }
            else
            {
                string     timestamp = availResponse.OTA_HotelAvailNotifRS.TimeStamp.ToString();
                ErrorsType errors    = (ErrorsType)availResponse.OTA_HotelAvailNotifRS.Items[0];

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

            WriteResponseLine(string.Format(""));
        }
コード例 #2
0
ファイル: API.cs プロジェクト: agrubin/SiteMinder
        static public async Task <HotelAvailNotifRQResponse> OTA_HotelAvailNotifRQ(string pmsID, string usernameAuthenticate, string passwordAuthenticate, AvailStatusMessages availStatusMessages)
        {
            HotelAvailNotifRQResponse response = null;

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

                OTA_HotelAvailNotifRQ body = new OTA_HotelAvailNotifRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.*/, TimeStamp = DateTime.Now, TimeStampSpecified = true, POS = CreatePOS(pmsID), AvailStatusMessages = new OTA_HotelAvailNotifRQAvailStatusMessages()
                };
                body.AvailStatusMessages.HotelCode          = availStatusMessages.HotelCode;
                body.AvailStatusMessages.AvailStatusMessage = new AvailStatusMessageType[availStatusMessages.AvailStatusMessageNodeList.Count];

                int index = 0;

                foreach (AvailStatusMessages.AvailStatusMessage aSM in availStatusMessages.AvailStatusMessageNodeList)
                {
                    AvailStatusMessageType bSM = new AvailStatusMessageType()
                    {
                        StatusApplicationControl = new StatusApplicationControlType()
                    };
                    bSM.StatusApplicationControl.Start         = aSM.StatusApplicationControlNode.Start;
                    bSM.StatusApplicationControl.End           = aSM.StatusApplicationControlNode.End;
                    bSM.StatusApplicationControl.RatePlanCode  = aSM.StatusApplicationControlNode.RatePlanCode;
                    bSM.StatusApplicationControl.InvTypeCode   = aSM.StatusApplicationControlNode.InvTypeCode;
                    bSM.StatusApplicationControl.Mon           = aSM.StatusApplicationControlNode.Mon;
                    bSM.StatusApplicationControl.Tue           = aSM.StatusApplicationControlNode.Tue;
                    bSM.StatusApplicationControl.Weds          = aSM.StatusApplicationControlNode.Weds;
                    bSM.StatusApplicationControl.Thur          = aSM.StatusApplicationControlNode.Thur;
                    bSM.StatusApplicationControl.Fri           = aSM.StatusApplicationControlNode.Fri;
                    bSM.StatusApplicationControl.Sat           = aSM.StatusApplicationControlNode.Sat;
                    bSM.StatusApplicationControl.Sun           = aSM.StatusApplicationControlNode.Sun;
                    bSM.StatusApplicationControl.MonSpecified  = true;
                    bSM.StatusApplicationControl.TueSpecified  = true;
                    bSM.StatusApplicationControl.WedsSpecified = true;
                    bSM.StatusApplicationControl.ThurSpecified = true;
                    bSM.StatusApplicationControl.FriSpecified  = true;
                    bSM.StatusApplicationControl.SatSpecified  = true;
                    bSM.StatusApplicationControl.SunSpecified  = true;

                    bSM.BookingLimit = aSM.BookingLimit;

                    if (aSM.LengthsOfStayNode != null)
                    {
                        bSM.LengthsOfStay = new LengthsOfStayType();
                        bSM.LengthsOfStay.LengthOfStay = new LengthsOfStayTypeLengthOfStay[aSM.LengthsOfStayNode.LengthOfStayNodeList.Count];

                        int indexLS = 0;

                        foreach (var lOS in aSM.LengthsOfStayNode.LengthOfStayNodeList)
                        {
                            bSM.LengthsOfStay.LengthOfStay[indexLS] = new LengthsOfStayTypeLengthOfStay();
                            bSM.LengthsOfStay.LengthOfStay[indexLS].MinMaxMessageTypeSpecified = true;
                            if (lOS.MinMaxMessageType == "SetMinLOS")
                            {
                                bSM.LengthsOfStay.LengthOfStay[indexLS].MinMaxMessageType = LengthsOfStayTypeLengthOfStayMinMaxMessageType.SetMinLOS;
                            }
                            else
                            {
                                bSM.LengthsOfStay.LengthOfStay[indexLS].MinMaxMessageType = LengthsOfStayTypeLengthOfStayMinMaxMessageType.SetMaxLOS;
                            }
                            bSM.LengthsOfStay.LengthOfStay[indexLS++].Time = lOS.Time;
                        }
                    }

                    if (aSM.StatusApplicationControlNode.DestinationSystemCodesNode != null)
                    {
                        bSM.StatusApplicationControl.DestinationSystemCodes = new DestinationSystemCodesTypeDestinationSystemCode[aSM.StatusApplicationControlNode.DestinationSystemCodesNode.DestinationSystemCodeNodeList.Count];

                        int indexDC = 0;

                        foreach (var dC in aSM.StatusApplicationControlNode.DestinationSystemCodesNode.DestinationSystemCodeNodeList)
                        {
                            bSM.StatusApplicationControl.DestinationSystemCodes[indexDC]         = new DestinationSystemCodesTypeDestinationSystemCode();
                            bSM.StatusApplicationControl.DestinationSystemCodes[indexDC++].Value = dC.InnerText;
                        }
                    }

                    if (aSM.RestricitionStatusNode != null)
                    {
                        bSM.RestrictionStatus = new AvailStatusMessageTypeRestrictionStatus();

                        if (aSM.RestricitionStatusNode.Status == "Open")
                        {
                            bSM.RestrictionStatus.Status          = AvailabilityStatusType.Open;
                            bSM.RestrictionStatus.StatusSpecified = true;
                        }

                        if (aSM.RestricitionStatusNode.Status == "Close")
                        {
                            bSM.RestrictionStatus.Status          = AvailabilityStatusType.Close;
                            bSM.RestrictionStatus.StatusSpecified = true;
                        }

                        if (aSM.RestricitionStatusNode.Restriction == "Arrival")
                        {
                            bSM.RestrictionStatus.Restriction          = RatePlanTypeRestrictionStatusRestriction.Arrival;
                            bSM.RestrictionStatus.RestrictionSpecified = true;
                        }

                        if (aSM.RestricitionStatusNode.Restriction == "Departure")
                        {
                            bSM.RestrictionStatus.Restriction          = RatePlanTypeRestrictionStatusRestriction.Departure;
                            bSM.RestrictionStatus.RestrictionSpecified = true;
                        }
                    }

                    body.AvailStatusMessages.AvailStatusMessage[index++] = bSM;
                }

                //
                // Send availability update.
                //

                response = await service.HotelAvailNotifRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false);
            }
            catch (NullReferenceException)
            {
                Exception exSetup = new Exception("OTA_HotelAvailNotifRQ arguments were not set up properly causing a null reference exception.");
                response = new HotelAvailNotifRQResponse();
                response.OTA_HotelAvailNotifRS       = new MessageAcknowledgementType();
                response.OTA_HotelAvailNotifRS.Items = new object[] { ProcessingException(exSetup) };
            }
            catch (Exception ex)
            {
                response = new HotelAvailNotifRQResponse();
                response.OTA_HotelAvailNotifRS       = new MessageAcknowledgementType();
                response.OTA_HotelAvailNotifRS.Items = new object[] { ProcessingException(ex) };
            }


            return(response);
        }