From fb70a72aa26fcd5d211f772d859e1436eaab8f3e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 18 Feb 2022 18:19:10 +0100 Subject: [PATCH] Fix warning (maybe) --- SteamWareLib/HwSwInfo.cs | 5 +- SteamWareLib/NetworkConnection.cs | 291 +++++++++++++++++++++--------- SteamWareLib/SteamWare.csproj | 18 +- SteamWareLib/UpdateMan.cs | 6 + SteamWareLib/user_std.cs | 2 +- TestBench/MainFOrm.Designer.cs | 1 - 6 files changed, 226 insertions(+), 97 deletions(-) diff --git a/SteamWareLib/HwSwInfo.cs b/SteamWareLib/HwSwInfo.cs index 74c6681..f7a37f8 100644 --- a/SteamWareLib/HwSwInfo.cs +++ b/SteamWareLib/HwSwInfo.cs @@ -31,7 +31,10 @@ namespace SteamWare { assembly = Assembly.GetExecutingAssembly(); } - + /// + /// Info hw/sw del server + /// + /// public HwSwInfo(Assembly targetAssembly) { assembly = targetAssembly; diff --git a/SteamWareLib/NetworkConnection.cs b/SteamWareLib/NetworkConnection.cs index 03fa1a3..024ff9d 100644 --- a/SteamWareLib/NetworkConnection.cs +++ b/SteamWareLib/NetworkConnection.cs @@ -5,106 +5,219 @@ using System.Runtime.InteropServices; namespace SteamWare { - public class NetworkConnection : IDisposable - { - string _networkName; - - public NetworkConnection(string networkName, NetworkCredential credentials) + /// + /// Helper x gestione accesso device di rete + /// + public class NetworkConnection : IDisposable { - _networkName = networkName; + string _networkName; - var netResource = new NetResource() - { - Scope = ResourceScope.GlobalNetwork, - ResourceType = ResourceType.Disk, - DisplayType = ResourceDisplaytype.Share, - RemoteName = networkName - }; + /// + /// Init classe + /// + /// + /// + public NetworkConnection(string networkName, NetworkCredential credentials) + { + _networkName = networkName; - var userName = string.IsNullOrEmpty(credentials.Domain) - ? credentials.UserName - : string.Format(@"{0}\{1}", credentials.Domain, credentials.UserName); + var netResource = new NetResource() + { + Scope = ResourceScope.GlobalNetwork, + ResourceType = ResourceType.Disk, + DisplayType = ResourceDisplaytype.Share, + RemoteName = networkName + }; - var result = WNetAddConnection2( - netResource, - credentials.Password, - userName, - 0); + var userName = string.IsNullOrEmpty(credentials.Domain) + ? credentials.UserName + : string.Format(@"{0}\{1}", credentials.Domain, credentials.UserName); - if (result != 0) - { - throw new Win32Exception(result); - } + var result = WNetAddConnection2( + netResource, + credentials.Password, + userName, + 0); + + if (result != 0) + { + throw new Win32Exception(result); + } + } + + /// + /// Dispose classe + /// + ~NetworkConnection() + { + Dispose(false); + } + /// + /// Dispose classe + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + /// + /// Dispose classe + /// + /// + protected virtual void Dispose(bool disposing) + { + WNetCancelConnection2(_networkName, 0, true); + } + + [DllImport("mpr.dll")] + private static extern int WNetAddConnection2(NetResource netResource, + string password, string username, int flags); + + [DllImport("mpr.dll")] + private static extern int WNetCancelConnection2(string name, int flags, + bool force); } - ~NetworkConnection() + /// + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class NetResource { - Dispose(false); + /// + /// Scope delal risorsa + /// + public ResourceScope Scope; + /// + /// TIpo di risorsa + /// + public ResourceType ResourceType; + /// + /// Tipèo display + /// + public ResourceDisplaytype DisplayType; + /// + /// Impiego + /// + public int Usage; + /// + /// Nome locale + /// + public string LocalName; + /// + /// Nome remoto + /// + public string RemoteName; + /// + /// Commento + /// + public string Comment; + /// + /// Provider + /// + public string Provider; } - public void Dispose() + /// + /// Enum Scope della risorsa + /// + public enum ResourceScope : int { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) + /// + /// connessa + /// + Connected = 1, + /// + /// rete globale + /// + GlobalNetwork, + /// + /// memorizzata + /// + Remembered, + /// + /// recente + /// + Recent, + /// + /// contesto + /// + Context + }; + /// + /// Enum tipo res + /// + public enum ResourceType : int { - WNetCancelConnection2(_networkName, 0, true); + /// + /// Qualsiasi + /// + Any = 0, + /// + /// Disco + /// + Disk = 1, + /// + /// Printer + /// + Print = 2, + /// + /// Riservato + /// + Reserved = 8, + } + /// + /// Enum tipo display + /// + public enum ResourceDisplaytype : int + { + /// + /// Generico + /// + Generic = 0x0, + /// + /// Dominio + /// + Domain = 0x01, + /// + /// Server + /// + Server = 0x02, + /// + /// COndivisione + /// + Share = 0x03, + /// + /// File + /// + File = 0x04, + /// + /// Gruppo + /// + Group = 0x05, + /// + /// Rete + /// + Network = 0x06, + /// + /// Radice + /// + Root = 0x07, + /// + /// Share admin + /// + Shareadmin = 0x08, + /// + /// Cartella + /// + Directory = 0x09, + /// + /// Albero + /// + Tree = 0x0a, + /// + /// NDS container + /// + Ndscontainer = 0x0b } - - [DllImport("mpr.dll")] - private static extern int WNetAddConnection2(NetResource netResource, - string password, string username, int flags); - - [DllImport("mpr.dll")] - private static extern int WNetCancelConnection2(string name, int flags, - bool force); - } - - [StructLayout(LayoutKind.Sequential)] - public class NetResource - { - public ResourceScope Scope; - public ResourceType ResourceType; - public ResourceDisplaytype DisplayType; - public int Usage; - public string LocalName; - public string RemoteName; - public string Comment; - public string Provider; - } - - public enum ResourceScope : int - { - Connected = 1, - GlobalNetwork, - Remembered, - Recent, - Context - }; - - public enum ResourceType : int - { - Any = 0, - Disk = 1, - Print = 2, - Reserved = 8, - } - - public enum ResourceDisplaytype : int - { - Generic = 0x0, - Domain = 0x01, - Server = 0x02, - Share = 0x03, - File = 0x04, - Group = 0x05, - Network = 0x06, - Root = 0x07, - Shareadmin = 0x08, - Directory = 0x09, - Tree = 0x0a, - Ndscontainer = 0x0b - } } diff --git a/SteamWareLib/SteamWare.csproj b/SteamWareLib/SteamWare.csproj index 5a14294..8befcb1 100644 --- a/SteamWareLib/SteamWare.csproj +++ b/SteamWareLib/SteamWare.csproj @@ -128,7 +128,7 @@ ..\packages\SteamWare.Logger.5.1.2109.1716\lib\net462\SteamWare.Logger.dll - c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll + ..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll @@ -212,8 +212,12 @@ - - + + ASPXCodeBehind + + + ASPXCodeBehind + @@ -296,7 +300,9 @@ - + + ASPXCodeBehind + True @@ -306,7 +312,9 @@ - + + ASPXCodeBehind + diff --git a/SteamWareLib/UpdateMan.cs b/SteamWareLib/UpdateMan.cs index a977dfa..8c2fcb7 100644 --- a/SteamWareLib/UpdateMan.cs +++ b/SteamWareLib/UpdateMan.cs @@ -88,7 +88,13 @@ namespace SteamWare #region Protected Properties + /// + /// password + /// protected string passwd { get; set; } = ""; + /// + /// Username + /// protected string userName { get; set; } = ""; #endregion Protected Properties diff --git a/SteamWareLib/user_std.cs b/SteamWareLib/user_std.cs index 317b54c..f286bed 100644 --- a/SteamWareLib/user_std.cs +++ b/SteamWareLib/user_std.cs @@ -1232,7 +1232,7 @@ namespace SteamWare /// /// traduce il lemma nella lingua dell'user corrente /// - /// + /// /// public string Traduci(string _lemma) { diff --git a/TestBench/MainFOrm.Designer.cs b/TestBench/MainFOrm.Designer.cs index 0cf2f3b..0b116c2 100644 --- a/TestBench/MainFOrm.Designer.cs +++ b/TestBench/MainFOrm.Designer.cs @@ -863,7 +863,6 @@ private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.Label lblChannelReceive; private System.Windows.Forms.GroupBox groupBox3; - private System.Windows.Forms.Button button3; private System.Windows.Forms.Label label8; private System.Windows.Forms.TextBox txtChannelSend; private System.Windows.Forms.Label lblTestLogger;