Shuxia Ning
2024-10-08 cf4967a0aebab18c5a37137f3e4c61b2d73a54bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
namespace IStation.Service
{
    /// <summary>
    /// 
    /// </summary>
    public partial class AnalysisFactor
    {
        private readonly string _filePath = Path.Combine(
                     Settings.ParasHelper.LocalFile.DataFolderDirectory,
                     Settings.ParasHelper.LocalFile.AnalysisFactorFile);
 
 
        private List<Model.AnalysisFactor> _list = null;
 
        /// <summary>
        /// 获取
        /// </summary>
        public List<Model.AnalysisFactor> GetList()
        {
            if (_list == null)
            {
                if (!File.Exists(_filePath))
                    return default;
                var json = File.ReadAllText(_filePath);
                _list = JsonHelper.Json2Object<List<Model.AnalysisFactor>>(json);
            }
            return _list;
        }
 
 
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool Save(List<Model.AnalysisFactor> list)
        {
            _list = list;
            var json = JsonHelper.Object2Json(list);
            File.WriteAllText(_filePath, json);
            return true;
        }
 
    }
}