Esempio n. 1
0
        private static void GetBuyPlanResult(System.Net.WebClient webClient, BuyPlan buyPlan, bool aggregated)
        {
            var baseurl = "http://10.8.8.176/adapter/api/buy-plan-forecast/{0}/{1}";

            var urlPath = buyPlan.GetUrlByBuyPlanType(aggregated);
            var url = string.Format(baseurl, buyPlan.Id, urlPath);
            Console.WriteLine("URL: " + url);

            System.Diagnostics.Debug.WriteLine("URL: " + url);
            try
            {
                var result = webClient.DownloadString(url);

                System.Diagnostics.Debug.WriteLine(result);
            }
            catch(Exception error)
            {
                Console.WriteLine("Error: " + error.Message);

                System.Diagnostics.Debug.WriteLine(error.Message);
            }
        }
Esempio n. 2
0
        private static ResponseData<ChildInfo> DownloadStudents(Uri serviceUri, System.Net.WebClient client)
        {
            // invoke the REST method
            var jsonData = client.DownloadString(serviceUri);

            var responseData = JsonConvert.DeserializeObject<ResponseData<ChildInfo>>(jsonData);
            return responseData;
        }
Esempio n. 3
0
        public string ReturnCurrencyRankToAnother(System.Net.WebClient client, Options.Currency ToCurrency,
            Currencies.ExchangeType exchangeType)
        {
            try
            {
                switch (exchangeType)
                {
                    case Currencies.ExchangeType.Kraken:
                        {
                            if (ToCurrency == Options.Currency.CNY)
                                return client.DownloadString(USDtoCNY);
                            else if (ToCurrency == Options.Currency.PLN)
                                return client.DownloadString(USDtoPLN);
                            else if (ToCurrency == Options.Currency.GBP)
                                return client.DownloadString(USDtoGBP);

                            break;
                        }
                    case Currencies.ExchangeType.Btce:
                        {
                            if (ToCurrency == Options.Currency.CNY)
                                return client.DownloadString(USDtoCNY);
                            else if (ToCurrency == Options.Currency.PLN)
                                return client.DownloadString(USDtoPLN);
                            else if (ToCurrency == Options.Currency.GBP)
                                return client.DownloadString(USDtoGBP);

                            break;
                        }

                    case Currencies.ExchangeType.Bitstamp:
                        {
                            if (ToCurrency == Options.Currency.CNY)
                                return client.DownloadString(USDtoCNY);
                            else if (ToCurrency == Options.Currency.EUR)
                                return client.DownloadString(USDtoEUR);
                            else if (ToCurrency == Options.Currency.PLN)
                                return client.DownloadString(USDtoPLN);
                            else if (ToCurrency == Options.Currency.GBP)
                                return client.DownloadString(USDtoGBP);
                            break;
                        }
                    case Currencies.ExchangeType.Bitcurex:
                        {
                            if (ToCurrency == Options.Currency.USD)
                                return client.DownloadString(EURtoUSD);
                            else if (ToCurrency == Options.Currency.CNY)
                                return client.DownloadString(EURtoCNY);
                            else if (ToCurrency == Options.Currency.GBP)
                                return client.DownloadString(EURtoGBP);
                            break;
                        }
                    case Currencies.ExchangeType.BtcChina:
                        {
                            if (ToCurrency == Options.Currency.USD)
                                return client.DownloadString(CNYtoUSD);
                            else if(ToCurrency== Options.Currency.EUR)
                                return client.DownloadString(CNYtoEUR);
                            else if(ToCurrency== Options.Currency.GBP)
                                return client.DownloadString(CNYtoGBP);
                            else if (ToCurrency == Options.Currency.PLN)
                                return client.DownloadString(CNYtoPLN);
                            break;

                        }
                    default:
                        break;
                }
            }
            catch (Exception e)
            {
                try
                {
                    //alternative to realtime values
                    return GetValueFromEuropeanCentralBank(ToCurrency, exchangeType);
                }
                catch (Exception error)
                {
                    Log.Error(error);
                }
                Log.Error(e);
            }
            return null;
        }
