示例#1
0
        private void getHotelsCompleted(IAsyncResult result)
        {
            var request  = (HttpWebRequest)result.AsyncState;
            var response = (HttpWebResponse)request.EndGetResponse(result);

            using (var stream = response.GetResponseStream())
            {
                var r    = new StreamReader(stream);
                var resp = r.ReadToEnd();

                JToken values = JsonConvert.DeserializeObject <JToken>(resp);

                var obj = JObject.Parse(values.ToString());

                var dict = obj["HotelListResponse"].ToObject <Dictionary <string, object> >();
                this.hotels       = Hotel.BestHotel(dict, this.remainMoney);
                this.remainMoney -= this.hotels.First().Price;
            }


            var      randomiser    = new DataToAttract();
            DateTime startDateTime = Convert.ToDateTime(this.trip.outBound.Last().ArrivingTime);
            DateTime endDateTime   = Convert.ToDateTime(this.trip.inBound.Last().DepartTime);

            this.randomisedAttractions = randomiser.schedule(startDateTime, endDateTime, this.attractions);



            this.finished = true;

            #endregion// hotels
        }
示例#2
0
        private void getHotelsCompleted(IAsyncResult result)
        {

            var request = (HttpWebRequest)result.AsyncState;
            var response = (HttpWebResponse)request.EndGetResponse(result);
            using (var stream = response.GetResponseStream())
            {
                var r = new StreamReader(stream);
                var resp = r.ReadToEnd();

                JToken values = JsonConvert.DeserializeObject<JToken>(resp);

                var obj = JObject.Parse(values.ToString());

                var dict = obj["HotelListResponse"].ToObject<Dictionary<string, object>>();
                this.hotels = Hotel.BestHotel(dict,this.remainMoney);
                this.remainMoney -= this.hotels.First().Price;
            }

            
            var randomiser = new DataToAttract();
            DateTime startDateTime = Convert.ToDateTime(this.trip.outBound.Last().ArrivingTime);
            DateTime endDateTime = Convert.ToDateTime(this.trip.inBound.Last().DepartTime);
            this.randomisedAttractions = randomiser.schedule(startDateTime, endDateTime, this.attractions);

             
 
            this.finished = true;

        #endregion// hotels

        }