public static HotelRoomAvailabilityResponse Availabilty(string SessionId, int ResIndex, string HotelCode, string SID)
        {
            var UName = ConfigurationSettings.AppSettings["TBOUserName"];
            var UPass = ConfigurationSettings.AppSettings["TBOPassword"];
            HotelRoomAvailabilityRequest req = new HotelRoomAvailabilityRequest
            {
                SessionId   = SessionId,
                ResultIndex = ResIndex,
                HotelCode   = HotelCode,
                IsCancellationPolicyRequired = true, // already come in Pricing
                Credentials = new AuthenticationData()
                {
                    UserName = UName,
                    Password = UPass
                }
            };

            ProviderLogger.LogRoomAvailabiltyReq(req, SID);

            IHotelService proxy = TBOCredentials.CreateProxy();
            HotelRoomAvailabilityResponse resp = new HotelRoomAvailabilityResponse();

            resp = proxy.AvailableHotelRooms(req);
            ProviderLogger.LogRoomAvailabilityProviderRsp(resp, SID);

            return(resp);
        }
        public static void LogRoomAvailabiltyReq(HotelRoomAvailabilityRequest AvailabiltyReq, string SearchId)
        {
            string path = MainPath + @"\TBOLogs\" + DateTime.UtcNow.Date.ToString("dd_MM_yyyy") + @"\" + SearchId + @"\RoomAvailabiltyReq\";

            Directory.CreateDirectory(path);
            path = path + "RoomAvailabiltyReq.txt";
            try
            {
                XmlSerializer xmlSerializer = new XmlSerializer(AvailabiltyReq.GetType());
                using (StreamWriter streamwriter = new StreamWriter(path, append: false))
                {
                    xmlSerializer.Serialize(streamwriter, AvailabiltyReq);
                    streamwriter.Close();
                }
            }
            catch (FileNotFoundException Ex)
            {
                throw new LoggerException(LoggerErrorCodes.LoggerFileNotFound, LoggerErrorCodes.LoggerFileNotFound + " -This path (" + path + ") doesn't exist with file name " + Ex.FileName + " .", Ex.Message);
            }
            catch (IOException Ex)
            {
                throw new LoggerException(LoggerErrorCodes.LoggerFileINProcess, LoggerErrorCodes.LoggerFileINProcess + " -This Logger File (" + path + ") in another process you can not access it right now.", Ex.Message);
            }
            catch (Exception Ex)
            {
                throw new LoggerException(LoggerErrorCodes.FailedLogIntoLogger, LoggerErrorCodes.FailedLogIntoLogger + " -Failed Log Into Logger with path (" + path + ").", Ex.Message);
            }
        }
        public HotelAvailabilityRS GetHotelAvailability(HDSRequest request)
        {
            HotelRoomAvailabilityRequest rawRq = new HotelRoomAvailabilityRequest();
            rawRq = (HotelRoomAvailabilityRequest)commonHelper.GenerateBaseRequest(rawRq, request);

            //stay date
            rawRq.arrivalDate = request.StayDate.GetCheckInUSFormat();
            rawRq.departureDate = request.StayDate.GetCheckOutUSFormat();

            //hotel
            rawRq.hotelId = (long)request.Hotels[0].Id;

            //room and num adults-children
            rawRq.RoomGroup = commonHelper.GenerateRoomGroup(request.Itineraries);

            //include details
            rawRq.includeDetails = true;
            rawRq.includeDetailsSpecified = true;
            rawRq.includeRoomImages = true;
            rawRq.includeRoomImagesSpecified = true;

            //submit soap request to expedia
            HotelRoomAvailabilityResponse rawRs;
            try
            {
                serviceObjShop = new Expedia.HotelShoppingServiceReference.HotelServicesClient();
                rawRs = serviceObjShop.getAvailability(rawRq);
            }
            catch (Exception e1)
            {
                HotelAvailabilityRS error = new HotelAvailabilityRS();
                error.Errors = new List<WarningAndError>();
                error.Errors.Add(new WarningAndError { Id = 9003, Message = "Error return from provider", DetailDescription = e1.ToString() });
                return error;
            }

            //do hotel availability mapping
            try
            {
                return objMapping.MappingHotelAvailability(rawRs);
            }
            catch (Exception e2)
            {
                HotelAvailabilityRS error = new HotelAvailabilityRS();
                error.Errors = new List<WarningAndError>();
                error.Errors.Add(new WarningAndError { Id = 9120, Message = "Hotel Availability mapping exception", DetailDescription = e2.ToString() });
                return error;
            }
        }
Example #4
0
        private List<Entity.Hotel> GetHotelsData(string city, int numberOfAdults, DateTime arrivalDate, DateTime departureDate)
        {
            var result = new List<Entity.Hotel>();
            var hotelServicesClient = new HotelServicesClient();

            var request = new HotelListRequest();
            request.arrivalDate = arrivalDate.ToString("MM/dd/yyyy");
            request.departureDate = departureDate.ToString("MM/dd/yyyy");
            request.city = city;
            request.cid = 55505;
            request.apiKey = "qb8es7zetcad5s5atuadxt3f";
            var room = new Room();
            room.numberOfAdults = numberOfAdults;
            request.RoomGroup = new[] { room };

            hotelServicesClient.Open();

            var hotelListResponse = hotelServicesClient.getList(request);

            var rooms = new List<HotelRoomResponse>();
            foreach (HotelSummary hotelSummary in hotelListResponse.HotelList.HotelSummary)
            {
                var roomRequest = new HotelRoomAvailabilityRequest();
                roomRequest.cid = 55505;
                roomRequest.apiKey = "qb8es7zetcad5s5atuadxt3f";
                roomRequest.hotelId = hotelSummary.hotelId;
                roomRequest.arrivalDate = arrivalDate.ToString("MM/dd/yyyy");
                roomRequest.departureDate = departureDate.ToString("MM/dd/yyyy");
                roomRequest.RoomGroup = new[] { room };
                var hotelRoomResponse = hotelServicesClient.getAvailability(roomRequest);
                foreach (HotelRoomResponse roomResponse in hotelRoomResponse.HotelRoomResponse)
                {
                    result.Add(new Entity.Hotel(hotelSummary.name,
                                                roomResponse.RateInfo.ChargeableRateInfo.commissionableUsdTotal,
                                                roomResponse.RateInfo.ChargeableRateInfo.currencyCode,
                                                @"http://media.expedia.com/" + hotelSummary.thumbNailUrl, city, roomResponse.rateDescription));
                }
            }
            return result;
        }