2016379205
- aggiunta ricerca x selVal - completata ricerca veto cancellazione
68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MP.Data
|
|
{
|
|
public class Utils
|
|
{
|
|
#region Public Methods
|
|
|
|
public static string ConvMinToTime(double minutes)
|
|
{
|
|
// FIXME TODO: da rendere parametrico da appsettings.json...
|
|
var ts = TimeSpan.FromMinutes(minutes);
|
|
string answ = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}"; //.{ts.Milliseconds}
|
|
return answ;
|
|
}
|
|
|
|
public static string ConvMsecToTime(long milliseconds)
|
|
{
|
|
// FIXME TODO: da rendere parametrico da appsettings.json...
|
|
var ts = TimeSpan.FromMilliseconds(milliseconds);
|
|
string answ = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}"; //.{ts.Milliseconds}
|
|
return answ;
|
|
}
|
|
|
|
public static async Task SaveToCsv<T>(List<T> reportData, string path)
|
|
{
|
|
var lines = new List<string>();
|
|
IEnumerable<PropertyDescriptor> props = TypeDescriptor.GetProperties(typeof(T)).OfType<PropertyDescriptor>();
|
|
var header = string.Join(";", props.ToList().Select(x => x.Name));
|
|
lines.Add(header);
|
|
var valueLines = reportData.Select(row => string.Join(";", header.Split(';').Select(a => row.GetType().GetProperty(a).GetValue(row, null))));
|
|
lines.AddRange(valueLines);
|
|
await Task.Run(() => File.WriteAllLines(path, lines.ToArray()));
|
|
}
|
|
|
|
public static string redKeyArtUsed
|
|
{
|
|
get => RedHash($"CACHE:CheckArtUsed");
|
|
}
|
|
public static string redKeyTabCheckArt
|
|
{
|
|
get => RedHash($"CACHE:TabCheckArt");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato da funzionalita' DbConfig) + keyName richiesto...
|
|
/// </summary>
|
|
public static string RedHash(string keyName)
|
|
{
|
|
string answ = keyName;
|
|
try
|
|
{
|
|
answ =$"MP:Data:{keyName}";
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |