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.

95 lines
3.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";
4 years ago
public const string DataCenterDbFileName = "数据中心数据库设置.ini";
public const string ExchangeCenterDbFileName = "交换中心数据库设置.ini";
1 year ago
public const string QiMingERPDatabase = "启明ERP数据库设置.ini";
4 years ago
private static DbSetting _scpDatabase;
private static DbSetting _appboxDatabase;
private static DbSetting _uniApiDatabase;
private static DbSetting _wmsDatabase;
1 year ago
private static DbSetting _qiMingERPDatabase;
4 years ago
private static DbSetting _dcDB;
private static DbSetting _ecDB;
1 year ago
public static DbSetting qiMingERPDatabase
{
get { return _qiMingERPDatabase ?? (_qiMingERPDatabase = GetConfigValues<DbSetting>(QiMingERPDatabase)); }
4 years ago
1 year ago
set { _qiMingERPDatabase = value; }
}
4 years ago
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; }
}
4 years ago
public static DbSetting DataCenterDB
{
get { return _dcDB ?? (_dcDB = GetConfigValues<DbSetting>(DataCenterDbFileName)); }
set { _dcDB = value; }
}
public static DbSetting ExchangeCenterDB
{
get { return _ecDB ?? (_ecDB = GetConfigValues<DbSetting>(ExchangeCenterDbFileName)); }
set { _ecDB = value; }
}
4 years ago
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;
}
}
}