116 lines
3.7 KiB
C#
116 lines
3.7 KiB
C#
using Api.Framework.SDK;
|
|
using Api.Framework.Tools;
|
|
using Chat.Framework.WXSdk.IPAD;
|
|
using Api.Framework.Tools;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Api.Framework.Timers;
|
|
using Chat.Framework;
|
|
using Api.Framework.Enums;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Api.Framework.Config
|
|
{
|
|
/// <summary>
|
|
/// 配置
|
|
/// </summary>
|
|
public class Setting
|
|
{
|
|
private ConnectionConfig _DbConfig;
|
|
/// <summary>
|
|
/// 数据库配置
|
|
/// </summary>
|
|
public ConnectionConfig DbConfig
|
|
{
|
|
get
|
|
{
|
|
if (_DbConfig == null)
|
|
{
|
|
IniHelper ini = new IniHelper(Util.MapFile("系统配置.ini", "Config"));
|
|
_DbConfig = new ConnectionConfig();
|
|
_DbConfig.ConnectionString = ini.GetValue("数据库", "链接");
|
|
var text = ini.GetValue("数据库", "类型");
|
|
if (!string.IsNullOrEmpty(text))
|
|
_DbConfig.DatabaseType = Util.ConvertEnum<DatabaseType>(int.Parse(ini.GetValue("数据库", "类型")));
|
|
}
|
|
_DbConfig.ConnectionString = _DbConfig.ConnectionString.Replace("Max Pool Size = 30", "Max Pool Size = 99999");
|
|
return _DbConfig;
|
|
}
|
|
set
|
|
{
|
|
_DbConfig = value;
|
|
IniHelper ini = new IniHelper(Util.MapFile("系统配置.ini", "Config"));
|
|
ini.SetValue("数据库", "链接", value.ConnectionString);
|
|
ini.SetValue("数据库", "类型", ((int)_DbConfig.DatabaseType).ToString());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 系统接口配置
|
|
/// </summary>
|
|
public ServerConfig ServerConfig { get; set; }
|
|
|
|
/// <summary>
|
|
/// 系统基础配置
|
|
/// </summary>
|
|
public SystemConfig SystemConfig { get; set; }
|
|
|
|
/// <summary>
|
|
/// 系统其他配置
|
|
/// </summary>
|
|
public OtherConfig OtherConfig { get; set; }
|
|
|
|
/// <summary>
|
|
/// 获取插件顺序
|
|
/// </summary>
|
|
public List<string> Plugins
|
|
{
|
|
get
|
|
{
|
|
return OtherConfig.Plugins;
|
|
}
|
|
}
|
|
|
|
public Setting()
|
|
{
|
|
//if (this.DbConfig.DatabaseType == DatabaseType.SQLITE) this.DbConfig.ConnectionString = string.Format("Data Source={0};Version=3;password={1};Journal Mode=WAL;", Util.MapFile("数据库.db", "Config"), "");
|
|
if (this.DbConfig.DatabaseType == DatabaseType.SQLITE)
|
|
this.DbConfig.ConnectionString = string.Format("Data Source={0};PRAGMA journal_mode=WAL;Version=3;Pooling=True;Max Pool Size=99999;", Util.MapFile("数据库.db", "Config"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化配置
|
|
/// </summary>
|
|
public void Iniconfig()
|
|
{
|
|
this.SystemConfig = Util.Read<SystemConfig>();
|
|
this.OtherConfig = Util.Read<OtherConfig>();
|
|
|
|
|
|
this.ServerConfig = Util.Read<ServerConfig>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存配置
|
|
/// </summary>
|
|
public void Save()
|
|
{
|
|
Util.Save(this.OtherConfig);
|
|
Util.Save(this.ServerConfig);
|
|
Util.Save(this.SystemConfig);
|
|
|
|
ChatClient.WXSdkConfig.MsgConvertToFriend = SystemConfig.msg_wx_convertswich == SwitchType.开启 ? true : false;
|
|
ChatClient.MessFrequentSleepTime = SystemConfig.mess_frequent_sleep_time;
|
|
|
|
#region 重新加载更新订单定时器
|
|
ApiClient.ResetTimer();
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
}
|