157 lines
3.9 KiB
C#
157 lines
3.9 KiB
C#
using System.Configuration;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
namespace EgwControlCenter
|
|
{
|
|
public class AccUtils
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// folder archiviazione dati configurazione (DATA\CONF)
|
|
/// </summary>
|
|
public static string ConfDir
|
|
{
|
|
get
|
|
{
|
|
return System.Windows.Forms.Application.StartupPath;
|
|
}
|
|
}
|
|
|
|
public static string ConfName = "ConfPatrol.json";
|
|
|
|
/// <summary>
|
|
/// folder archiviazione dati storici giornalieri (DATA\DAT)
|
|
/// </summary>
|
|
public static string dataDatDir
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", System.Windows.Forms.Application.StartupPath, CRS("dataDatPath"));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// folder archiviazione dati (DATA)
|
|
/// </summary>
|
|
public static string dataDir
|
|
{
|
|
get
|
|
{
|
|
return System.Windows.Forms.Application.StartupPath;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// File icona default
|
|
/// </summary>
|
|
public static string defIconFilePath
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\favicon.ico", resxDir);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// File persistenza generale
|
|
/// </summary>
|
|
public static string defPersLayerFile
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", dataDatDir, CRS("defaultPersLayerFile"));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// file persistenza generale
|
|
/// </summary>
|
|
public static string histPersLayerFile
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", dataDatDir, DateTime.Now);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// File configurazione default x MAIN
|
|
/// </summary>
|
|
public static string mainConfFilePath
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", ConfDir, CRS("mainConfFile"));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// folder archiviazione dati configurazione (DATA\CONF)
|
|
/// </summary>
|
|
public static string resxDir
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}", System.Windows.Forms.Application.StartupPath, CRS("resxPath"));
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// legge conf in formato INT
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
public static int CRI(string key)
|
|
{
|
|
int answ = 0;
|
|
try
|
|
{
|
|
int.TryParse(CRS(key), out answ);
|
|
//answ = Convert.ToInt32(CRS(key));
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// legge conf in formato stringa
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
public static string CRS(string key)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
var rawVal = ConfigurationManager.AppSettings[key];
|
|
answ = $"{rawVal}";
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// legge conf in formato BOOLean
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
public static bool CRB(string key)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = Convert.ToBoolean(CRS(key));
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
#endregion Public Methods
|
|
}
|
|
} |