Exemple #1
0
        public WeatherData GetData(string city)
        {
            using (var client = new WebClient())
            {
                var apiUrl = string.Format(Url, city, AppId, Units);

                try
                {
                    var     data        = client.DownloadString(apiUrl);
                    dynamic jsonData    = JsonConvert.DeserializeObject(data);
                    string  countryCode = jsonData.sys.country;

                    var weatherData = new WeatherData
                    {
                        City           = jsonData.name,
                        Country        = CountryCodeConverter.ConvertTwoLetterCodeToName(countryCode),
                        Temperature    = jsonData.main.temp,
                        TempratureMax  = jsonData.main.temp_max,
                        TemperatureMin = jsonData.main.temp_min,
                        Conditions     = jsonData.weather[0].description,
                        Humidity       = jsonData.main.humidity,
                        WindSpeed      = jsonData.wind.speed
                    };

                    return(weatherData);
                }
                catch
                {
                    return(new WeatherData()
                    {
                        City = "Not found",
                        Country = "Not found",
                        Temperature = "Not found",
                        TempratureMax = "Not found",
                        TemperatureMin = "Not found",
                        Conditions = "Not found",
                        Humidity = "Not found",
                        WindSpeed = "Not found"
                    });
                }
            }
        }
Exemple #2
0
        public static void DebugTest()
        {
            var inputpath  = @"E:\SaaS\Input for debug code\city of mount juliet\Check Run 5-21-19";
            var inputfile  = File.ReadAllBytes(inputpath);
            var conversion = new PaymentPsTool();
            var result     = conversion.ProcessDataFile(inputfile);

            CountryCodeConverter.ConvertToThreeLetterISORegionName("");

            File.WriteAllText(@"E:\SaaS\Input for debug code\city of mount juliet\Payment.txt", result.ToString());

            //var inputpath = @"E:\SaaS\Input for debug code\city of mount juliet\CityofMountJuliet_Vendors.xlsx";
            //var inputfile = File.ReadAllBytes(inputpath);


            //var conversion = new MasterDataPsTool();
            //Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            //var result = conversion.ProcessDataFile(inputfile);
            //File.WriteAllText(@"E:\SaaS\Input for debug code\city of mount juliet\Master.txt", result.ToString());
        }
Exemple #3
0
 public override string Format(string value)
 {
     return(CountryCodeConverter.ConvertToThreeLetterISORegionName(value));
 }