ningshuxia
2025-04-01 f2feed624a3186e020bc0283b41e36eb89164a6c
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
namespace IStation.Service
{
    /// <summary>
    /// 
    /// </summary>
    public partial class ScheduleConfig
    {
        private readonly string _filePath = Path.Combine(
                    Settings.ParasHelper.LocalFile.DataFolderDirectory,
                    Settings.ParasHelper.LocalFile.ScheduleConfigFile);
 
        private Model.ChScheduleConfig _model = null;
 
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Model.ChScheduleConfig Get()
        {
            if (_model == null)
            {
                if (!File.Exists(_filePath))
                    return default;
                var json = File.ReadAllText(_filePath);
                _model = JsonHelper.Json2Object<Model.ChScheduleConfig>(json);
            }
            return _model;
        }
 
        /// <summary>
        /// 获取一输水
        /// </summary>
        public Model.ScheduleConfig GetStation1()
        {
            var config = Get();
            return config?.Station1;
        }
 
 
        /// <summary>
        /// 获取二输水
        /// </summary>
        public Model.ScheduleConfig GetStation2()
        {
            var config = Get();
            return config?.Station2;
        }
 
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Save(Model.ChScheduleConfig model)
        {
            _model = model;
            if (model == null)
                return false;
            var json = JsonHelper.Object2Json(model);
            File.WriteAllText(_filePath, json);
            return true;
        }
 
    }
}