Ejemplo n.º 1
0
        /// <summary>
        /// 酒店数据缓存查询指令
        /// </summary>
        /// <param name="hotelCode"></param>
        static void CreateHotelAvailabilityCacheRQRequest(string hotelCode)
        {
            System.Diagnostics.Stopwatch stop = new System.Diagnostics.Stopwatch();
            stop.Reset();
            stop.Start();

            EyouSoft.HotelBI.AvailCache.MHotelAvailabilityCacheRQInfo info = new EyouSoft.HotelBI.AvailCache.MHotelAvailabilityCacheRQInfo();
            info.HotelCode = hotelCode;
            Console.WriteLine(info.RequestXML);
            string s = EyouSoft.HotelBI.Utils.CreateRequest(info.RequestXML, true);

            Console.WriteLine(s);
            CreateFile(hotelCode + "RQ.xml", info.RequestXML);
            CreateFile(hotelCode + "RS.xml", s);

            stop.Stop();
            Console.WriteLine("执行时间:" + stop.ElapsedMilliseconds);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 载入酒店价格信息
        /// </summary>
        /// <param name="hotelId">酒店编号</param>
        /// <param name="hotelCode">酒店代码</param>
        private void LoadHotelRate(string hotelId, string hotelCode)
        {
            Console.WriteLine("正在载入酒店" + hotelCode + "价格信息");
            EyouSoft.HotelBI.AvailCache.MHotelAvailabilityCacheRQInfo info = new EyouSoft.HotelBI.AvailCache.MHotelAvailabilityCacheRQInfo();
            info.HotelCode = hotelCode;

            string xml = string.Empty;

            try
            {
                xml = EyouSoft.HotelBI.Utils.CreateRequest(info.RequestXML, true);
            }
            catch (Exception e)
            {
                CreateFile("HttpRequestRateError.txt", e.Message + e.StackTrace + "\n" + info.RequestXML + "\n", true);
                return;
            }

            if (string.IsNullOrEmpty(xml))
            {
                Console.WriteLine("酒店" + hotelCode + "价格信息请求返回的XML数据为空");
                CreateFile("HttpRequestRateError.txt", "价格信息请求返回的XML数据为空" + info.RequestXML + "\n", true);
                return;
            }

            SqlParameter parm = new SqlParameter("@HotelId", SqlDbType.Char);

            parm.Value = hotelId;

            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, SQL_DELETE_HotelRate, parm);

            try
            {
                XElement xResponse = XElement.Parse(xml);
                XElement xHotelAvailabilityCacheRS = Utils.GetXElement(xResponse, "HotelAvailabilityCacheRS");
                XElement xHotelRoomTypesRoot       = Utils.GetXElement(xHotelAvailabilityCacheRS, "HotelRoomTypes");
                var      xHotelRoomTypes           = Utils.GetXElements(xHotelRoomTypesRoot, "HotelRoomType");

                SqlParameter[] parms =
                {
                    new SqlParameter("@HotelId",         SqlDbType.NVarChar),
                    new SqlParameter("@RoomTypeCode",    SqlDbType.NVarChar),
                    new SqlParameter("@VendorCode",      SqlDbType.NVarChar),
                    new SqlParameter("@RatePlanCode",    SqlDbType.NVarChar),
                    new SqlParameter("@Payment",         SqlDbType.NVarChar),
                    new SqlParameter("@AmountPrice",     SqlDbType.Money),
                    new SqlParameter("@AmountBeforeTax", SqlDbType.Money),
                    new SqlParameter("@DisplayPrice",    SqlDbType.Money),
                    new SqlParameter("@StartDate",       SqlDbType.DateTime),
                    new SqlParameter("@EndDate",         SqlDbType.DateTime),
                    new SqlParameter("@FreeMeal",        SqlDbType.Int),
                };

                foreach (var xHotelRoomType in xHotelRoomTypes)
                {
                    string roomTypeCode = Utils.GetXAttributeValue(xHotelRoomType, "RoomType");
                    string vendorCode   = Utils.GetXAttributeValue(xHotelRoomType, "Vendor");
                    string ratePlanCode = Utils.GetXAttributeValue(xHotelRoomType, "RatePlan");

                    XElement xRatesRoot = Utils.GetXElement(xHotelRoomType, "Rates");
                    var      xRates     = Utils.GetXElements(xRatesRoot, "Rate");

                    foreach (var xRate in xRates)
                    {
                        string   payment         = Utils.GetXAttributeValue(xRate, "Payment");
                        decimal  amountPrice     = Utils.GetDecimal(Utils.GetXElement(xRate, "AmountPrice").Value);
                        decimal  displayPrice    = Utils.GetDecimal(Utils.GetXElement(xRate, "DisplayPrice").Value);
                        decimal  amountBeforeTax = Utils.GetDecimal(Utils.GetXElement(xRate, "AmountBeforeTax").Value);
                        DateTime startDate       = Utils.GetDateTime(Utils.GetXAttributeValue(xRate, "StartDate"), DateTime.Now);
                        DateTime endDate         = Utils.GetDateTime(Utils.GetXAttributeValue(xRate, "EndDate"), DateTime.Now);
                        int      freeMeal        = (int)Utils.GetDecimal(Utils.GetXElement(xRate, "FreeMeal").Value, 0);

                        parms[0].Value  = hotelId;
                        parms[1].Value  = roomTypeCode;
                        parms[2].Value  = vendorCode;
                        parms[3].Value  = ratePlanCode;
                        parms[4].Value  = payment;
                        parms[5].Value  = amountPrice;
                        parms[6].Value  = amountBeforeTax;
                        parms[7].Value  = displayPrice;
                        parms[8].Value  = startDate;
                        parms[9].Value  = endDate;
                        parms[10].Value = freeMeal;

                        Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, SQL_INSERT_HotelRate, parms);
                    }
                }
            }
            catch (Exception e)
            {
                CreateFile("ParseRateXMLError.txt", e.Message + e.StackTrace + "\n" + xml + "\n", true);
                return;
            }
        }