protected void btnGetWaetherForecast_Click(object sender, EventArgs e)
        {
            WeatherService.WeatherServiceClient weatherServiceClient = new WeatherService.WeatherServiceClient();
            //lblWeatherResult.Text = weatherServiceClient.GetWeatherData(txtZipCodeWeatherService.Text);
            WeatherService.WeatherObj weatherObj     = weatherServiceClient.GetWeatherData(txtZipCodeWeatherService.Text);
            TableHeaderRow            tableHeaderRow = new TableHeaderRow();
            TableHeaderCell           dateHeaderCell = new TableHeaderCell();

            dateHeaderCell.Text = "Date"; //TODO : Format date correctly
            TableHeaderCell minTempH = new TableHeaderCell();

            minTempH.Text = "Min Temp";
            TableHeaderCell maxTempH = new TableHeaderCell();

            maxTempH.Text = "Max Temp";
            tableHeaderRow.Cells.Add(dateHeaderCell);
            tableHeaderRow.Cells.Add(minTempH);
            tableHeaderRow.Cells.Add(maxTempH);
            tblWeatherForecast.Rows.Add(tableHeaderRow);
            foreach (WeatherService.WeatherObj.DailyForecastsObj dailyForecastObj in weatherObj.DailyForecasts)
            {
                TableRow  row      = new TableRow();
                TableCell dateCell = new TableCell();
                dateCell.Text = dailyForecastObj.Date; //TODO : Format date correctly
                TableCell minTemp = new TableCell();
                minTemp.Text = dailyForecastObj.Temperature.Minimum.Value + dailyForecastObj.Temperature.Minimum.Unit;
                TableCell maxTemp = new TableCell();
                maxTemp.Text = dailyForecastObj.Temperature.Maximum.Value + dailyForecastObj.Temperature.Maximum.Unit;
                row.Cells.Add(dateCell);
                row.Cells.Add(minTemp);
                row.Cells.Add(maxTemp);
                tblWeatherForecast.Rows.Add(row);
            }
        }
Example #2
0
        public static async Task Main(string[] args)
        {
            Console.WriteLine("Requesting current weather..");

            using var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var client = new WeatherService.WeatherServiceClient(channel);

            var request = new WeatherRequest
            {
                Location = BragaCode
            };

            var weatherData = await client.RequestCurrentWeatherDataAsync(request);

            Console.WriteLine(JsonConvert.SerializeObject(weatherData));

            Console.WriteLine("Requesting historic data..");

            var historicData = await client.RequestHistoricDataAsync(request);

            Console.WriteLine(JsonConvert.SerializeObject(historicData));

            Console.ReadLine();
        }
