コード例 #1
0
ファイル: API.cs プロジェクト: agrubin/SiteMinder
        static public async Task <HotelRateAmountNotifRQResponse> OTA_HotelRateAmountNotifRQ(string pmsID, string usernameAuthenticate, string passwordAuthenticate, RateAmountMessages rateAmountMessages)
        {
            HotelRateAmountNotifRQResponse response = null;

            try
            {
                PmsXchangeServiceClient    service = new AsyncServiceConnection().service;
                OTA_HotelRateAmountNotifRQ body    = new OTA_HotelRateAmountNotifRQ()
                {
                    Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.*/, TimeStamp = DateTime.Now, TimeStampSpecified = true, POS = CreatePOS(pmsID), RateAmountMessages = new OTA_HotelRateAmountNotifRQRateAmountMessages()
                };
                body.RateAmountMessages.HotelCode         = rateAmountMessages.HotelCode;
                body.RateAmountMessages.RateAmountMessage = new RateAmountMessageType[rateAmountMessages.RateAmountMessageNodeList.Count];

                //
                // IMPORTANT NOTE:
                //  There was a slight error made in filling out the body elements for this request.  I delegted the bad code
                //  and left this framework.  Use thde codel in the OTA_HotelAvailNotifR API as a model to complete it.

                /*
                 * int index = 0;
                 *
                 * foreach (RateAmountMessages.RateAmountMessage rAM in rateAmountMessages.RateAmountMessageNodeList)
                 * {
                 * }
                 */

                //
                // Send rates update.
                //

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

            return(response);
        }
コード例 #2
0
ファイル: RateAmountUpdate.cs プロジェクト: ognjenm/egle
        /// <summary>
        /// Send the rate Amount update message for a rate plan
        /// </summary>
        /// <param name="businessShortname">Business short name</param>
        /// <param name="businessId">Business Id</param>
        /// <param name="roomTypeId">Room type id</param>
        /// <param name="ratePlanId">Rate Plan Id</param>
        /// <param name="startDate">Start date</param>
        /// <param name="endDate">End date</param>
        public void SendRateAmountUpdate(string businessShortname, long businessId, int roomTypeId, int ratePlanId, DateTime? startDate = null, DateTime? endDate = null)
        {
            var hotelRateAmountNotif = new OTA_HotelRateAmountNotifRQ();

            hotelRateAmountNotif.RateAmountMessages = new OTA_HotelRateAmountNotifRQRateAmountMessages();
            hotelRateAmountNotif.RateAmountMessages.HotelCode = businessShortname;

            var rates = GetRateAmounts(businessId, roomTypeId, ratePlanId, startDate, endDate);

            if (rates != null && rates.Any())
            {
                hotelRateAmountNotif.RateAmountMessages.RateAmountMessage = rates.ToArray();

                SetLocatorId(hotelRateAmountNotif);

                PPCGateway.Publish(hotelRateAmountNotif);
            }
        }
コード例 #3
0
ファイル: RateAmountUpdate.cs プロジェクト: ognjenm/egle
        /// <summary>
        /// Send the rate Amount for a business
        /// </summary>
        /// <param name="businessId">Business Id</param>
        /// <param name="businessShortname">Business short name</param>
        /// <returns>True if it is a success</returns>
        public bool SendRateAmountUpdate(long businessId, string businessShortname)
        {
            var hotelRateAmountNotif = new OTA_HotelRateAmountNotifRQ();

            hotelRateAmountNotif.RateAmountMessages = new OTA_HotelRateAmountNotifRQRateAmountMessages();
            hotelRateAmountNotif.RateAmountMessages.HotelCode = businessShortname;

            var roomsType = roomTypeManager.GetAllActiveWithRatePlansForBusiness(businessId, RatePlanTypeEnum.Unknown);

            var rateAmountMessageTypes = new List<RateAmountMessageType>();

            foreach (var roomType in roomsType)
            {
                int ratePlanId = int.Parse(roomType.Code);
                var rateAmountMessages = GetRateAmounts(businessId, roomType.Id, ratePlanId);
                rateAmountMessageTypes.AddRange(rateAmountMessages);
            }

            hotelRateAmountNotif.RateAmountMessages.RateAmountMessage = rateAmountMessageTypes.ToArray();

            SetLocatorId(hotelRateAmountNotif);

            PPCGateway.Publish(hotelRateAmountNotif);

            return true;
        }
コード例 #4
0
ファイル: RateAmountUpdate.cs プロジェクト: ognjenm/egle
        /// <summary>
        /// Set the different position of the messages
        /// </summary>
        /// <param name="message">OTA_HotelRateAmountNotifRQ</param>
        private void SetLocatorId(OTA_HotelRateAmountNotifRQ message)
        {
            int locator = 1;

            foreach (var rateMessage in message.RateAmountMessages.RateAmountMessage)
            {
                rateMessage.LocatorID = locator.ToString();

                locator++;
            }
        }