Esempio n. 4
0
 private static string DownloadPage(System.Net.WebClient client, string uri)
 {
     try
     {
         string pageContent = client.DownloadString(uri);
         return pageContent;
     }
     catch
     {
         return DownloadPage(client, uri);
     }
 }
Esempio n. 5
0
        public string GetResponseInSpecificCurrency(System.Net.WebClient client, Options.Currency currency,
    Currencies.ExchangeType exchangeType, Currencies.CoinType coinType)
        {
            try
            {
                if (coinType == Currencies.CoinType.Bitcoin)
                {
                    switch (exchangeType)
                    {
                        case Currencies.ExchangeType.LilionTransfer:
                            {
                                switch (currency)
                                {
                                    case Options.Currency.CNY:
                                        return client.DownloadString(lilionTransferUSD); // needs recalculation
                                    case Options.Currency.GBP:
                                        return client.DownloadString(lilionTransferGBP);
                                    case Options.Currency.PLN:
                                        return client.DownloadString(lilionTransferPLN);
                                    case Options.Currency.USD:
                                        return client.DownloadString(lilionTransferUSD);
                                    case Options.Currency.EUR:
                                        return client.DownloadString(lilionTransferEUR);
                                }
                                break;
                            }

                        case Currencies.ExchangeType.MTGOX:
                            {
                                switch (currency)
                                {
                                    case Options.Currency.CNY:
                                        return client.DownloadString(mtgoxBTCCNY);
                                    case Options.Currency.GBP:
                                        return client.DownloadString(mtgoxBTCGBP);
                                    case Options.Currency.PLN:
                                        return client.DownloadString(mtgoxBTCPLN);
                                    case Options.Currency.USD:
                                        return client.DownloadString(mtgoxBTCUSD);
                                    case Options.Currency.EUR:
                                        return client.DownloadString(mtgoxBTCEUR);

                                }
                                break;
                            }

                        case Currencies.ExchangeType.Bitcurex:
                            {
                                switch (currency)
                                {
                                    case Options.Currency.PLN:
                                        return client.DownloadString(bitcurexPLN);
                                    case Options.Currency.EUR:
                                        return client.DownloadString(bitcurexEUR);
                                    default:
                                        return client.DownloadString(bitcurexEUR);
                                }
                            }
                        case Currencies.ExchangeType.Kraken:
                            {
                                switch (currency)
                                {
                                    case Options.Currency.EUR:
                                        return client.DownloadString(krakenBTCEUR);
                                    case Options.Currency.USD:
                                        return client.DownloadString(krakenBTCUSD);
                                    default:
                                        return client.DownloadString(krakenBTCUSD);
                                }
                            }

                        case Currencies.ExchangeType.Btce:
                            {
                                switch (currency)
                                {
                                    case Options.Currency.USD:
                                        return client.DownloadString(btceBTCUSD);
                                    case Options.Currency.EUR:
                                        return client.DownloadString(btceBTCEUR);
                                    default:
                                        return client.DownloadString(btceBTCUSD);
                                }
                            }
                        case Currencies.ExchangeType.Bitstamp:
                        default:
                            return client.DownloadString(bitstampUSD);
                    }
                }
                #region litecoin
                if (coinType == Currencies.CoinType.Litecoin)
                {
                    switch (exchangeType)
                    {
                        case Currencies.ExchangeType.Kraken:
                            {
                                switch (currency)
                                {
                                    case Options.Currency.EUR:
                                        return client.DownloadString(krakenLTCEUR);
                                    case Options.Currency.USD:
                                        return client.DownloadString(krakenLTCUSD);
                                    default:
                                        return client.DownloadString(krakenLTCUSD);
                                }
                            }
                        case Currencies.ExchangeType.Btce:
                            {
                                switch (currency)
                                {
                                    case Options.Currency.EUR:
                                        return client.DownloadString(btceLTCEUR);
                                    case Options.Currency.USD:
                                        return client.DownloadString(btceLTCUSD);
                                    default:
                                        return client.DownloadString(btceLTCUSD);
                                }
                            }
                        default:
                            break;
                    }
                }
            #endregion
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
            return null;
        }