You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.1 KiB
69 lines
2.1 KiB
4 years ago
|
using System;
|
||
|
using CK.SCP.Utils;
|
||
|
namespace CK.SCP.Models
|
||
|
{
|
||
|
|
||
|
public static class GlobalConfig
|
||
|
{
|
||
|
public const string ScpDbFileName = "Scp数据库设置.ini";
|
||
|
public const string AppBoxDbFileName = "AppBox数据库设置.ini";
|
||
|
public const string UniApiDbFileName = "接口数据库设置.ini";
|
||
|
public const string UniApiConfigFileName = "ERP接口设置.ini";
|
||
|
public const string DurationFileName = "执行周期设置.ini";
|
||
|
public const string UpdateFileName = "自动更新设置.ini";
|
||
|
|
||
|
public const string WmsDbFileName = "Wms数据库设置.ini";
|
||
|
|
||
|
|
||
|
private static DbSetting _scpDatabase;
|
||
|
private static DbSetting _appboxDatabase;
|
||
|
private static DbSetting _uniApiDatabase;
|
||
|
private static DbSetting _wmsDatabase;
|
||
|
|
||
|
|
||
|
public static DbSetting ScpDatabase
|
||
|
{
|
||
|
get { return _scpDatabase ?? (_scpDatabase = GetConfigValues<DbSetting>(ScpDbFileName)); }
|
||
|
|
||
|
set { _scpDatabase = value; }
|
||
|
}
|
||
|
|
||
|
public static DbSetting AppBoxDatabase
|
||
|
{
|
||
|
get { return _appboxDatabase ?? (_appboxDatabase = GetConfigValues<DbSetting>(AppBoxDbFileName)); }
|
||
|
|
||
|
set { _appboxDatabase = value; }
|
||
|
}
|
||
|
|
||
|
public static DbSetting UniApiDatabase
|
||
|
{
|
||
|
get { return _uniApiDatabase ?? (_uniApiDatabase = GetConfigValues<DbSetting>(UniApiDbFileName)); }
|
||
|
|
||
|
set { _uniApiDatabase = value; }
|
||
|
}
|
||
|
public static DbSetting WmsDatabase
|
||
|
{
|
||
|
get { return _wmsDatabase ?? (_wmsDatabase = GetConfigValues<DbSetting>(WmsDbFileName)); }
|
||
|
|
||
|
set { _wmsDatabase = value; }
|
||
|
}
|
||
|
|
||
|
|
||
|
public static T GetConfigValues<T>(string filename) where T : new()
|
||
|
{
|
||
|
T t = new T();
|
||
|
if (FileHelper.Exists(filename))
|
||
|
{
|
||
|
t = JsonHelper.ReadConfigFromFile<T>(filename);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
throw new Exception($"配置文件{filename}丢失,请重新配置");
|
||
|
}
|
||
|
|
||
|
return t;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|