diff --git a/IOB-UT-NEXT/IniFile.cs b/IOB-UT-NEXT/IniFile.cs index a23f2453..66114c6a 100644 --- a/IOB-UT-NEXT/IniFile.cs +++ b/IOB-UT-NEXT/IniFile.cs @@ -16,7 +16,6 @@ namespace IOB_UT_NEXT #endregion Public Fields - #region Public Constructors /// @@ -253,9 +252,6 @@ namespace IOB_UT_NEXT #region Private Methods - - // INI filename - /// /// GetPrivateProfileInt: import windows dll functions /// diff --git a/IOB-UT-NEXT/IobWinStatus.cs b/IOB-UT-NEXT/IobWinStatus.cs index c0dd09e4..a5fdfe10 100644 --- a/IOB-UT-NEXT/IobWinStatus.cs +++ b/IOB-UT-NEXT/IobWinStatus.cs @@ -55,6 +55,11 @@ namespace IOB_UT_NEXT /// public DateTime lastUpdate { get; set; } = DateTime.Now.AddDays(-1); + /// + /// Valore minimo da considerare come delta secondi x indicare variazione sui dati temporali + /// + public int minDeltaSec { get; set; } = 5; + /// /// Status del SINGOLO IOB /// @@ -105,11 +110,6 @@ namespace IOB_UT_NEXT /// public Dictionary setupParams { get; set; } = new Dictionary(); - /// - /// Valore minimo da considerare come delta secondi x indicare variazione sui dati temporali - /// - public int minDeltaSec { get; set; } = 5; - #endregion Public Properties #region Public Methods diff --git a/IOB-UT-NEXT/Objects.cs b/IOB-UT-NEXT/Objects.cs index a9a63508..d7cd69eb 100644 --- a/IOB-UT-NEXT/Objects.cs +++ b/IOB-UT-NEXT/Objects.cs @@ -65,8 +65,6 @@ namespace IOB_UT_NEXT /// public class BaseRawTransf { - #region Public Properties - /// /// Data-Ora riferimento (x ordinamento fifo) /// @@ -104,9 +102,7 @@ namespace IOB_UT_NEXT this.mesContent = mesContent; this.mesType = mesType; } - - #endregion Public Properties - } + } #endif /// @@ -813,7 +809,7 @@ namespace IOB_UT_NEXT public int Period { get; set; } = 60; /// - /// UM parametro, impiegato anche x conversione (es epoch --> datetime) + /// UM parametro, impiegato anche x conversione (es epoch --> datetime) /// public string UM { get; set; } = ""; diff --git a/IOB-UT-NEXT/RedisMan.cs b/IOB-UT-NEXT/RedisMan.cs index abfa8ba2..d689f27f 100644 --- a/IOB-UT-NEXT/RedisMan.cs +++ b/IOB-UT-NEXT/RedisMan.cs @@ -26,7 +26,9 @@ namespace IOB_UT_NEXT /// IP/nome server /// Cod IOB /// Tipo di IOB - /// Minima differenza in secondi x considerare variazione dati DataOra + /// + /// Minima differenza in secondi x considerare variazione dati DataOra + /// public RedisIobCache(string codServer, string codIob, string tipoIob, int minDeltaS) { // init dati di base... @@ -1105,16 +1107,16 @@ namespace IOB_UT_NEXT /// protected string currIobType = "ND"; - /// - /// Hash REDIS x dati IOB - /// - protected string redIobKey = ""; - /// /// Nome del channel REDIS x dati IOB /// protected string redIobChannel = "IobChannel"; + /// + /// Hash REDIS x dati IOB + /// + protected string redIobKey = ""; + /// /// Hash REDIS x dati server /// diff --git a/IOB-UT-NEXT/TimeUtils.cs b/IOB-UT-NEXT/TimeUtils.cs index 9d4dae2d..c46e0744 100644 --- a/IOB-UT-NEXT/TimeUtils.cs +++ b/IOB-UT-NEXT/TimeUtils.cs @@ -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 } -} +} \ No newline at end of file diff --git a/IOB-UT-NEXT/baseUtils.cs b/IOB-UT-NEXT/baseUtils.cs index 553ee0ea..ccf8e57b 100644 --- a/IOB-UT-NEXT/baseUtils.cs +++ b/IOB-UT-NEXT/baseUtils.cs @@ -41,15 +41,15 @@ namespace IOB_UT_NEXT /// public static bool MPIO_Online = false; + #endregion Public Fields + #if false /// /// Oggetto connessione REDIS /// - public static RedisIobCache redisMan = new RedisIobCache(); + public static RedisIobCache redisMan = new RedisIobCache(); #endif - #endregion Public Fields - #region Public Properties /// diff --git a/IOB-UT-NEXT/fileMover.cs b/IOB-UT-NEXT/fileMover.cs index 8d7583d7..4c02a6cc 100644 --- a/IOB-UT-NEXT/fileMover.cs +++ b/IOB-UT-NEXT/fileMover.cs @@ -13,15 +13,6 @@ namespace IOB_UT_NEXT /// public class fileMover { - #region Protected Fields - - /// - /// path di lavoro dei metodi leggi/scrivi - /// - protected string _workPath; - - #endregion Protected Fields - #region Public Fields /// @@ -42,7 +33,7 @@ namespace IOB_UT_NEXT /// inizializza il metodo alla cartella indicata /// /// - /// non serve +... x retrocompatibilità... + /// non serve +... x retrocompatibilit�... public fileMover(string _path, string _log) { setDirs(_path); @@ -59,111 +50,6 @@ namespace IOB_UT_NEXT #endregion Public Constructors - #region Private Methods - - /// - /// cerca di caricare la directoryInfo o da httpcontext-application re-position o direttamente come workpath - /// - /// - private DirectoryInfo getDirectoryInfo() - { - DirectoryInfo _di; - _di = new DirectoryInfo(_workPath); - return _di; - } - - /// - /// Recupera oggetto DirInfo da path - /// - /// - /// - private DirectoryInfo getDirectoryInfo(string path) - { - DirectoryInfo _di = new DirectoryInfo(path); - return _di; - } - - /// - /// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente come workpath + nomefile - /// - /// path completo file - /// - private FileInfo getFileInfoByName(string _fullPath) - { - FileInfo _fi; - _fi = new FileInfo(_fullPath); - return _fi; - } - - /// - /// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente come workpath + nomefile - /// - /// cartella file - /// nome file - /// - private FileInfo getFileInfoByName(string _path, string _nomeFile) - { - FileInfo _fi; - _fi = new FileInfo(_path + "\\" + _nomeFile); - return _fi; - } - - /// - /// setta le directory - /// - /// - private void setDirs(string _path) - { - _workPath = _path; - } - - #endregion Private Methods - - #region Protected Methods - - /// - /// converte un byte[] in una string - /// - /// - /// - protected string byteToStr(byte[] _array) - { - System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding(); - return encod.GetString(_array); - } - - /// - /// converte una string in un byte[] - /// - /// - /// - protected byte[] strToByte(string _val) - { - System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding(); - return encod.GetBytes(_val); - } - - /// - /// verifica esistenza directory ed eventualmente crea restituendo nome completo di "/" finale - /// - /// - /// - 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 /// @@ -253,16 +139,15 @@ namespace IOB_UT_NEXT } /// - /// 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. /// /// Lo stream da cui leggere /// Lunghezza buffer iniziale (-1 = default 32k) 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; } + /// + /// Elimina i file + vecchi di maxNumDays giorni + /// + /// + 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}"); + } + } + /// /// elimina il file + vecchio /// @@ -541,24 +443,6 @@ namespace IOB_UT_NEXT catch { } } - /// - /// Elimina i file + vecchi di maxNumDays giorni - /// - /// - public void deleteOlderThan(int maxNumDays) - { - DirectoryInfo _di = checkDir(); - FileInfo[] _fis = _di.GetFiles(); - DateTime dateLimit = DateTime.Now.AddDays(-maxNumDays); - try - { - _fis.Where(x => x.LastWriteTime x.Delete()); - } - catch(Exception exc) - { - Logging.Instance.Error($"Eccezione in deleteOlderThan{Environment.NewLine}{exc}"); - } - } /// /// elenco dei files come array di oggetti FileInfo @@ -582,7 +466,7 @@ namespace IOB_UT_NEXT } /// - /// elimina la directory di lavoro se è dir virtuale mappata + /// elimina la directory di lavoro se � dir virtuale mappata /// /// public bool eliminaDir() @@ -852,7 +736,7 @@ namespace IOB_UT_NEXT /// imposta la dir di lavoro /// /// - /// non serve +... x retrocompatibilità... + /// non serve +... x retrocompatibilit�... 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 + + /// + /// path di lavoro dei metodi leggi/scrivi + /// + protected string _workPath; + + #endregion Protected Fields + + #region Protected Methods + + /// + /// converte un byte[] in una string + /// + /// + /// + protected string byteToStr(byte[] _array) + { + System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding(); + return encod.GetString(_array); + } + + /// + /// converte una string in un byte[] + /// + /// + /// + protected byte[] strToByte(string _val) + { + System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding(); + return encod.GetBytes(_val); + } + + /// + /// verifica esistenza directory ed eventualmente crea restituendo nome completo di "/" finale + /// + /// + /// + 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 + + /// + /// cerca di caricare la directoryInfo o da httpcontext-application re-position o + /// direttamente come workpath + /// + /// + private DirectoryInfo getDirectoryInfo() + { + DirectoryInfo _di; + _di = new DirectoryInfo(_workPath); + return _di; + } + + /// + /// Recupera oggetto DirInfo da path + /// + /// + /// + private DirectoryInfo getDirectoryInfo(string path) + { + DirectoryInfo _di = new DirectoryInfo(path); + return _di; + } + + /// + /// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente + /// come workpath + nomefile + /// + /// path completo file + /// + private FileInfo getFileInfoByName(string _fullPath) + { + FileInfo _fi; + _fi = new FileInfo(_fullPath); + return _fi; + } + + /// + /// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente + /// come workpath + nomefile + /// + /// cartella file + /// nome file + /// + private FileInfo getFileInfoByName(string _path, string _nomeFile) + { + FileInfo _fi; + _fi = new FileInfo(_path + "\\" + _nomeFile); + return _fi; + } + + /// + /// setta le directory + /// + /// + private void setDirs(string _path) + { + _workPath = _path; + } + + #endregion Private Methods } } \ No newline at end of file