static wsresult processJsonWS(String data) { JavaScriptSerializer js = new JavaScriptSerializer(); wsresult r = js.Deserialize <wsresult>(data); return(r); }
protected void Button5_Click(object sender, EventArgs e) { locationObject locObject = Cache["locObject"] as locationObject; if (locObject == null) { //Cache is invalid now make panel invisible Panel2.Visible = true; Panel3.Visible = false; } else { Panel2.Visible = true; Panel3.Visible = true; // Cache is valid // Get All city Info Double lat = locObject.latitude; Double lon = locObject.longitude; String solarbaseurl = "http://*****:*****@solarbaseurl + "SolarIntensity?lat=" + lat + "&lon =" + lon; String windbaseurl = "http://*****:*****@windbaseurl + "WindIntensity?lat=" + lat + "&lon =" + lon; String mapbaseurl = "http://*****:*****@mapbaseurl + "/getMapURL?lat=" + lat + "&lon=" + lon; String gasbaseurl = "http://*****:*****@gasbaseurl + "/getGasStation?lat=" + lat + "&lon=" + lon; try { string solarjson = getJsonString(solarurl); string windjson = getJsonString(windurl); string mapjson = getJsonString(mapurl); string gasjson = getJsonString(gasurl); wsresult solarws = processJsonWS(solarjson); wsresult windws = processJsonWS(windjson); imgresult imgrs = processJsonImg(mapjson); gasresult[] gasoutput = processJsonGas(gasjson); ListView1.DataSource = gasoutput; ListView1.DataBind(); if (solarws.status.Equals("Invalid Input")) { Label7.Text = "Invalid Input"; } else { Label7.Text = solarws.avgIntensity.ToString(); } if (windws.status.Equals("Invalid Input")) { Label6.Text = "Invalid Input"; } else { Label6.Text = windws.avgIntensity.ToString(); } Image1.ImageUrl = imgrs.url; } catch (Exception err) { Console.WriteLine(err); } } }