Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Invalid Parameters");
                Console.WriteLine("Parameters (only one at a time)");
                Console.WriteLine("------------------------------");
                Console.WriteLine("ALLPROPERTIES - Generate excel report with all properties");
                Console.WriteLine("ALLPROPERTYDESCANDIMAGE - Download Amadeus Hotel's images");
                Console.WriteLine("CANCELGDSBOOKINGS - Cancel incomplete booking");
                Console.WriteLine("REMOVEDEADIMAGES - Remove dead image urls");
                Console.WriteLine("CLEARGDSLOG - clear gds transaction log");
                Console.WriteLine("UPDATEGDSRATES - update gds rates transaction log");
                Console.WriteLine("UPDATEGDSSTARRATINGS - update gds star ratings");
                Console.WriteLine("UPDATETAMARINDMASTER - update tamarind master");
                Console.WriteLine("UPDATETBOMASTER - update TBO master");
                Console.WriteLine("UPDATETBOHOTELCITYEXCEL - update TBO Hotel Cities from Excel");


                LogHandler.AddLog("Using Default ConnectionString " + System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
                LogHandler.AddLog("Using ReadOnly ConnectionString " + System.Configuration.ConfigurationManager.ConnectionStrings["ReadOnlyConnection"].ConnectionString);


                //   Console.ReadLine();

                return;
            }
            try
            {
                if (args[0].ToUpper() == PROPERTYREPORT)
                {
                    PropertyReport pr = new PropertyReport();
                    pr.GenerateReport();
                }
                else if (args[0].ToUpper() == PROPERTYDESCRIPTIONANDIMAGE)
                {
                    //update image and description
                    PropertyDetails pd = new PropertyDetails();

                    if (pd.UpdatePropertyDescriptionandImages())
                    {
                        Console.WriteLine("------------------------------");
                        Console.WriteLine("Property images and descriptions successfully updated");
                        Console.WriteLine("------------------------------");
                    }
                    else
                    {
                        Console.WriteLine("------------------------------");
                        Console.WriteLine("Error in updating images and descriptions");
                        Console.WriteLine("------------------------------");
                    }
                }
                else if (args[0].ToUpper() == CANCELINCOMPLETEGDSBOOKINGS)
                {
                    //update image and description
                    CancelGDSBookings pc = new CancelGDSBookings();
                    if (pc.CancelInCompleteGDSBookings())
                    {
                        Console.WriteLine("------------------------------");
                        Console.WriteLine("Invalid GDS Bookings successfully cancelled");
                        Console.WriteLine("------------------------------");
                    }
                    else
                    {
                        Console.WriteLine("------------------------------");
                        Console.WriteLine("Invalid GDS Bookings cancellation failed");
                        Console.WriteLine("------------------------------");
                    }
                }
                else if (args[0].ToUpper() == REMOVEDEADIMAGES)
                {
                    ImageUrlFixer fx = new ImageUrlFixer();
                    fx.FixInvalidPicturesAll();
                }
                else if (args[0].ToUpper() == CLEARGDSLOG)
                {
                    CleadGDSTransactionLog clr = new CleadGDSTransactionLog();
                    clr.ClearGDSLog();
                }
                else if (args[0].ToUpper() == UPDATEGDSRATES)
                {
                    UpdateGDSRates clr = new UpdateGDSRates();
                    clr.UpdatePropertyRates();
                }
                else if (args[0].ToUpper() == UPDATEGDSSTARRATINGS)
                {
                    UpdateStarRating clr = new UpdateStarRating();
                    clr.UpdatePropertyStarRatings();
                }
                else if (args[0].ToUpper() == UPDATETAMARINDMASTER)
                {
                    UpdateTamarindMaster clr = new UpdateTamarindMaster();
                    clr.UpdateMaster();
                }
                else if (args[0].ToUpper() == UPDATETBOMASTER)
                {
                    UpdateTBO clr = new UpdateTBO();
                    clr.UpdateMaster();
                }
                else if (args[0].ToUpper() == UPDATETBOHOTELCITYEXCEL)
                {
                    UpdateTBO clr = new UpdateTBO();
                    clr.UpdateHotelCityExcel();
                }
                else
                {
                    Console.WriteLine("Invalid Argument");
                }
            }
            catch (Exception ex)
            {
                LogHandler.LogError(ex);
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        private List <CLayer.PropertyFiles> GetGDSImages(string response, long id)
        {
            List <CLayer.PropertyFiles> picturelist = new List <CLayer.PropertyFiles>();
            XmlDocument xmlDoc = new XmlDocument();
            string      a      = string.Empty;

            //  List<CLayer.PropertyFiles> pictureslist = new List<CLayer.PropertyFiles>();
            try
            {
                // xmlDoc.Load(@"F:\HotelDescriptiveIno.xml");
                xmlDoc.LoadXml(response);
                XmlNamespaceManager xmlnsManager    = new System.Xml.XmlNamespaceManager(xmlDoc.NameTable);
                XmlNode             node            = null;
                XmlNode             nodeImages      = null;
                XmlNode             nodeguestImages = null;

                string nodeRoot           = "/soapenv:Envelope/soapenv:Body/";
                string nodevalue          = "/si:OTA_HotelDescriptiveInfoRS/si:HotelDescriptiveContents/si:HotelDescriptiveContent/si:HotelInfo/si:Descriptions";                                    //"/si:MultimediaDescriptions/si:MultimediaDescription/si:ImageItems/si:ImageItem/si:ImageFormat/si:URL";
                string nodevalueguestroom = "/si:OTA_HotelDescriptiveInfoRS/si:HotelDescriptiveContents/si:HotelDescriptiveContent/si:HotelInfo/si:CategoryCodes/si:CategoryCodes/si:GuestRoomInfo"; //si:MultimediaDescriptions/si:MultimediaDescription/si:ImageItems/si:ImageItem/si:ImageFormat/si:URL";

                xmlnsManager.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
                xmlnsManager.AddNamespace("awsse", "http://xml.amadeus.com/2010/06/Session_v3");
                xmlnsManager.AddNamespace("wsa", "http://www.w3.org/2005/08/addressing");
                xmlnsManager.AddNamespace("si", "http://www.opentravel.org/OTA/2003/05");

                nodeImages      = xmlDoc.SelectSingleNode(nodeRoot + nodevalue, xmlnsManager);
                nodeguestImages = xmlDoc.SelectSingleNode(nodeRoot + nodevalueguestroom, xmlnsManager);

                #region MAIN IMAGES
                if (nodeImages != null)
                {
                    XmlNodeList list         = nodeImages.SelectNodes("//si:MultimediaDescriptions/si:MultimediaDescription", xmlnsManager);
                    int         PictureCount = 0;
                    int         nodes        = 0;
                    if (list != null)
                    {
                        foreach (XmlNode item in list)
                        {
                            var subItem = item.SelectNodes("//si:ImageItems", xmlnsManager);
                            if (subItem != null)
                            {
                                foreach (XmlNode sItem in subItem)
                                {
                                    IEnumerable <XmlNode> subInnerItem = sItem.SelectNodes("//si:ImageItem", xmlnsManager).Cast <XmlNode>().OrderByDescending(r => Convert.ToDateTime(r.Attributes["LastModifyDateTime"].Value));
                                    // IEnumerable<XmlNode> subInnerItem = sItem.SelectNodes("//si:ImageItem/si:ImageFormat[@DimensionCategory='E']", xmlnsManager).Cast<XmlNode>().OrderByDescending(r => Convert.ToDecimal(r.Attributes["LastModifyDateTime"].Value));
                                    if (subInnerItem != null)
                                    {
                                        foreach (XmlNode sItem1 in subInnerItem)
                                        {
                                            var subUrlItem = sItem1.SelectNodes("//si:ImageItem/si:ImageFormat[@DimensionCategory='E']", xmlnsManager);
                                            if (subUrlItem != null)
                                            {
                                                PictureCount = subInnerItem.Count();
                                                foreach (XmlNode UItem in subUrlItem)
                                                {
                                                    var UrlItem = UItem.ChildNodes[0].InnerText;  //url

                                                    bool bImageExists = true;
                                                    if (!string.IsNullOrEmpty(UrlItem))
                                                    {
                                                        bImageExists = APIUtility.DoesImageExistRemotely(UrlItem);
                                                    }

                                                    if (bImageExists)
                                                    {
                                                        CLayer.PropertyFiles picture = new CLayer.PropertyFiles();
                                                        picture.FileName   = UrlItem;// itemimg.ImageFormat.Where(x => x.DimensionCategory == "E").ToList()[0].URL;
                                                        picture.PropertyId = id;
                                                        picture.IsValid    = true;
                                                        picturelist.Add(picture);
                                                        BLayer.Property.GDSSaveImageurl(id, picture.FileName);
                                                    }
                                                    nodes++;
                                                    if (nodes == PictureCount)
                                                    {
                                                        break;
                                                    }
                                                }
                                            }
                                            if (nodes == PictureCount)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    if (nodes == PictureCount)
                                    {
                                        break;
                                    }
                                }
                            }
                            if (nodes == PictureCount)
                            {
                                break;
                            }
                        }
                    }
                }
                #endregion


                #region GUESTROOMIMAGES
                if (nodeguestImages != null)
                {
                    XmlNodeList listGuestRoomImages = nodeguestImages.SelectNodes("//si:MultimediaDescriptions/si:MultimediaDescription", xmlnsManager);
                    if (listGuestRoomImages != null)
                    {
                        int PictureCount = 0;
                        int nodes        = 0;
                        foreach (XmlNode item in listGuestRoomImages)
                        {
                            var subItem = item.SelectNodes("//si:ImageItems", xmlnsManager);
                            if (subItem != null)
                            {
                                foreach (XmlNode sItem in subItem)
                                {
                                    IEnumerable <XmlNode> subInnerItem = sItem.SelectNodes("//si:ImageItem", xmlnsManager).Cast <XmlNode>().OrderByDescending(r => Convert.ToDateTime(r.Attributes["LastModifyDateTime"].Value));
                                    // IEnumerable<XmlNode> subInnerItem = sItem.SelectNodes("//si:ImageItem/si:ImageFormat[@DimensionCategory='E']", xmlnsManager).Cast<XmlNode>().OrderByDescending(r => Convert.ToDecimal(r.Attributes["LastModifyDateTime"].Value));
                                    if (subInnerItem != null)
                                    {
                                        foreach (XmlNode sItem1 in subInnerItem)
                                        {
                                            var subUrlItem = sItem1.SelectNodes("//si:ImageItem/si:ImageFormat[@DimensionCategory='E']", xmlnsManager);
                                            if (subUrlItem != null)
                                            {
                                                PictureCount = subInnerItem.Count();
                                                foreach (XmlNode UItem in subUrlItem)
                                                {
                                                    var  UrlItem      = UItem.ChildNodes[0].InnerText; //url
                                                    bool bImageExists = true;
                                                    if (!string.IsNullOrEmpty(UrlItem))
                                                    {
                                                        bImageExists = APIUtility.DoesImageExistRemotely(UrlItem);
                                                    }

                                                    if (bImageExists)
                                                    {
                                                        CLayer.PropertyFiles picture = new CLayer.PropertyFiles();
                                                        picture.FileName   = UrlItem;// itemimg.ImageFormat.Where(x => x.DimensionCategory == "E").ToList()[0].URL;
                                                        picture.PropertyId = id;
                                                        picturelist.Add(picture);
                                                        BLayer.Property.GDSSaveImageurl(id, picture.FileName);
                                                    }
                                                    nodes++;
                                                    if (nodes == PictureCount)
                                                    {
                                                        break;
                                                    }
                                                }
                                            }
                                            if (nodes == PictureCount)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    if (nodes == PictureCount)
                                    {
                                        break;
                                    }
                                }
                            }
                            if (nodes == PictureCount)
                            {
                                break;
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                LogHandler.AddLog(ex.Message);
            }
            return(picturelist);
        }
Ejemplo n.º 5
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);
        }