using Serilog; using System.Runtime.InteropServices; namespace AipGateway.API { public static class LicenseManager { [DllImport("LicenseManager.dll", CallingConvention = CallingConvention.StdCall)] public static extern int ValidateLicense([In] string licenseFilePath, ref int licenseAccounts); public static int LocalValidateLicense() { int licenseAccounts = 0; try { // 현재 실행 위치의 한 단계 위 경로를 얻어옵니다. string currDirectory = Directory.GetCurrentDirectory(); string? parentDirectory = Directory.GetParent(currDirectory)?.FullName; if (parentDirectory == null) { Log.Error("라이센스 파일의 경로를 얻지 못하였습니다."); return -1; } string licenseFilePath = Path.Combine(parentDirectory, "License", "license.xml"); //Log.Information("LicenseFilePath: {0}, {1}", parentDirectory, licenseFilePath); if (!File.Exists(licenseFilePath)) { Log.Error("라이센스 정보를 찾을 수 없습니다."); return -2; } int result = ValidateLicense(licenseFilePath, ref licenseAccounts); if (result != 0) { Log.Error("라이센스 정보가 일치하지 않습니다. [error Code: {0}]", result); return -3; } //Log.Information("라이센스 할당 Accounts: {0} EA.", licenseAccounts); } catch (Exception ex) { Log.Error("라이센스 파일 검증 오류..."); Log.Error("라이센스 파일 검증 오류", ex); return -4; } return licenseAccounts; } } }