public async Task <List <Article> > GetArticlesAsync() { var URI = new Uri(string.Format(URL, string.Empty)); Articles = new List <Article>(); try { //send async GET request to specified uri var response = await client.GetAsync(URI); //if API is active (http 200 ok) if (response.IsSuccessStatusCode) { //wait incomming response (JSON file) var content = await response.Content.ReadAsStringAsync(); var list = Welcome.FromJson(content); Articles = list.Articles; } } catch (Exception ex) { Debug.WriteLine(@" ERROR {0}", ex.Message); } //null or full return(Articles); }
protected void GetDeezerAPILogin() { string webresult = DeezerRequest("deezer.getUserData"); var welcome = Welcome.FromJson(webresult); // Check for Valid User ID if (welcome.Results.User.UserId > 0) { // Check for Valid API Key if (!string.IsNullOrEmpty(welcome.Results.CheckForm) && welcome.Results.User.UserId != 0) { // Write API Key to Var apiKey = api_token + welcome.Results.CheckForm; // Write UserID to Var userid = welcome.Results.User.UserId.ToString(); } else { throw new Exception("Wrong User Information"); } } else { throw new Exception("Cannot get Deezer API Key"); } }
private async System.Threading.Tasks.Task AuthenticateWithWNS() { Dictionary <String, String> creds = GetCredentials(); Debug.WriteLine($"[PushNotifications] creds fetched bout to dictionary!"); Dictionary <String, String> values = new Dictionary <String, String> { { "grant_type", "client_credentials" }, { "client_id", creds["AppSID"] }, { "client_secret", creds["AppSecret"] }, { "scope", "notify.windows.com" } }; Debug.WriteLine($"[PushNotifications] values created"); var content = new FormUrlEncodedContent(values); Debug.WriteLine($"[PushNotifications] formurlencodedcontent"); var response = await client.PostAsync("https://login.live.com/accesstoken.srf", content); Debug.WriteLine($"[PushNotifications] post post req"); if (response.IsSuccessStatusCode) { Debug.WriteLine($"[PushNotifications] post req success"); var responseString = await response.Content.ReadAsStringAsync(); var data = Welcome.FromJson(responseString); this.token = data.AccessToken; this.isAuthenticated = true; Debug.WriteLine($"[PushNotifications] " + this.token); } else { Debug.WriteLine($"[PushNotifications] could not get access token!"); } }
private void GatherSteamData() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; try { using (var webClient = new System.Net.WebClient()) { var json = webClient.DownloadString("https://crowbar.steamstat.us/Barney"); var welcome = Welcome.FromJson(json); metroLink_OnlineOnSteam.Text = welcome.Services.Online.Title.ToString(); metroLink_StatusStore.Text = welcome.Services.Store.Status.ToString(); metroLink_StatusCommunity.Text = welcome.Services.Community.Status.ToString(); metroLink_cms.Text = welcome.Services.Cms.Status.ToString(); metroLink_cmsWS.Text = welcome.Services.CmsWs.Status.ToString(); metroLink_StatusWebapi.Text = welcome.Services.Webapi.Status.ToString(); metroLink_StatusSteamDB.Text = welcome.Services.Database.Status.ToString(); metroLink_CSLogin.Text = welcome.Services.CsgoSessions.Status.ToString(); metroLink_CSInventories.Text = welcome.Services.CsgoCommunity.Status.ToString(); metroLink_CSMMSL.Text = welcome.Services.CsgoMmScheduler.Status.ToString(); metroLink_tf2api.Text = welcome.Services.Tf2.Status.ToString(); metroLink_dota2api.Text = welcome.Services.Dota2.Status.ToString(); } } catch (Exception e) { Console.WriteLine("SteamServersForm Exeption: " + e); } }
/// <summary> /// Tracks the search. /// http://ws.audioscrobbler.com/2.0/?method=artist.search&artist={busqueda}&api_key={personal_api_key}&format=json /// </summary> /// <param name="search">Search.</param> public async void TrackSearch(string search) { var messageResult = new MessageResult <IList <Track> >(); try { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(ConfigApi.MediaTypeJson)); var response = await client.GetAsync(ConfigApi.UrlLastFM + ConfigApi.TrackSearchEndPoint + $"&track={search}&api_key={ConfigApi.ApiKey_LastFM}&format=json"); if (response.IsSuccessStatusCode) { var ContentString = await response.Content.ReadAsStringAsync(); var trackResponse = Welcome.FromJson(ContentString); messageResult.Value = new List <Track>(trackResponse.Results.Trackmatches.Track); messageResult.IsSuccess = true; } else { throw new Exception("Hubo un error al consultar el track"); } } } catch (Exception) { throw; } TrackSearch_Completed?.Invoke(this, new GenericEventArgs <MessageResult <IList <Track> > >(messageResult)); }
public static Welcome Work(string filename) { string jsonText = File.ReadAllText(filename); var welcome = Welcome.FromJson(jsonText); return(welcome); }
static void Main(string[] args) { string jsonString = File.ReadAllText("zhepa.json"); var welcome = Welcome.FromJson(jsonString); Console.WriteLine(welcome.Data.Persons[0].FirstName.Ru); }
public ActionResult DeviceData() { var client = new RestClient(); client.BaseUrl = new Uri("https://api.ambientweather.net"); //client.Authenticator = new HttpBasicAuthenticator("username", "password"); var request = new RestRequest(); request.Resource = "v1/devices/"; var applicationKey = new Parameter("applicationKey", "1c790b09742a40b494d4c2fc98e5bea240cb433303ea4f65bb3699ade56baeeb", ParameterType.QueryString); var apiKey = new Parameter("apiKey", "1e496310ad4443a48e275ce5c16cc59da0a6afca1bfa49dab8840c3a11c566bb", ParameterType.QueryString); request.Parameters.Add(applicationKey); request.Parameters.Add(apiKey); IRestResponse response = client.Execute(request); var welcome = Welcome.FromJson(response.Content.ToString()); List <Welcome> welcomeList = welcome; foreach (var item in (List <Welcome>)welcomeList) { //ViewBag.MacAddress = item.MacAddress; } //Console.WriteLine(welcome.ToString()); return(View()); }
private void Load_from_JSON() { string jsonString = File.ReadAllText("zhepa.json"); welcome = Welcome.FromJson(jsonString); //Console.WriteLine(welcome.Data.Persons[0].FirstName.Ru); }
public void OnGet() { using (var webClient = new System.Net.WebClient()) { string breweryData = webClient.DownloadString("https://justbrewit2021.azurewebsites.net/OtherAPI"); Welcome[] brewery = Welcome.FromJson(breweryData); ViewData["MyBreweryAPI"] = brewery; } }
public void OnGet() { using (var webClient = new WebClient()) { string jsonString = webClient.DownloadString("https://data.cincinnati-oh.gov/api/views/8us8-wi2w/rows.json?accessType=DOWNLOAD"); var welcome = Welcome.FromJson(jsonString); ViewData["Welcome"] = welcome; } }
static void Main() { // read the JSON into variable string json = System.IO.File.ReadAllText("input.json"); // Convert the JSON text into C# object var welcomes = Welcome.FromJson(json); foreach (var welcome in welcomes) { // Your logic } }
private void SicaklikBilgisiAl() { foreach (HavuzJSON item in urlListesi) { string geciciSicaklik = ""; string geciciTarih = ""; if (!string.IsNullOrEmpty(item.url)) { using (var webClient = new System.Net.WebClient()) { var json = webClient.DownloadString(item.url); // Now parse with JSON.Net var welcome = Welcome.FromJson(json); for (int i = 0; i < welcome.Feeds.Count; i++) { try { geciciSicaklik = welcome.Feeds[i].Field1.ToString(); geciciTarih = welcome.Feeds[i].CreatedAt.ToString(); } catch (Exception) { geciciSicaklik = Localization.Olculemedi; geciciTarih = Localization.Guncellenemedi; } } } if (string.Equals(geciciSicaklik, Localization.Olculemedi)) { item.sicaklik = geciciSicaklik; item.GuncellenmeTarihi = DateTime.Now; } else { item.sicaklik = Convert.ToInt32(geciciSicaklik).ToString(); item.GuncellenmeTarihi = Convert.ToDateTime(geciciTarih); } } else { geciciSicaklik = Localization.Olculemedi; geciciTarih = Localization.Guncellenemedi; } if (item.GuncellenmeTarihi == Convert.ToDateTime("01.01.0001 00:00:00")) { item.GuncellenmeTarihi = DateTime.Now; item.sicaklik = Localization.Olculemedi; } } }
public void OnGet() { using (var webClient = new WebClient()) { String key = System.IO.File.ReadAllText("WeatherAPIKey.txt"); String weatherString = webClient.DownloadString("https://api.weatherbit.io/v2.0/current?&city=Cincinnati&country=USA&key=" + key); QuickTypeWeather.Welcome welcomeWeather = QuickTypeWeather.Welcome.FromJson(weatherString); long precip = 0; foreach (QuickTypeWeather.Datum weather in welcomeWeather.Data) { precip = weather.Precip; } if (precip < 1) { ViewData["WeatherMessage"] = "Water your plants!"; } IDictionary <long, QuickTypePlants.Welcome> allPlants = new Dictionary <long, QuickTypePlants.Welcome>(); String plantsJSON = webClient.DownloadString("http://plantplaces.com/perl/mobile/viewplantsjsonarray.pl?WetTolerant=on"); QuickTypePlants.Welcome[] welcomePlants = QuickTypePlants.Welcome.FromJson(plantsJSON); foreach (QuickTypePlants.Welcome plant in welcomePlants) { allPlants.Add(plant.Id, plant); } String jsonString = webClient.DownloadString("https://www.plantplaces.com/perl/mobile/viewspecimenlocations.pl?Lat=39.14455075&Lng=-84.5093939666667&Range=0.5&Source=location&Version=2"); JSchema schema = JSchema.Parse(System.IO.File.ReadAllText("SpecimenSchema.json")); JObject jsonObject = JObject.Parse(jsonString); IList <string> validationEvents = new List <string>(); if (jsonObject.IsValid(schema, out validationEvents)) { Welcome welcome = Welcome.FromJson(jsonString); List <Specimen> specimens = welcome.Specimens; List <Specimen> waterMeSpecimens = new List <Specimen>(); foreach (Specimen specimen in specimens) { if (allPlants.ContainsKey(specimen.PlantId)) { waterMeSpecimens.Add(specimen); } } ViewData["Specimens"] = waterMeSpecimens; } else { foreach (string evt in validationEvents) { Console.WriteLine(evt); } ViewData["Specimens"] = new List <Specimen>(); } } }
public void OnGet() { using (var webClient = new WebClient()) { string recepies = webClient.DownloadString("https://momsspaghetti.azurewebsites.net/?getMostSearched=true"); JArray recepiesjsonArray = JArray.Parse(recepies); var result = Welcome.FromJson(recepiesjsonArray.ToString()); /*ViewData["Recepies"] = recepiesjsonArray.ToString();*/ ViewData["Recepies"] = result; } }
private void Form1_Load(object sender, EventArgs e) { Timer t1 = new Timer(); t1.Interval = 50; t1.Tick += new EventHandler(timer1_Tick); t1.Enabled = true; using (var webClient = new WebClient()) { string jsonString = webClient.DownloadString("https://adgambling.com/keywords.json"); var welcome = Welcome.FromJson(jsonString); Console.WriteLine(welcome); } }
static void Main(string[] args) { //var people = new List<Person>(); var file = @"C:\Users\alexa\OneDrive\Documents\job\Vertmarkets\Subscribers.json"; var json = File.ReadAllText(file); var welcome = Welcome.FromJson(json); var people = welcome.Data.ToList(); foreach (Person per in people) { Console.WriteLine(per.FirstName); } Console.ReadLine(); }
private void GatherCSRegionsData() { try { using (var webClient = new System.Net.WebClient()) { var json = webClient.DownloadString("https://crowbar.steamstat.us/Barney"); var welcome = Welcome.FromJson(json); metroLink_us_northcentral.Text = welcome.Services.CsgoUsNorthcentral.Status.ToString(); metroLink_us_northeast.Text = welcome.Services.CsgoUsNortheast.Status.ToString(); metroLink_us_northwest.Text = welcome.Services.CsgoUsNorthwest.Status.ToString(); metroLink_us_southeast.Text = welcome.Services.CsgoUsSoutheast.Status.ToString(); metroLink_us_southwest.Text = welcome.Services.CsgoUsSouthwest.Status.ToString(); metroLink_brazil.Text = welcome.Services.CsgoBrazil.Status.ToString(); metroLink_peru.Text = welcome.Services.CsgoPeru.Status.ToString(); metroLink_chile.Text = welcome.Services.CsgoChile.Status.ToString(); metroLink_emirates.Text = welcome.Services.CsgoEmirates.Status.ToString(); metroLink_spain.Text = welcome.Services.CsgoSpain.Status.ToString(); metroLink_poland.Text = welcome.Services.CsgoPoland.Status.ToString(); metroLink_eu_east.Text = welcome.Services.CsgoEuEast.Status.ToString(); metroLink_eu_north.Text = welcome.Services.CsgoEuNorth.Status.ToString(); metroLink_eu_west.Text = welcome.Services.CsgoEuWest.Status.ToString(); metroLink_south_africa.Text = welcome.Services.CsgoSouthAfrica.Status.ToString(); metroLink_india_east.Text = welcome.Services.CsgoIndiaEast.Status.ToString(); metroLink_india.Text = welcome.Services.CsgoIndia.Status.ToString(); metroLink_china_guangzhou.Text = welcome.Services.CsgoChinaGuangzhou.Status.ToString(); metroLink_china_shanghai.Text = welcome.Services.CsgoChinaShanghai.Status.ToString(); metroLink_china_tianjin.Text = welcome.Services.CsgoChinaTianjin.Status.ToString(); metroLink_singapore.Text = welcome.Services.CsgoSingapore.Status.ToString(); metroLink_hong_kong.Text = welcome.Services.CsgoHongKong.Status.ToString(); metroLink_japan.Text = welcome.Services.CsgoJapan.Status.ToString(); metroLink_australia.Text = welcome.Services.CsgoAustralia.Status.ToString(); } } catch (Exception E) { Console.WriteLine(E); } }
public async Task <IEnumerable <DomainModel.Notification> > GetNotificationsForDistrictAsync(string districtName) { var action = "api/action/19115store_getNotificationsForDistrict?id=28dc65ad-fff5-447b-99a3-95b71b4a7d1e"; var response = await _client.GetAsync($"{action}&district={districtName}&apikey={_apiKey}"); response.EnsureSuccessStatusCode(); var jsonString = await response.Content.ReadAsStringAsync(); var welcome = Welcome.FromJson(jsonString); if (!welcome.Result.Success) { return(new List <DomainModel.Notification>()); } return(welcome.Result.Result.Notifications.ToDomainModel()); }
private void Window() { string data; WebClient client = new WebClient(); data = client.DownloadString("https://nationalbank.kz/rss/rates_all.xml"); XmlDocument doc = new XmlDocument(); doc.LoadXml(data); XmlNode newNode = doc.DocumentElement; string jsonString = JsonConvert.SerializeXmlNode(newNode); var currency = Welcome.FromJson(jsonString); currencyGrid.ItemsSource = currency.Rss.Channel.Item; }
public RootObject ReadJson(string jsonFile) { try { string json = File.ReadAllText(jsonFile); dataContent = Welcome.FromJson(json); WorksByIds = dataContent.WorksById; return(dataContent); } catch (FileNotFoundException exception) { log.Error("File not found", exception); throw; } catch (Exception exception) { log.Error("Unknown problem: ", exception); throw; } }
private void Button_Click(object sender, RoutedEventArgs e) { try { string jsonString; using (var wc = new WebClient()) jsonString = wc.DownloadString("http://api.openweathermap.org/data/2.5/weather?q=" + TBMiasto.Text.ToString() + ",pl&appid=e3bb48f5e5555457cb51cee4bee3ceca"); var welcome = Welcome.FromJson(jsonString); (welcome.Main.Temp - 273).ToString(); TBPogoda.Text = $"Dzisiaj w {TBMiasto.Text.ToString()} jest { (welcome.Main.Temp - 273.15).ToString()} stopni. \n" + $"Ciśnienie: {welcome.Main.Pressure.ToString()}\n" + $"Wiatr: {welcome.Wind.Speed*3.6} km/h \n"; var uri = new Uri("http://openweathermap.org/img/w/" + welcome.Weather[0].Icon + ".png"); var bitmap = new BitmapImage(uri); Icon.Source = bitmap; } catch (Exception ex) { TBPogoda.Text = "Nie udało się pobrac pogody!"; } }
public void OnPost() { string city = BreweryCity; // Check whether city populated on screen IsCityNull = string.IsNullOrEmpty(city); // Fetch data from API only when city populated if (!IsCityNull) { Url = "https://api.openbrewerydb.org/breweries?by_city=" + city; } using (var webClient = new WebClient()) { string brewery = webClient.DownloadString(Url); Welcome[] welcome = Welcome.FromJson(brewery); ViewData["Welcome"] = welcome; } IsSearchCity = true; }
public override void Process(object randomNumb) { try { Log.WriteToLog("Nacisniecie przyciksu wykonaj. Z parametrami: temp: " + Temp + " mail: " + MailAdress + " miasto: " + City); var mailsender = new MailSender(MailAdress); string jsonString; using (var wc = new WebClient()) jsonString = wc.DownloadString("http://api.openweathermap.org/data/2.5/weather?q=" + City + ",pl&appid=e3bb48f5e5555457cb51cee4bee3ceca"); var welcome = Welcome.FromJson(jsonString); if (welcome.Main.Temp - 273 < Temp) { Log.WriteToLog("Temperatura jest niższa niz podano nie robie nic"); App.Current.Dispatcher.Invoke(new Action(() => { MainWindow w = (MainWindow)App.Current.MainWindow; w.WriteConsoleTextBox("Temperatura jest niższa niz podano nie robie nic"); })); return; } Random random = new Random(); var pictureName = "tmpTempSender" + randomNumb.ToString() + ".png"; string Message = $"Dzisiaj w {City} jest { (welcome.Main.Temp - 273.15).ToString()} stopni. \n" + $"Ciśnienie: {welcome.Main.Pressure.ToString()}\n" + $"Wiatr: {welcome.Wind.Speed * 3.6} km/h \n"; var uri = "http://openweathermap.org/img/w/" + welcome.Weather[0].Icon + ".png"; using (var wc = new WebClient()) wc.DownloadFile(uri, pictureName); mailsender.SendEmail(Message, uri.ToString(), pictureName); Log.WriteToLog("Barwo! Wysłałeś Obrazek o URL: " + uri.ToString() + "\n"); } catch (Exception x) { Log.WriteToLog("Błąd: " + x); } }
public void OnGet() { using (var webClient = new WebClient()) { String jsonString = webClient.DownloadString("https://roster19fs702420191018063705.azurewebsites.net/Feed"); JSchema schema = JSchema.Parse(System.IO.File.ReadAllText("WelcomeSchema.json")); JArray jsonArray = JArray.Parse(jsonString); IList <string> validationEvents = new List <string>(); if (jsonArray.IsValid(schema, out validationEvents)) { Welcome[] welcome = Welcome.FromJson(jsonString); ViewData["Welcome"] = welcome; } else { Console.WriteLine("Not valid. Fool."); foreach (string evt in validationEvents) { Console.WriteLine(evt); } ViewData["Welcome"] = new Welcome[0]; } } }
public async Task MainAsync() { _client = new DiscordSocketClient(); _client.MessageReceived += MessageReceived; _welcomes = new List <Welcome>(); for (int i = 0; i < jsonFiles.Length; i++) { string file = jsonFiles[i]; StreamReader sr = new StreamReader("./Resources/" + file); string jsonString = sr.ReadToEnd(); Welcome welcome = Welcome.FromJson(jsonString); _welcomes.Add(welcome); } string token = ""; // Remember to keep this private! await _client.LoginAsync(TokenType.Bot, token); await _client.StartAsync(); // Block this task until the program is closed. await Task.Delay(-1); }
public async Task <List <Result> > SearchLocation(string query) { var result = new List <Result>(); const string appId = "51n1d12kkw6EasbuRYvc"; const string appCode = "1HhHoOJH2-jUQBfI5bMfQQ"; const string baseUrl = "https://places.cit.api.here.com/places/v1/autosuggest"; var url = $"{baseUrl}?at=40.74917%2C-73.98529&q={query}&Accept-Language=en-US%2Cen%3Bq%3D0.9%2Che-IL%3Bq%3D0.8%2Che%3Bq%3D0.7&app_id={appId}&app_code={appCode}"; using (var client = new HttpClient()) { var response = await client.GetAsync(url); if (response == null) { return(result); } var jsonString = await response.Content.ReadAsStringAsync(); var res = Welcome.FromJson(jsonString); result.AddRange(res.Results); } return(result); }
public void OnGet() { // this new array will hold only specimens that like water. List <Specimen> waterLovingSpecimens = new List <Specimen>(); // what is the precip? long precip = 0; string plantJson = GetData("http://plantplaces.com/perl/mobile/viewplantsjsonarray.pl?WetTolerant=on"); Plant[] allPlants = Plant.FromJson(plantJson); String key = System.IO.File.ReadAllText("WeatherAPIKey.txt"); string weatherEndpoint = "https://api.weatherbit.io/v2.0/current?&city=Cincinnati&country=USA&key=" + key; string strWeatherJson = GetData(weatherEndpoint); QuickTypeWeather.Weather weather = QuickTypeWeather.Weather.FromJson(strWeatherJson); List <QuickTypeWeather.Datum> weatherData = weather.Data; foreach (QuickTypeWeather.Datum weatherDatum in weatherData) { precip = weatherDatum.Precip; } string jsonString = GetData("https://www.plantplaces.com/perl/mobile/viewspecimenlocations.pl?Lat=39.14455075&Lng=-84.5093939666667&Range=0.5&Source=location&Version=2"); // do some validation before we consume the data. string strSchema = System.IO.File.ReadAllText("SpecimenSchema.json"); JSchema schema = JSchema.Parse(strSchema); JObject jsonObject = JObject.Parse(jsonString); if (jsonObject.IsValid(schema)) { Welcome welcome = Welcome.FromJson(jsonString); Specimen[] allSpecimens = welcome.Specimens; // populate a dictionary with plant data. IDictionary <long, Plant> plants = new Dictionary <long, Plant>(); foreach (Plant plant in allPlants) { plants.Add(plant.Id, plant); } // iterate over the specimens, to find which ones like water. foreach (Specimen specimen in allSpecimens) { if (plants.ContainsKey(specimen.PlantId)) { waterLovingSpecimens.Add(specimen); } } if (precip < 1) { ViewData["Message"] = "It's dry! Water these plants."; } } else { ViewData["Message"] = "Invalid JSON"; } // TODO only show water-loving specimens ViewData["allSpecimens"] = waterLovingSpecimens; string yearStarted = "2006"; int foo = Convert.ToInt32(yearStarted); string name = "My Plant Diary"; ViewData["Name"] = name; }
private void Window() { var input = citySearch.Text; string data; WebClient client = new WebClient(); string apiCall = "http://api.apixu.com/v1/forecast.json?key=d0e03472b60b4f3d92b135909191102&q=" + input + "&days=5"; try { data = client.DownloadString(apiCall); var weather = Welcome.FromJson(data); BitmapImage image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri("http:" + weather.Forecast.Forecastday[0].Day.Condition.Icon); image.EndInit(); img1.Source = image; cityName.Text = weather.Location.Name + "\n" + weather.Location.Country; date1.Text = weather.Forecast.Forecastday[0].Date.Date.ToString("dd.MM.yy"); avgTempDescription.Text = weather.Forecast.Forecastday[0].Day.AvgtempC + " °C " + weather.Forecast.Forecastday[0].Day.Condition.Text; Temp.Text = "Min temp: \t Max temp: \n" + weather.Forecast.Forecastday[0].Day.MintempC + " °C \t\t" + weather.Forecast.Forecastday[0].Day.MaxtempC + " °C "; avgHumidity.Text = "Humidity: " + weather.Forecast.Forecastday[0].Day.Avghumidity + " %"; avgWindSpeed.Text = "Wind speed: " + weather.Forecast.Forecastday[0].Day.MaxwindKph + " k/h"; BitmapImage image2 = new BitmapImage(); image2.BeginInit(); image2.UriSource = new Uri("http:" + weather.Forecast.Forecastday[1].Day.Condition.Icon); image2.EndInit(); img2.Source = image2; date2.Text = weather.Forecast.Forecastday[1].Date.Date.ToString("dd.MM.yy"); avgTempDescription2.Text = weather.Forecast.Forecastday[1].Day.AvgtempC + " °C " + weather.Forecast.Forecastday[1].Day.Condition.Text; Temp2.Text = "Min temp: \t Max temp: \n" + weather.Forecast.Forecastday[1].Day.MintempC + " °C \t\t" + weather.Forecast.Forecastday[1].Day.MaxtempC + " °C "; avgHumidity2.Text = "Humidity: " + weather.Forecast.Forecastday[1].Day.Avghumidity + " %"; avgWindSpeed2.Text = "Wind speed: " + weather.Forecast.Forecastday[1].Day.MaxwindKph + " k/h"; BitmapImage image3 = new BitmapImage(); image3.BeginInit(); image3.UriSource = new Uri("http:" + weather.Forecast.Forecastday[2].Day.Condition.Icon); image3.EndInit(); img3.Source = image3; date3.Text = weather.Forecast.Forecastday[2].Date.Date.ToString("dd.MM.yy"); avgTempDescription3.Text = weather.Forecast.Forecastday[2].Day.AvgtempC + " °C " + weather.Forecast.Forecastday[2].Day.Condition.Text; Temp3.Text = "Min temp: \t Max temp: \n" + weather.Forecast.Forecastday[2].Day.MintempC + " °C \t\t" + weather.Forecast.Forecastday[2].Day.MaxtempC + " °C "; avgHumidity3.Text = "Humidity: " + weather.Forecast.Forecastday[2].Day.Avghumidity + " %"; avgWindSpeed3.Text = "Wind speed: " + weather.Forecast.Forecastday[2].Day.MaxwindKph + " k/h"; BitmapImage image4 = new BitmapImage(); image4.BeginInit(); image4.UriSource = new Uri("http:" + weather.Forecast.Forecastday[3].Day.Condition.Icon); image4.EndInit(); img4.Source = image4; date4.Text = weather.Forecast.Forecastday[3].Date.Date.ToString("dd.MM.yy"); avgTempDescription4.Text = weather.Forecast.Forecastday[3].Day.AvgtempC + " °C " + weather.Forecast.Forecastday[3].Day.Condition.Text; Temp4.Text = "Min temp: \t Max temp: \n" + weather.Forecast.Forecastday[3].Day.MintempC + " °C \t\t" + weather.Forecast.Forecastday[3].Day.MaxtempC + " °C "; avgHumidity4.Text = "Humidity: " + weather.Forecast.Forecastday[3].Day.Avghumidity + " %"; avgWindSpeed4.Text = "Wind speed: " + weather.Forecast.Forecastday[3].Day.MaxwindKph + " k/h"; BitmapImage image5 = new BitmapImage(); image5.BeginInit(); image5.UriSource = new Uri("http:" + weather.Forecast.Forecastday[4].Day.Condition.Icon); image5.EndInit(); img5.Source = image5; date5.Text = weather.Forecast.Forecastday[4].Date.Date.ToString("dd.MM.yy"); avgTempDescription5.Text = weather.Forecast.Forecastday[4].Day.AvgtempC + " °C " + weather.Forecast.Forecastday[4].Day.Condition.Text; Temp5.Text = "Min temp: \t Max temp: \n" + weather.Forecast.Forecastday[4].Day.MintempC + " °C \t\t" + weather.Forecast.Forecastday[4].Day.MaxtempC + " °C "; avgHumidity5.Text = "Humidity: " + weather.Forecast.Forecastday[4].Day.Avghumidity + " %"; avgWindSpeed5.Text = "Wind speed: " + weather.Forecast.Forecastday[4].Day.MaxwindKph + " k/h"; } catch { cityName.Text = "No results found."; } }
public async Task <IEnumerable <ProcessInfo> > Run(string asset, object args) { List <ProcessInfo> list = new List <ProcessInfo>(); string fileName = null; // string user, password; bunu uzak pc de test et. var dic = args as IDictionary <string, object>; if (null != dic) { if (dic.TryGetValue("fileName", out object temp1) && (null != temp1 && temp1 is string)) { fileName = temp1?.ToString(); } } if (String.IsNullOrEmpty(fileName)) { fileName = @"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"; } var startInfo = new ProcessStartInfo { FileName = fileName, Arguments = "get-process | ConvertTo-Json", RedirectStandardOutput = true, UseShellExecute = false }; using (Process process = Process.Start(startInfo)) { string table = (await process.StandardOutput.ReadToEndAsync())?.Trim(); try { process.Kill(); } catch { } if (!String.IsNullOrEmpty(table)) { var welcome = Welcome.FromJson(table); if (null != welcome) { list.Capacity = welcome.Length; foreach (var item in welcome) { ProcessInfo pi = new ProcessInfo(); pi.CpuUsage = item.Cpu ?? 0.0; pi.Description = item.Description; pi.Id = item.Id.ToString(); pi.MemoryUsage = item.PrivateMemorySize64; pi.Name = item.Name; list.Add(pi); } } } } return(list); }