Exemplo n.º 1
0
        public bool UpdatePropertyDescriptionandImages()
        {
            bool   result  = false;
            long   id1     = 0;
            string HotelID = string.Empty;

            try
            {
                String hotelcode = string.Empty;

                List <CLayer.Property> objProperties   = BLayer.Property.GetAllGDSPropertiesWithOutData().ToList();
                List <CLayer.Property> objDescriptions = BLayer.Property.GetAllGDSPropertyDescriptionsWithOutData();
                //  List<CLayer.Property> objFormattedDescriptions = BLayer.Property.GetAllGDSPropertyFormattedDescriptionsWithOutData();
                List <CLayer.Property>               objTitles = BLayer.Property.GetAllGDSPropertyTitlesWithOutData();
                CLayer.GDSBookingDetails.Envelope    ss        = new CLayer.GDSBookingDetails.Envelope();
                CLayer.GDSBookingDetailsAdv.Envelope ssAdv     = new CLayer.GDSBookingDetailsAdv.Envelope();// ser.Deserialize<CLayer.GDSBookingDetailsAdv.Envelope>(hotel);
                long id = 0;
                foreach (var pitem in objProperties)
                {
                    try
                    {
                        #region Update Property Description
                        StringBuilder Description = new StringBuilder();
                        //Update property description start
                        Serializer ser = new Serializer();
                        id  = pitem.PropertyId;
                        id1 = id;
                        string HotelCode = pitem.HotelID;
                        HotelID = HotelCode;
                        string hotel = GetGDS_Hotel_Details(HotelCode);



                        ss = ser.Deserialize <CLayer.GDSBookingDetails.Envelope>(hotel);

                        DataTable dtHotel = BLayer.Property.GetHotelFormattedDescription(id);
                        string    FormattedDescription = string.Empty;
                        if (dtHotel.Rows.Count > 0)
                        {
                            foreach (DataRow dr in dtHotel.Rows)
                            {
                                FormattedDescription = Convert.ToString(dr["FormattedDescription"]);
                            }
                        }



                        if (string.IsNullOrEmpty(FormattedDescription))
                        {
                            FormattedDescription = GDSProcess.GDSFormatDescription.GetFormattedDescription(hotel);
                            BLayer.Property.GDSUpdatePropertyDescriptionFormatted(id, FormattedDescription, GDSProcess.GDSFormatDescription.StarRatings, "");
                        }
                        int LocalStarRating = APIUtility.GetStarRating(hotel);
                        if (LocalStarRating > 0)
                        {
                            BLayer.Property.GDSUpdatePropertyStarRatings(id, LocalStarRating);
                        }



                        if (ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents != null)
                        {
                            var TitleItem = objTitles.Where(x => x.HotelID == HotelCode).ToList();
                            if (TitleItem != null)
                            {
                                if (TitleItem.Count > 0)
                                {
                                    string Title = ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelName;
                                    BLayer.Property.GDSUpdatePropertyTitle(id, Title);
                                }
                            }

                            #region Update Description Without Formatting

                            if (string.IsNullOrEmpty(FormattedDescription))
                            {
                                var DescriptionItem = objDescriptions.Where(x => x.HotelID == HotelCode).ToList();
                                if (DescriptionItem != null)
                                {
                                    if (DescriptionItem.Count > 0)
                                    {
                                        if (ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo != null)
                                        {
                                            var description = ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo.Descriptions;
                                            if (description != null)
                                            {
                                                var descriptionList = description.MultimediaDescriptions.MultimediaDescription;


                                                var Descriptions = from order in descriptionList
                                                                   where order.TextItems != null
                                                                   select order;
                                                string HotelDescription = string.Empty;
                                                foreach (var desc in Descriptions)
                                                {
                                                    if (desc.InfoCode != null)
                                                    {
                                                        foreach (var datas in desc.TextItems.TextItem.Description)
                                                        {
                                                            HotelDescription = HotelDescription + datas.__Text + "#256#";
                                                        }
                                                    }
                                                    // HotelDescription = HotelDescription + "<br>";
                                                }
                                                Description.Append(HotelDescription);

                                                BLayer.Property.GDSUpdatePropertyDescription(id, Description.ToString());
                                            }
                                        }
                                    }
                                }
                            }

                            #endregion

                            //update property description end
                            #endregion

                            #region Update Property Images old method
                            //  var ssw = ss.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo.Descriptions;
                            ////  var sswguest = ssAdv.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo.CategoryCodes.GuestRoomInfo.Where(x => x.Code == 28);

                            //  if (ssw!=null)
                            //  {
                            //      var sswList = ssw;

                            //      List<CLayer.PropertyFiles> picturelist = new List<CLayer.PropertyFiles>();
                            //      //var filteredOrders = from order in sswList
                            //      //                     where order.ImageItems != null
                            //      //                     select order;

                            //      int nos = 0;
                            //    BLayer.Property.DeleteGDSPropertyImages(id);

                            //      foreach (var item in sswList.MultimediaDescriptions.MultimediaDescription)
                            //      {
                            //          if (item.ImageItems != null)
                            //          {
                            //              var t = item.ImageItems.ImageItem;
                            //              if (t != null)
                            //              {
                            //                  foreach (var itemimg in t)
                            //                  {
                            //                      CLayer.PropertyFiles picture = new CLayer.PropertyFiles();
                            //                      picture.FileName = itemimg.ImageFormat.Where(x => x.DimensionCategory == "E").ToList()[0].URL;
                            //                      picture.PropertyId = id;
                            //                      picturelist.Add(picture);
                            //                      BLayer.Property.GDSSaveImageurl(id, picture.FileName);
                            //                      nos++;
                            //                      if (nos == PictureCount) break;
                            //                  }
                            //              }
                            //          }
                            //          if (nos == PictureCount) break;
                            //      }
                            //      if(picturelist.Count<8)
                            //      {
                            //          ssAdv = ser.Deserialize<CLayer.GDSBookingDetailsAdv.Envelope>(hotel);
                            //          var sswguest = ssAdv.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.HotelInfo.CategoryCodes.GuestRoomInfo.Where(x => x.Code == 28);
                            //          if (sswguest != null)
                            //          {
                            //              int PictureCount = 8 - picturelist.Count;
                            //              int ImgCounter = 0;
                            //              foreach (var item in sswguest)
                            //              {
                            //                  foreach (var itemAdv in item.MultimediaDescriptions)
                            //                  {
                            //                      if (itemAdv.ImageItems != null)
                            //                      {
                            //                          var t = itemAdv.ImageItems;
                            //                          if (t != null)
                            //                          {
                            //                              foreach (var itemimg in t)
                            //                              {
                            //                                  CLayer.PropertyFiles picture = new CLayer.PropertyFiles();
                            //                                  picture.FileName = itemimg.ImageFormat.Where(x => x.DimensionCategory == "E").ToList()[0].URL;
                            //                                  picture.PropertyId = id;
                            //                                  picturelist.Add(picture);
                            //                                  BLayer.Property.GDSSaveImageurl(id, picture.FileName);
                            //                                  ImgCounter++;
                            //                                  if (ImgCounter == PictureCount) break;
                            //                              }
                            //                          }
                            //                      }
                            //                      if (ImgCounter == PictureCount) break;
                            //                  }
                            //                  if (ImgCounter == PictureCount) break;
                            //              }
                            //          }
                            //      }


                            //  }
                            #endregion



                            #region update property contact numbers
                            //update GDS Property contact numbers start
                            CLayer.GDSBookingDetails.Envelope GDSBookingDetails = ss;
                            string Phone  = string.Empty;
                            string Mobile = string.Empty;
                            string Email  = string.Empty;
                            if (GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Emails != null)
                            {
                                Email = GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Emails.Email.ToString();
                            }
                            if (GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones != null)
                            {
                                if (GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones.Phone.Where(x => x.PhoneTechType == "1").Count() > 0)
                                {
                                    Phone = GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones.Phone.Where(x => x.PhoneTechType == "1").FirstOrDefault().PhoneNumber;
                                }
                                if (GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones.Phone.Where(x => x.PhoneTechType == "5").Count() > 0)
                                {
                                    Mobile = GDSBookingDetails.Body.OTA_HotelDescriptiveInfoRS.HotelDescriptiveContents.HotelDescriptiveContent.ContactInfos.ContactInfo.Phones.Phone.Where(x => x.PhoneTechType == "5").FirstOrDefault().PhoneNumber;
                                }
                                if ((!string.IsNullOrEmpty(Phone)) || (!string.IsNullOrEmpty(Mobile)) || (!string.IsNullOrEmpty(Email)))
                                {
                                    BLayer.Property.GDSUpdatePropertyContactNumbers(id, Phone, Mobile, Email);
                                }
                            }
                            //update GDS Property Contact numbers end
                            //#region Transaction Log

                            //APIUtility.GenerateGDSTransactionLog("", "BulkImageandDescriptionSuccess", 0, (int)CLayer.ObjectStatus.GDSType.BulkHotelImageDescriptionUpdation, 0);

                            //#endregion Transaction log end
                            #endregion
                        }


                        #region UPDATE PROPERTY IMAGES
                        long ImageCount = BLayer.Property.GetGDSPropertyImagesCount(id);
                        if (ImageCount < 1)
                        {
                            BLayer.Property.DeleteGDSPropertyImages(id);
                            List <CLayer.PropertyFiles> pictlist = GetGDSImages(hotel, id);
                        }


                        #endregion

                        //    WriteToLog(HotelID);
                    }
                    catch (Exception ex)
                    {
                        //  LogHandler.AddLog("Error in-"+hotelcode);
                        WriteToLog(HotelID, true);
                    }
                    finally
                    {
                    }
                }
                result = true;
            }
            catch (Exception ex)
            {
                LogHandler.AddLog(ex.Message);
                string a = id1.ToString();
                result = false;

                throw ex;
            }
            return(result);
        }
