9670e170f2
- cambio livello logging x tracciare meglio funzionamento eventi - modifica modalità serializzazione TSData (nuovo costruttore) x ridurre dimensione cache redis (circa -40%)
54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlTypes;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GWMS.Data
|
|
{
|
|
public class TSData
|
|
{
|
|
#region Public Constructors
|
|
|
|
///// <summary>
|
|
///// Init generico per retrocompatibilità e deserializzazione
|
|
///// </summary>
|
|
public TSData() { }
|
|
|
|
/// <summary>
|
|
/// Costruttore "Smart" per la creazione rapida e ottimizzata
|
|
/// </summary>
|
|
/// <param name="dt"></param>
|
|
/// <param name="val"></param>
|
|
/// <param name="doRound"></param>
|
|
public TSData(DateTime dt, double val, bool doRound = true)
|
|
{
|
|
if (doRound)
|
|
{
|
|
// Arrotonda al secondo: crea una nuova data ignorando i Tick (millisecondi)
|
|
DtEvent = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second);
|
|
// Arrotonda a 2 decimali
|
|
ValDouble = Math.Round(val, 2);
|
|
}
|
|
else
|
|
{
|
|
DtEvent = dt;
|
|
ValDouble = val;
|
|
}
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
[JsonProperty("d")]
|
|
public DateTime DtEvent { get; set; } = DateTime.Now;
|
|
|
|
[JsonProperty("v")]
|
|
public double ValDouble { get; set; } = 0;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
} |