DreamineVMS 1.0.0.0
Windows PC의 RTSP·USB 카메라 영상을 HLS로 변환해 원격 CCTV Viewer에 전달하는 데스크톱 에이전트입니다.
로딩중...
검색중...
일치하는것 없음
AgentSettingsWriter.cs
이 파일의 문서화 페이지로 가기
1using System.IO;
2using System.Text.Json;
3using System.Text.Json.Nodes;
4
6
15public sealed class AgentSettingsWriter
16{
25 private readonly string _settingsPath;
26
36 {
37 _settingsPath = Path.Combine(AppContext.BaseDirectory, "appsettings.local.json");
38 }
39
88 public async Task SaveAsync(string serverUrl, string email, string password, CancellationToken cancellationToken = default)
89 {
90 JsonObject root = await LoadRootAsync(cancellationToken).ConfigureAwait(false);
91
92 root["Agent"] = new JsonObject
93 {
94 ["ServerUrl"] = serverUrl,
95 ["Email"] = email,
96 ["Password"] = password
97 };
98
99 string json = root.ToJsonString(new JsonSerializerOptions { WriteIndented = true });
100 await File.WriteAllTextAsync(_settingsPath, json, cancellationToken).ConfigureAwait(false);
101 }
102
127 private async Task<JsonObject> LoadRootAsync(CancellationToken cancellationToken)
128 {
129 if (!File.Exists(_settingsPath)) return [];
130 string json = await File.ReadAllTextAsync(_settingsPath, cancellationToken).ConfigureAwait(false);
131 if (string.IsNullOrWhiteSpace(json)) return [];
132 return JsonNode.Parse(json) as JsonObject ?? [];
133 }
134}
async Task< JsonObject > LoadRootAsync(CancellationToken cancellationToken)
async Task SaveAsync(string serverUrl, string email, string password, CancellationToken cancellationToken=default)