Compare commits

..

No commits in common. "c909ce2cc1b5d82450e98da268470374db06e3b8" and "a61195ca03b0bf1ea7c5d5ba3f071cbf461d348b" have entirely different histories.

View File

@ -1,5 +1,10 @@
using System;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Web.Script.Serialization;
using System.Diagnostics.SymbolStore;
using System.Threading;
using Newtonsoft.Json;
using System.Net.Http;
@ -8,22 +13,20 @@ namespace AIParkingApplication
{
public partial class Statistic : UserControl
{
private readonly HttpClient client;
private readonly Thread thrStatistics;
private const string AIPARKING_CLIENT_HTTP_API_REQUEST = "http://{0}:{1}{2}";
Label lblLoaiXe;
Label lblXeMay;
Label lblOto;
Label lblSoLuong;
Label lblTT;
Label lblSoLuongXeMay;
Label lblSoLuongOto;
public Statistic(string apiUrl)
public Statistic()
{
InitializeComponent();
client = new HttpClient { BaseAddress = new Uri(apiUrl), Timeout = TimeSpan.FromMilliseconds(5000) };
thrStatistics = new Thread(new ThreadStart(GetStatistic));
thrStatistics.IsBackground = true;
Thread thrStatistics = new Thread(new ThreadStart(GetStatistic));
thrStatistics.Start();
}
@ -39,6 +42,8 @@ namespace AIParkingApplication
private async void GETDataFromServer()
{
try
{
using (var client = new HttpClient { BaseAddress = new Uri("http://192.168.1.123:80/"), Timeout = TimeSpan.FromMilliseconds(5000) })
{
HttpResponseMessage response = await client.GetAsync("/api/statistics");
response.EnsureSuccessStatusCode();
@ -59,7 +64,7 @@ namespace AIParkingApplication
{
lblVehicleTotalOut.Text = vehicle.TotelOut;
}));
}
}
catch (Exception ex)
{
@ -72,13 +77,14 @@ namespace AIParkingApplication
tlpStatisticTable.BorderStyle = BorderStyle.FixedSingle;
tlpStatisticTable.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
System.Drawing.Font labelFont = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
lblLoaiXe = new Label() { Text = "Loại xe", Font = labelFont };
lblXeMay = new Label() { Text = "Xe máy", Font = labelFont };
lblOto = new Label() { Text = "Ô tô", Font = labelFont };
lblSoLuong = new Label() { Text = "Số Lượng", Font = labelFont };
lblSoLuongXeMay = new Label() { Text = "0", Font = labelFont };
lblSoLuongOto = new Label() { Text = "0", Font = labelFont };
lblLoaiXe = new Label() { Text = "Loại xe", Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0) };
lblXeMay = new Label() { Text = "Xe máy", Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0) };
lblOto = new Label() { Text = "Ô tô", Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0) };
lblSoLuong = new Label() { Text = "Số Lượng", Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0) };
lblTT = new Label() { Text = "TT", Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0) };
lblSoLuongXeMay = new Label() { Text = "0", Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0) };
lblSoLuongOto = new Label() { Text = "0", Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0) };
//Fill to StaticTable
tlpStatisticTable.Controls.Add(lblLoaiXe, 0, 0);