SysParam.cs 1.08 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2
using Newtonsoft.Json;
using System;
3
using System.Collections.Generic;
潘栩锋's avatar
潘栩锋 committed
4
using System.IO;
5 6 7 8 9 10
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.Winder.Server
{
潘栩锋's avatar
潘栩锋 committed
11
    public class SysParam
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
    {
        /// <summary>
        /// OBJ服务端口
        /// </summary>
        public int OBJ_Port { get; set; } = 20004;

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

        public SysParam()
        {
            Load();
        }
        public void Save()
        {
潘栩锋's avatar
潘栩锋 committed
29 30
            string json = JsonConvert.SerializeObject(this, Formatting.Indented);
            File.WriteAllText("system.json", json);
31 32 33
        }
        public void Load()
        {
潘栩锋's avatar
潘栩锋 committed
34 35 36 37 38 39 40 41 42
            if (File.Exists("system.json"))
            {
                try
                {
                    string json = File.ReadAllText("system.json");
                    JsonConvert.PopulateObject(json, this);
                }
                catch
                {
43

潘栩锋's avatar
潘栩锋 committed
44 45
                }
            }
46
        }
潘栩锋's avatar
潘栩锋 committed
47

48 49
    }
}