Initial commit

v1.0
This commit is contained in:
2023-03-14 17:30:09 +09:00
parent fa3fe72e21
commit 59dac350d8
25 changed files with 2072 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
using HSUCO_CCTV_Monitoring;
using HSUCO_CCTV_Monitoring.Properties;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HSUCO_Server_Monitoring
{
public partial class MainForm : Form
{
private string configPath = "config.xml";
private Config config;
private List<NVRStatus> nvrStatuses = new List<NVRStatus>();
private readonly object locker = new object();
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
if (!System.IO.File.Exists(configPath))
{
MessageBox.Show("config 파일을 찾을수 없습니다");
Application.Exit();
return;
}
config = XmlSystem.LoadFromPath<Config>("config.xml");
InitializeNVR();
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
Size = Screen.PrimaryScreen.WorkingArea.Size;
tableLayoutPanelMaster.ColumnStyles[0].SizeType = SizeType.Absolute;
tableLayoutPanelMaster.ColumnStyles[0].Width = 1490;
tableLayoutPanelMaster.ColumnStyles[1].SizeType = SizeType.AutoSize;
Task.Run(() => NVR_Runner());
Task.Run(() => CCTV_Runner());
}
public void InitializeNVR()
{
for (int i = 0; i < config.NVR.Count; i++)
{
NVRStatus nvrStatus = new NVRStatus(config.NVR[i].Name, Resources.NVR_Success, Resources.NVR_Fail, Resources.NVR_Inspection);
nvrStatuses.Add(nvrStatus);
flowLayoutPanel.Controls.Add(nvrStatus);
}
}
private void NVR_Runner()
{
Worker worker = new Worker(config);
worker.UpdateMessage += UpdateMessage;
worker.Start_NVR();
}
private void CCTV_Runner()
{
Worker worker = new Worker(config);
worker.UpdateMessage += UpdateMessage;
worker.Start_CCTV();
}
private void UpdateMessage(MessageSender sender, int from, StatusResult result)
{
Invoke((Action)(() =>
{
switch (sender)
{
case MessageSender.NVR:
nvrStatuses[from].StatusUpdate(result, DateTime.Now);
if (result != StatusResult.Success)
{
Log.WriteLog(LogLevel.Trace, "NVR " + (result == StatusResult.Fail ? "Fail" : "Inspection") + " : " + config.NVR[from].Name + " / " + config.NVR[from].IpAddress);
}
break;
case MessageSender.CCTV:
if (result == StatusResult.Success)
{
listBox1.Items.Remove(config.CCTV[from].Name);
listBox2.Items.Remove(config.CCTV[from].Name);
}
else if (result == StatusResult.Inspection)
{
if (!listBox1.Items.Contains((config.CCTV[from].Name)))
{
listBox1.Items.Add(config.CCTV[from].Name);
}
listBox2.Items.Remove(config.CCTV[from].Name);
Log.WriteLog(LogLevel.Trace, "CCTV Inspection : " + config.CCTV[from].Name + " / " + config.CCTV[from].IpAddress);
}
else
{
listBox1.Items.Remove(config.CCTV[from].Name);
if (!listBox2.Items.Contains(config.CCTV[from].Name))
{
listBox2.Items.Add(config.CCTV[from].Name);
}
Log.WriteLog(LogLevel.Trace, "CCTV Fail : " + config.CCTV[from].Name + " / " + config.CCTV[from].IpAddress);
}
break;
default:
break;
}
}));
}
}
}