diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07be0d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,513 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/windows,linux,c,c++,csharp,powershell +# Edit at https://www.toptal.com/developers/gitignore?templates=windows,linux,c,c++,csharp,powershell + +### C ### +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +### C++ ### +# Prerequisites + +# Compiled Object files +*.slo + +# Precompiled Headers + +# Compiled Dynamic libraries + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai + +# Executables + +### Csharp ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.meta +*.iobj +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +### Linux ### + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### PowerShell ### +# Exclude packaged modules +*.zip + +# Exclude .NET assemblies from source + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/windows,linux,c,c++,csharp,powershell \ No newline at end of file diff --git a/HSUCO_CCTV_Monitoring.sln b/HSUCO_CCTV_Monitoring.sln new file mode 100644 index 0000000..1ccac06 --- /dev/null +++ b/HSUCO_CCTV_Monitoring.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32526.322 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HSUCO_CCTV_Monitoring", "HSUCO_CCTV_Monitoring\HSUCO_CCTV_Monitoring.csproj", "{E1F4C9BF-FE6C-4F46-843C-93B4C575703C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E1F4C9BF-FE6C-4F46-843C-93B4C575703C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1F4C9BF-FE6C-4F46-843C-93B4C575703C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1F4C9BF-FE6C-4F46-843C-93B4C575703C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1F4C9BF-FE6C-4F46-843C-93B4C575703C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B311C77A-EE6C-4648-A538-58BD9A4B8620} + EndGlobalSection +EndGlobal diff --git a/HSUCO_CCTV_Monitoring/App.config b/HSUCO_CCTV_Monitoring/App.config new file mode 100644 index 0000000..ecdcf8a --- /dev/null +++ b/HSUCO_CCTV_Monitoring/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/HSUCO_CCTV_Monitoring/DataModel.cs b/HSUCO_CCTV_Monitoring/DataModel.cs new file mode 100644 index 0000000..b37e6af --- /dev/null +++ b/HSUCO_CCTV_Monitoring/DataModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + + +namespace HSUCO_Server_Monitoring +{ + [Serializable] + public struct Config + { + public List NVR { get; set; } + public List CCTV { get; set; } + public int NVR_DelayTime { get; set; } + public int CCTV_DelayTime { get; set; } + public struct Information + { + public string Name { get; set; } + public string IpAddress { get; set; } + } + + } + public enum MessageSender + { + NVR, + CCTV + } + public enum StatusResult + { + Success, + Fail, + Inspection + + } +} diff --git a/HSUCO_CCTV_Monitoring/HSUCO_CCTV_Monitoring.csproj b/HSUCO_CCTV_Monitoring/HSUCO_CCTV_Monitoring.csproj new file mode 100644 index 0000000..f897b81 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/HSUCO_CCTV_Monitoring.csproj @@ -0,0 +1,117 @@ + + + + + Debug + AnyCPU + {E1F4C9BF-FE6C-4F46-843C-93B4C575703C} + WinExe + HSUCO_CCTV_Monitoring + HSUCO_CCTV_Monitoring + v4.7.2 + 512 + true + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + HSUCO_Server_Monitoring.Program + + + + + + + + + + + + + + + + + + + Form + + + MainForm.cs + + + + True + True + Resources.resx + + + + + + UserControl + + + NVRStatus.cs + + + + + MainForm.cs + + + ResXFileCodeGenerator + Designer + Resources.Designer.cs + + + NVRStatus.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HSUCO_CCTV_Monitoring/Log.cs b/HSUCO_CCTV_Monitoring/Log.cs new file mode 100644 index 0000000..963a5be --- /dev/null +++ b/HSUCO_CCTV_Monitoring/Log.cs @@ -0,0 +1,174 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Text; + +namespace HSUCO_Server_Monitoring +{ + public static class Log + { + //로그파일 이름 규칙 어셈블리명-날짜.log + public static LogLevel logLevel { get; set; } + + private static string logDateTime; + + static Log() + { + SetLogFile(DateTime.Now.ToString("yyyy-MM-dd")); // Log파일 이름 세팅을 위한 함수 호출 + } + + /// + /// 로그 파일 리스너 세팅 + /// + /// 로그파일 이름에 들어갈 DateTime String + private static void SetLogFile(string dateTimeString) + { + logDateTime = dateTimeString; + + if (!System.IO.Directory.Exists("logs")) + { + System.IO.Directory.CreateDirectory("logs"); + } + var logFileName = $"logs/{logDateTime}.log"; + Trace.Listeners.Clear(); + Trace.Listeners.Add(new TextWriterTraceListener(new FileStream(logFileName, FileMode.Append, FileAccess.Write, FileShare.Read))); + Trace.Write("====================================================================================================// "); + Trace.Write(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); + Trace.WriteLine(" //===================================================================================================="); + Trace.Flush(); + } + + //FATAL > ERROR > WARN > INFO > DEBUG > TRACE + public static void FATAL(string message) + { + if (LogLevel.FATAL >= logLevel) + { + // Call Location + var stackTrace = new StackTrace(); + var methodBase = stackTrace.GetFrame(1).GetMethod(); + string location = methodBase.DeclaringType != null + ? methodBase.DeclaringType.Name + "/" + : "null/"; + location += methodBase.Name; + // Call Location End + WriteLog(LogLevel.FATAL, location + "\t" + message); + } + } + + public static void ERROR(string message) + { + if (LogLevel.Error >= logLevel) + { + // Call Location + var stackTrace = new StackTrace(); + var methodBase = stackTrace.GetFrame(1).GetMethod(); + string location = methodBase.DeclaringType != null + ? methodBase.DeclaringType.Name + "/" + : "null/"; + location += methodBase.Name; + // Call Location End + WriteLog(LogLevel.Error, location + "\t" + message); + } + } + + public static void WARN(string message) + { + if (LogLevel.Warn >= logLevel) + { + // Call Location + var stackTrace = new StackTrace(); + var methodBase = stackTrace.GetFrame(1).GetMethod(); + string location = methodBase.DeclaringType != null + ? methodBase.DeclaringType.Name + "/" + : "null/"; + location += methodBase.Name; + // Call Location End + WriteLog(LogLevel.Warn, location + "\t" + message); + } + } + + public static void INFO(string message) + { + if (LogLevel.Info >= logLevel) + { + // Call Location + var stackTrace = new StackTrace(); + var methodBase = stackTrace.GetFrame(1).GetMethod(); + string location = methodBase.DeclaringType != null + ? methodBase.DeclaringType.Name + "/" + : "null/"; + location += methodBase.Name; + // Call Location End + WriteLog(LogLevel.Info, location + "\t" + message); + } + } + + public static void DEBUG(string message) + { + if (LogLevel.Debug >= logLevel) + { + // Call Location + var stackTrace = new StackTrace(); + var methodBase = stackTrace.GetFrame(1).GetMethod(); + string location = methodBase.DeclaringType != null + ? methodBase.DeclaringType.Name + "/" + : "null/"; + location += methodBase.Name; + // Call Location End + WriteLog(LogLevel.Debug, location + "\t" + message); + } + } + + public static void TRACE(string message) + { + if (LogLevel.Trace >= logLevel) + { + var stackTrace = new StackTrace(); + var methodBase = stackTrace.GetFrame(1).GetMethod(); + string location = methodBase.DeclaringType != null + ? methodBase.DeclaringType.Name + "/" + : "null/"; + location += methodBase.Name; + // Call Location End + WriteLog(LogLevel.Debug, location + "\t" + message); + WriteLog(LogLevel.Trace, message); + } + } + + /// + /// + /// + /// enum LogLevel + /// 로그 메세지 + public static void WriteLog(LogLevel logLevel, string message) + { + string nowDateTime = DateTime.Now.ToString("yyyy-MM-dd"); + if (nowDateTime != logDateTime) + { + SetLogFile(nowDateTime); + } + + // Log String + var stringBuilder = new StringBuilder(); + stringBuilder.Append("["); + stringBuilder.Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); + stringBuilder.Append("]"); + stringBuilder.Append("\t"); + stringBuilder.Append(logLevel); + stringBuilder.Append("\t"); + stringBuilder.Append(message.Trim()); + Trace.WriteLine(stringBuilder.ToString()); + Trace.Flush(); + } + } + + public enum LogLevel + { + Trace, + Debug, + Info, + Warn, + Error, + FATAL + } +} \ No newline at end of file diff --git a/HSUCO_CCTV_Monitoring/MainForm.Designer.cs b/HSUCO_CCTV_Monitoring/MainForm.Designer.cs new file mode 100644 index 0000000..7605779 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/MainForm.Designer.cs @@ -0,0 +1,163 @@ +namespace HSUCO_Server_Monitoring +{ + partial class MainForm + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. + /// + private void InitializeComponent() + { + this.tableLayoutPanelMaster = new System.Windows.Forms.TableLayoutPanel(); + this.label2 = new System.Windows.Forms.Label(); + this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.listBox2 = new System.Windows.Forms.ListBox(); + this.tableLayoutPanelMaster.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanelMaster + // + this.tableLayoutPanelMaster.BackColor = System.Drawing.Color.White; + this.tableLayoutPanelMaster.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; + this.tableLayoutPanelMaster.ColumnCount = 2; + this.tableLayoutPanelMaster.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 500F)); + this.tableLayoutPanelMaster.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelMaster.Controls.Add(this.label2, 1, 2); + this.tableLayoutPanelMaster.Controls.Add(this.flowLayoutPanel, 0, 0); + this.tableLayoutPanelMaster.Controls.Add(this.label1, 1, 0); + this.tableLayoutPanelMaster.Controls.Add(this.listBox1, 1, 1); + this.tableLayoutPanelMaster.Controls.Add(this.listBox2, 1, 3); + this.tableLayoutPanelMaster.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanelMaster.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanelMaster.Margin = new System.Windows.Forms.Padding(0); + this.tableLayoutPanelMaster.Name = "tableLayoutPanelMaster"; + this.tableLayoutPanelMaster.RowCount = 2; + this.tableLayoutPanelMaster.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.tableLayoutPanelMaster.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanelMaster.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.tableLayoutPanelMaster.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanelMaster.Size = new System.Drawing.Size(804, 361); + this.tableLayoutPanelMaster.TabIndex = 4; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.label2.Dock = System.Windows.Forms.DockStyle.Fill; + this.label2.Font = new System.Drawing.Font("마비옛체", 20F, System.Drawing.FontStyle.Bold); + this.label2.ForeColor = System.Drawing.Color.Red; + this.label2.Location = new System.Drawing.Point(502, 181); + this.label2.Margin = new System.Windows.Forms.Padding(0); + this.label2.Name = "label2"; + this.label2.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); + this.label2.Size = new System.Drawing.Size(1274, 30); + this.label2.TabIndex = 6; + this.label2.Text = "CCTV (연결끊김)"; + // + // flowLayoutPanel + // + this.flowLayoutPanel.BackColor = System.Drawing.Color.Black; + this.flowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel.Location = new System.Drawing.Point(1, 1); + this.flowLayoutPanel.Margin = new System.Windows.Forms.Padding(0); + this.flowLayoutPanel.Name = "flowLayoutPanel"; + this.tableLayoutPanelMaster.SetRowSpan(this.flowLayoutPanel, 4); + this.flowLayoutPanel.Size = new System.Drawing.Size(500, 359); + this.flowLayoutPanel.TabIndex = 4; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); + this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.label1.Dock = System.Windows.Forms.DockStyle.Fill; + this.label1.Font = new System.Drawing.Font("마비옛체", 20F, System.Drawing.FontStyle.Bold); + this.label1.ForeColor = System.Drawing.Color.Blue; + this.label1.Location = new System.Drawing.Point(502, 1); + this.label1.Margin = new System.Windows.Forms.Padding(0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); + this.label1.Size = new System.Drawing.Size(1274, 30); + this.label1.TabIndex = 5; + this.label1.Text = "CCTV (점검필요)"; + // + // listBox1 + // + this.listBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); + this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.listBox1.Font = new System.Drawing.Font("마비옛체", 12.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 18; + this.listBox1.Location = new System.Drawing.Point(502, 32); + this.listBox1.Margin = new System.Windows.Forms.Padding(0); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(1274, 148); + this.listBox1.TabIndex = 7; + // + // listBox2 + // + this.listBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.listBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.listBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.listBox2.Font = new System.Drawing.Font("마비옛체", 12.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.listBox2.FormattingEnabled = true; + this.listBox2.ItemHeight = 18; + this.listBox2.Location = new System.Drawing.Point(502, 212); + this.listBox2.Margin = new System.Windows.Forms.Padding(0); + this.listBox2.Name = "listBox2"; + this.listBox2.Size = new System.Drawing.Size(1274, 148); + this.listBox2.TabIndex = 8; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(804, 361); + this.Controls.Add(this.tableLayoutPanelMaster); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MainForm"; + this.Text = "서부권 통합관제센터 CCTV NVR 모니터링"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.tableLayoutPanelMaster.ResumeLayout(false); + this.tableLayoutPanelMaster.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanelMaster; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.ListBox listBox2; + } +} + diff --git a/HSUCO_CCTV_Monitoring/MainForm.cs b/HSUCO_CCTV_Monitoring/MainForm.cs new file mode 100644 index 0000000..9abaa46 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/MainForm.cs @@ -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 nvrStatuses = new List(); + 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.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; + } + })); + } + + + + } +} \ No newline at end of file diff --git a/HSUCO_CCTV_Monitoring/MainForm.resx b/HSUCO_CCTV_Monitoring/MainForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/HSUCO_CCTV_Monitoring/NVRStatus.Designer.cs b/HSUCO_CCTV_Monitoring/NVRStatus.Designer.cs new file mode 100644 index 0000000..55fac85 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/NVRStatus.Designer.cs @@ -0,0 +1,102 @@ +namespace HSUCO_CCTV_Monitoring +{ + partial class NVRStatus + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 구성 요소 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. + /// + private void InitializeComponent() + { + this.label_ServerName = new System.Windows.Forms.Label(); + this.label_LastUpdateTimeName = new System.Windows.Forms.Label(); + this.label_LastUpdateTime = new System.Windows.Forms.Label(); + this.pictureBox_Status = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox_Status)).BeginInit(); + this.SuspendLayout(); + // + // label_ServerName + // + this.label_ServerName.AutoSize = true; + this.label_ServerName.Font = new System.Drawing.Font("마비옛체", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label_ServerName.Location = new System.Drawing.Point(90, 5); + this.label_ServerName.Name = "label_ServerName"; + this.label_ServerName.Size = new System.Drawing.Size(107, 22); + this.label_ServerName.TabIndex = 1; + this.label_ServerName.Text = "주차장 이름"; + // + // label_LastUpdateTimeName + // + this.label_LastUpdateTimeName.AutoSize = true; + this.label_LastUpdateTimeName.Font = new System.Drawing.Font("마비옛체", 13F); + this.label_LastUpdateTimeName.Location = new System.Drawing.Point(90, 35); + this.label_LastUpdateTimeName.Name = "label_LastUpdateTimeName"; + this.label_LastUpdateTimeName.Size = new System.Drawing.Size(158, 20); + this.label_LastUpdateTimeName.TabIndex = 2; + this.label_LastUpdateTimeName.Text = "마지막 상태 변경 시간"; + // + // label_LastUpdateTime + // + this.label_LastUpdateTime.AutoSize = true; + this.label_LastUpdateTime.Font = new System.Drawing.Font("DS-Digital", 13F); + this.label_LastUpdateTime.Location = new System.Drawing.Point(120, 55); + this.label_LastUpdateTime.Name = "label_LastUpdateTime"; + this.label_LastUpdateTime.Size = new System.Drawing.Size(160, 18); + this.label_LastUpdateTime.TabIndex = 3; + this.label_LastUpdateTime.Text = "0000-00-00 00:00:00"; + // + // pictureBox_Status + // + this.pictureBox_Status.Location = new System.Drawing.Point(0, 0); + this.pictureBox_Status.Name = "pictureBox_Status"; + this.pictureBox_Status.Size = new System.Drawing.Size(80, 80); + this.pictureBox_Status.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox_Status.TabIndex = 0; + this.pictureBox_Status.TabStop = false; + // + // ServerStatus + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); + this.Controls.Add(this.label_LastUpdateTime); + this.Controls.Add(this.label_LastUpdateTimeName); + this.Controls.Add(this.label_ServerName); + this.Controls.Add(this.pictureBox_Status); + this.Margin = new System.Windows.Forms.Padding(5); + this.Name = "ServerStatus"; + this.Size = new System.Drawing.Size(288, 80); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox_Status)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox_Status; + private System.Windows.Forms.Label label_ServerName; + private System.Windows.Forms.Label label_LastUpdateTimeName; + private System.Windows.Forms.Label label_LastUpdateTime; + } +} diff --git a/HSUCO_CCTV_Monitoring/NVRStatus.cs b/HSUCO_CCTV_Monitoring/NVRStatus.cs new file mode 100644 index 0000000..2e1b530 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/NVRStatus.cs @@ -0,0 +1,66 @@ +using HSUCO_Server_Monitoring; +using System; +using System.Drawing; +using System.Runtime.Remoting.Channels; +using System.Windows.Forms; + +namespace HSUCO_CCTV_Monitoring +{ + public partial class NVRStatus : UserControl + { + private Image _success; + private Image _fail; + private Image _inspection; + private string _nvrName; + private StatusResult _statusResult; + private DateTime _lastUpdateTime; + + public NVRStatus(string nvrName, Image success, Image fail, Image inspection) + { + _nvrName = nvrName; + + _statusResult = StatusResult.Fail; + _lastUpdateTime = DateTime.Now; + + _success = success; + _fail = fail; + _inspection = inspection; + + InitializeComponent(); + label_ServerName.Text = _nvrName; + + DisplayChange(); + } + + public void StatusUpdate(StatusResult result, DateTime dateTime) + { + if (_statusResult != result) + { + _statusResult = result; + _lastUpdateTime = dateTime; + DisplayChange(); + } + + } + + private void DisplayChange() + { + switch(_statusResult) + { + case StatusResult.Success: + pictureBox_Status.Image = _success; + break; + case StatusResult.Fail: + pictureBox_Status.Image = _fail; + break; + case StatusResult.Inspection: + pictureBox_Status.Image = _inspection; + break; + default: + break; + + } + label_LastUpdateTime.Text = _lastUpdateTime.ToString("yyyy-MM-dd HH:mm:ss"); + } + } +} diff --git a/HSUCO_CCTV_Monitoring/NVRStatus.resx b/HSUCO_CCTV_Monitoring/NVRStatus.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/NVRStatus.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/HSUCO_CCTV_Monitoring/Program.cs b/HSUCO_CCTV_Monitoring/Program.cs new file mode 100644 index 0000000..0061202 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace HSUCO_Server_Monitoring +{ + internal static class Program + { + /// + /// 해당 애플리케이션의 주 진입점입니다. + /// + [STAThread] + static void Main() + { + Log.logLevel = LogLevel.Trace; + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/HSUCO_CCTV_Monitoring/Properties/AssemblyInfo.cs b/HSUCO_CCTV_Monitoring/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..019ef84 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("HSUCO_Server_Monitoring")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HSUCO_Server_Monitoring")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("e1f4c9bf-fe6c-4f46-843c-93b4c575703c")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/HSUCO_CCTV_Monitoring/Properties/Resources.Designer.cs b/HSUCO_CCTV_Monitoring/Properties/Resources.Designer.cs new file mode 100644 index 0000000..1ab7fa4 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/Properties/Resources.Designer.cs @@ -0,0 +1,93 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + +namespace HSUCO_CCTV_Monitoring.Properties { + using System; + + + /// + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + /// + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을 + // 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HSUCO_CCTV_Monitoring.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 + /// 재정의합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다. + /// + internal static System.Drawing.Bitmap NVR_Fail { + get { + object obj = ResourceManager.GetObject("NVR_Fail", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다. + /// + internal static System.Drawing.Bitmap NVR_Inspection { + get { + object obj = ResourceManager.GetObject("NVR_Inspection", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다. + /// + internal static System.Drawing.Bitmap NVR_Success { + get { + object obj = ResourceManager.GetObject("NVR_Success", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/HSUCO_CCTV_Monitoring/Properties/Resources.resx b/HSUCO_CCTV_Monitoring/Properties/Resources.resx new file mode 100644 index 0000000..a008de0 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/Properties/Resources.resx @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\NVR_Fail.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\NVR_Inspection.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\NVR_Success.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/HSUCO_CCTV_Monitoring/Properties/Settings.Designer.cs b/HSUCO_CCTV_Monitoring/Properties/Settings.Designer.cs new file mode 100644 index 0000000..72805c2 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + +namespace HSUCO_CCTV_Monitoring.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/HSUCO_CCTV_Monitoring/Properties/Settings.settings b/HSUCO_CCTV_Monitoring/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/HSUCO_CCTV_Monitoring/Resources/NVR_Fail.png b/HSUCO_CCTV_Monitoring/Resources/NVR_Fail.png new file mode 100644 index 0000000..bda18f4 Binary files /dev/null and b/HSUCO_CCTV_Monitoring/Resources/NVR_Fail.png differ diff --git a/HSUCO_CCTV_Monitoring/Resources/NVR_Inspection.png b/HSUCO_CCTV_Monitoring/Resources/NVR_Inspection.png new file mode 100644 index 0000000..c589137 Binary files /dev/null and b/HSUCO_CCTV_Monitoring/Resources/NVR_Inspection.png differ diff --git a/HSUCO_CCTV_Monitoring/Resources/NVR_Success.png b/HSUCO_CCTV_Monitoring/Resources/NVR_Success.png new file mode 100644 index 0000000..8fbb7d4 Binary files /dev/null and b/HSUCO_CCTV_Monitoring/Resources/NVR_Success.png differ diff --git a/HSUCO_CCTV_Monitoring/StatusChecker.cs b/HSUCO_CCTV_Monitoring/StatusChecker.cs new file mode 100644 index 0000000..4826a91 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/StatusChecker.cs @@ -0,0 +1,51 @@ +using System; +using System.Diagnostics.Tracing; +using System.Net.NetworkInformation; +using System.Text; + +namespace HSUCO_Server_Monitoring +{ + public class StatusChecker + { + public StatusResult Check(string ip) + { + try + { + Ping ping = new Ping(); + PingOptions options = new PingOptions(); + options.DontFragment = true; + string data = "hsuco"; + byte[] buffer = ASCIIEncoding.ASCII.GetBytes(data); + int timeout = 120; + const int repetCount = 5; + + int successCount = 0; + for (int i = 0; i < repetCount; i++) + { + var reply = ping.Send(System.Net.IPAddress.Parse(ip), timeout, buffer, options); + if (reply.Status == IPStatus.Success) + { + successCount++; + } + + } + int marginal = (int)(repetCount * 0.6); + if (successCount >= marginal) + { + return StatusResult.Success; + } + if (successCount == 0) + { + return StatusResult.Fail; + } + return StatusResult.Inspection; + } + catch(Exception ex) + { + Log.FATAL(ex.Message); + return StatusResult.Fail; + } + } + + } +} \ No newline at end of file diff --git a/HSUCO_CCTV_Monitoring/Worker.cs b/HSUCO_CCTV_Monitoring/Worker.cs new file mode 100644 index 0000000..5b2f597 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/Worker.cs @@ -0,0 +1,53 @@ +using System.Threading; + +namespace HSUCO_Server_Monitoring +{ + public class Worker + { + public delegate void MessageHandler(MessageSender sender, int from, StatusResult result); + + public event MessageHandler UpdateMessage; + + private bool loop = true; + private Config _config; + public Worker(Config config) + { + _config = config; + + } + public void Start_NVR() + { + StatusChecker statusChecker = new StatusChecker(); + while (loop) + { + for (int i = 0; i < _config.NVR.Count; i++) + { + StatusResult result = statusChecker.Check(_config.NVR[i].IpAddress); + UpdateMessage(MessageSender.NVR, i,result); + } + Thread.Sleep(_config.NVR_DelayTime); + } + } + public void Start_CCTV() + { + int workerCount = _config.CCTV.Count / 50; + + StatusChecker statusChecker = new StatusChecker(); + while (loop) + { + for (int i = 0; i < _config.CCTV.Count; i++) + { + StatusResult result = statusChecker.Check(_config.CCTV[i].IpAddress); + UpdateMessage(MessageSender.CCTV, i, result); + } + Thread.Sleep(_config.CCTV_DelayTime); + } + } + public void End() + { + loop = false; + } + } + + +} diff --git a/HSUCO_CCTV_Monitoring/XmlSystem.cs b/HSUCO_CCTV_Monitoring/XmlSystem.cs new file mode 100644 index 0000000..5b10205 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/XmlSystem.cs @@ -0,0 +1,84 @@ +using System; +using System.IO; +using System.Xml.Serialization; + +namespace HSUCO_Server_Monitoring +{ + public static class XmlSystem + { + public static bool Save(string path, T data) where T : struct + { + if (string.IsNullOrWhiteSpace(path)) + { + return false; + } + string directory = Path.GetDirectoryName(System.IO.Path.GetFullPath(path)); + if (!System.IO.Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + using (StreamWriter sw = new StreamWriter(path)) + { + XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); + XmlSerializerNamespaces xmlSerializerNamespaces = new XmlSerializerNamespaces(); + + xmlSerializerNamespaces.Add("", ""); + xmlSerializer.Serialize(sw, data, xmlSerializerNamespaces); + sw.Close(); + } + return true; + } + + public static T LoadFromPath(string path) where T : struct + { + if (string.IsNullOrWhiteSpace(path)) + { + return default; + } + string directory = Path.GetDirectoryName(System.IO.Path.GetFullPath(path)); + if (!System.IO.Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + if (!File.Exists(path)) + { + return default; + } + using (StreamReader sr = new StreamReader(path)) + { + try + { + XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); + T data = (T)xmlSerializer.Deserialize(sr); + return data; + } + catch (Exception ex) + { + Log.FATAL(ex.Message); + return default; + } + } + } + + public static T LoadFromData(string data) where T : struct + { + if (string.IsNullOrWhiteSpace(data)) + { + return default; + } + using (StringReader sr = new StringReader(data)) + { + try + { + XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); + return (T)xmlSerializer.Deserialize(sr); + } + catch (Exception ex) + { + Log.FATAL(ex.Message); + return default; + } + } + } + } +} diff --git a/HSUCO_CCTV_Monitoring/packages.config b/HSUCO_CCTV_Monitoring/packages.config new file mode 100644 index 0000000..a6f18b8 --- /dev/null +++ b/HSUCO_CCTV_Monitoring/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file