|
|
|
|
using HighWayIot.Repository.domain;
|
|
|
|
|
using HighWayIot.TouchSocket;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.Remoting.Channels;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using TouchSocket.Sockets;
|
|
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
|
|
|
|
|
namespace RFIDSocket
|
|
|
|
|
{
|
|
|
|
|
public partial class RFIDSocket : Form
|
|
|
|
|
{
|
|
|
|
|
private static DataAnalysis RFIDData = DataAnalysis.Instance;
|
|
|
|
|
private static ServerConnect ServerConnect = ServerConnect.Instance;
|
|
|
|
|
|
|
|
|
|
string CPort = "1234";
|
|
|
|
|
string CIP = "127.0.0.1";
|
|
|
|
|
|
|
|
|
|
int PageNo = 1;
|
|
|
|
|
|
|
|
|
|
private List<RFIDContent> Content = new List<RFIDContent>();
|
|
|
|
|
|
|
|
|
|
public RFIDSocket()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitAction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitAction()
|
|
|
|
|
{
|
|
|
|
|
if (!ServerConnect.State)
|
|
|
|
|
{
|
|
|
|
|
MonitorState.Text = "关";
|
|
|
|
|
MonitorState.BackColor = Color.Yellow;
|
|
|
|
|
}
|
|
|
|
|
else if (ServerConnect.State)
|
|
|
|
|
{
|
|
|
|
|
MonitorState.Text = "开";
|
|
|
|
|
MonitorState.BackColor = Color.LightGreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CPort = ClientPort.Text;
|
|
|
|
|
CIP = ClientIP.Text;
|
|
|
|
|
|
|
|
|
|
ServerIP.DataSource = ServerConnect.IPConfig.Keys.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MonitorOnOff_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!ServerConnect.State)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, bool> results = ServerConnect.ConnectAllServer(CIP, CPort, ServerPort.Text);
|
|
|
|
|
bool flag = false;
|
|
|
|
|
foreach(var pair in results)
|
|
|
|
|
{
|
|
|
|
|
if (!pair.Value)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"{pair.Key}连接启动失败!");
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!flag)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("监听服务启动成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (ServerConnect.State)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, bool> results = ServerConnect.ConnectAllStop();
|
|
|
|
|
bool flag = false;
|
|
|
|
|
foreach (var pair in results)
|
|
|
|
|
{
|
|
|
|
|
if (!pair.Value)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"{pair.Key}连接关闭失败!");
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!flag)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("监听服务关闭成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetPort_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CPort = ClientPort.Text;
|
|
|
|
|
CIP = ClientIP.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TableTimer_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!ServerConnect.State)
|
|
|
|
|
{
|
|
|
|
|
MonitorOnOff.Text = "启动监听";
|
|
|
|
|
MonitorState.Text = "关";
|
|
|
|
|
MonitorState.BackColor = Color.Yellow;
|
|
|
|
|
}
|
|
|
|
|
else if (ServerConnect.State)
|
|
|
|
|
{
|
|
|
|
|
MonitorOnOff.Text = "关闭监听";
|
|
|
|
|
MonitorState.Text = "开";
|
|
|
|
|
MonitorState.BackColor = Color.LightGreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RFIDData.GetData();
|
|
|
|
|
|
|
|
|
|
CotentData.DataSource = null;
|
|
|
|
|
switch (PageNo)
|
|
|
|
|
{
|
|
|
|
|
case 1: ContentPages(0); PageRange.Text = "0 - 50"; break;
|
|
|
|
|
case 2: ContentPages(50); PageRange.Text = "51 - 100"; break;
|
|
|
|
|
case 3: ContentPages(100); PageRange.Text = "101 - 150"; break;
|
|
|
|
|
case 4: ContentPages(150); PageRange.Text = "151 - 200"; break;
|
|
|
|
|
default: ContentPages(0); PageRange.Text = "0 - 50"; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StateRefresh();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RFIDSocket_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ServerConnect.State)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, bool> results = ServerConnect.ConnectAllStop();
|
|
|
|
|
bool flag = false;
|
|
|
|
|
foreach (var pair in results)
|
|
|
|
|
{
|
|
|
|
|
if (!pair.Value)
|
|
|
|
|
{
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
if(MessageBox.Show("退出确认", "部分服务未能完全关闭!确认要退出?", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
results = ServerConnect.ConnectAllDispose();
|
|
|
|
|
flag = false;
|
|
|
|
|
foreach (var pair in results)
|
|
|
|
|
{
|
|
|
|
|
if (!pair.Value)
|
|
|
|
|
{
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("退出确认", "部分服务未能完全释放!确认要退出?", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StateRefresh()
|
|
|
|
|
{
|
|
|
|
|
if (RFIDData.HeartbeatsState.Where(x => x.IP == ServerConnect.IPConfig[ServerIP.Text].ToString()).Count() != 0)
|
|
|
|
|
{
|
|
|
|
|
ConnectPictureBox.Image = Properties.Resources.ConnectNormal;
|
|
|
|
|
ConnectState.Text = "正常";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ConnectPictureBox.Image = Properties.Resources.ConnectWarning;
|
|
|
|
|
ConnectState.Text = "异常";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RFIDData.AlarmState.Where(x => x.IP == ServerConnect.IPConfig[ServerIP.Text].ToString()).Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
DevicePictureBox.Image = Properties.Resources.ConnectNormal;
|
|
|
|
|
DeviceState.Text = "正常";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DevicePictureBox.Image = Properties.Resources.ConnectWarning;
|
|
|
|
|
DeviceState.Text = "异常";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TotalCount.Text = Content.Count.ToString();
|
|
|
|
|
NormalCount.Text = Content.Where(x => x.Tips == "ok").Count().ToString();
|
|
|
|
|
WarningCount.Text = Content.Where(x => x.Tips != "ok").Count().ToString();
|
|
|
|
|
NoReadCount.Text = Content.Where(x => x.Tips == "noread").Count().ToString();
|
|
|
|
|
NearCount.Text = Content.Where(x => x.Tips == "near").Count().ToString();
|
|
|
|
|
ShortCount.Text = Content.Where(x => x.Tips == "short").Count().ToString();
|
|
|
|
|
MultiCount.Text = Content.Where(x => x.Tips == "multi").Count().ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ContentPages(int skip)
|
|
|
|
|
{
|
|
|
|
|
Content = RFIDData.rFIDContents.Where(x => x.IP == ServerConnect.IPConfig[ServerIP.Text].ToString()).Reverse<RFIDContent>().Take(200).ToList();
|
|
|
|
|
CotentData.DataSource = Content.Skip(skip).Take(50).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PgUp_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(PageNo == 1)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("已经是首页!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PageNo--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PgDn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (PageNo == 4)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("已经是尾页!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PageNo++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LogStart_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RFIDLog rFIDLog = new RFIDLog();
|
|
|
|
|
rFIDLog.Show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|