Example #3
0
        static async Task Main(string[] args)
        {
            // The port number(5001) must match the port of the gRPC server.
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var cts = new CancellationTokenSource();

            var weatherClient = new WeatherService.WeatherServiceClient(channel);
            var streamingData = weatherClient.RequestStreamData(new WeatherRequest {
                Location = "27.9506,-82.4572"
            });

            try
            {
                //Get the data as the server pushes it to us
                await foreach (var weatherData in streamingData.ResponseStream.ReadAllAsync(cancellationToken: cts.Token))
                {
                    Console.WriteLine($"{weatherData.Temperature}");
                }
            }
            catch (RpcException ex) when(ex.StatusCode == StatusCode.Cancelled)
            {
                Console.WriteLine("Stream cancelled.");
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Example #4
0
        static void Main(string[] args)
        {
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new WeatherService.WeatherServiceClient(channel);

            while (true)
            {
                //var response = client.GetWeather(new WeatherRequest()
                //{
                //  StationId = 1
                //});

                //var response = client.GetWeatherStream(new WeatherRequest()
                //{
                //  StationId = 1
                //});

                var response = client.GetWeatherReadings(new WeatherRequest()
                {
                    StationId = 1
                });

                //ProcessStream(response).Wait();
                //Console.Write($"{response}");

                foreach (var item in response.TheReadings)
                {
                    Console.WriteLine($"Colletion: {item}");
                }

                Console.ReadLine();
            }
        }
Example #5
0
 public WeatherServiceController(
     WeatherService.WeatherServiceClient weatherClient,
     ILogger <WeatherServiceController> logger
     )
 {
     _weatherClient = weatherClient;
     _logger        = logger;
 }
        protected void get_local_weather_Click(object sender, EventArgs e)
        {
            WeatherService.WeatherServiceClient weatherService = new WeatherService.WeatherServiceClient();
            if (this.location_input.Text != "")
            {
                WeatherService.Conditions todays_condish = weatherService.getCurrentCondition(this.location_input.Text);
                if (todays_condish != null)
                {
                    WeatherService.Conditions[] forcast = weatherService.getForeCast(this.location_input.Text);
                    //Setup data view for today's current condition and temp:
                    this.location_output.Text     = this.location_input.Text;
                    this.condition_output.Text    = todays_condish.Condition;
                    this.current_temp_output.Text = todays_condish.TempF;

                    //Setup data view for the 10 day forcast:
                    table.Append("<table border='1'>");

                    //Setup forcast day headers:
                    table.Append("<tr>");
                    foreach (WeatherService.Conditions condish in forcast)
                    {
                        table.Append(string.Format("<th style=\"widthL 250px; text-algin: center;\">{0} <br /> [{1}]", condish.DayOfWeek, condish.Date));
                    }
                    table.Append("</tr>");
                    table.Append("<tr>");
                    int id = 0;
                    foreach (WeatherService.Conditions condish in forcast)
                    {
                        table.Append("<td style=\"width: 250px; height: 100px;\">");
                        table.Append(string.Format("<p ID=\"condition{0}\" runat=\"server\" style=\"margin - bottom:10px; margin - top:20px; padding - right:50px; \">Expected Condition: {1}</p>", id, condish.Condition));
                        table.Append("<br />");
                        table.Append(string.Format("<p ID=\"temp{0}\" runat=\"server\" style=\"margin - bottom:10px; margin - top:20px; padding - right:50px; \">Expected Temp: {1}</p>", id, condish.TempF));
                        table.Append("<br />");
                        table.Append(string.Format("<p ID=\"high{0}\" runat=\"server\" style=\"margin - bottom:10px; margin - top:20px; padding - right:50px; \">Expected High: {1}</p>", id, condish.High));
                        table.Append("<br />");
                        table.Append(string.Format("<p ID=\"low{0}\" runat=\"server\" style=\"margin - bottom:10px; margin - top:20px; padding - right:50px; \">Expected Low: {1}</p>", id, condish.Low));
                        table.Append("<br />");
                        table.Append("</td>");
                        //Increment identifier:
                        id += 1;
                    }
                    table.Append("</tr>");
                    table.Append("</table>");
                    forecast_place_holder.Controls.Add(new Literal {
                        Text = table.ToString()
                    });
                }
                else
                {//Not found
                    this.location_output.Text     = "Location Not Found.";
                    this.condition_output.Text    = "Not Defined.";
                    this.current_temp_output.Text = "Not Defined.";
                }
            }
        }
Example #7
0
        protected void WeatherButton_Click(object sender, EventArgs e)
        {
            WeatherService.IWeatherService weatherService = new WeatherService.WeatherServiceClient();
            string zipcode = WeatherZipCodeTextBox.Text;
            string units   = WeatherUnitsTextBox.Text;

            string[] forcast = weatherService.getForcast(zipcode, units);
            for (int i = 0; i != forcast.Length; i++)
            {
                ForcastLabel.Text += forcast[i] + "<br>";
            }
            LocationOutLabel.Text = weatherService.getLocation(zipcode);
        }
Example #8
0
        static async Task Main(string[] args)
        {
            // The port number(5001) must match the port of the gRPC server.
            var channel = GrpcChannel.ForAddress("https://localhost:5001");

            Console.WriteLine("Got Channel");
            var client = new WeatherService.WeatherServiceClient(channel);

            Console.WriteLine("calling GetWeather...");
            var weatherResponse = await client.GetWeatherAsync(new WeatherRequest());

            foreach (var item in weatherResponse.Items)
            {
                Console.WriteLine($"{item.TempC } {item.Syummary} ");
            }
        }
Example #9
0
        static async Task Main(string[] args)
        {
            // The port number(5001) must match the port of the gRPC server.
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var weatherclient = new WeatherService.WeatherServiceClient(channel);
            var currentData   = await weatherclient.RequestCurrentWeatherDataAsync(new WeatherRequest { Location = "MyTown" });

            var historicData = await weatherclient.RequestHistoricDataAsync(new WeatherRequest { Location = "MyTown" });

            var client = new Greeter.GreeterClient(channel);
            var reply  = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" });

            Console.WriteLine(
                $"The current weather for {currentData.Location} is {currentData.Temperature} degrees F with winds {currentData.Windspeed} from {currentData.Winddirection}");
            Console.WriteLine(
                $"The high temps for the past 10 days were ");
            foreach (var data in historicData.Data)
            {
                Console.WriteLine($"{data.Temperature}");
            }


            var echoClient = new EchoService.EchoServiceClient(channel);
            var response   = echoClient.EchoMe(
                new EchoRequest()
            {
                Text = $"ABCDEFG-{DateTime.Now.ToShortDateString()}"
            });

            Console.WriteLine($"[{response.Original}] => [{response.Result}]");


            response = echoClient.ReverseEcho(
                new EchoRequest()
            {
                Text = $"ABCDEFG-{DateTime.Now.ToShortDateString()}"
            });

            Console.WriteLine($"[{response.Original}] => [{response.Result}]");


            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
        static async Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new WeatherService.WeatherServiceClient(channel);
            var request = new WeatherForecastRequest
            {
                CityName = "Berlin",
                FromDate = Timestamp.FromDateTime(DateTime.Now.ToUniversalTime()),
                ToDate   = Timestamp.FromDateTime(DateTime.Now.ToUniversalTime().AddDays(5))
            };
            var result = await client.GetWeatherForecastAsync(request);

            foreach (var item in result.Items)
            {
                Console.WriteLine($"Weather for {item.CityName} in {item.Date} is {item.Summary} {item.TemperatureC}°C/{ item.TemperatureK}K");
            }

            Console.ReadLine();
        }
Example #11
0
        private static async Task GetResponse()
        {
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new WeatherService.WeatherServiceClient(channel);

            while (true)
            {
                var request = new WeatherRequest()
                {
                    StationId = 0
                };

                var response = await client.GetWeatherSamplesAsync(request);

                Console.WriteLine($"Samples Gathered: {response.Time.ToDateTime().ToLongTimeString()}");
                foreach (var res in response.Samples)
                {
                    Console.WriteLine($"{res}");
                }
                Console.WriteLine(new String('-', 80));
                Console.ReadKey();
            }
        }
Example #12
0
 public GrpcWeatherForecastClient(WeatherService.WeatherServiceClient client, IMapper mapper)
 {
     _client = client;
     _mapper = mapper;
 }