using System; using System.Collections.Generic; using System.Linq; using System.Text; using Misc; using System.Net; using System.IO; using System.ComponentModel; using System.Xml.Serialization; using FLY.Thick.Base.Common; using Newtonsoft.Json; namespace FLY.Thick.Base.Server { //代替TDInitParam public class SysParam : INotifyPropertyChanged { #region 属性,成员变量的代理 /// /// 本机obj服务地址 /// public string Addr { get; set; } = "0.0.0.0:20006"; /// /// AD盒硬件版本, 默认为 A版:flyad7, B版:ad2021 /// public string FlyAdHardwareVersion { get; set; } = "A"; /// /// 数据库保存的月数 /// public int DbKeepMonth { get; set; } = 12; /// /// 数据库路径 /// public string DbDirPath { get; set; } = @"D:\flydata"; #endregion private string param_path = "sysparam.json"; public SysParam() { } public SysParam(string param_path) { if (!string.IsNullOrEmpty(param_path)) this.param_path = param_path; if (!Load()) { Save(); } } public bool Load() { try { if (File.Exists(param_path)) { string json = File.ReadAllText(param_path); JsonConvert.PopulateObject(json, this); return true; } } catch { //异常,没有json 解码失败 } return false; } public bool Save() { try { File.WriteAllText(param_path, JsonConvert.SerializeObject(this, Formatting.Indented)); return true; } catch { //异常,没有json 编码失败 } return false; } #region INotifyPropertyChanged 成员 public event PropertyChangedEventHandler PropertyChanged; #endregion } }