public static async Task<decimal> FetchPriceAsync(int typeId, int region = -1, int system = -1, PriceType type = PriceType.sell, PriceMeasure measure = PriceMeasure.min)
		{
			try
			{
				var webClient = new WebClient();
				var uri = GetUriForRequest(typeId, region, system);
				var xml = await webClient.DownloadStringTaskAsync(uri);
				var xdoc = XDocument.Parse(xml);
				return Decimal.Parse(xdoc.Descendants(type.ToString()).Single().Descendants(measure.ToString()).Single().Value);
			}
			catch (Exception e)
			{
				Console.Error.WriteLine(e);
				return -1;
			}
		}
Esempio n. 2
0
        /// <summary>
        /// Blocks on FetchPriceAsync. For testing purposes only
        /// </summary>
        public static decimal FetchPrice(int typeId, int region = -1, int system = -1, PriceType type = PriceType.sell, PriceMeasure measure = PriceMeasure.min)
        {
            var fetchPriceAsync = FetchPriceAsync(typeId, region, system, type, measure);

            return(fetchPriceAsync.Result);
        }
Esempio n. 3
0
        public static async Task <decimal> FetchPriceAsync(int typeId, int region = -1, int system = -1, PriceType type = PriceType.sell, PriceMeasure measure = PriceMeasure.min)
        {
            try
            {
                var webClient = new WebClient();
                var uri       = GetUriForRequest(typeId, region, system);
                var xml       = await webClient.DownloadStringTaskAsync(uri);

                var xdoc = XDocument.Parse(xml);
                return(Decimal.Parse(xdoc.Descendants(type.ToString()).Single().Descendants(measure.ToString()).Single().Value));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
                return(-1);
            }
        }
		/// <summary>
		/// Blocks on FetchPriceAsync. For testing purposes only
		/// </summary>
		public static decimal FetchPrice(int typeId, int region = -1, int system = -1, PriceType type = PriceType.sell, PriceMeasure measure = PriceMeasure.min)
		{
			var fetchPriceAsync = FetchPriceAsync(typeId, region, system, type, measure);
			return fetchPriceAsync.Result;
		}
Esempio n. 5
0
 public EveCentralCell(TypeID typeId, int region = -1, int system = 30000142, PriceType type = PriceType.sell, PriceMeasure measure = PriceMeasure.min)
 {
     var uri = FetchEveCentralPrice.GetUriForRequest(typeId.ToInt(), region, system);
     var xpath = "/evec_api/marketstat/type/"+type.ToString()+"/"+measure.ToString();
     text = "=ImportXML(\"" + uri + "&clock=\"&GoogleClock(), \"" + xpath + "\")";
 }