日期:2014-05-17 浏览次数:20550 次
/// <summary> /// 根据酒店ID查询酒店价格 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void getHotelPriceByHotelID(object rtBox) { RichTextBox rtb = rtBox as RichTextBox; string[] serverlist = { ConfigurationManager.AppSettings["serverlist"].ToString() }; //初始化池 SockIOPool pool = SockIOPool.GetInstance(); pool.SetServers(serverlist); pool.InitConnections = 3; pool.MinConnections = 3; pool.MaxConnections = 30; pool.SocketConnectTimeout = 1000; pool.SocketTimeout = 3000; pool.MaintenanceSleep = 30; pool.Failover = true; pool.Nagle = false; pool.Initialize(); log.Info("根据酒店ID查询酒店价格,初始化池成功!"); Stopwatch sp = new Stopwatch(); sp.Start(); List<Manager.hotel_HotelLinkRelation> relList; using (HotelDataContext hotelData = new HotelDataContext()) { relList = Manager.HotelManager.GetHotelLinkRelation(); } log.Info("根据酒店ID查询酒店价格,酒店信息读取成功!"); string strTaken = GDSDataAccess.GDSDataAccessElong.GetTaken(); //实例化memcached客户端 MemcachedClient mc = new MemcachedClient(); mc.EnableCompression = true; for (int i = 0; i < relList.Count; i++) { ReturnClass rc = new ReturnClass(); try { GetHotelListResponse HotelList = GDSDataAccess.GDSDataAccessElong.GetHotelList(strTaken, relList[i].ExHotelCode); rc = Manager.ELongManager.ELongDataDeal(HotelList); } catch { rc.Code = -1; } if (rc.Code != 0) { rtb.Text += relList[i].ExHotelCode; } } log.Info("根据酒店ID查询酒店价格,更新成功!"); sp.Stop(); Console.WriteLine(sp.ElapsedMilliseconds); SockIOPool.GetInstance().Shutdown(); //关闭池, 关闭sockets log.Info("根据酒店ID查询酒店价格,关闭池, 关闭sockets成功!"); }