Exemplo n.º 1
0
        protected void ddlVilles_SelectedIndexChanged(object sender, EventArgs e)
        {
            try {
                GlobalWeather service = new GlobalWeather();

                string Data = service.GetWeather(ddlVilles.Text, ddlPays.Text);

                XElement Temp = XElement.Load(new System.IO.StringReader(Data));

                string chaine = Temp.Value;

                // ---------------------- Determine le nombre d'espace ---------------------
                string[] res = chaine.Split(' ');


                // ---  Recupere la valeur entre l'espace 14 et 13 en partant de la fin ----
                string FMax = res[res.Length - 14]; // temperature Max
                string FMin = res[res.Length - 10]; // temperature Min

                //string directionVent = res[res.Length - 29]; // direction vent
                //string vitesseVent = res[res.Length - 25]; // vitesse vent

                string humidite = res[res.Length - 6]; // humidite de l'air
                string presure  = res[res.Length - 5]; // pression

                // ------------------ Convertie la valeur String en Double -----------------
                double a = double.Parse(FMax);
                double b = double.Parse(FMin);


                // -------------------- Convertie la valeur F en Celcus C ------------------
                double CMax0 = (a - 32) * 5 / 9;
                double CMin0 = (b - 32) * 5 / 9;
                double CMax  = Math.Round(CMax0, 0); // temperature Max
                double CMin  = Math.Round(CMin0, 0); // temperature Min

                // ------------------------------- RESULTAT --------------------------------
                lblTemperatureMax.Text = "Max : " + FMax + " F " + "(" + CMax + " C)";
                lblTemperatureMin.Text = "Min : " + FMin + " F " + "(" + CMin + " C)";

                //lblDirection.Text = "Direction : " + directionVent;
                //lblVitesse.Text = "Wind : " + vitesseVent + " MPH";

                lblHumidite.Text      = "Humidity : " + humidite;
                lblPrecipitation.Text = "Presure : " + presure + "''";
            }
            catch
            {
                lblTemperatureMax.Text = "PLEASE TRY";
                lblTemperatureMin.Text = "AGAIN LATER";

                //lblDirection.Text = "Direction : " + directionVent;
                //lblVitesse.Text = "Wind : " + vitesseVent + " MPH";

                lblHumidite.Text      = "PLEASE TRY";
                lblPrecipitation.Text = "AGAIN LATER";
            }

            // lblTemperatureMax.Text = Temp.Value;
        }
    private void GetWeather()
    {
        GlobalWeather gw     = new GlobalWeather();
        string        result = gw.GetWeather(DropDownList2.SelectedItem.Text, DropDownList1.SelectedItem.Text);

        string[] res = GetStringInBetween(result);
        Label1.Text = "Temperature : " + res[0];
    }
Exemplo n.º 3
0
        private void GetWeather()
        {
            GlobalWeather gw     = new GlobalWeather();
            string        result = gw.GetWeather(ddlCity.SelectedItem.Text, ddlCountry.SelectedItem.Text);

            string[] res = GetStringInBetween(result);
            lblTemp1.Text = "Temperature : " + res[0];
        }
Exemplo n.º 4
0
        public void TestGlobalWeather()
        {
            GlobalWeather gw = new GlobalWeather();
            WeatherReport wr = gw.getWeatherReport("LEBL");

            Assert.IsNotNull(wr.station);
            Assert.AreEqual("LEBL", wr.station.icao);
            Assert.AreEqual("Barcelona / Aeropuerto", wr.station.name);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     GlobalWeather gw = new GlobalWeather();
     Label1.Text = gw.GetWeather("lucknow", "india");
     DropDownList1.DataSource = gw.GetCitiesByCountry("india");
     DropDownList1.DataBind();
     GridView1.DataSource = gw.GetCitiesByCountry("pakistan");
     GridView1.DataBind();
 }
Exemplo n.º 6
0
		public void TestGlobalWeather ()
		{
			GlobalWeather gw = new GlobalWeather ();
			WeatherReport wr = gw.getWeatherReport ("LEBL");
			
			Assert.IsNotNull (wr.station);
			Assert.AreEqual ("LEBL", wr.station.icao);
			Assert.AreEqual ("Barcelona / Aeropuerto", wr.station.name);
		}
Exemplo n.º 7
0
        public GlobalWeather GetService()
        {
            if (this._globalWeather == null)
            {
                _globalWeather     = new GlobalWeather();
                _globalWeather.Url = ConfigurationManager.AppSettings["WebServiceXUrl"];
            }

            return(_globalWeather);
        }
Exemplo n.º 8
0
        protected void ddlPays_SelectedIndexChanged(object sender, EventArgs e)
        {
            GlobalWeather service = new GlobalWeather();

            string Data = service.GetCitiesByCountry(ddlPays.Text);

            //XmlReader xtr = new XmlTextReader(new System.IO.StringReader(Data));

            XElement city = XElement.Load(new System.IO.StringReader(Data));

            ddlVilles.Items.Clear();

            foreach (XElement name in city.Elements("Table").Elements("City"))
            {
                ddlVilles.Items.Add(name.Value);
            }
        }
Exemplo n.º 9
0
    public static void Main(string[] args)
    {
        // Create instance of the GlobalWeather.dll.
        GlobalWeather Weather = new GlobalWeather();

        // Get input from user.
        // NOTE: An input value of "France" does work (as of 23/10/2016).
        Console.Write("Enter Country: ");
        string Country = Console.ReadLine();

        string Data = Weather.GetCitiesByCountry(Country);

        Console.WriteLine(Data);

        //converting the string Respsonse to XML
        //XmlTextReader xtr = new XmlTextReader(new System.IO.StringReader(Data));
        //DataSet ds = new DataSet();
        //ds.ReadXml(xtr);
        //Console.Write(ds.GetXml());
    }
Exemplo n.º 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Ensure that the code executes only when the page loads
        if (!IsPostBack)
        {
            try
            {
                //captures the user long id
                lblClientNumber.Text = Page.User.Identity.Name;
                //parse the login clientnumber to integer
                int clientNumber = int.Parse(Page.User.Identity.Name.ToString());

                //Store this clientNumber value in a Session variable
                Session["ClientNumber"] = clientNumber;

                //lambda used to return the clientID
                int clientId = db.Clients.Where(record => record.ClientNumber == clientNumber).Select(record => record.ClientId).Single();
                //Store this ClientId value in a Session variable
                Session["ClientId"] = clientId;
                //Define a LINQ-to-SQL Server query  object with all records from the BankAccount table whose ClientID matches the ClientID retrieved in the previous step
                IQueryable <BankOfBIT.Models.BankAccount> query = db.BankAccounts.Where(record => record.ClientId == clientId);
                //binding the data
                gvAccounts.DataSource = query.ToList();
                //mutiple controls option
                this.DataBind();

                //add for assignment5 exchange lbl
                GlobalWeather weather = new GlobalWeather();

                lblExchangeRate.Text = weather.GetWeather("Winnipeg", "Canada");
            }
            //If an exception occurs during this routine, display an appropriate message in the Message label at the bottom of the form
            catch (Exception)
            {
                lblWarnings.Text = "Something went wrong trying to load the data";
            }
        }
    }