CodeMaid:

- ancora fix librerie base IOB-UT-NEXT
This commit is contained in:
Samuele Locatelli
2022-09-08 18:52:30 +02:00
parent 3a7eff3554
commit d37d71c51d
7 changed files with 173 additions and 176 deletions
-4
View File
@@ -16,7 +16,6 @@ namespace IOB_UT_NEXT
#endregion Public Fields
#region Public Constructors
/// <summary>
@@ -253,9 +252,6 @@ namespace IOB_UT_NEXT
#region Private Methods
// INI filename
/// <summary>
/// GetPrivateProfileInt: import windows dll functions
/// </summary>
+5 -5
View File
@@ -55,6 +55,11 @@ namespace IOB_UT_NEXT
/// </summary>
public DateTime lastUpdate { get; set; } = DateTime.Now.AddDays(-1);
/// <summary>
/// Valore minimo da considerare come delta secondi x indicare variazione sui dati temporali
/// </summary>
public int minDeltaSec { get; set; } = 5;
/// <summary>
/// Status del SINGOLO IOB
/// </summary>
@@ -105,11 +110,6 @@ namespace IOB_UT_NEXT
/// </summary>
public Dictionary<string, string> setupParams { get; set; } = new Dictionary<string, string>();
/// <summary>
/// Valore minimo da considerare come delta secondi x indicare variazione sui dati temporali
/// </summary>
public int minDeltaSec { get; set; } = 5;
#endregion Public Properties
#region Public Methods
+2 -6
View File
@@ -65,8 +65,6 @@ namespace IOB_UT_NEXT
/// </summary>
public class BaseRawTransf
{
#region Public Properties
/// <summary>
/// Data-Ora riferimento (x ordinamento fifo)
/// </summary>
@@ -104,9 +102,7 @@ namespace IOB_UT_NEXT
this.mesContent = mesContent;
this.mesType = mesType;
}
#endregion Public Properties
}
}
#endif
/// <summary>
@@ -813,7 +809,7 @@ namespace IOB_UT_NEXT
public int Period { get; set; } = 60;
/// <summary>
/// UM parametro, impiegato anche x conversione (es epoch --> datetime)
/// UM parametro, impiegato anche x conversione (es epoch --&gt; datetime)
/// </summary>
public string UM { get; set; } = "";
+8 -6
View File
@@ -26,7 +26,9 @@ namespace IOB_UT_NEXT
/// <param name="codServer">IP/nome server</param>
/// <param name="codIob">Cod IOB</param>
/// <param name="tipoIob">Tipo di IOB</param>
/// <param name="minDeltaS">Minima differenza in secondi x considerare variazione dati DataOra</param>
/// <param name="minDeltaS">
/// Minima differenza in secondi x considerare variazione dati DataOra
/// </param>
public RedisIobCache(string codServer, string codIob, string tipoIob, int minDeltaS)
{
// init dati di base...
@@ -1105,16 +1107,16 @@ namespace IOB_UT_NEXT
/// </summary>
protected string currIobType = "ND";
/// <summary>
/// Hash REDIS x dati IOB
/// </summary>
protected string redIobKey = "";
/// <summary>
/// Nome del channel REDIS x dati IOB
/// </summary>
protected string redIobChannel = "IobChannel";
/// <summary>
/// Hash REDIS x dati IOB
/// </summary>
protected string redIobKey = "";
/// <summary>
/// Hash REDIS x dati server
/// </summary>
+6 -6
View File
@@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IOB_UT_NEXT
{
public class TimeUtils
{
#region Public Methods
public static DateTime epochConvert(double epoch)
{
DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, 0); //from start epoch time
DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, 0); //from start epoch time
date = date.AddSeconds(epoch);
return date;
}
#endregion Public Methods
}
}
}
+3 -3
View File
@@ -41,15 +41,15 @@ namespace IOB_UT_NEXT
/// </summary>
public static bool MPIO_Online = false;
#endregion Public Fields
#if false
/// <summary>
/// Oggetto connessione REDIS
/// </summary>
public static RedisIobCache redisMan = new RedisIobCache();
public static RedisIobCache redisMan = new RedisIobCache();
#endif
#endregion Public Fields
#region Public Properties
/// <summary>
+149 -146
View File
@@ -13,15 +13,6 @@ namespace IOB_UT_NEXT
/// </summary>
public class fileMover
{
#region Protected Fields
/// <summary>
/// path di lavoro dei metodi leggi/scrivi
/// </summary>
protected string _workPath;
#endregion Protected Fields
#region Public Fields
/// <summary>
@@ -42,7 +33,7 @@ namespace IOB_UT_NEXT
/// inizializza il metodo alla cartella indicata
/// </summary>
/// <param name="_path"></param>
/// <param name="_log">non serve +... x retrocompatibilità...</param>
/// <param name="_log">non serve +... x retrocompatibilit...</param>
public fileMover(string _path, string _log)
{
setDirs(_path);
@@ -59,111 +50,6 @@ namespace IOB_UT_NEXT
#endregion Public Constructors
#region Private Methods
/// <summary>
/// cerca di caricare la directoryInfo o da httpcontext-application re-position o direttamente come workpath
/// </summary>
/// <returns></returns>
private DirectoryInfo getDirectoryInfo()
{
DirectoryInfo _di;
_di = new DirectoryInfo(_workPath);
return _di;
}
/// <summary>
/// Recupera oggetto DirInfo da path
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
private DirectoryInfo getDirectoryInfo(string path)
{
DirectoryInfo _di = new DirectoryInfo(path);
return _di;
}
/// <summary>
/// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente come workpath + nomefile
/// </summary>
/// <param name="_fullPath">path completo file</param>
/// <returns></returns>
private FileInfo getFileInfoByName(string _fullPath)
{
FileInfo _fi;
_fi = new FileInfo(_fullPath);
return _fi;
}
/// <summary>
/// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente come workpath + nomefile
/// </summary>
/// <param name="_path">cartella file</param>
/// <param name="_nomeFile">nome file</param>
/// <returns></returns>
private FileInfo getFileInfoByName(string _path, string _nomeFile)
{
FileInfo _fi;
_fi = new FileInfo(_path + "\\" + _nomeFile);
return _fi;
}
/// <summary>
/// setta le directory
/// </summary>
/// <param name="_path"></param>
private void setDirs(string _path)
{
_workPath = _path;
}
#endregion Private Methods
#region Protected Methods
/// <summary>
/// converte un byte[] in una string
/// </summary>
/// <param name="_array"></param>
/// <returns></returns>
protected string byteToStr(byte[] _array)
{
System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding();
return encod.GetString(_array);
}
/// <summary>
/// converte una string in un byte[]
/// </summary>
/// <param name="_val"></param>
/// <returns></returns>
protected byte[] strToByte(string _val)
{
System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding();
return encod.GetBytes(_val);
}
/// <summary>
/// verifica esistenza directory ed eventualmente crea restituendo nome completo di "/" finale
/// </summary>
/// <param name="_path"></param>
/// <returns></returns>
protected string verDir(string _path)
{
DirectoryInfo di = getDirectoryInfo(_path);
if (!di.Exists)
{
di.Create();
}
if (!_path.EndsWith("/") && !_path.EndsWith(@"\"))
{
_path += "/";
}
return _path;
}
#endregion Protected Methods
#region Public Methods
/// <summary>
@@ -253,16 +139,15 @@ namespace IOB_UT_NEXT
}
/// <summary>
/// Legge i dati da uno stream fino a quando arriva alla fine.
/// I dati sono restituiti come un byte[] array. un eccezione IOException è
/// sollevata se una delle chiamate IO sottostanti fallisce.
/// Legge i dati da uno stream fino a quando arriva alla fine. I dati sono restituiti come
/// un byte[] array. Un eccezione IOException viene sollevata se una delle chiamate IO
/// sottostanti fallisce.
/// </summary>
/// <param name="stream">Lo stream da cui leggere</param>
/// <param name="initialLength">Lunghezza buffer iniziale (-1 = default 32k)</param>
public static byte[] ReadFully(Stream stream, int initialLength)
{
// If we've been passed an unhelpful initial length, just
// use 32K.
// If we've been passed an unhelpful initial length, just use 32K.
if (initialLength < 1)
{
initialLength = 32768;
@@ -276,8 +161,7 @@ namespace IOB_UT_NEXT
{
read += chunk;
// If we've reached the end of our buffer, check to see if there's
// any more information
// If we've reached the end of our buffer, check to see if there's any more information
if (read == buffer.Length)
{
int nextByte = stream.ReadByte();
@@ -288,8 +172,7 @@ namespace IOB_UT_NEXT
return buffer;
}
// Nope. Resize the buffer, put in the byte we've just
// read, and continue
// Nope. Resize the buffer, put in the byte we've just read, and continue
byte[] newBuffer = new byte[buffer.Length * 2];
Array.Copy(buffer, newBuffer, buffer.Length);
newBuffer[read] = (byte)nextByte;
@@ -513,6 +396,25 @@ namespace IOB_UT_NEXT
return fatto;
}
/// <summary>
/// Elimina i file + vecchi di maxNumDays giorni
/// </summary>
/// <returns></returns>
public void deleteOlderThan(int maxNumDays)
{
DirectoryInfo _di = checkDir();
FileInfo[] _fis = _di.GetFiles();
DateTime dateLimit = DateTime.Now.AddDays(-maxNumDays);
try
{
_fis.Where(x => x.LastWriteTime < dateLimit).ToList().ForEach(x => x.Delete());
}
catch (Exception exc)
{
Logging.Instance.Error($"Eccezione in deleteOlderThan{Environment.NewLine}{exc}");
}
}
/// <summary>
/// elimina il file + vecchio
/// </summary>
@@ -541,24 +443,6 @@ namespace IOB_UT_NEXT
catch
{ }
}
/// <summary>
/// Elimina i file + vecchi di maxNumDays giorni
/// </summary>
/// <returns></returns>
public void deleteOlderThan(int maxNumDays)
{
DirectoryInfo _di = checkDir();
FileInfo[] _fis = _di.GetFiles();
DateTime dateLimit = DateTime.Now.AddDays(-maxNumDays);
try
{
_fis.Where(x => x.LastWriteTime <dateLimit).ToList().ForEach(x => x.Delete());
}
catch(Exception exc)
{
Logging.Instance.Error($"Eccezione in deleteOlderThan{Environment.NewLine}{exc}");
}
}
/// <summary>
/// elenco dei files come array di oggetti FileInfo
@@ -582,7 +466,7 @@ namespace IOB_UT_NEXT
}
/// <summary>
/// elimina la directory di lavoro se è dir virtuale mappata
/// elimina la directory di lavoro se dir virtuale mappata
/// </summary>
/// <returns></returns>
public bool eliminaDir()
@@ -852,7 +736,7 @@ namespace IOB_UT_NEXT
/// imposta la dir di lavoro
/// </summary>
/// <param name="_path"></param>
/// <param name="_log">non serve +... x retrocompatibilità...</param>
/// <param name="_log">non serve +... x retrocompatibilit...</param>
public void setDirectory(string _path, string _log)
{
setDirs(_path);
@@ -911,7 +795,8 @@ namespace IOB_UT_NEXT
{
s.SetLevel(5);
byte[] buffer = new byte[4096];
// effettuo una ricerca dei files corrispondenti al criterio regexp, e per ognuno effettuo inserimento in zipfile...
// effettuo una ricerca dei files corrispondenti al criterio regexp, e per
// ognuno effettuo inserimento in zipfile...
FileInfo[] filesTrovati = elencoFiles_FI(regExp);
ZipEntry entry;
foreach (FileInfo _fi in filesTrovati)
@@ -923,7 +808,8 @@ namespace IOB_UT_NEXT
s.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(_fi.FullName))
{
// Using a fixed size buffer here makes no noticeable difference for output but keeps a lid on memory usage.
// Using a fixed size buffer here makes no noticeable difference for
// output but keeps a lid on memory usage.
int sourceBytes;
do
{
@@ -1026,5 +912,122 @@ namespace IOB_UT_NEXT
}
#endregion Public Methods
#region Protected Fields
/// <summary>
/// path di lavoro dei metodi leggi/scrivi
/// </summary>
protected string _workPath;
#endregion Protected Fields
#region Protected Methods
/// <summary>
/// converte un byte[] in una string
/// </summary>
/// <param name="_array"></param>
/// <returns></returns>
protected string byteToStr(byte[] _array)
{
System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding();
return encod.GetString(_array);
}
/// <summary>
/// converte una string in un byte[]
/// </summary>
/// <param name="_val"></param>
/// <returns></returns>
protected byte[] strToByte(string _val)
{
System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding();
return encod.GetBytes(_val);
}
/// <summary>
/// verifica esistenza directory ed eventualmente crea restituendo nome completo di "/" finale
/// </summary>
/// <param name="_path"></param>
/// <returns></returns>
protected string verDir(string _path)
{
DirectoryInfo di = getDirectoryInfo(_path);
if (!di.Exists)
{
di.Create();
}
if (!_path.EndsWith("/") && !_path.EndsWith(@"\"))
{
_path += "/";
}
return _path;
}
#endregion Protected Methods
#region Private Methods
/// <summary>
/// cerca di caricare la directoryInfo o da httpcontext-application re-position o
/// direttamente come workpath
/// </summary>
/// <returns></returns>
private DirectoryInfo getDirectoryInfo()
{
DirectoryInfo _di;
_di = new DirectoryInfo(_workPath);
return _di;
}
/// <summary>
/// Recupera oggetto DirInfo da path
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
private DirectoryInfo getDirectoryInfo(string path)
{
DirectoryInfo _di = new DirectoryInfo(path);
return _di;
}
/// <summary>
/// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente
/// come workpath + nomefile
/// </summary>
/// <param name="_fullPath">path completo file</param>
/// <returns></returns>
private FileInfo getFileInfoByName(string _fullPath)
{
FileInfo _fi;
_fi = new FileInfo(_fullPath);
return _fi;
}
/// <summary>
/// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente
/// come workpath + nomefile
/// </summary>
/// <param name="_path">cartella file</param>
/// <param name="_nomeFile">nome file</param>
/// <returns></returns>
private FileInfo getFileInfoByName(string _path, string _nomeFile)
{
FileInfo _fi;
_fi = new FileInfo(_path + "\\" + _nomeFile);
return _fi;
}
/// <summary>
/// setta le directory
/// </summary>
/// <param name="_path"></param>
private void setDirs(string _path)
{
_workPath = _path;
}
#endregion Private Methods
}
}