[성현모] eCIA 컨피그 동기화

This commit is contained in:
SHM
2025-07-18 17:35:56 +09:00
parent 8f30c01bfb
commit 9e698bfb1e
10 changed files with 108 additions and 6 deletions

View File

@ -0,0 +1,3 @@
{
"ProjectName": "eCIA v2 by SystemX2"
}

View File

@ -9,6 +9,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eCIA_v2.Shared", "eCIA_v2\e
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eCIA_v2.Web", "eCIA_v2\eCIA_v2.Web\eCIA_v2.Web.csproj", "{E1C6EEC0-19BF-433B-AF54-7A85034146A5}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eCIA_v2.Web", "eCIA_v2\eCIA_v2.Web\eCIA_v2.Web.csproj", "{E1C6EEC0-19BF-433B-AF54-7A85034146A5}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{2A3A057F-5D22-31FD-628C-DF5EF75AEF1E}"
ProjectSection(SolutionItems) = preProject
Config\eCIAConfig.json = Config\eCIAConfig.json
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU

View File

@ -1,9 +1,11 @@
@inherits LayoutComponentBase @using eCIA_v2.Shared.Services
@inherits LayoutComponentBase
@inject ConfigService _configService;
<RadzenLayout> <RadzenLayout>
<RadzenBody> <RadzenBody>
<div> <div>
<RadzenText Text="ProjectName"></RadzenText> <RadzenText Text="@($"{_configService?.GetConfig()?.ProjectName}")"></RadzenText>
</div> </div>
<div style="margin:0; padding:0;"> <div style="margin:0; padding:0;">
@Body @Body
@ -16,3 +18,11 @@
</RadzenFooter> </RadzenFooter>
</RadzenLayout> </RadzenLayout>
<RadzenComponents /> <RadzenComponents />
@code{
protected override void OnInitialized()
{
base.OnInitialized();
_configService?.ReadConfig();
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace eCIA_v2.Shared.Models
{
public class eCIAConfig
{
public string ProjectName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,64 @@
using eCIA_v2.Shared.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace eCIA_v2.Shared.Services
{
public class ConfigService
{
private eCIAConfig? config = new eCIAConfig();
public void ReadConfig()
{
string projectDir = Path.Combine(AppContext.BaseDirectory, @"..\..\..\");
//Web프로젝트와 Windows프로젝트간 1뎁스 차이가 있어서 체크후 없으면 경로변경
if (Directory.Exists($"{projectDir}../../Config") == false)
projectDir = Path.Combine(projectDir, @"..\");
string sourceDir = $"{projectDir}../../Config/";
string targetDir = $"{projectDir}/bin/Config/";
CopyDirectory(sourceDir, targetDir);
string readJson = File.ReadAllText($"{targetDir}/eCIAConfig.json");
config = JsonConvert.DeserializeObject<eCIAConfig>(readJson);
}
public static void CopyDirectory(string sourceDir, string targetDir, bool overwrite = true)
{
if (!Directory.Exists(sourceDir))
{
throw new DirectoryNotFoundException($"원본 디렉토리를 찾을 수 없습니다: {sourceDir}");
}
// 대상 디렉토리 생성
Directory.CreateDirectory(targetDir);
// 파일 복사
foreach (string file in Directory.GetFiles(sourceDir))
{
string destFile = Path.Combine(targetDir, Path.GetFileName(file));
File.Copy(file, destFile, overwrite);
}
// 하위 디렉토리 재귀적으로 복사
foreach (string subDir in Directory.GetDirectories(sourceDir))
{
string subDirName = Path.GetFileName(subDir);
string destSubDir = Path.Combine(targetDir, subDirName);
CopyDirectory(subDir, destSubDir, overwrite);
}
}
public eCIAConfig? GetConfig()
{
return config;
}
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Razor"> <Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>

View File

@ -11,6 +11,7 @@ builder.Services.AddRazorComponents()
// Add device-specific services used by the eCIA_v2.Shared project // Add device-specific services used by the eCIA_v2.Shared project
builder.Services.AddSingleton<IFormFactor, FormFactor>(); builder.Services.AddSingleton<IFormFactor, FormFactor>();
builder.Services.AddSingleton<ConfigService>();
builder.Services.AddRadzenComponents(); builder.Services.AddRadzenComponents();

View File

@ -23,11 +23,12 @@ namespace eCIA_v2
builder.Services.AddMauiBlazorWebView(); builder.Services.AddMauiBlazorWebView();
builder.Services.AddRadzenComponents(); builder.Services.AddRadzenComponents();
builder.Services.AddSingleton<ConfigService>();
#if DEBUG #if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools(); builder.Services.AddBlazorWebViewDeveloperTools();
builder.Logging.AddDebug(); builder.Logging.AddDebug();
#endif #endif
return builder.Build(); return builder.Build();
} }
} }

View File

@ -3,6 +3,10 @@
"Windows Machine": { "Windows Machine": {
"commandName": "Project", "commandName": "Project",
"nativeDebugging": false "nativeDebugging": false
},
"WSL": {
"commandName": "WSL2",
"distributionName": ""
} }
} }
} }

View File

@ -37,6 +37,7 @@
<!-- 명시적으로 en-US만 포함 --> <!-- 명시적으로 en-US만 포함 -->
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net9.0-windows10.0.19041.0|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net9.0-windows10.0.19041.0|AnyCPU'">