private static IEnumerable <GetPvPowerForecastsResponse> PowerForecasts(IEnumerable <Location> locations) { using (var client = new SolcastClient()) { return(locations.Select(location => client.GetPvPowerForecasts(location)).ToList()); } }
private static async Task <GetPvPowerForecastsResponse> PowerForecastAsync(Location location) { using (var client = new SolcastClient()) { return(await client.GetPvPowerForecastsAsync(location)); } }
private static GetPvPowerForecastsResponse PowerForecast(Location location) { using (var client = new SolcastClient()) { client.RateLimitExceededFn = message => { // Custom Action code to place if RateLimit has been exceeded }; return(client.GetPvPowerForecasts(location)); } }
public void TestPowerLatestEstimatedActuals() { var location = Places.Sydney(); Debug.WriteLine(location.Dump()); using (var client = new SolcastClient()) { var results = client.GetLatestPvPowerEstimatedActuals(location); Assert.NotNull(results); Assert.NotNull(results.EstimatedActuals); } }
private static IEnumerable <GetPvPowerForecastsResponse> BatchedPowerForecasts(IEnumerable <Location> locations) { var results = new List <GetPvPowerForecastsResponse>(); using (var client = new SolcastClient()) { Parallel.ForEach(locations, location => { results.Add(client.GetPvPowerForecasts(location)); }); } return(results); }
public void TestPowerForecast() { var location = Places.Sydney(); Debug.WriteLine(location.Dump()); using (var client = new SolcastClient()) { var results = client.GetPvPowerForecasts(location); Assert.NotNull(results); Assert.NotNull(results.Forecasts); Assert.True(results.Forecasts.Count == ForecastDefault.Count); } }
public void TestRadiationLatestEstimatedActuals() { var location = Places.Sydney(); Debug.WriteLine(location.Dump()); Task.Run(async() => { using (var client = new SolcastClient()) { var results = await client.GetLatestRadiationEstimatedActualsAsync(location); Assert.NotNull(results); Assert.NotNull(results.EstimatedActuals); } }).Wait(); }
private static GetPvPowerForecastsResponse WaitRetryPowerForecast(Location location) { // Set a policy on WebServiceExceptions with StatusCode of 429 to wait and retry the request again in 5 seconds var policy = Policy .Handle <WebServiceException>(z => z.StatusCode == 429) .WaitAndRetry(new[] { TimeSpan.FromSeconds(5) }); return(policy.Execute(() => { using (var client = new SolcastClient()) { return client.GetPvPowerForecasts(location); } })); }
public void TestRadiationForecast() { var location = Places.Sydney(); Debug.WriteLine(location.Dump()); Task.Run(async() => { using (var client = new SolcastClient()) { var results = await client.GetRadiationForecastsAsync(location); Assert.NotNull(results); Assert.NotNull(results.Forecasts); Assert.True(results.Forecasts.Count == ForecastDefault.Count); } }).Wait(); }