private double Fill(InstallationsOKResponse installationsOKResponse) { double bv = 0; var site = installationsOKResponse.Records.First(); this.dataGridView1.Rows.Clear(); foreach (var item in site.Extended) { var code = item.Code; if (code == "bv") { var rawValue = item.RawValue; bv = Convert.ToDouble(rawValue, CultureInfo.InvariantCulture); //bv = 23; } var description = item.Description; var formattedValue = item.FormattedValue; //formattedValue = this.bv.ToString(); if (!string.IsNullOrEmpty(formattedValue) && !formattedValue.StartsWith("Not")) { //Console.WriteLine(description + ": " + formattedValue); this.dataGridView1.Rows.Add(description, formattedValue); } } long syscreated = site.Syscreated.Value; DateTime sc = DateTimeOffset.FromUnixTimeSeconds(syscreated).LocalDateTime; this.dataGridView1.Rows.Add("syscreated", sc.ToString()); long lastTimestamp = site.LastTimestamp.Value; DateTime lt = DateTimeOffset.FromUnixTimeSeconds(lastTimestamp).LocalDateTime; this.dataGridView1.Rows.Add("last_timestamp", lt.ToString()); this.StartTimer2(lt); string currentTime = site.CurrentTime; this.dataGridView1.Rows.Add("current_time", currentTime); this.dataGridView1.Rows.Add("count", ++count); return(bv); }
public static InstallationsOKResponse GetInstallations() { ServiceClientCredentials credentials = new BasicAuthenticationCredentials(); using (VrmApiClient client = new VrmApiClient(credentials)) { Credential credential = new Credential() { Username = Settings.Default.Username, Password = Settings.Default.Password }; LoginOKResponse loginOKResponse = client.Login(credential); //Console.WriteLine("Login: "******"Bearer " + loginOKResponse.Token; InstallationsOKResponse installationsOKResponse = client.Installations(xAuthorization, loginOKResponse.IdUser, extended: 1); //Console.WriteLine("Installations: " + installationsOKResponse.Success + ", " + installationsOKResponse.Records.Count); //var site = installationsOKResponse.Records.First(); ////var extended = site["extended"] as JArray; ////foreach (var item in extended) ////{ //// Console.WriteLine(item["description"] + ": " + item["formattedValue"]); ////} //int idSite = Convert.ToInt32(site["idSite"]); // long //SystemOverviewOKResponse systemOverviewOKResponse = client.SystemOverview(xAuthorization, idSite); //Console.WriteLine("systemOverviewOKResponse: " + systemOverviewOKResponse.Success.Value + ", " + systemOverviewOKResponse.Records.Devices.Count); //var device = systemOverviewOKResponse.Records.Devices.First(d => (string)d["name"] == "Solar Charger"); //int instance = Convert.ToInt32(device["instance"]); // long //SolarChargerSummaryOKResponse solarChargerSummaryOKResponse = client.SolarChargerSummary(xAuthorization, idSite, instance); //Console.WriteLine("solarChargerSummaryOKResponse: " + solarChargerSummaryOKResponse.Success.Value + ", " + solarChargerSummaryOKResponse.Records.Meta.Count); client.Logout(xAuthorization); //Console.WriteLine("Logout"); return(installationsOKResponse); } }