/// <summary> /// Set the different position of the messages /// </summary> /// <param name="message">OTA_HotelAvailNotifRQ</param> private void SetLocatorId(OTA_HotelAvailNotifRQ message) { int locator = 1; foreach (var availMessage in message.AvailStatusMessages.AvailStatusMessage) { availMessage.LocatorID = locator.ToString(); locator++; } }
/// <summary> /// This method will push an inventory message on the queue /// </summary> /// <param name="businessShortname">Business Short Name</param> /// <param name="roomTypeIds">room type Ids</param> /// <param name="startDate">Start Date</param> /// <param name="endDate">End Date</param> public void SendInventoryClose(string businessShortname, int[] roomTypeIds, DateTime startDate, DateTime endDate) { var hotelAvailNotifRq = new OTA_HotelAvailNotifRQ(); var hotelAvailNotifRqAvailStatusMessages = new OTA_HotelAvailNotifRQAvailStatusMessages(); hotelAvailNotifRq.AvailStatusMessages = hotelAvailNotifRqAvailStatusMessages; hotelAvailNotifRqAvailStatusMessages.HotelCode = businessShortname; var availStatusMessages = new List<AvailStatusMessageType>(); foreach (var roomTypeId in roomTypeIds) { var availStatusMessageType = new AvailStatusMessageType(); availStatusMessageType.BookingLimit = "0"; availStatusMessageType.StatusApplicationControl = new StatusApplicationControlType(); availStatusMessageType.StatusApplicationControl.Start = startDate.ToString(Formats.UNIVERSAL_SHORT_DATE); availStatusMessageType.StatusApplicationControl.End = endDate.ToString(Formats.UNIVERSAL_SHORT_DATE); availStatusMessageType.StatusApplicationControl.InvTypeCode = roomTypeId.ToString(); availStatusMessages.Add(availStatusMessageType); } hotelAvailNotifRqAvailStatusMessages.AvailStatusMessage = availStatusMessages.ToArray(); SetLocatorId(hotelAvailNotifRq); PPCGateway.Publish(hotelAvailNotifRq); }
/// <summary> /// This method will push a message on the queue /// </summary> /// <param name="businessShortname">Business Short Name</param> /// <param name="startDate">start date</param> /// <param name="endDate">end date</param> /// <param name="roomTypeIds">room type ids</param> public void SendInventoryUpdate(string businessShortname, int[] roomTypeIds, DateTime startDate, DateTime endDate) { var hotelAvailNotifRq = new OTA_HotelAvailNotifRQ(); var hotelAvailNotifRQAvailStatusMessages = new OTA_HotelAvailNotifRQAvailStatusMessages(); hotelAvailNotifRq.AvailStatusMessages = hotelAvailNotifRQAvailStatusMessages; hotelAvailNotifRQAvailStatusMessages.HotelCode = businessShortname; var availStatusMessages = new List<AvailStatusMessageType>(); foreach (var roomTypeId in roomTypeIds) { IEnumerable<AvailStatusMessageType> roomTypeavailStatusMessages = GetInventoryAvailability(roomTypeId, startDate, endDate); if (roomTypeavailStatusMessages != null) { availStatusMessages.AddRange(roomTypeavailStatusMessages); } } if (availStatusMessages.Any()) { hotelAvailNotifRQAvailStatusMessages.AvailStatusMessage = availStatusMessages.ToArray(); SetLocatorId(hotelAvailNotifRq); PPCGateway.Publish(hotelAvailNotifRq); } }
/// <summary> /// Send a rate restriction for a rate plan /// </summary> /// <param name="businessShortname">Business short name</param> /// <param name="roomTypeId">Room type id</param> /// <param name="ratePlanId">Rate plan id</param> /// <param name="status">Availability status</param> /// <param name="startDate">Start date</param> /// <param name="endDate">End date</param> /// <returns>True if it is a success</returns> public bool SendRatesRestrictionUpdate(string businessShortname, int roomTypeId, int ratePlanId, AvailabilityStatusType status = AvailabilityStatusType.Open, DateTime? startDate = null, DateTime? endDate = null) { var hotelAvailNotifRq = new OTA_HotelAvailNotifRQ(); var hotelAvailNotifRQAvailStatusMessages = new OTA_HotelAvailNotifRQAvailStatusMessages(); hotelAvailNotifRq.AvailStatusMessages = hotelAvailNotifRQAvailStatusMessages; hotelAvailNotifRQAvailStatusMessages.HotelCode = businessShortname; List<AvailStatusMessageType> availStatusMessages = null; if (status != AvailabilityStatusType.Close) { availStatusMessages = GetRateRestrictions(businessShortname, roomTypeId, ratePlanId, status, startDate, endDate); } else { availStatusMessages = new List<AvailStatusMessageType> { GetCloseRestrictionRates(roomTypeId, ratePlanId, startDate, endDate) }; } if (availStatusMessages != null) { hotelAvailNotifRQAvailStatusMessages.AvailStatusMessage = availStatusMessages.ToArray(); SetLocatorId(hotelAvailNotifRq); PPCGateway.Publish(hotelAvailNotifRq); } return true; }
/// <summary> /// Send rates restriction update for a business /// </summary> /// <param name="businessId">Busisness Id</param> /// <param name="businessShortname">Business short name</param> /// <param name="status">AvailabilityStatusType</param> /// <returns>True if it is a success</returns> public bool SendRatesRestrictionUpdate(string businessShortname, long businessId, AvailabilityStatusType status) { var hotelAvailNotifRq = new OTA_HotelAvailNotifRQ(); var hotelAvailNotifRQAvailStatusMessages = new OTA_HotelAvailNotifRQAvailStatusMessages(); hotelAvailNotifRq.AvailStatusMessages = hotelAvailNotifRQAvailStatusMessages; hotelAvailNotifRQAvailStatusMessages.HotelCode = businessShortname; var availStatusMessages = GetRateRestrictions(businessId, status); if (availStatusMessages != null) { hotelAvailNotifRQAvailStatusMessages.AvailStatusMessage = availStatusMessages.ToArray(); SetLocatorId(hotelAvailNotifRq); PPCGateway.Publish(hotelAvailNotifRq); } return true; }
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); }