From 62cc21f43df3eddcd4faecc3af12974331f0f346 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 17 Sep 2021 14:51:27 +0200 Subject: [PATCH] Eliminazioni warnings vari codice --- .editorconfig | 3 + NKC_WF/BasePage.cs | 2 +- NKC_WF/BaseUserControl.cs | 4 +- NKC_WF/Compressor.cs | 25 +-- NKC_WF/Controllers/BatchProcController.cs | 2 +- .../cmp_batchDetailSplit.ascx.cs | 37 ++--- NKC_WF/WebUserControls/cmp_footer.ascx.cs | 37 +++-- NKC_WF/WebUserControls/cmp_menuTop.ascx.cs | 111 +++++++------ NKC_WF/WebUserControls/cmp_numRow.ascx.cs | 25 ++- NKC_WF/WebUserControls/mod_righePag.ascx.cs | 152 ++++++++++-------- 10 files changed, 214 insertions(+), 184 deletions(-) diff --git a/.editorconfig b/.editorconfig index 770d280..7932c1e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -41,3 +41,6 @@ dotnet_diagnostic.CA1716.severity = none # CA2227: Le proprietà delle raccolte devono essere di sola lettura dotnet_diagnostic.CA2227.severity = none + +# CA1805: Do not initialize unnecessarily +dotnet_diagnostic.CA1805.severity = none diff --git a/NKC_WF/BasePage.cs b/NKC_WF/BasePage.cs index 2454bf8..b49937d 100644 --- a/NKC_WF/BasePage.cs +++ b/NKC_WF/BasePage.cs @@ -48,7 +48,7 @@ namespace NKC_WF /// public void lgFatal(string message, Exception exc) { - logger.lg.scriviLog(message, tipoLog.FATAL); + logger.lg.scriviLog($"{message}{Environment.NewLine}{exc}", tipoLog.FATAL); } /// diff --git a/NKC_WF/BaseUserControl.cs b/NKC_WF/BaseUserControl.cs index fe00cf3..d29ab87 100644 --- a/NKC_WF/BaseUserControl.cs +++ b/NKC_WF/BaseUserControl.cs @@ -22,7 +22,7 @@ namespace NKC_WF /// /// Codice macchina (da v2) /// - public string PlaceCod = "WRK001"; + public string PlaceCod = "VIRTNE"; #endregion Public Fields @@ -206,7 +206,7 @@ namespace NKC_WF /// public void lgFatal(string message, Exception exc) { - logger.lg.scriviLog(message, tipoLog.FATAL); + logger.lg.scriviLog($"{message}{Environment.NewLine}{exc}", tipoLog.FATAL); } /// diff --git a/NKC_WF/Compressor.cs b/NKC_WF/Compressor.cs index e30cd3f..ddbd6fe 100644 --- a/NKC_WF/Compressor.cs +++ b/NKC_WF/Compressor.cs @@ -5,6 +5,7 @@ namespace NKC_WF { public static class Compressor { + #region Public Methods public static byte[] Compress(byte[] data) { @@ -18,22 +19,28 @@ namespace NKC_WF public static byte[] Decompress(byte[] data) { + byte[] answ = new byte[1]; MemoryStream input = new MemoryStream(); input.Write(data, 0, data.Length); input.Position = 0; GZipStream gzip = new GZipStream(input, CompressionMode.Decompress, true); - MemoryStream output = new MemoryStream(); - byte[] buff = new byte[64]; - int read = -1; - read = gzip.Read(buff, 0, buff.Length); - while (read > 0) + using (MemoryStream output = new MemoryStream()) { - output.Write(buff, 0, read); + byte[] buff = new byte[64]; + int read = -1; read = gzip.Read(buff, 0, buff.Length); + while (read > 0) + { + output.Write(buff, 0, read); + read = gzip.Read(buff, 0, buff.Length); + } + gzip.Close(); + answ = output.ToArray(); } - gzip.Close(); - return output.ToArray(); + return answ; } + + #endregion Public Methods } -} +} \ No newline at end of file diff --git a/NKC_WF/Controllers/BatchProcController.cs b/NKC_WF/Controllers/BatchProcController.cs index cfc5bc7..7ff08f5 100644 --- a/NKC_WF/Controllers/BatchProcController.cs +++ b/NKC_WF/Controllers/BatchProcController.cs @@ -576,7 +576,7 @@ namespace NKC_WF.Controllers answ = "WRONG DATA (expected baseNestAnsw object)"; } } - catch (Exception exc) + catch { answ = "NO"; } diff --git a/NKC_WF/WebUserControls/cmp_batchDetailSplit.ascx.cs b/NKC_WF/WebUserControls/cmp_batchDetailSplit.ascx.cs index 2b6bb98..58fa094 100644 --- a/NKC_WF/WebUserControls/cmp_batchDetailSplit.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_batchDetailSplit.ascx.cs @@ -12,15 +12,6 @@ namespace NKC_WF.WebUserControls { public partial class cmp_batchDetailSplit : BaseUserControl { - #region Protected Fields - - /// - /// Master Place (hard-coded) - /// - protected string PlaceCod = "VIRTNE"; - - #endregion Protected Fields - #region Protected Properties protected bool BatchIsAncestor @@ -59,20 +50,6 @@ namespace NKC_WF.WebUserControls } } - public bool isSplitted - { - get - { - bool answ = false; - bool.TryParse(hfIsSplit.Value, out answ); - return answ; - } - set - { - hfIsSplit.Value = $"{value}"; - } - } - protected int lastValRatio { get @@ -192,6 +169,20 @@ namespace NKC_WF.WebUserControls } } + public bool isSplitted + { + get + { + bool answ = false; + bool.TryParse(hfIsSplit.Value, out answ); + return answ; + } + set + { + hfIsSplit.Value = $"{value}"; + } + } + #endregion Public Properties #region Private Methods diff --git a/NKC_WF/WebUserControls/cmp_footer.ascx.cs b/NKC_WF/WebUserControls/cmp_footer.ascx.cs index 00af3f7..8da28c6 100644 --- a/NKC_WF/WebUserControls/cmp_footer.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_footer.ascx.cs @@ -6,14 +6,14 @@ namespace NKC_WF.WebUserControls { public partial class cmp_footer : BaseUserControl { - public event EventHandler eh_doRefresh; - protected void Page_Load(object sender, EventArgs e) + #region Private Methods + + private void setClock() { - // sistemo le stringhe... - lblApp.Text = string.Format("{0} v.{1}", ConfigurationManager.AppSettings.Get("appName"), System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); - setTimer(); - setClock(); + lblDateTime.Text = DateTime.Now.ToString("ddd dd.MM.yyyy, HH:mm:ss"); + lblCodOperatore.Text = $"{user_std.UtSn.CognomeNome} ({Page.User.Identity.Name})"; } + /// /// imposta il tempo di scadenza del timer x il refresh della pagina (della parte top) per evitare che la sessione sul server scada /// @@ -21,20 +21,25 @@ namespace NKC_WF.WebUserControls { Timer1.Interval = SteamWare.memLayer.ML.confReadInt("intUpdatePagina_ms"); } + + #endregion Private Methods + + #region Protected Methods + + protected void Page_Load(object sender, EventArgs e) + { + // sistemo le stringhe... + lblApp.Text = string.Format("{0} v.{1}", ConfigurationManager.AppSettings.Get("appName"), System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); + setTimer(); + setClock(); + } + protected void Timer1_Tick(object sender, EventArgs e) { setClock(); - // se qualcuno ascolta sollevo evento nuovo valore... - if (eh_doRefresh != null) - { - eh_doRefresh(this, new EventArgs()); - } + raiseEvent(); } - private void setClock() - { - lblDateTime.Text = DateTime.Now.ToString("ddd dd.MM.yyyy, HH:mm:ss"); - lblCodOperatore.Text = $"{user_std.UtSn.CognomeNome} ({Page.User.Identity.Name})"; - } + #endregion Protected Methods } } \ No newline at end of file diff --git a/NKC_WF/WebUserControls/cmp_menuTop.ascx.cs b/NKC_WF/WebUserControls/cmp_menuTop.ascx.cs index 31b4edf..4faeab6 100644 --- a/NKC_WF/WebUserControls/cmp_menuTop.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_menuTop.ascx.cs @@ -7,44 +7,27 @@ namespace NKC_WF.WebUserControls { public partial class cmp_menuTop : BaseUserControl { - public event EventHandler eh_doRefresh; - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - checkAuth(); - searchVal = ""; - doSearch(); - updateTreeMenu(); - } - } - - private void checkAuth() - { - // in primis SOLO SE non è permesso login anonymous... - if (!enableAnonym) - { - if (!Page.User.Identity.IsAuthenticated) - { - Response.Redirect("default"); - } - } - } + #region Protected Properties /// - /// imposta visibilità search globale + /// Valore ricerca attivo /// - public bool showSearch + protected string searchVal { get { - return divSearch.Visible; + return txtSearch.Text.Trim(); } set { - divSearch.Visible = value; + txtSearch.Text = value.Trim(); } } + + #endregion Protected Properties + + #region Public Properties + /// /// Abilitazione esecuzione anonima /// @@ -62,9 +45,35 @@ namespace NKC_WF.WebUserControls } } - protected void txtSearch_TextChanged(object sender, EventArgs e) + /// + /// imposta visibilità search globale + /// + public bool showSearch { - doSearch(); + get + { + return divSearch.Visible; + } + set + { + divSearch.Visible = value; + } + } + + #endregion Public Properties + + #region Private Methods + + private void checkAuth() + { + // in primis SOLO SE non è permesso login anonymous... + if (!enableAnonym) + { + if (!Page.User.Identity.IsAuthenticated) + { + Response.Redirect("default"); + } + } } private void doSearch() @@ -78,27 +87,9 @@ namespace NKC_WF.WebUserControls { memLayer.ML.emptySessionVal("valoreSearch"); } - // se qualcuno ascolta sollevo evento nuovo valore... - if (eh_doRefresh != null) - { - eh_doRefresh(this, new EventArgs()); - } + raiseEvent(); } - /// - /// Valore ricerca attivo - /// - protected string searchVal - { - get - { - return txtSearch.Text.Trim(); - } - set - { - txtSearch.Text = value.Trim(); - } - } /// /// aggiornamento del menù /// @@ -127,6 +118,11 @@ namespace NKC_WF.WebUserControls } } } + + #endregion Private Methods + + #region Protected Methods + /// /// click su pagina corrente, fa update! /// @@ -140,9 +136,28 @@ namespace NKC_WF.WebUserControls Response.Redirect("default"); } } + protected void lbtSearch_Click(object sender, EventArgs e) { doSearch(); } + + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + checkAuth(); + searchVal = ""; + doSearch(); + updateTreeMenu(); + } + } + + protected void txtSearch_TextChanged(object sender, EventArgs e) + { + doSearch(); + } + + #endregion Protected Methods } } \ No newline at end of file diff --git a/NKC_WF/WebUserControls/cmp_numRow.ascx.cs b/NKC_WF/WebUserControls/cmp_numRow.ascx.cs index 33f8f54..a5acd8c 100644 --- a/NKC_WF/WebUserControls/cmp_numRow.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_numRow.ascx.cs @@ -4,20 +4,8 @@ namespace NKC_WF.WebUserControls { public partial class cmp_numRow : BaseUserControl { - public event EventHandler eh_doRefresh; - protected void Page_Load(object sender, EventArgs e) - { + #region Public Properties - } - - private void raiseEvent() - { - // se qualcuno ascolta sollevo evento nuovo valore... - if (eh_doRefresh != null) - { - eh_doRefresh(this, new EventArgs()); - } - } public int numRow { set @@ -32,10 +20,19 @@ namespace NKC_WF.WebUserControls } } + #endregion Public Properties + + #region Protected Methods + + protected void Page_Load(object sender, EventArgs e) + { + } + protected void txtNumRow_TextChanged(object sender, EventArgs e) { - raiseEvent(); } + + #endregion Protected Methods } } \ No newline at end of file diff --git a/NKC_WF/WebUserControls/mod_righePag.ascx.cs b/NKC_WF/WebUserControls/mod_righePag.ascx.cs index 7163ade..0af3cf1 100644 --- a/NKC_WF/WebUserControls/mod_righePag.ascx.cs +++ b/NKC_WF/WebUserControls/mod_righePag.ascx.cs @@ -6,80 +6,17 @@ namespace NKC_WF.WebUserControls { public partial class mod_righePag : BaseUserControl { + #region Public Events + /// /// indicato (nuovo) numero righe x pagina /// public event EventHandler eh_newNum; - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - numRowReq = numRowPag; - } - } - /// - /// stringa UID univoca - /// - public string uid - { - get - { - return this.UniqueID.Replace("$", "_").Replace("-", "_"); - } - } - /// - /// effettua traduzione del lemma - /// - /// - /// - public string traduci(string lemma) - { - return user_std.UtSn.Traduci(lemma); - } - /// - /// aggiorno controllo paginazione... - /// - /// - /// - protected void txtNumRighe_TextChanged(object sender, EventArgs e) - { - // salvo num righe... - numRowPag = numRowReq; - // sollevo evento nuovo valore... - if (eh_newNum != null) - { - eh_newNum(this, new EventArgs()); - } - } - /// - /// numero righe per pagina (in sessione) - /// - public int numRowPag - { - get - { - int answ = 10; - try - { - answ = memLayer.ML.IntSessionObj(uid + "_numRowPag"); - } - catch - { - answ = 10; - } - return answ; - } - set - { - memLayer.ML.setSessionVal(uid + "_numRowPag", value); - numRowReq = value; - } - } + + #endregion Public Events + + #region Protected Properties + /// /// numero righe gridview da mostrare legato a controllo textbox /// @@ -106,5 +43,80 @@ namespace NKC_WF.WebUserControls txtNumRighe.Text = value.ToString(); } } + + #endregion Protected Properties + + #region Public Properties + + /// + /// numero righe per pagina (in sessione) + /// + public int numRowPag + { + get + { + int answ = 10; + try + { + answ = memLayer.ML.IntSessionObj(uid + "_numRowPag"); + } + catch + { + answ = 10; + } + return answ; + } + set + { + memLayer.ML.setSessionVal(uid + "_numRowPag", value); + numRowReq = value; + } + } + + /// + /// stringa UID univoca + /// + public string uid + { + get + { + return this.UniqueID.Replace("$", "_").Replace("-", "_"); + } + } + + #endregion Public Properties + + #region Protected Methods + + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + numRowReq = numRowPag; + } + } + + /// + /// aggiorno controllo paginazione... + /// + /// + /// + protected void txtNumRighe_TextChanged(object sender, EventArgs e) + { + // salvo num righe... + numRowPag = numRowReq; + // sollevo evento nuovo valore... + if (eh_newNum != null) + { + eh_newNum(this, new EventArgs()); + } + } + + #endregion Protected Methods } } \ No newline at end of file