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
|
|
|
}
|
}
|