Check requestResult.Data null, Set lblStatusSign.BackColor Status
This commit is contained in:
parent
2aa346ec64
commit
241162c5ee
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
|||
using Newtonsoft.Json;
|
||||
using System.Drawing;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
|
||||
namespace BITable
|
||||
{
|
||||
|
@ -136,6 +137,8 @@ namespace BITable
|
|||
}
|
||||
|
||||
private void ShowImageOnUI(RequestResult requestResult)
|
||||
{
|
||||
if (requestResult != null && requestResult.Data != null)
|
||||
{
|
||||
foreach (var item in requestResult.Data)
|
||||
{
|
||||
|
@ -190,6 +193,7 @@ namespace BITable
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DoRequest(int option, bool isClearFaceImage, bool isClearIDCard)
|
||||
{
|
||||
|
@ -247,7 +251,6 @@ namespace BITable
|
|||
{
|
||||
if (!string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl))
|
||||
{
|
||||
|
||||
DoRequestAPI(1, true, true);
|
||||
}
|
||||
else
|
||||
|
@ -415,6 +418,7 @@ namespace BITable
|
|||
{
|
||||
lblStatus.Text = "ĐANG XỬ LÝ";
|
||||
}));
|
||||
|
||||
if (isClearIDCard)
|
||||
{
|
||||
pictureBoxIDCard.Invoke(new Action(() =>
|
||||
|
@ -476,13 +480,15 @@ namespace BITable
|
|||
{
|
||||
lblStatusSign.Invoke(new Action(() =>
|
||||
{
|
||||
lblStatusSign.BackColor = Color.Blue;
|
||||
lblStatusSign.BackColor = Color.Green;
|
||||
}));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var client = new HttpClient { BaseAddress = new Uri("http://api.bitableconnect.beetai.com/"), Timeout = TimeSpan.FromMilliseconds(10000) })
|
||||
using (var client = new HttpClient { BaseAddress = new Uri("http://api.bitableconnect.beetai.com/"), Timeout = TimeSpan.FromMilliseconds(20000) })
|
||||
{
|
||||
try
|
||||
{
|
||||
string deviceName = string.Empty;
|
||||
txtDeviceName.Invoke(new Action(() =>
|
||||
|
@ -503,6 +509,27 @@ namespace BITable
|
|||
{
|
||||
txtIPAddress.Text = deviceUrl.Substring(7, deviceUrl.Length - 28);
|
||||
}));
|
||||
|
||||
if (!Util.IsPingable(txtIPAddress.Text, out long pingTime))
|
||||
{
|
||||
lblStatusSign.Invoke(new Action(() =>
|
||||
{
|
||||
lblStatusSign.BackColor = Color.Red;
|
||||
}));
|
||||
MessageBox.Show("Không thể ping tới thiết bị!");
|
||||
}
|
||||
else
|
||||
{
|
||||
lblStatusSign.Invoke(new Action(() =>
|
||||
{
|
||||
lblStatusSign.BackColor = Color.Green;
|
||||
}));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Kết nối tới server api gặp sự cố!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user