This commit is contained in:
DucDangAnh 2020-06-24 16:26:56 +07:00
commit d359929042
4 changed files with 449 additions and 0 deletions

View File

@ -57,6 +57,7 @@
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -95,6 +96,12 @@
<Compile Include="PlateProcessor.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Statistic.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Statistic.Designer.cs">
<DependentUpon>Statistic.cs</DependentUpon>
</Compile>
<Compile Include="StatusBar.cs">
<SubType>UserControl</SubType>
</Compile>
@ -121,6 +128,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Statistic.resx">
<DependentUpon>Statistic.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="StatusBar.resx">
<DependentUpon>StatusBar.cs</DependentUpon>
</EmbeddedResource>

201
AIParkingApplication/Statistic.Designer.cs generated Normal file
View File

@ -0,0 +1,201 @@
namespace AIParkingApplication
{
partial class Statistic
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.grbVehicleStatistics = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.lblVehicleTotalOut = new System.Windows.Forms.Label();
this.lblVehicleTotalIn = new System.Windows.Forms.Label();
this.tlpStatisticTable = new System.Windows.Forms.TableLayoutPanel();
this.grbLoginInfo = new System.Windows.Forms.GroupBox();
this.lblAuthorization = new System.Windows.Forms.Label();
this.lblUsername = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.grbVehicleStatistics.SuspendLayout();
this.grbLoginInfo.SuspendLayout();
this.SuspendLayout();
//
// grbVehicleStatistics
//
this.grbVehicleStatistics.Controls.Add(this.label4);
this.grbVehicleStatistics.Controls.Add(this.label3);
this.grbVehicleStatistics.Controls.Add(this.lblVehicleTotalOut);
this.grbVehicleStatistics.Controls.Add(this.lblVehicleTotalIn);
this.grbVehicleStatistics.Controls.Add(this.tlpStatisticTable);
this.grbVehicleStatistics.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbVehicleStatistics.Location = new System.Drawing.Point(1, 1);
this.grbVehicleStatistics.Name = "grbVehicleStatistics";
this.grbVehicleStatistics.Size = new System.Drawing.Size(290, 189);
this.grbVehicleStatistics.TabIndex = 0;
this.grbVehicleStatistics.TabStop = false;
this.grbVehicleStatistics.Text = "Thống kê xe";
//
// label4
//
this.label4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label4.Location = new System.Drawing.Point(183, 133);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(60, 20);
this.label4.TabIndex = 2;
this.label4.Text = "Xe ra";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label3.Location = new System.Drawing.Point(42, 133);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(60, 20);
this.label3.TabIndex = 2;
this.label3.Text = "Xe vào";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblVehicleTotalOut
//
this.lblVehicleTotalOut.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblVehicleTotalOut.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblVehicleTotalOut.Location = new System.Drawing.Point(183, 161);
this.lblVehicleTotalOut.Name = "lblVehicleTotalOut";
this.lblVehicleTotalOut.Size = new System.Drawing.Size(60, 20);
this.lblVehicleTotalOut.TabIndex = 1;
this.lblVehicleTotalOut.Text = "0";
this.lblVehicleTotalOut.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblVehicleTotalIn
//
this.lblVehicleTotalIn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblVehicleTotalIn.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblVehicleTotalIn.Location = new System.Drawing.Point(42, 161);
this.lblVehicleTotalIn.Name = "lblVehicleTotalIn";
this.lblVehicleTotalIn.Size = new System.Drawing.Size(60, 20);
this.lblVehicleTotalIn.TabIndex = 1;
this.lblVehicleTotalIn.Text = "0";
this.lblVehicleTotalIn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// tlpStatisticTable
//
this.tlpStatisticTable.ColumnCount = 2;
this.tlpStatisticTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tlpStatisticTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tlpStatisticTable.Location = new System.Drawing.Point(6, 22);
this.tlpStatisticTable.Name = "tlpStatisticTable";
this.tlpStatisticTable.RowCount = 3;
this.tlpStatisticTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tlpStatisticTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tlpStatisticTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tlpStatisticTable.Size = new System.Drawing.Size(278, 100);
this.tlpStatisticTable.TabIndex = 0;
//
// grbLoginInfo
//
this.grbLoginInfo.Controls.Add(this.lblAuthorization);
this.grbLoginInfo.Controls.Add(this.lblUsername);
this.grbLoginInfo.Controls.Add(this.label2);
this.grbLoginInfo.Controls.Add(this.label1);
this.grbLoginInfo.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbLoginInfo.Location = new System.Drawing.Point(1, 198);
this.grbLoginInfo.Name = "grbLoginInfo";
this.grbLoginInfo.Size = new System.Drawing.Size(290, 93);
this.grbLoginInfo.TabIndex = 1;
this.grbLoginInfo.TabStop = false;
this.grbLoginInfo.Text = "Thông tin đăng nhập";
//
// lblAuthorization
//
this.lblAuthorization.AutoSize = true;
this.lblAuthorization.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblAuthorization.Location = new System.Drawing.Point(109, 60);
this.lblAuthorization.Name = "lblAuthorization";
this.lblAuthorization.Size = new System.Drawing.Size(127, 18);
this.lblAuthorization.TabIndex = 0;
this.lblAuthorization.Text = "Nhân Viên Bảo Vệ";
//
// lblUsername
//
this.lblUsername.AutoSize = true;
this.lblUsername.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblUsername.Location = new System.Drawing.Point(109, 27);
this.lblUsername.Name = "lblUsername";
this.lblUsername.Size = new System.Drawing.Size(48, 18);
this.lblUsername.TabIndex = 0;
this.lblUsername.Text = "baove";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(16, 60);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(85, 18);
this.label2.TabIndex = 0;
this.label2.Text = "Phân quyền";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(16, 27);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(73, 18);
this.label1.TabIndex = 0;
this.label1.Text = "Tài khoản";
//
// Statistic
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.grbLoginInfo);
this.Controls.Add(this.grbVehicleStatistics);
this.Name = "Statistic";
this.Size = new System.Drawing.Size(292, 292);
this.Load += new System.EventHandler(this.Statistic_Load);
this.grbVehicleStatistics.ResumeLayout(false);
this.grbLoginInfo.ResumeLayout(false);
this.grbLoginInfo.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox grbVehicleStatistics;
private System.Windows.Forms.TableLayoutPanel tlpStatisticTable;
private System.Windows.Forms.GroupBox grbLoginInfo;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblAuthorization;
private System.Windows.Forms.Label lblUsername;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label lblVehicleTotalOut;
private System.Windows.Forms.Label lblVehicleTotalIn;
}
}

