private async Task ResumeAfterFormDialog(IDialogContext context, IAwaitable <WeatherQuery> result)
        {
            try
            {
                var searchQuery = await result;
                var weatherInfo = await weatherService.GetWeatherAsync(searchQuery);

                var message = context.MakeMessage();
                message.Text = $"{weatherInfo.Name}の天気は...";
                message.Attachments.Add(new Attachment()
                {
                    ContentUrl  = weatherService.GetWeatherIcon(weatherInfo),
                    ContentType = "image/png"
                });

                await context.PostAsync(message);

#if DEBUG
                await context.PostAsync(this.FormatWeatherInfo(weatherInfo));
#endif
            }
            catch (FormCanceledException ex)
            {
                throw ex;
            }
            finally
            {
                context.Done <object>(null);
            }
        }
示例#2
0
        public MapsModule()
        {
            InitializeComponent();

            TilesLayer.DataProvider = MapUtils.CreateBingDataProvider(BingMapKind.Area);
            mapControl1.SetMapItemFactory(new DemoWeatherItemFactory());

            this._openWeatherMapService          = new OpenWeatherMapService(LoadCapitalsFromXML());
            OpenWeatherMapService.ReadCompleted += OpenWeatherMapService_ReadCompleted;
            _openWeatherMapService.GetWeatherAsync();
        }
        static async Task <bool> GetPressure(TelemetryItem inputTable)
        {
            OpenWeatherMapService client = new OpenWeatherMapService(owmKey);
            var result = await client.GetWeatherAsync("Sydney, AU", LanguageCode.EN, Unit.Metric);

            if (result.IsSuccess)
            {
                inputTable.hPa      = result.Response.MainWeather.Pressure;
                inputTable.Humidity = result.Response.MainWeather.Humidity;

                return(true);
            }
            return(false);
        }
        public static async Task Run([TimerTrigger("0 */15 * * * *")] TimerInfo myTimer, TraceWriter log, ExecutionContext context, [Blob("cache/weatherData.json", System.IO.FileAccess.Write)] CloudBlockBlob blob)
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(context.FunctionAppDirectory)
                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables()
                         .Build();

            string apiKey = config["ApiKey"]; //Robert Schlaeger API Key for OpenWeatherMap
            OpenWeatherMapService weatherService = new OpenWeatherMapService(apiKey);

            OpenWeatherMapServiceResponse <WeatherRoot> res = await weatherService.GetWeatherAsync("München", LanguageCode.DE);

            log.Info(res.Response.CityId.ToString());

            var outputJson = JsonConvert.SerializeObject(res.Response);

            blob.Properties.ContentType = "application/json";
            await blob.UploadTextAsync(outputJson);

            //TODO: Implement Parsing
        }