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 { /// /// 配置 /// public class Setting { private ConnectionConfig _DbConfig; /// /// 数据库配置 /// 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(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()); } } /// /// 系统接口配置 /// public ServerConfig ServerConfig { get; set; } /// /// 系统基础配置 /// public SystemConfig SystemConfig { get; set; } /// /// 系统其他配置 /// public OtherConfig OtherConfig { get; set; } /// /// 获取插件顺序 /// public List 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")); } /// /// 初始化配置 /// public void Iniconfig() { this.SystemConfig = Util.Read(); this.OtherConfig = Util.Read(); this.ServerConfig = Util.Read(); } /// /// 保存配置 /// 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 } } }