View File

@ -0,0 +1,118 @@
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;
namespace AIParkingApplication
{
public partial class Statistic : UserControl
{
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()
{
InitializeComponent();
Thread thrStatistics = new Thread(new ThreadStart(GetStatistic));
thrStatistics.Start();
}
private void GetStatistic()
{
while (true)
{
string strGETRequest = GETDataFromServer("192.168.1.123", "80", "/api/statistics");
JavaScriptSerializer js = new JavaScriptSerializer();
var obj = js.Deserialize<dynamic>(strGETRequest);
Vehicle.NumberOfCar = obj["oto"];
Vehicle.NumberOfMoto = obj["moto"];
Vehicle.TotalIn = obj["total_in"];
Vehicle.TotelOut = obj["total_out"];
lblSoLuongXeMay?.Invoke(new Action(() =>
{
lblSoLuongXeMay.Text = Vehicle.NumberOfMoto.ToString();
}));
lblSoLuongOto?.Invoke(new Action(() =>
{
lblSoLuongOto.Text = Vehicle.NumberOfCar.ToString();
}));
lblVehicleTotalIn?.Invoke(new Action(() =>
{
lblVehicleTotalIn.Text = Vehicle.TotalIn;
}));
lblVehicleTotalOut?.Invoke(new Action(() =>
{
lblVehicleTotalOut.Text = Vehicle.TotelOut;
}));
Thread.Sleep(1000);
}
}
private string GETDataFromServer(string serverUrl, string apiPort, string apiPath)
{
string responseString = "";
string requestUriString = string.Format(AIPARKING_CLIENT_HTTP_API_REQUEST, serverUrl, apiPort, apiPath);
var request = (HttpWebRequest)WebRequest.Create(requestUriString);
string postData = $"";
byte[] data = Encoding.ASCII.GetBytes(postData);
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
try
{
var response = (HttpWebResponse)request.GetResponse();
responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
Console.WriteLine(responseString);
}
catch (Exception ex)
{
}
return responseString;
}
private void Statistic_Load(object sender, EventArgs e)
{
tlpStatisticTable.BorderStyle = BorderStyle.FixedSingle;
tlpStatisticTable.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
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);
tlpStatisticTable.Controls.Add(lblXeMay, 0, 1);
tlpStatisticTable.Controls.Add(lblOto, 0, 2);
tlpStatisticTable.Controls.Add(lblSoLuong, 1, 0);
tlpStatisticTable.Controls.Add(lblSoLuongXeMay, 1, 1);
tlpStatisticTable.Controls.Add(lblSoLuongOto, 1, 2);
}
static class Vehicle
{
public static int NumberOfCar { get; set; }
public static int NumberOfMoto { get; set; }
public static string TotalIn { get; set; }
public static string TotelOut { get; set; }
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>