feat: CCTV 리스트 Json 파일에서 불러오기로 추가

prototype
HyungJune Kim 7 months ago
parent f4304373b1
commit 90bcf08256

@ -23,5 +23,10 @@ namespace SmartAquaViewer.Classes
public const string DATA_FOLDER = "data_folder"; public const string DATA_FOLDER = "data_folder";
public const string REC_FOLDER = "REC"; public const string REC_FOLDER = "REC";
} }
public class DataFiles
{
public const string CCTV_LIST = "cctvlist.json";
}
} }
} }

@ -75,6 +75,11 @@ namespace SmartAquaViewer.Classes
return DataFilePath; return DataFilePath;
} }
public string GetDataFileContentPath(string filePath)
{
return Path.Combine(CurrentDirectory, DataFilePath, filePath);
}
public void CreateDirectory(string folderName) public void CreateDirectory(string folderName)
{ {
string directoryPath = Path.Combine(Environment.CurrentDirectory, folderName); string directoryPath = Path.Combine(Environment.CurrentDirectory, folderName);

@ -31,6 +31,8 @@ namespace SmartAquaViewer
{ {
ConfigData.Instance.LoadConfig(); ConfigData.Instance.LoadConfig();
CreateDirectories(); CreateDirectories();
Datas.Instance.GetCCTVInfoListFromJson();
} }
private void CreateDirectories() private void CreateDirectories()

@ -2,10 +2,15 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Media.Media3D;
using Newtonsoft.Json;
using SmartAquaViewer.Classes;
using SmartAquaViewer.DataAnalysis; using SmartAquaViewer.DataAnalysis;
using static MaterialDesignThemes.Wpf.Theme.ToolBar; using static MaterialDesignThemes.Wpf.Theme.ToolBar;
@ -41,9 +46,90 @@ namespace SmartAquaViewer.Model
OnPropertyChanged(nameof(WaterQualityList)); OnPropertyChanged(nameof(WaterQualityList));
} }
public void SetCCTVInfoList() public void GetCCTVInfoListFromJson()
{ {
string cctvListPath = Utils.Instance.GetDataFileContentPath(Constants.DataFiles.CCTV_LIST);
if (!File.Exists(cctvListPath))
CreateAndSetMockUpCCTVInfoList(cctvListPath);
return;
string jsonString = File.ReadAllText(cctvListPath);
var cctvInfoList = JsonConvert.DeserializeObject<List<CCTVInfo>>(jsonString) ?? new List<CCTVInfo>();
CctvInfoList = new ObservableCollection<CCTVInfo>(cctvInfoList);
}
public void CreateAndSetMockUpCCTVInfoList(string filePath)
{
CctvInfoList.Clear();
CctvInfoList = new ObservableCollection<CCTVInfo>()
{
new()
{
DeviceId = "000001",
DeviceName = "CCTV 1",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-07",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000002",
DeviceName = "CCTV 2",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-08",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000003",
DeviceName = "CCTV 3",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-01",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000004",
DeviceName = "CCTV 4",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-02",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000005",
DeviceName = "CCTV 5",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-03",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000006",
DeviceName = "CCTV 6",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-04",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000007",
DeviceName = "CCTV 7",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-05",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000008",
DeviceName = "CCTV 8",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-06",
Status = CCTVStatus.Disconnected
}
};
string updatedJson = JsonConvert.SerializeObject(CctvInfoList, Formatting.Indented);
File.WriteAllText(filePath, updatedJson);
}
public ObservableCollection<CCTVInfo> GetCCTVInfoList()
{
return CctvInfoList;
} }
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;

@ -55,7 +55,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="OxyPlot.Wpf" Version="2.2.0" /> <PackageReference Include="OxyPlot.Wpf" Version="2.2.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-rc.1.efcore.9.0.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-rc.1.efcore.9.0.0" />
<PackageReference Include="System.Drawing.Common" Version="9.0.8" /> <PackageReference Include="System.Drawing.Common" Version="9.0.8" />

@ -138,65 +138,7 @@ namespace SmartAquaViewer.ViewModel
BtnVisibilityRight = Visibility.Collapsed; BtnVisibilityRight = Visibility.Collapsed;
BtnVisibilityStop = Visibility.Collapsed; BtnVisibilityStop = Visibility.Collapsed;
CCTVInfoList = new ObservableCollection<CCTVInfo>() CCTVInfoList = Datas.Instance.GetCCTVInfoList();
{
new()
{
DeviceId = "000001",
DeviceName = "CCTV 1",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-07",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000002",
DeviceName = "CCTV 2",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-08",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000003",
DeviceName = "CCTV 3",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-01",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000004",
DeviceName = "CCTV 4",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-02",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000005",
DeviceName = "CCTV 5",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-03",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000006",
DeviceName = "CCTV 6",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-04",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000007",
DeviceName = "CCTV 7",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-05",
Status = CCTVStatus.Disconnected
},
new()
{
DeviceId = "000008",
DeviceName = "CCTV 8",
RtspUrl = "rtsp://210.217.121.58:8554/CAM-06",
Status = CCTVStatus.Disconnected
}
};
BuildPlayers(CCTVInfoList); BuildPlayers(CCTVInfoList);

Loading…
Cancel
Save