protected virtual IList<Tour> GetToursFromHtml(IPttRequest request, IOperator op, HtmlDocument html, out TourFactoryStatus status) { status = new TourFactoryStatus { Success = true, MoveToNextHotel = false }; if (html.DocumentNode.SelectNodes(op.TourInfo.XPath) == null) { if (op.ExtensiveLoggingNeeded) { Logger.LogProcess("TourFactory.GetToursFromHtml xpath node selection returns no nodes"); } status.MoveToNextHotel = true; return null; } if (_beforeIteratingWhileGettingTours != null) { var ret = _beforeIteratingWhileGettingTours(request, html); if (op.ExtensiveLoggingNeeded) { Logger.LogProcess("TourFactory.GetToursFromHtml _beforeIteratingWhileGettingTours flags:"+ret.ToString()); } status.MoveToNextHotel = status.MoveToNextHotel || ret.HasFlag(TourFactoryControlFlags.MoveToNextHotel); if (ret.HasFlag(TourFactoryControlFlags.Return)) { return null; } } var list = new List<Tour>(); foreach (HtmlNode node in html.DocumentNode.SelectNodes(op.TourInfo.XPath)) { if (_iteratingWhileGettingToursBeforeTourItemSet != null) { var ret = _iteratingWhileGettingToursBeforeTourItemSet(request, node); if (op.ExtensiveLoggingNeeded) { Logger.LogProcess("TourFactory.GetToursFromHtml _iteratingWhileGettingToursBeforeTourItemSet flags:" + ret.ToString()); } status.MoveToNextHotel = status.MoveToNextHotel || ret.HasFlag(TourFactoryControlFlags.MoveToNextHotel); if (ret.HasFlag(TourFactoryControlFlags.Continue)) { continue; } if (ret.HasFlag(TourFactoryControlFlags.Break)) { break; } if (ret.HasFlag(TourFactoryControlFlags.Return)) { return null; } } var tourItem = new Tour(); tourItem.City = Dictionnaries.Regions[op.QueryObject.OriginId]; tourItem.TO = op.Name.Replace("_", "");//anex_ gibiler icin tourItem.IssueDate = DateTime.Now; tourItem.Date = op.TourInfo.GetFieldValue<DateTime>(node, "Date"); tourItem.Night = op.TourInfo.GetFieldValue<string>(node, "Night"); tourItem.Hotel = op.TourInfo.GetFieldValue<string>(node, "Hotel"); tourItem.RoomType = op.TourInfo.GetFieldValue<string>(node, "RoomType"); tourItem.ACC = op.TourInfo.GetFieldValue<string>(node, "Accomodation"); tourItem.Price = op.TourInfo.GetFieldValue<Double>(node, "Price"); var meal = op.TourInfo.GetFieldValue<string>(node, "Meal"); var mealTypeIndex = 7; var innerMealIndex = 0; foreach (var mealtypeAlternative in op.MealTypes) { if (mealtypeAlternative.Contains(meal)) { mealTypeIndex = innerMealIndex; break; } innerMealIndex++; } tourItem.Meal = Dictionnaries.MealTypes[mealTypeIndex]; tourItem.SPONo = op.TourInfo.GetFieldValue<string>(node, "SPONo"); if (_iteratingWhileGettingToursAfterTourItemSet != null) { var ret = _iteratingWhileGettingToursAfterTourItemSet(request, tourItem); if (op.ExtensiveLoggingNeeded) { Logger.LogProcess("TourFactory.GetToursFromHtml _iteratingWhileGettingToursAfterTourItemSet flags:" + ret.ToString()); } status.MoveToNextHotel = status.MoveToNextHotel || ret.HasFlag(TourFactoryControlFlags.MoveToNextHotel); if (ret.HasFlag(TourFactoryControlFlags.Continue)) { continue; } if (ret.HasFlag(TourFactoryControlFlags.Break)) { break; } if (ret.HasFlag(TourFactoryControlFlags.Return)) { return null; } } if (op.QueryObject != null && tourItem.Price < op.QueryObject.MinPrice) { if (op.ExtensiveLoggingNeeded) { Logger.LogProcess("TourFactory.GetToursFromHtml tour info found but less than minprice:" + tourItem.Price); } continue; } if (op.QueryObject != null && (op.QueryObject.MealType == mealTypeIndex || op.QueryObject.MealType == 0)) { if (op.ExtensiveLoggingNeeded) { Logger.LogProcess("TourFactory.GetToursFromHtml tour info added:" + tourItem.ToString()); } list.Add(tourItem); } else { if (op.ExtensiveLoggingNeeded) { Logger.LogProcess("TourFactory.GetToursFromHtml tour info found but excluded bcz of meal type:" + mealTypeIndex); } } } return list; }