Statistic - use ApiController instead baseAddress

This commit is contained in:
DucDangAnh 2020-07-01 17:24:38 +07:00
parent d1128f34c2
commit ede593da17
2 changed files with 7 additions and 4 deletions

View File

@ -11,6 +11,8 @@ namespace AIParkingApplication
private LaneIn laneIn;
private LaneOut laneOut;
private StatusBar statusBar;
private Statistic statistic;
public AIParkingApplicationForm()
{
@ -29,6 +31,8 @@ namespace AIParkingApplication
statusBar.Location = new System.Drawing.Point(0, 692);
statusBar.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
Controls.Add(statusBar);
statistic = new Statistic(apiController, TimeSpan.FromMinutes(10));
StartLanes();
}

View File

@ -10,7 +10,7 @@ namespace AIParkingApplication
private readonly Thread thrStatistics;
private readonly TimeSpan updateInterval;
private ParkInfo parkInfo;
private string baseAddress;
private ApiController apiController;
private Label lblLoaiXe;
private Label lblXeMay;
@ -19,10 +19,10 @@ namespace AIParkingApplication
private Label lblSoLuongXeMay;
private Label lblSoLuongOto;
public Statistic(string baseAddress, TimeSpan updateInterval)
public Statistic(ApiController apiController, TimeSpan updateInterval)
{
InitializeComponent();
this.baseAddress = baseAddress;
this.apiController = apiController;
this.updateInterval = updateInterval;
thrStatistics = new Thread(new ThreadStart(GetStatistic)) { IsBackground = true };
thrStatistics.Start();
@ -40,7 +40,6 @@ namespace AIParkingApplication
async void GetDataFromServer()
{
ApiController apiController = new ApiController(this.baseAddress);
parkInfo = await apiController.GetStatisticInfo();
}