Exemplo n.º 2
0
        public bool UpdatePropertyRates()
        {
            bool   Output = false;
            long   id1    = 0;
            string start  = "";
            string End    = "";

            try
            {
                String hotelcode = string.Empty;

                List <CLayer.Property> objProperties = BLayer.Property.GetAllGDSPropertiesRecommended().ToList();

                CLayer.GDSBookingDetails.Envelope    ss    = new CLayer.GDSBookingDetails.Envelope();
                CLayer.GDSBookingDetailsAdv.Envelope ssAdv = new CLayer.GDSBookingDetailsAdv.Envelope();// ser.Deserialize<CLayer.GDSBookingDetailsAdv.Envelope>(hotel);
                long id = 0;
                foreach (var pitem in objProperties)
                {
                    try
                    {
                        StringBuilder Description = new StringBuilder();
                        Serializer    ser         = new Serializer();
                        id  = pitem.PropertyId;
                        id1 = id;
                        string HotelCode  = pitem.HotelID;
                        string GDSCountry = pitem.Countryname;

                        //    string hotel = GetGDS_Hotel_Details(HotelCode);


                        start = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd");
                        End   = DateTime.Now.Date.AddDays(2).ToString("yyyy-MM-dd");

                        #region Rate Calculation
                        string result = HotelMultiSingleAvailability(HotelCode, start, End);

                        Serializer ser1 = new Serializer();
                        CLayer.HotelAvailability.Envelope              HotelResult         = new CLayer.HotelAvailability.Envelope();
                        CLayer.HotelAvailabilityAdvanced.Envelope      HotelResultAdv      = new CLayer.HotelAvailabilityAdvanced.Envelope();
                        CLayer.HotelAvailabilityAdvancedFirst.Envelope HotelResultAdvFirst = new CLayer.HotelAvailabilityAdvancedFirst.Envelope();


                        try
                        {
                            HotelResult = ser1.Deserialize <CLayer.HotelAvailability.Envelope>(result);
                        }
                        catch (Exception ex)
                        {
                            try
                            {
                                HotelResultAdv = ser1.Deserialize <CLayer.HotelAvailabilityAdvanced.Envelope>(result);
                            }
                            catch (Exception ex1)
                            {
                                HotelResultAdvFirst = ser1.Deserialize <CLayer.HotelAvailabilityAdvancedFirst.Envelope>(result);
                            }
                        }
                        if (HotelResult.Body != null)
                        {
                            decimal GDSRateConversion = 0;
                            string  GDSCurrencyCode   = "INR";
                            if (HotelResult.Body.OTA_HotelAvailRS.CurrencyConversions != null)
                            {
                                var item = HotelResult.Body.OTA_HotelAvailRS.CurrencyConversions;
                                CLayer.GDSCurrencyConversions objCurrencyConversion = new CLayer.GDSCurrencyConversions();
                                objCurrencyConversion.RateConversion = item.CurrencyConversion.RateConversion;
                                GDSRateConversion = objCurrencyConversion.RateConversion;
                                objCurrencyConversion.DecimalPlaces         = item.CurrencyConversion.DecimalPlaces;
                                objCurrencyConversion.RequestedCurrencyCode = item.CurrencyConversion.RequestedCurrencyCode;
                                objCurrencyConversion.SourceCurrencyCode    = item.CurrencyConversion.SourceCurrencyCode;
                                GDSCurrencyCode = objCurrencyConversion.SourceCurrencyCode;
                                //  Session["GDSCurrencyConversion"] = objCurrencyConversion;
                            }
                            //if (GDSCountry == "")
                            //{
                            //     Session["GDSCurrencyConversion"] = null;
                            //}


                            if (HotelResult.Body.OTA_HotelAvailRS.HotelStays != null)
                            {
                                foreach (var item in HotelResult.Body.OTA_HotelAvailRS.HotelStays)
                                {
                                    //    InventoryAPIType = (int)CLayer.ObjectStatus.InventoryAPIType.Amadeus;
                                    string HotelId = item.BasicPropertyInfo.HotelCode;

                                    List <CLayer.Accommodation> objAcc = BLayer.Accommodation.GetAllAccByPropertyid(id);

                                    long   AccomodationId = 0;
                                    string RoomStayRPH    = item.RoomStayRPH;
                                    List <CLayer.RoomStaysResult> RoomStaysResultList = new List <CLayer.RoomStaysResult>();
                                    if (!string.IsNullOrEmpty(RoomStayRPH))
                                    {
                                        string[] RoomStayRPHList = RoomStayRPH.Split(' ');
                                        RoomStaysResultList = GetRoomStays(HotelResult.Body.OTA_HotelAvailRS.RoomStays, RoomStayRPHList, GDSCurrencyCode, GDSRateConversion);
                                    }
                                    CultureInfo culture = CultureInfo.CurrentCulture;

                                    CLayer.GDSRates Rdata       = new CLayer.GDSRates();
                                    string          BookingCode = RoomStaysResultList.OrderBy(x => x.AmountAfterTax).FirstOrDefault().BookingCode;
                                    Rdata.Rate    = RoomStaysResultList.OrderBy(x => x.AmountAfterTax).FirstOrDefault().AmountAfterTax;
                                    Rdata.RateFor = 2;
                                    long userId = 0;
                                    Rdata.UpdatedBy       = 1;
                                    Rdata.StartDate       = DateTime.Parse(start, CultureInfo.CurrentCulture);
                                    Rdata.EndDate         = DateTime.Parse(End, CultureInfo.CurrentCulture);
                                    Rdata.BookingCode     = BookingCode;
                                    Rdata.Status          = 1;
                                    Rdata.AccommodationId = objAcc.Where(X => X.BookingCode == BookingCode).FirstOrDefault().AccommodationId;
                                    long gdsRateId = BLayer.Rate.GDSRateSave(Rdata);
                                }
                            }
                            else
                            {
                                start = DateTime.Now.Date.AddDays(4).ToString("yyyy-MM-dd");
                                End   = DateTime.Now.Date.AddDays(5).ToString("yyyy-MM-dd");
                                UpdateGDSRate(id, HotelCode, start, End);
                            }
                        }

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        LogHandler.AddLog("Error rate updation-Hotel ID" + id.ToString());
                    }
                }

                Output = true;
            }
            catch (Exception ex)
            {
                LogHandler.AddLog(ex.Message);
                string a = id1.ToString();
                Output = false;
                //#region Transaction Log
                //APIUtility.GenerateGDSTransactionLog("", "BulkImageandDescriptionFailure", 0, (int)CLayer.ObjectStatus.GDSType.BulkHotelImageDescriptionUpdation, 0);
                //#endregion Transaction Log end
                throw ex;
            }
            return(Output);
        }
