Exemplo n.º 1
0
    protected void btnGetTideHeights_Click(object sender, EventArgs e)
    {
        var client  = new RestClient("https://www.worldtides.info/api");
        var request = new RestRequest(Method.POST);

        request.AddHeader("cache-control", "no-cache");
        request.AddHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
        request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"key\"\r\n\r\n690ef839-345b-4cdf-9ca3-8010e5376eb0\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"heights\"\r\n\r\n" + txtHeight.Text + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"lat\"\r\n\r\n" + txtLat.Text + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"lon\"\r\n\r\n" + txtLon.Text + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"length\"\r\n\r\n" + txtLength.Text + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"step\"\r\n\r\n" + txtSteps.Text + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"extremes\"\r\n\r\n" + txtExtremes.Text + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"datum\"\r\n\r\n" + drpDatum.SelectedItem.Value + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", ParameterType.RequestBody);
        IRestResponse response = client.Execute(request);
        TideData      tideData = JsonConvert.DeserializeObject <TideData>(response.Content.ToString());

        Session["TideData"] = tideData;
        Response.Redirect("Results.aspx");
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["TideData"] != null)
     {
         TideData tideData = (TideData)Session["TideData"];
         txtDatum.Text            = tideData.RequestDatum;
         txtLat.Text              = tideData.ResponseLat.ToString();
         txtLon.Text              = tideData.ResponseLon.ToString();
         txtStation.Text          = tideData.Station;
         lstHeightData.DataSource = tideData.Heights;
         lstHeightData.DataBind();
         lstExtreme.DataSource = tideData.Extremes;
         lstExtreme.DataBind();
     }
 }
Exemplo n.º 3
0
        private async void UpdateWeather()
        {
            main.Visibility = Visibility.Collapsed;
            var forecast = await weatherService.GetForecastAsync();

            Temp.Text              = forecast.Current.Temperature.ToString();
            FeelsLike.Text         = forecast.Current.FeelsLike.ToString();
            Humidity.Text          = forecast.Current.Humidity.ToString();
            Wind.Text              = $"{(int)forecast.Current.WindSpeed}{forecast.Current.WindDirection}";
            CurrentConditions.Text = forecast.Current.WeatherDescription;
            var when  = DateTime.Now;
            var tides = await TideData.GetNextTides(when, TideData.Location.BowleysBar);

            HighTide.Text = tides.HighTide;
            LowTide.Text  = tides.LowTide;
            LargeMap.Navigate(new Uri(largeMapUrl));
            SmallMap.Navigate(new Uri(smallMapUrl));
            main.Visibility = Visibility.Visible;
        }