コード例 #1
0
        public static void LogHotelBookReq(HotelBookRequest HotelBookReq, string SearchId)
        {
            string path = MainPath + @"\TBOLogs\" + DateTime.UtcNow.Date.ToString("dd_MM_yyyy") + @"\" + SearchId + @"\HotelBookReq\";

            Directory.CreateDirectory(path);
            path = path + "HotelBookReq.txt";
            try
            {
                XmlSerializer xmlSerializer = new XmlSerializer(HotelBookReq.GetType());
                using (StreamWriter streamwriter = new StreamWriter(path, append: false))
                {
                    xmlSerializer.Serialize(streamwriter, HotelBookReq);
                    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);
            }
        }
コード例 #2
0
        public static HotelBookResponse Booking(HotelBookRequest req, string SID)
        {
            var UName = ConfigurationSettings.AppSettings["TBOUserName"];
            var UPass = ConfigurationSettings.AppSettings["TBOPassword"];

            IHotelService proxy = TBOCredentials.CreateProxy();

            req.Credentials = new AuthenticationData()
            {
                UserName = UName,
                Password = UPass
            };
            req.RestrictDuplicateBooking = true;
            ProviderLogger.LogHotelBookReq(req, SID);
            HotelBookResponse resp      = new HotelBookResponse();
            Stopwatch         stopwatch = new Stopwatch();

            stopwatch.Start();
            resp = proxy.HotelBook(req);
            stopwatch.Stop();
            TimeSpan ts1          = stopwatch.Elapsed;
            TimeSpan baseInterval = new TimeSpan(0, 0, 60);

            if (ts1 > baseInterval)
            {
                BookDetail.DetailService(req.ClientReferenceNumber);
            }
            ProviderLogger.LogHotelBookResp(resp, SID);

            return(resp);
        }
コード例 #3
0
        public static HotelBookRequest MapBookReq(Hotels.Common.Models.TBOBookReq bookReq)
        {
            List <TBO.WSDL.hotelServiceRef.Guest> guests = new List <TBO.WSDL.hotelServiceRef.Guest>();

            if (bookReq.PaymentInfo != null)
            {
                Enum.TryParse(bookReq.PaymentInfo.PaymentModeType, out PaymentModeType PayModeTyp);
            }

            foreach (var item in bookReq.Guests)
            {
                Enum.TryParse(item.GuestType, out GuestType Guesttype);
                guests.Add(new TBO.WSDL.hotelServiceRef.Guest()
                {
                    Age         = item.Age,
                    FirstName   = item.FirstName,
                    GuestInRoom = item.GuestInRoom,
                    GuestType   = Guesttype,
                    LastName    = item.LastName,
                    LeadGuest   = item.LeadGuest,
                    Title       = item.Title
                });
            }
            List <TBO.WSDL.hotelServiceRef.RequestedRooms> rooms = new List <TBO.WSDL.hotelServiceRef.RequestedRooms>();

            foreach (var item in bookReq.HotelRooms)
            {
                List <TBO.WSDL.hotelServiceRef.SuppInfo> suppInfos = new List <TBO.WSDL.hotelServiceRef.SuppInfo>();
                if (item.Supplements != null)
                {
                    foreach (var sup in item.Supplements)
                    {
                        Enum.TryParse(sup.SuppChargeType, out SuppChargeType ChargTyp);

                        suppInfos.Add(new TBO.WSDL.hotelServiceRef.SuppInfo()
                        {
                            Price          = sup.Price,
                            SuppID         = sup.SuppID,
                            SuppChargeType = ChargTyp,
                            SuppIsSelected = sup.SuppIsSelected
                        });
                    }
                }

                //pass the same room combination that you have passed in AvailabilityAndPricing
                //with same roomtypename , roomplancode and rateplancode.
                rooms.Add(new RequestedRooms()
                {
                    RatePlanCode = item.RatePlanCode,
                    RoomIndex    = item.RoomIndex,
                    RoomRate     = new TBO.WSDL.hotelServiceRef.Rate
                    {
                        RoomFare  = item.RoomRate.RoomFare,
                        RoomTax   = item.RoomRate.RoomTax,
                        TotalFare = item.RoomRate.TotalFare,
                    },
                    RoomTypeCode = item.RoomTypeCode,
                    RoomTypeName = item.RoomTypeName,
                    Supplements  = suppInfos.ToArray()
                });
            }
            HotelBookRequest TBOReq = new HotelBookRequest
            {
                Guests      = guests.ToArray(),
                HotelRooms  = rooms.ToArray(),
                AddressInfo = new TBO.WSDL.hotelServiceRef.AddressInfo
                {
                    AddressLine1 = bookReq.AddressInfo?.AddressLine1,
                    AddressLine2 = bookReq.AddressInfo?.AddressLine2,
                    AreaCode     = bookReq.AddressInfo?.AreaCode,
                    City         = bookReq.AddressInfo?.City,
                    Country      = bookReq.AddressInfo?.Country,
                    CountryCode  = bookReq.AddressInfo?.CountryCode,
                    Email        = bookReq.AddressInfo?.Email,
                    PhoneNo      = bookReq.AddressInfo?.PhoneNo,
                    State        = bookReq.AddressInfo?.State,
                    ZipCode      = bookReq.AddressInfo?.ZipCode
                },
                ClientReferenceNumber = "070817125855789" + "#" + RandomString(4),//RandomNumber(15)+"#" + RandomString(4),
                GuestNationality      = bookReq.GuestNationality,
                HotelCode             = bookReq.HotelCode,
                HotelName             = bookReq.HotelName,
                NoOfRooms             = bookReq.NoOfRooms,
                PaymentInfo           = new TBO.WSDL.hotelServiceRef.PaymentInfo
                {
                    VoucherBooking = true,// bookReq.PaymentInfo.VoucherBooking,
                    //PaymentModeType = PayModeTyp
                },
                ResultIndex = bookReq.ResultIndex,
                SessionId   = bookReq.SessionId,
            };

            return(TBOReq);
        }