Exemplo n.º 3
0
        public bool UpdatePropertyStarRatings()
        {
            bool   result  = false;
            long   id1     = 0;
            string HotelID = string.Empty;

            try
            {
                String hotelcode = string.Empty;

                List <CLayer.Property>               objProperties = BLayer.Property.GetAllGDSProperties().ToList();
                CLayer.GDSBookingDetails.Envelope    ss            = new CLayer.GDSBookingDetails.Envelope();
                CLayer.GDSBookingDetailsAdv.Envelope ssAdv         = new CLayer.GDSBookingDetailsAdv.Envelope();// ser.Deserialize<CLayer.GDSBookingDetailsAdv.Envelope>(hotel);
                long id = 0;
                foreach (var pitem in objProperties)
                {
                    try
                    {
                        //  #region Update Property Description
                        StringBuilder Description = new StringBuilder();
                        //Update property description start
                        Serializer ser = new Serializer();
                        id  = pitem.PropertyId;
                        id1 = id;
                        string HotelCode = pitem.HotelID;
                        HotelID = HotelCode;
                        string hotel = GetGDS_Hotel_Details(HotelCode);



                        ss = ser.Deserialize <CLayer.GDSBookingDetails.Envelope>(hotel);

                        DataTable dtHotel = BLayer.Property.GetHotelFormattedDescription(id);
                        string    FormattedDescription = string.Empty;
                        if (dtHotel.Rows.Count > 0)
                        {
                            foreach (DataRow dr in dtHotel.Rows)
                            {
                                FormattedDescription = Convert.ToString(dr["FormattedDescription"]);
                            }
                        }

                        FormattedDescription = GDSProcess.GDSFormatDescription.GetFormattedDescription(hotel);



                        int StarRatings     = GDSProcess.GDSFormatDescription.StarRatings;
                        int LocalStarRating = APIUtility.GetStarRating(hotel);
                        if (LocalStarRating > 0)
                        {
                            BLayer.Property.GDSUpdatePropertyStarRatings(id, LocalStarRating);
                        }
                        if ((LocalStarRating == 0) && (StarRatings == 0))
                        {
                            BLayer.Property.GDSUpdatePropertyStarRatings(id, 0);
                        }
                    }
                    catch (Exception ex)
                    {
                        //  LogHandler.AddLog("Error in-"+hotelcode);
                        WriteToLog(HotelID.ToString() + "-" + ex.Message, true);
                    }
                    finally
                    {
                    }
                }
                result = true;
            }
            catch (Exception ex)
            {
                LogHandler.AddLog(ex.Message);
                string a = id1.ToString();
                result = false;

                throw ex;
            }
            return(result);
        }