34 lines
1016 B
C#
Raw Normal View History

2025-04-17 20:28:50 +08:00
namespace JiShe.CollectBus.IoTDB.Provider
2025-04-02 14:06:40 +08:00
{
/// <summary>
/// 设备路径构建器
/// </summary>
public static class DevicePathBuilder
{
/// <summary>
2025-04-03 16:46:26 +08:00
/// 构建设备路径,由于路径的层级约束规范不能是纯数字字符,所以需要做特殊处理。
2025-04-02 14:06:40 +08:00
/// </summary>
/// <typeparam name="T"></typeparam>
2025-04-02 17:23:52 +08:00
/// <param name="entity"></param>
2025-04-02 14:06:40 +08:00
/// <returns></returns>
2025-04-07 16:44:25 +08:00
public static string GetDevicePath<T>(T entity) where T : IoTEntity
2025-04-02 14:06:40 +08:00
{
2025-04-03 16:46:26 +08:00
return $"root.{entity.SystemName.ToLower()}.`{entity.ProjectCode}`.`{entity.DeviceId}`";
2025-04-02 14:06:40 +08:00
}
2025-04-02 17:23:52 +08:00
2025-04-02 14:06:40 +08:00
/// <summary>
2025-04-02 17:23:52 +08:00
/// 获取表名称
2025-04-02 14:06:40 +08:00
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="entity"></param>
/// <returns></returns>
2025-04-02 17:23:52 +08:00
public static string GetTableName<T>() where T : IoTEntity
2025-04-02 14:06:40 +08:00
{
2025-04-02 17:23:52 +08:00
var type = typeof(T);
2025-04-03 16:46:26 +08:00
return $"{type.Name.ToLower()}";
2025-04-02 14:06:40 +08:00
}
}
}