private HotelMerchandise SearchHotel(Terms.Sales.Business.HotelSearchCondition searchCondition) { hotelSearchHotelByZyl.Debug("Hotel UserInfo Start :" + DateTime.Now.ToLongTimeString()); searchCondition.UserInfo = UserInfo; hotelSearchHotelByZyl.Debug("Hotel UserInfo End :" + DateTime.Now.ToLongTimeString()); //��Cache�в��ҽ�� HotelMerchandise hotelMerchandise = (HotelMerchandise)MVMerchandisePool.Find(searchCondition); if (hotelMerchandise == null) { DateTime SearchingBeginningTime = DateTime.Now; //log zyl hotelSearchHotelByZyl.Debug("Search Hotel Start :" + DateTime.Now.ToLongTimeString()); TERMS.Common.Search.HotelSearchCondition termsHotelSC = ConvertHotelSearchCondition(searchCondition); DateTime dtBeginTime = new DateTime(); //log begin 20090312 Leon dtBeginTime = System.DateTime.Now; hotelLog.Info(m_LogRandomID + " >Search From Terms Product Begin Start time : " + dtBeginTime); IList<HotelProduct> products = new List<HotelProduct>(); //��ѯ�õ�Hotel Product DateTime dtNow = DateTime.Now; hotelSearchHotelByZyl.Debug("MV_B2C Hotel GetProductFrame Start :" + dtNow.ToString("HH:mm:ss") + ":" + dtNow.Millisecond); products = new TERMS.Business.Centers.ProductCenter.Search.HotelProductSearcher().Search(termsHotelSC, UserInfo.Entity); dtNow = DateTime.Now; hotelSearchHotelByZyl.Debug("MV_B2C Hotel GetProductFrame Conclusion :" + dtNow.ToString("HH:mm:ss") + ":" + dtNow.Millisecond); //log hotelLog.Info(m_LogRandomID + " >Search From Terms Product End time : " + ((TimeSpan)System.DateTime.Now.Subtract(dtBeginTime)).ToString()); dtBeginTime = System.DateTime.Now; hotelLog.Info(m_LogRandomID + " >TERMS Search hotel Begin time : " + dtBeginTime); HotelProduct hotelProduct = products[0]; dtNow = DateTime.Now; hotelSearchHotelByZyl.Debug("MV_B2C Hotel GetProductItems Start :" + dtNow.ToString("HH:mm:ss") + ":" + dtNow.Millisecond); IList<TERMS.Core.Product.Component> hotels = hotelProduct.Items; dtNow = DateTime.Now; hotelSearchHotelByZyl.Debug("MV_B2C Hotel GetProductItems Conclusion :" + dtNow.ToString("HH:mm:ss") + ":" + dtNow.Millisecond); if (hotels.Count == 0) { m_Error = "Searching is not available in Web Searching now. Please choose another travel date or destination.(h1)"; return null; } //log begin 20090312 Leon try { if (hotelProduct.ItemGetter != null && hotelProduct.ItemGetter.Log != null) hotelLog.Info(m_LogRandomID + " > " + hotelProduct.ItemGetter.Log.Text); hotelLog.Info(m_LogRandomID + " >TERMS Search hotel End time : " + ((TimeSpan)System.DateTime.Now.Subtract(dtBeginTime)).ToString()); dtBeginTime = System.DateTime.Now; hotelLog.Info(m_LogRandomID + " >Create Hotel Merchandise Begin time : " + dtBeginTime); } catch { } //����Hotel Merchandise TERMS.Business.Centers.SalesCenter.HotelProfile hotelProfile = new TERMS.Business.Centers.SalesCenter.HotelProfile("mv"); hotelProfile.CheckInDate = searchCondition.CheckIn; hotelProfile.CheckOutDate = searchCondition.CheckOut; hotelProfile.Location = searchCondition.Location; hotelMerchandise = new HotelMerchandise(hotelProfile, hotelProduct); //log hotelLog.Info(m_LogRandomID + " >Create Hotel Merchandise End time : " + ((TimeSpan)System.DateTime.Now.Subtract(dtBeginTime)).ToString()); if (hotelMerchandise == null || hotelMerchandise.Items == null || hotelMerchandise.Items.Count == 0) { m_Error = "Searching is not available in Web Searching now. Please choose another travel date or destination.(h1)"; return null; } //log dtBeginTime = System.DateTime.Now; hotelLog.Info(m_LogRandomID + " >Convert Hotel to MV Hotel Begin time : " + dtBeginTime); hotelMerchandise = ConvertHotelToMVHotel(searchCondition, hotelMerchandise); //log hotelLog.Info(m_LogRandomID + " >Convert Hotel to MV Hotel End time : " + ((TimeSpan)System.DateTime.Now.Subtract(dtBeginTime)).ToString()); if (hotelMerchandise == null || hotelMerchandise.Items == null || hotelMerchandise.Items.Count == 0) { m_Error = "Searching is not available in Web Searching now. Please choose another travel date or destination.(h1)"; return null; } hotelSearchHotelByZyl.Info("MV_B2C Hotel Count :" + hotelMerchandise.Items.Count); MVMerchandisePool.Cache(searchCondition.Clone(), hotelMerchandise); //Cache hotelSearchHotelByZyl.Debug("Search Hotel End :" + DateTime.Now.ToLongTimeString()); //��¼Searchʱ�� DateTime SearchingEndingTime = DateTime.Now; SearchingLogger searchingLogger = new SearchingLogger(); searchingLogger.Log(SearchingBeginningTime, SearchingEndingTime, searchCondition); } return hotelMerchandise; //return null; }
private PackageMerchandise SearchPackage(Terms.Sales.Business.PackageSearchCondition searchCondition) { searchCondition.UserInfo = UserInfo; searchCondition.AirSearchCondition.UserInfo = UserInfo; searchCondition.HotelSearchCondition.UserInfo = UserInfo; if (searchCondition.HotelSearchCondition2 != null) searchCondition.HotelSearchCondition2.UserInfo = UserInfo; //��Cache�в��ҽ� PackageMerchandise packageMerchandise = (PackageMerchandise)MVMerchandisePool.Find(searchCondition); if (packageMerchandise == null) { DateTime SearchingBeginningTime = DateTime.Now; Utility.Transaction.Difference.To = "OnSearch1 End"; Utility.Transaction.Difference.EndTime = DateTime.Now; Utility.Transaction.Difference.From = "Search Package By Find"; Utility.Transaction.Difference.StarTime = DateTime.Now; PackageProductSearcher searcher = new PackageProductSearcher(); TERMS.Common.Search.PackageSearchCondition pkgCondition = new TERMS.Common.Search.PackageSearchCondition(); DateTime depDate = searchCondition.AirSearchCondition.GetAddTripCondition()[0].DepartureDate; DateTime rtnDate = new DateTime(); string fromAirportCode = searchCondition.AirSearchCondition.GetAddTripCondition()[0].Departure.Code; string toAirportCode = searchCondition.AirSearchCondition.GetAddTripCondition()[0].Destination.Code; string rtnFromAirportCode = string.Empty; string rtnToAirportCode = string.Empty; int adultNumber = searchCondition.AirSearchCondition.GetPassengerNumber(TERMS.Common.PassengerType.Adult); int childNumber = searchCondition.AirSearchCondition.GetPassengerNumber(TERMS.Common.PassengerType.Child); IList<PackageProduct> pkgs = new List<PackageProduct>(); if (searchCondition.AirSearchCondition.FlightType.ToLower().Equals("oneway")) { //û�� } else if (searchCondition.AirSearchCondition.FlightType.ToLower().Equals("roundtrip")) { rtnDate = searchCondition.AirSearchCondition.GetAddTripCondition()[1].DepartureDate; pkgCondition.AirCondition = new TERMS.Common.Search.AirSearchCondition(fromAirportCode, true, toAirportCode, true, depDate, true, rtnDate, true, adultNumber, childNumber, 0); } else { rtnDate = searchCondition.AirSearchCondition.GetAddTripCondition()[1].DepartureDate; rtnFromAirportCode = searchCondition.AirSearchCondition.GetAddTripCondition()[1].Departure.Code; rtnToAirportCode = searchCondition.AirSearchCondition.GetAddTripCondition()[1].Destination.Code; pkgCondition.AirCondition = new TERMS.Common.Search.AirSearchCondition(fromAirportCode, true, toAirportCode, true, depDate, true, rtnFromAirportCode, true, rtnToAirportCode, true, rtnDate, true, adultNumber, childNumber, 0); } if (ConfigurationManager.AppSettings.Get("IsOpenCommNetFareTicket") != null) pkgCondition.AirCondition.IsAvailableOnly = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("IsOpenCommNetFareTicket").ToString()); //����Airlines if (searchCondition.AirSearchCondition.Airlines != null && searchCondition.AirSearchCondition.Airlines.Length > 0) pkgCondition.AirCondition.AddAirlines(searchCondition.AirSearchCondition.Airlines); //����Cabin for (int i = 0; i < pkgCondition.AirCondition.Trips.Count; i++) pkgCondition.AirCondition.Trips[i].Cabin = searchCondition.AirSearchCondition.AirTripCondition[i].Cabin; //ת��Hotel Search Condition pkgCondition.HotelCondition = ConvertHotelSearchCondition(searchCondition.HotelSearchCondition); pkgs = searcher.Search(pkgCondition); //Ϊ�̷߳�����Ӳ��� package PackageProduct pkg = package = pkgs[0]; Utility.Transaction.Difference.To = "Intel Search Over"; Utility.Transaction.Difference.EndTime = DateTime.Now; Utility.Transaction.Difference.From = "Return AIRItem Start"; Utility.Transaction.Difference.StarTime = DateTime.Now; //�����߳� ͬʱ��ѯ Air �� Hotel PackageThreadStar(); //IList<TERMS.Core.Product.Component> aa = pkg.AirGroup.Items; if (packageair == null || packageair.Count == 0) { m_Error = "Searching is not available in Web Searching now. Please choose another travel date or destination.(pa1)"; return null; } Utility.Transaction.Difference.To = "Return AIRItem End"; Utility.Transaction.Difference.EndTime = DateTime.Now; Utility.Transaction.Difference.From = "Return HotelItem Start"; Utility.Transaction.Difference.StarTime = DateTime.Now; //IList<TERMS.Core.Product.Component> BB = pkg.HotelGroup.Items; if (packagehotel == null || packagehotel.Count == 0) { m_Error = "Searching is not available in Web Searching now. Please choose another travel date or destination.(ph1)"; return null; } Utility.Transaction.Difference.To = "Return HotelItem End"; Utility.Transaction.Difference.EndTime = DateTime.Now; Utility.Transaction.Difference.From = "Convert Start"; Utility.Transaction.Difference.StarTime = DateTime.Now; TERMS.Business.Centers.ProductCenter.Profiles.PackageProfile packageProfile = (TERMS.Business.Centers.ProductCenter.Profiles.PackageProfile)pkg.Profile; packageProfile.SetParam("ADULT_NUMBER", adultNumber); packageProfile.SetParam("CHILD_NUMBER", childNumber); packageProfile.SetParam("CheckIn", searchCondition.HotelSearchCondition.CheckIn); packageProfile.SetParam("CheckOut", searchCondition.HotelSearchCondition.CheckOut); packageProfile.SetParam("Location", searchCondition.HotelSearchCondition.Location); try { packageMerchandise = new PackageMerchandise(packageProfile, pkg); if (packageMerchandise.Items[1] == null || ((HotelMerchandise)packageMerchandise.Items[1]).Items == null || ((HotelMerchandise)packageMerchandise.Items[1]).Items.Count == 0) { m_Error = "Searching is not available in Web Searching now. Please choose another travel date or destination."; return null; } for (int i = 1; i < packageMerchandise.Items.Count; i++) { HotelMerchandise hotelMerchandise = (HotelMerchandise)packageMerchandise.Items[i]; hotelMerchandise.Profile.CheckInDate = searchCondition.HotelSearchCondition.CheckIn; hotelMerchandise.Profile.CheckOutDate = searchCondition.HotelSearchCondition.CheckOut;// hotelMerchandise = ConvertHotelToMVHotel(searchCondition.HotelSearchCondition, hotelMerchandise); } //�ж� if (packageMerchandise.Items[1] == null || ((HotelMerchandise)packageMerchandise.Items[1]).Items == null || ((HotelMerchandise)packageMerchandise.Items[1]).Items.Count == 0) { m_Error = "Searching is not available in Web Searching now. Please choose another travel date or destination."; return null; } MVMerchandisePool.Cache(searchCondition.Clone(), packageMerchandise); //Cache if (searchCondition.OptionalHotelSearchConditions.Count > 0) { for (int j = 0; j < searchCondition.OptionalHotelSearchConditions.Count; j++) { packageMerchandise.Items.Add(SearchHotel(searchCondition.OptionalHotelSearchConditions[j])); } packageMerchandise.ReSetPMItems(); // �趨��Ĭ���������� } packageMerchandise.Reset();//��Ϊ��ʼ��packageMerchandise �е� CurrentItem } catch (Exception Ex) { throw new Exception(Ex.Message); } //��¼Searchʱ�� DateTime SearchingEndingTime = DateTime.Now; SearchingLogger searchingLogger = new SearchingLogger(); searchingLogger.Log(SearchingBeginningTime, SearchingEndingTime, searchCondition); } else { if (searchCondition.OptionalHotelSearchConditions.Count == packageMerchandise.CurrentItems.Count - 3) { packageMerchandise.Items.RemoveAt(packageMerchandise.Items.Count - 1); packageMerchandise.CurrentItems.RemoveAt(packageMerchandise.CurrentItems.Count - 1); packageMerchandise.CurrentHotelListNumber = 0; packageMerchandise.Reset(); packageMerchandise.ReSetPMItems(); } if (searchCondition.IsReset) //����packageMerchandise �е� CurrentItem { for (int i = 2; i < packageMerchandise.Items.Count; i++) { packageMerchandise.Items.Remove(packageMerchandise.Items[i]); } packageMerchandise.CurrentHotelListNumber = 0; packageMerchandise.Reset(); packageMerchandise.ReSetPMItems(); } } List<int> searchFaildHotelIndexs = new List<int>(); for (int i = 0; i < searchCondition.OptionalHotelSearchConditions.Count; i++) { HotelMerchandise hotelMerchandise = (HotelMerchandise)MVMerchandisePool.Find(searchCondition.OptionalHotelSearchConditions[i]); if (hotelMerchandise == null) { hotelMerchandise = SearchHotel(searchCondition.OptionalHotelSearchConditions[i]); if (hotelMerchandise == null) //Search Hotelʧ�� searchFaildHotelIndexs.Add(i); packageMerchandise.Items.Add(hotelMerchandise); packageMerchandise.Reset(i + 2); packageMerchandise.ReSetPMItems(); } else { if ((packageMerchandise.Items.Count - 1) >= (i + 2))//�ж��±�(i+2),��Items �����Ƿ���� packageMerchandise.Items[i + 2] = hotelMerchandise; else { packageMerchandise.Items.Add(hotelMerchandise); packageMerchandise.Reset(i + 2); packageMerchandise.ReSetPMItems(); } if (searchCondition.IsReset) //����packageMerchandise �е� CurrentItem[i+2] packageMerchandise.Reset(i + 2); } } if (searchFaildHotelIndexs.Count > 0) //Search Hotelʧ�� { for (int i = 0; i < searchFaildHotelIndexs.Count; i++) { //���Searchʧ�ܵ�Hotel Search Condition searchCondition.OptionalHotelSearchConditions.RemoveAt(searchFaildHotelIndexs[i] - i); packageMerchandise.Items.RemoveAt(searchFaildHotelIndexs[i] + 2 - i); packageMerchandise.CurrentItems.RemoveAt(searchFaildHotelIndexs[i] + 2 - i); } packageMerchandise.ReSetPMItems(); return null; } searchCondition.IsReset = false; Utility.Transaction.Difference.To = "Convert End"; Utility.Transaction.Difference.EndTime = DateTime.Now; Utility.Transaction.Difference.From = "Search End"; Utility.Transaction.Difference.StarTime = DateTime.Now; packageMerchandise.UserInfo = UserInfo.User.UserName; return packageMerchandise; }
private AirMerchandise SearchAir(Terms.Sales.Business.AirSearchCondition searchCondition) { searchCondition.UserInfo = UserInfo; //bool isOpenCommNetFareTicket = false; bool isOpenAllFareTypeAir = false; bool isOnlyShowPubFareTicket = true; bool hasMajorAirlinesForAvailable = false; bool hasMajorAirlinesForSelect = false; bool isAvailableOnly = false; if (ConfigurationManager.AppSettings.Get("IsOpenAllFareTypeAir") != null) isOpenAllFareTypeAir = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("IsOpenAllFareTypeAir").ToString()); if (ConfigurationManager.AppSettings.Get("IsOnlyShowPubFareTicket") != null) isOnlyShowPubFareTicket = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("IsOnlyShowPubFareTicket").ToString()); if (ConfigurationManager.AppSettings.Get("HasMajorAirlinesForAvailable") != null) hasMajorAirlinesForAvailable = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("HasMajorAirlinesForAvailable").ToString()); if (ConfigurationManager.AppSettings.Get("HasMajorAirlinesForSelect") != null) hasMajorAirlinesForSelect = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("HasMajorAirlinesForSelect").ToString()); if (ConfigurationManager.AppSettings.Get("IsAvailableOnly") != null) isAvailableOnly = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("IsAvailableOnly").ToString()); //by cjc, ��ʱ��ʾ���еĻ�Ʊ searchCondition.IsLogin = Utility.IsLogin; //��Cache�в��ҽ�� AirMerchandise airMerchandise = (AirMerchandise)MVMerchandisePool.Find(searchCondition); if (airMerchandise == null) { DateTime SearchingBeginningTime = DateTime.Now; AirProductSearcher searcher = new AirProductSearcher(); DateTime depDate = searchCondition.GetAddTripCondition()[0].DepartureDate; DateTime rtnDate = new DateTime(); string fromAirportCode = searchCondition.GetAddTripCondition()[0].Departure.Code; string toAirportCode = searchCondition.GetAddTripCondition()[0].Destination.Code; string rtnFromAirportCode = string.Empty; string rtnToAirportCode = string.Empty; int adultNumber = searchCondition.GetPassengerNumber(TERMS.Common.PassengerType.Adult); int childNumber = searchCondition.GetPassengerNumber(TERMS.Common.PassengerType.Child); IList<AirProduct> airs = new List<AirProduct>(); DateTime dtBeginTime = new DateTime(); //log begin 20090312 Leon try { dtBeginTime = System.DateTime.Now; log.Info(m_LogRandomID + " >Search From Terms Product Begin Start time : " + dtBeginTime); if (searchCondition.FlightType.ToLower().Equals("oneway")) log.Info(m_LogRandomID + " >===================== OneWay ====================="); else if (searchCondition.FlightType.ToLower().Equals("roundtrip")) log.Info(m_LogRandomID + " >===================== Roundtrip ====================="); else log.Info(m_LogRandomID + " >===================== OpenJW ====================="); } catch { } //ת����ѯ���� TERMS.Common.Search.AirSearchCondition termsSearchCondition; if (searchCondition.FlightType.ToLower().Equals("oneway")) { termsSearchCondition = new TERMS.Common.Search.AirSearchCondition(fromAirportCode, true, toAirportCode, true, depDate, true, adultNumber, childNumber, 0); } else if (searchCondition.FlightType.ToLower().Equals("roundtrip")) { rtnDate = searchCondition.GetAddTripCondition()[1].DepartureDate; termsSearchCondition = new TERMS.Common.Search.AirSearchCondition(fromAirportCode, true, toAirportCode, true, depDate, true, rtnDate, true, adultNumber, childNumber, 0); } else //Open Jaw { rtnDate = searchCondition.GetAddTripCondition()[1].DepartureDate; rtnFromAirportCode = searchCondition.GetAddTripCondition()[1].Departure.Code; rtnToAirportCode = searchCondition.GetAddTripCondition()[1].Destination.Code; termsSearchCondition = new TERMS.Common.Search.AirSearchCondition(fromAirportCode, true, toAirportCode, true, depDate, true, rtnFromAirportCode, true, rtnToAirportCode, true, rtnDate, true, adultNumber, childNumber, 0); } //ָ�����չ�˾ if (searchCondition.Airlines != null && searchCondition.Airlines.Length > 0) termsSearchCondition.AddAirlines(searchCondition.Airlines); //�ƶ��յ� for (int i = 0; i < termsSearchCondition.Trips.Count; i++) termsSearchCondition.Trips[i].Cabin = searchCondition.AirTripCondition[i].Cabin; //��������ָ����ѯ��ʾ���� if (!isOpenAllFareTypeAir) { //if isOpenAllFareTypeAir is false , un-login condition come into effect. if (!Utility.IsLogin) { termsSearchCondition.HasMajorAirlinesForAvailable = hasMajorAirlinesForAvailable; termsSearchCondition.HasMajorAirlinesForSelect = hasMajorAirlinesForSelect; termsSearchCondition.IsAvailableOnly = isAvailableOnly; //if un-login and only show PUB fare if (isOnlyShowPubFareTicket) { termsSearchCondition.HasMajorAirlinesForAvailable = true; termsSearchCondition.HasMajorAirlinesForSelect = true; termsSearchCondition.FareType = TERMS.Common.AirFareType.Published; termsSearchCondition.IsAvailableOnly = true; } else { termsSearchCondition.FareType = TERMS.Common.AirFareType.All; } } else { //��¼����ʾ���л�Ʊ���� termsSearchCondition.HasMajorAirlinesForAvailable = true; termsSearchCondition.HasMajorAirlinesForSelect = true; termsSearchCondition.FareType = TERMS.Common.AirFareType.All; termsSearchCondition.IsAvailableOnly = false; } } else { //��ʾ���л�Ʊ���� termsSearchCondition.HasMajorAirlinesForAvailable = true; termsSearchCondition.HasMajorAirlinesForSelect = true; termsSearchCondition.FareType = TERMS.Common.AirFareType.All; termsSearchCondition.IsAvailableOnly = false; } //ִ�в�ѯ airs = searcher.Search(termsSearchCondition, UserInfo.Entity); log.Info(m_LogRandomID + " >Search From Terms Product End time : " + ((TimeSpan)System.DateTime.Now.Subtract(dtBeginTime)).ToString()); dtBeginTime = System.DateTime.Now; if (airs.Count == 0 || airs[0].Items == null) return null; TERMS.Business.Centers.ProductCenter.Profiles.AirProfile oldProfile = (TERMS.Business.Centers.ProductCenter.Profiles.AirProfile)airs[0].Profile; oldProfile.SetParam("ADULT_NUMBER", adultNumber); oldProfile.SetParam("CHILD_NUMBER", childNumber); oldProfile.SetParam("IS_LOGIN", Utility.IsLogin); //log begin 20090312 Leon try { log.Info(m_LogRandomID + " >Become Merchandise Begin Begin Start time : " + dtBeginTime); if (airMerchandise != null && airMerchandise.Items != null) log.Info(m_LogRandomID + " > " + airs[0].ItemGetter.Log.Text); else log.Info(m_LogRandomID + " >No Result"); log.Info(m_LogRandomID + " >Become Merchandise Begin End time : " + ((TimeSpan)System.DateTime.Now.Subtract(dtBeginTime)).ToString()); } catch { } airMerchandise = new AirMerchandise(oldProfile, airs[0]); MVMerchandisePool.Cache(searchCondition.Clone(), airMerchandise); //Cache //��¼Searchʱ�� DateTime SearchingEndingTime = DateTime.Now; SearchingLogger searchingLogger = new SearchingLogger(); searchingLogger.Log(SearchingBeginningTime, SearchingEndingTime, searchCondition); } return airMerchandise; }