using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.Weight2.Server
{
    public class SysParam 
    {
        /// <summary>
        /// OBJ服务端口
        /// </summary>
        public int OBJ_Port { get; set; } = 20005;

        /// <summary>
        /// 远程服务器
        /// </summary>
        public string BlowingAddr { get; set; } = "127.0.0.1:20006";


        /// <summary>
        /// 数据库保持时间 默认6个月
        /// </summary>
        public int DBKeepMonth { get; set; } = 6;

        public SysParam()
        {
            Load();
        }
        public void Save()
        {
            string json  = Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
            File.WriteAllText("system.json", json);
        }
        public void Load()
        {
            if (!File.Exists("system.json")) 
            {
                return;
            }
            try
            {
                string json = File.ReadAllText("system.json");
                Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
            }
            catch { 
            
            }
        }
    }
}