ningshuxia
2023-02-07 d027501182b03a0c036af712a2b7f31d55144562
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.DAL.LocalFile
{
    /// <summary>
    /// 监测数据集配置
    /// </summary>
    public class MonitorDataSetConfig
    {
         
        /// <summary>
        /// 监测数据集文件夹
        /// </summary>
        public static string MonitorDataFolder
        {
            get { return _monitor_data_folder; }
        } 
        private static string _monitor_data_folder = "MonitorData";
 
 
        /// <summary>
        /// 信号记录文件扩展名
        /// </summary>
        public static string SignalRecordFileExtension
        {
            get
            {
                return _signal_record_file_extension;
            }
        } 
        private static string _signal_record_file_extension = ".csv";
 
 
        /// <summary>
        /// 文件名间隔字符
        /// </summary>
        public static char Separator
        {
            get
            {
                return _separator;
            }
        }
        private const char _separator = '-';
 
         
        #region Path
 
        /// <summary>
        /// 查询监测数据集文件夹
        /// </summary> 
        public static string GetMonitorDataFolder(long projectId, long sceneId)
        {
            var sceneFolder = FileHelper.GetSceneFolder(projectId, sceneId);
            if (!Directory.Exists(sceneFolder))
                Directory.CreateDirectory(sceneFolder);
            var monitorDataSetFolder = Path.Combine(sceneFolder, MonitorDataFolder);
            if (!Directory.Exists(monitorDataSetFolder))
                Directory.CreateDirectory(monitorDataSetFolder);
            return monitorDataSetFolder;
        }
 
        /// <summary>
        /// 查询日期文件夹
        /// </summary>
        public static string GetMonthFolder(long projectId, long sceneId, int year, int month)
        {
            var monitorDataSetFolder = GetMonitorDataFolder(projectId, sceneId);
            string timeFolderName = "";
            if (month < 10)
            {
                timeFolderName = $"{year}{Separator}0{month}";
            }
            else
            {
                timeFolderName = $"{year}{Separator}{month}";
            }
            var timeFolderPath = Path.Combine(monitorDataSetFolder, timeFolderName);
            if (!Directory.Exists(timeFolderPath))
                Directory.CreateDirectory(timeFolderPath);
            return timeFolderPath;
        }
 
        /// <summary>
        /// 查询监测数据集文件夹 
        /// </summary>
        public static string GetMonitorDataSetFolder(long projectId, long sceneId, long monitorPointId, int year, int month)
        {
            var timeFolder = GetMonthFolder(projectId, sceneId, year, month);
            var monitorPointFolderPath = Path.Combine(timeFolder, monitorPointId.ToString());
            if (!Directory.Exists(monitorPointFolderPath))
                Directory.CreateDirectory(monitorPointFolderPath);
            return monitorPointFolderPath;
        }
 
        /// <summary>
        /// 查询信号记录文件路径
        /// </summary>
        public static string GetSignalRecordFile(long projectId, long sceneId, long monitorPointId, long signaId, int year, int month)
        {
            var monitorPointFolder = GetMonitorDataSetFolder(projectId, sceneId, monitorPointId, year, month);
            var fileName = Path.Combine(monitorPointFolder, signaId + SignalRecordFileExtension);
            return fileName;
        }
        #endregion
 
 
    }
}