Update vor Umbau Service
This commit is contained in:
46
API_NetFramework/TableConfigProvider.cs
Normal file
46
API_NetFramework/TableConfigProvider.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
|
||||
namespace WebApp
|
||||
{
|
||||
public class TableConfigRoot
|
||||
{
|
||||
public System.Collections.Generic.List<TableConfig> Tables { get; set; }
|
||||
}
|
||||
|
||||
public class TableConfig
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public string SqlList { get; set; }
|
||||
public string SqlById { get; set; }
|
||||
public string IdField { get; set; }
|
||||
public string DisplayField { get; set; }
|
||||
public string JsonField { get; set; }
|
||||
}
|
||||
|
||||
public static class TableConfigProvider
|
||||
{
|
||||
private static TableConfigRoot _cache;
|
||||
|
||||
public static TableConfigRoot LoadConfig()
|
||||
{
|
||||
if (_cache != null)
|
||||
return _cache;
|
||||
|
||||
// ✅ HttpContext.Current verwenden statt Context
|
||||
string path = HttpContext.Current.Server.MapPath("~/App_Data/TableConfig.json");
|
||||
|
||||
if (!File.Exists(path))
|
||||
throw new FileNotFoundException("TableConfig.json nicht gefunden", path);
|
||||
|
||||
string json = File.ReadAllText(path);
|
||||
_cache = JsonConvert.DeserializeObject<TableConfigRoot>(json);
|
||||
if (_cache.Tables == null) _cache.Tables = new System.Collections.Generic.List<TableConfig>();
|
||||
return _cache;
|
||||
}
|
||||
|
||||
public static void ResetCache() => _cache = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user