65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LiMan.Transfer
|
|
{
|
|
public class utils
|
|
{
|
|
/// <summary>
|
|
/// Classe logger
|
|
/// </summary>
|
|
public static Logger lg = LogManager.GetCurrentClassLogger();
|
|
/// <summary>
|
|
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
|
/// </summary>
|
|
/// <param name="txt2log"></param>
|
|
public static void lgInfo(string txt2log)
|
|
{
|
|
lg.Info(txt2log);
|
|
}
|
|
/// <summary>
|
|
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
|
|
/// </summary>
|
|
/// <param name="txt2log"></param>
|
|
public static void lgError(string txt2log)
|
|
{
|
|
lg.Error(txt2log);
|
|
}
|
|
|
|
public static string machineName
|
|
{
|
|
get
|
|
{
|
|
return Dns.GetHostName();
|
|
}
|
|
}
|
|
|
|
public static List<string> machineIp
|
|
{
|
|
get
|
|
{
|
|
List<string> ipList = new List<string>();
|
|
try
|
|
{
|
|
IPAddress[] ipAddresses = Dns.GetHostAddresses(machineName);
|
|
foreach (var ip in ipAddresses)
|
|
{
|
|
ipList.Add($"{ip}");
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
// Machine not found...
|
|
lgError($"Eccezione in recupero MachineIp{Environment.NewLine}{exc}");
|
|
}
|
|
return ipList;
|
|
}
|
|
}
|
|
}
|
|
}
|