148 lines
4.4 KiB
C#
148 lines
4.4 KiB
C#
using IOB_MAN8.Core.Models;
|
|
using EgwCoreLib.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace IOB_MAN8.Core.Config
|
|
{
|
|
public class AppSettings
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Abilitazione notifiche in tray
|
|
/// </summary>
|
|
public bool EnableNotify { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Conf x file gestione IOB
|
|
/// </summary>
|
|
public IobAdaptConf IobAdapt { get; set; } = new IobAdaptConf();
|
|
|
|
/// <summary>
|
|
/// Lista ulteriori configurazioni KeyValuePair
|
|
/// </summary>
|
|
public Dictionary<string, string> OptKVP { get; set; } = new Dictionary<string, string>();
|
|
|
|
/// <summary>
|
|
/// Stringa connessione REDIS
|
|
/// </summary>
|
|
public string Redis { get; set; } = "localhost, DefaultDatabase=10, connectTimeout=5000, syncTimeout=5000, asyncTimeout=5000, abortConnect=false, ssl=false";
|
|
|
|
/// <summary>
|
|
/// Configurazione timers e schedularzione x reboot
|
|
/// </summary>
|
|
public TaskConf TaskData { get; set; } = new TaskConf();
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Restituisce chiave se presente nel dizionario OptKVP
|
|
/// </summary>
|
|
/// <param name="chiave"></param>
|
|
/// <returns></returns>
|
|
public string GetKVP(string chiave)
|
|
{
|
|
string answ = "";
|
|
if (OptKVP.ContainsKey(chiave))
|
|
{
|
|
answ = OptKVP[chiave];
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Restituisce chiave se presente nel dizionario OptKVP convertita come INT
|
|
/// </summary>
|
|
/// <param name="chiave"></param>
|
|
/// <returns>Se non la trova restituisce defaultVal</returns>
|
|
public int GetKVP_Int(string chiave, int defaultVal)
|
|
{
|
|
int answ = defaultVal;
|
|
if (OptKVP.ContainsKey(chiave))
|
|
{
|
|
var rawVal = OptKVP[chiave];
|
|
if (!string.IsNullOrEmpty(rawVal))
|
|
{
|
|
int.TryParse(rawVal, out answ);
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Public Classes
|
|
|
|
public class IobAdaptConf
|
|
{
|
|
#region Public Properties
|
|
|
|
public string ConfDir { get; set; } = "CONF";
|
|
public string ConfFile { get; set; } = "IOB-MAN-CONFIG.json";
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
public class TaskConf
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Abilitazione autoreboot (da verifica conf)
|
|
/// </summary>
|
|
[NotMapped]
|
|
public bool AutoRebootEnabled
|
|
{
|
|
get => !string.IsNullOrEmpty(AutoRebootSched) && AutoRebootSched.Contains(":");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Intervallo in minuti esecuzione task, default 1440 = 1 day
|
|
/// </summary>
|
|
public int AutoRebootMinutes { get; set; } = 1440;
|
|
|
|
/// <summary>
|
|
/// DataOra autoreboot, se != null è abilitato
|
|
/// </summary>
|
|
public string AutoRebootSched { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Data ora autoriavvio come timespan sul giorno, default zero = midnight
|
|
/// </summary>
|
|
[NotMapped]
|
|
public TimeSpan AutoRebootTSpan
|
|
{
|
|
get
|
|
{
|
|
TimeSpan answ = new TimeSpan(0);
|
|
if (AutoRebootSched.Contains(":"))
|
|
{
|
|
TimeSpan.TryParse(AutoRebootSched, out answ);
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tempo del timer per verifica riavvio processi fermati in caso d autorestart abilitato
|
|
/// </summary>
|
|
public int TimerCheckMSec { get; set; } = 40000;
|
|
|
|
/// <summary>
|
|
/// Tempo del tick-timer per verifica scadenza task di controllo stato
|
|
/// </summary>
|
|
public int TimerFastMSec { get; set; } = 2000;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
#endregion Public Classes
|
|
}
|
|
} |