示例#1
0
    private MVHotel GetBeingChangedHotel(HotelMerchandise m_SaleMerchandise, string hotelid, string hotelName, string strCheckin)
    {
        MVHotel currentHotel = null;

        //���ҵ�ǰ�޸ĵ�Hotel
        for (int i = 0; i < m_SaleMerchandise.Items.Count; i++)
        {
            MVHotel hotel = (MVHotel)m_SaleMerchandise.Items[i];

            if (!string.IsNullOrEmpty(hotelid)) //����HotelID���ҵ�ǰ�޸ĵ�Hotel
            {
                if (hotel.HotelInformation.HotelCode.ToString().Trim() == hotelid.Trim())
                {
                    currentHotel = hotel;
                    break;
                }
            }
            else if (!string.IsNullOrEmpty(hotelName) && !string.IsNullOrEmpty(strCheckin)) //����HotelName��CheckIn���ҵ�ǰ�޸ĵ�Hotel
            {
                if ((hotel.HotelInformation.Name.Trim() == hotelName.Trim()) &&
                    (hotel.Profile.CheckInDate == Convert.ToDateTime(strCheckin)))
                {
                    currentHotel = hotel;
                    break;
                }
            }
        }
        return currentHotel;
    }
    private HotelMerchandise ConvertHotelToMVHotel(Terms.Sales.Business.HotelSearchCondition searchCondition, HotelMerchandise hotelMerchandise)
    {
        if (hotelMerchandise.Items == null) return null;
        if (hotelMerchandise.Items.Count == 0) return null;

        //��Hotel Merchandise�Ľṹ���ɣ�HotelMerchandise -> MVHotel -> MVRoom -> HotelMaterial
        for (int i = hotelMerchandise.Items.Count - 1; i >= 0; i--)
        {
            TERMS.Business.Centers.SalesCenter.Hotel hotel = ConvertRooms(hotelMerchandise.Items[i], searchCondition);

            if (hotel == null)
                hotelMerchandise.Items.RemoveAt(i);
            else
            {
                hotelMerchandise.Items[i] = new MVHotel(hotelMerchandise.Items[i]);

                hotelMerchandise.Items[i].Profile.CheckInDate = hotelMerchandise.Profile.CheckInDate;
                hotelMerchandise.Items[i].Profile.CheckOutDate = hotelMerchandise.Profile.CheckOutDate;

                if (((MVHotel)hotelMerchandise.Items[i]).Items != null)
                {
                    foreach (MVRoom room in ((MVHotel)hotelMerchandise.Items[i]).Items)
                    {
                        room.Profile.CheckInDate = hotelMerchandise.Profile.CheckInDate;
                        room.Profile.CheckOutDate = hotelMerchandise.Profile.CheckOutDate;
                    }
                }

                try
                {
                    decimal dec = hotelMerchandise.Items[i].RoomPrice;
                }
                catch
                {
                    hotelMerchandise.Items.RemoveAt(i);
                    continue;
                }

                //��Map�ĵ�ַ��ֵ
                if (hotelMerchandise.Items[i].HotelInformation.Images.Count > 0)
                {
                    if (hotelMerchandise.Items[i].Source == "GTA")
                    {
                        for (int index = 0; index < hotelMerchandise.Items[i].HotelInformation.Images.Count; index++)
                        {
                            if (string.IsNullOrEmpty(hotelMerchandise.Items[i].HotelInformation.Images[index].Name))
                            {
                                hotelMerchandise.Items[i].HotelInformation.MapUrl = hotelMerchandise.Items[i].HotelInformation.Images[index].Filename;

                                hotelMerchandise.Items[i].HotelInformation.Images.RemoveAt(index);

                                continue;
                            }
                        }
                    }
                    if (hotelMerchandise.Items[i].Source == "TRAVCO")
                    {
                        for (int index = 0; index < hotelMerchandise.Items[i].HotelInformation.Images.Count; index++)
                        {
                            if (hotelMerchandise.Items[i].HotelInformation.Images[index].Name.Trim().ToUpper() == "MAP".Trim().ToUpper())
                            {
                                hotelMerchandise.Items[i].HotelInformation.MapUrl = hotelMerchandise.Items[i].HotelInformation.Images[index].Filename;

                                hotelMerchandise.Items[i].HotelInformation.Images.RemoveAt(index);

                                continue;
                            }
                        }
                    }

                    //add zyl 2009-8-19 ��hotel�� localʱ �� webconfig�е����õ�·���滻ͼƬ·���е� "~/" ��ΪͼƬ�ϴ�ʱ���ϴ���TERMS��
                    if (hotelMerchandise.Items[i].Source == "LOCAL")
                    {
                        string imgHand = string.Empty;

                        if (System.Configuration.ConfigurationManager.AppSettings["URL.Head"] != null)
                            imgHand = System.Configuration.ConfigurationManager.AppSettings["URL.Head"];

                        for (int index = 0; index < hotelMerchandise.Items[i].HotelInformation.Images.Count; index++)
                        {
                            if (!string.IsNullOrEmpty(imgHand))
                            {
                                hotelMerchandise.Items[i].HotelInformation.Images[index].Filename =
                                    hotelMerchandise.Items[i].HotelInformation.Images[index].Filename.Trim().Replace("~/", imgHand);
                            }
                        }
                    }
                }
                else
                {
                    //add zyl 2009-9-2 ��hotel�� localʱ ���û��ͼƬ��Ϣ�Ͳ�Ҫ��ʾ��ǰ̨
                    if (hotelMerchandise.Items[i].Source == "LOCAL")
                    {
                        hotelMerchandise.Items.RemoveAt(i);
                        continue;
                    }
                }
            }
        }

        return hotelMerchandise;
    }
    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;
    }