2024-01-09 17:27:33 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2024-01-16 16:03:13 +08:00
|
|
|
using System.Data;
|
|
|
|
using Aitex.Core.RT.DBCore;
|
2024-01-09 17:27:33 +08:00
|
|
|
using SciChart.Core.Extensions;
|
|
|
|
|
|
|
|
namespace Aitex.Core.RT.DataCollection.HighPerformance;
|
|
|
|
|
2024-01-15 09:38:57 +08:00
|
|
|
public class DataTraceHelper
|
2024-01-09 17:27:33 +08:00
|
|
|
{
|
|
|
|
public static readonly IEnumerable<Type> SupportedValueTypes =
|
2024-01-16 16:03:13 +08:00
|
|
|
[
|
|
|
|
typeof(bool), typeof(double), typeof(float), typeof(int), typeof(uint),
|
|
|
|
typeof(short), typeof(ushort), typeof(long), typeof(ulong)
|
|
|
|
];
|
2024-01-09 17:27:33 +08:00
|
|
|
|
|
|
|
public static string Format<T>(T value)
|
|
|
|
{
|
|
|
|
if (value is bool b)
|
|
|
|
return b ? "'1'" : "'0'";
|
|
|
|
|
|
|
|
if (value is float or double)
|
|
|
|
{
|
|
|
|
var dVal = Convert.ToDouble(value);
|
|
|
|
return dVal.IsNaN() ? "'0.0'" : $"'{value}'";
|
|
|
|
}
|
|
|
|
|
2024-01-16 16:03:13 +08:00
|
|
|
if (value is int or uint or ushort or short or ulong or long)
|
2024-01-09 17:27:33 +08:00
|
|
|
{
|
|
|
|
return $"'{value}'";
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new InvalidCastException("unknown type of data to be cached.");
|
|
|
|
}
|
2024-01-16 16:03:13 +08:00
|
|
|
|
|
|
|
public static DataTable CheckDiskUsage()
|
|
|
|
{
|
|
|
|
var sql = MECF.Framework.Common.Properties.Resources.SqlScript_TableDiskUsage;
|
|
|
|
return DB.ExecuteDataTable(sql);
|
|
|
|
}
|
2024-01-09 17:27:33 +08:00
|
|
|
}
|