68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Net.Http;
|
|||
|
|
using System.Net.Http.Headers;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace FrontEnd
|
|||
|
|
{
|
|||
|
|
public class Cam
|
|||
|
|
{
|
|||
|
|
public int Id { get; set; }
|
|||
|
|
public string Ip { get; set; }
|
|||
|
|
public string Label { get; set; }
|
|||
|
|
public bool Status { get; set; }
|
|||
|
|
public int Client_Id { get; set; }
|
|||
|
|
public float X { get; set; }
|
|||
|
|
public float Y { get; set; }
|
|||
|
|
public float Angle { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class Client
|
|||
|
|
{
|
|||
|
|
public int Id { get; set; }
|
|||
|
|
public string Ip { get; set; }
|
|||
|
|
public string Label { get; set; }
|
|||
|
|
public bool Status { get; set; }
|
|||
|
|
public float X { get; set; }
|
|||
|
|
public float Y { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class Communicator
|
|||
|
|
{
|
|||
|
|
static private HttpClient client = new HttpClient();
|
|||
|
|
|
|||
|
|
static Communicator()
|
|||
|
|
{
|
|||
|
|
client.BaseAddress = new Uri("http://ui.askill.science:8003/");
|
|||
|
|
client.DefaultRequestHeaders.Accept.Clear();
|
|||
|
|
client.DefaultRequestHeaders.Accept.Add(
|
|||
|
|
new MediaTypeWithQualityHeaderValue("application/json"));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static async Task<List<Cam>> GetCamsAsync()
|
|||
|
|
{
|
|||
|
|
List<Cam> cams = null;
|
|||
|
|
HttpResponseMessage response = await client.GetAsync("cam/");
|
|||
|
|
if (response.IsSuccessStatusCode)
|
|||
|
|
{
|
|||
|
|
cams = await response.Content.ReadAsAsync<List<Cam>>();
|
|||
|
|
}
|
|||
|
|
return cams;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static async Task<List<Client>> GetClientsAsync()
|
|||
|
|
{
|
|||
|
|
List<Client> clients = null;
|
|||
|
|
HttpResponseMessage response = await client.GetAsync("client/");
|
|||
|
|
if (response.IsSuccessStatusCode)
|
|||
|
|
{
|
|||
|
|
clients = await response.Content.ReadAsAsync<List<Client>>();
|
|||
|
|
}
|
|||
|
|
return clients;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|