static void Main(string[] args) { IDictionary <string, string> CheckExists = new Dictionary <string, string>(); OTAHotelServiceLogic hotelServiceLogic = new OTAHotelServiceLogic(); IList <HotelRateRlanCacheDTO> changeItems = hotelServiceLogic.GetHotelRatePlanCacheChange("2"); changeItems = changeItems.OrderBy(a => a.HotelCode).ToList(); foreach (var item in changeItems) { string hotelId = string.Empty; if (CheckExists.ContainsKey(item.HotelCode)) { hotelId = CheckExists[item.HotelCode]; } else { DB_HotelInitilizeLogic logic = new DB_HotelInitilizeLogic(); hotelId = logic.GetHotelIdByCode(Convert.ToInt32(item.HotelCode)); CheckExists.Add(item.HotelCode, hotelId); } if (!string.IsNullOrEmpty(hotelId)) { DB_PriceInitilizeLogic priceLogic = new DB_PriceInitilizeLogic(); // string responseXml = hotelServiceLogic.GetHotelRatePlan(item.HotelCode, item.RatePlanCode); priceLogic.Process(hotelId, item.HotelCode, item.RatePlanCode, item.Start, item.End, false); Console.WriteLine(item.HotelCode + "," + item.RatePlanCode); } } Console.Read(); }
static void Main(string[] args) { logger.Info("Program Started"); IList <string> hotelCodeList = new List <string>(); OTAHotelServiceLogic hotelService = new OTAHotelServiceLogic(); string hotelXml = hotelService.GetHotelByAreaId(1); XmlDocument doc = new XmlDocument(); doc.LoadXml(hotelXml); XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("c", "http://www.opentravel.org/OTA/2003/05"); var nodes = doc.SelectNodes("c:Property", nsmgr); var rsNode = doc.SelectSingleNode("Response/HotelResponse/c:OTA_HotelSearchRS/c:Properties", nsmgr); foreach (XmlNode item in rsNode.ChildNodes) { hotelCodeList.Add(item.Attributes["HotelCode"].Value); } doc = null; Parallel.ForEach(hotelCodeList, obj => { Rego: try { DB_HotelInitilizeLogic hotelLogic = new DB_HotelInitilizeLogic(); hotelLogic.ProcessHotel(obj); } catch (Exception e) { logger.Fatal(e.ToString()); if (e.Message.ToLower().Contains("timeout")) { goto Rego; } } }); //for (int i = 0; i < hotelCodeList.Count; i++) //{ // DB_HotelInitilizeLogic hotelLogic = new DB_HotelInitilizeLogic(); // hotelLogic.ProcessHotel(hotelCodeList[i]); //} }