Merge branch 'develop'

This commit is contained in:
Samuele Locatelli
2022-02-18 18:19:37 +01:00
6 changed files with 226 additions and 97 deletions
+4 -1
View File
@@ -31,7 +31,10 @@ namespace SteamWare
{
assembly = Assembly.GetExecutingAssembly();
}
/// <summary>
/// Info hw/sw del server
/// </summary>
/// <param name="targetAssembly"></param>
public HwSwInfo(Assembly targetAssembly)
{
assembly = targetAssembly;
+202 -89
View File
@@ -5,106 +5,219 @@ using System.Runtime.InteropServices;
namespace SteamWare
{
public class NetworkConnection : IDisposable
{
string _networkName;
public NetworkConnection(string networkName, NetworkCredential credentials)
/// <summary>
/// Helper x gestione accesso device di rete
/// </summary>
public class NetworkConnection : IDisposable
{
_networkName = networkName;
string _networkName;
var netResource = new NetResource()
{
Scope = ResourceScope.GlobalNetwork,
ResourceType = ResourceType.Disk,
DisplayType = ResourceDisplaytype.Share,
RemoteName = networkName
};
/// <summary>
/// Init classe
/// </summary>
/// <param name="networkName"></param>
/// <param name="credentials"></param>
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);
}
}
/// <summary>
/// Dispose classe
/// </summary>
~NetworkConnection()
{
Dispose(false);
}
/// <summary>
/// Dispose classe
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Dispose classe
/// </summary>
/// <param name="disposing"></param>
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()
/// <summary>
///
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public class NetResource
{
Dispose(false);
/// <summary>
/// Scope delal risorsa
/// </summary>
public ResourceScope Scope;
/// <summary>
/// TIpo di risorsa
/// </summary>
public ResourceType ResourceType;
/// <summary>
/// Tipèo display
/// </summary>
public ResourceDisplaytype DisplayType;
/// <summary>
/// Impiego
/// </summary>
public int Usage;
/// <summary>
/// Nome locale
/// </summary>
public string LocalName;
/// <summary>
/// Nome remoto
/// </summary>
public string RemoteName;
/// <summary>
/// Commento
/// </summary>
public string Comment;
/// <summary>
/// Provider
/// </summary>
public string Provider;
}
public void Dispose()
/// <summary>
/// Enum Scope della risorsa
/// </summary>
public enum ResourceScope : int
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
/// <summary>
/// connessa
/// </summary>
Connected = 1,
/// <summary>
/// rete globale
/// </summary>
GlobalNetwork,
/// <summary>
/// memorizzata
/// </summary>
Remembered,
/// <summary>
/// recente
/// </summary>
Recent,
/// <summary>
/// contesto
/// </summary>
Context
};
/// <summary>
/// Enum tipo res
/// </summary>
public enum ResourceType : int
{
WNetCancelConnection2(_networkName, 0, true);
/// <summary>
/// Qualsiasi
/// </summary>
Any = 0,
/// <summary>
/// Disco
/// </summary>
Disk = 1,
/// <summary>
/// Printer
/// </summary>
Print = 2,
/// <summary>
/// Riservato
/// </summary>
Reserved = 8,
}
/// <summary>
/// Enum tipo display
/// </summary>
public enum ResourceDisplaytype : int
{
/// <summary>
/// Generico
/// </summary>
Generic = 0x0,
/// <summary>
/// Dominio
/// </summary>
Domain = 0x01,
/// <summary>
/// Server
/// </summary>
Server = 0x02,
/// <summary>
/// COndivisione
/// </summary>
Share = 0x03,
/// <summary>
/// File
/// </summary>
File = 0x04,
/// <summary>
/// Gruppo
/// </summary>
Group = 0x05,
/// <summary>
/// Rete
/// </summary>
Network = 0x06,
/// <summary>
/// Radice
/// </summary>
Root = 0x07,
/// <summary>
/// Share admin
/// </summary>
Shareadmin = 0x08,
/// <summary>
/// Cartella
/// </summary>
Directory = 0x09,
/// <summary>
/// Albero
/// </summary>
Tree = 0x0a,
/// <summary>
/// NDS container
/// </summary>
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
}
}
+13 -5
View File
@@ -128,7 +128,7 @@
<HintPath>..\packages\SteamWare.Logger.5.1.2109.1716\lib\net462\SteamWare.Logger.dll</HintPath>
</Reference>
<Reference Include="System">
<HintPath>c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll</HintPath>
</Reference>
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
@@ -212,8 +212,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ApplicationSimplePage.cs" />
<Compile Include="ApplicationUserControl.cs" />
<Compile Include="ApplicationSimplePage.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="ApplicationUserControl.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="authProxy.cs" />
<Compile Include="BillingProxy.cs" />
<Compile Include="calc.cs" />
@@ -296,7 +300,9 @@
<Compile Include="PasswordHash.cs" />
<Compile Include="SteamwareStrings.cs" />
<Compile Include="UpdateMan.cs" />
<Compile Include="UserPage.cs" />
<Compile Include="UserPage.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="pieChart.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
@@ -306,7 +312,9 @@
<Compile Include="selDataVoc.cs" />
<Compile Include="selettori.cs" />
<Compile Include="DataType\DatoBarPlot.cs" />
<Compile Include="UserControl.cs" />
<Compile Include="UserControl.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="user_std.cs" />
<Compile Include="utils.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+6
View File
@@ -88,7 +88,13 @@ namespace SteamWare
#region Protected Properties
/// <summary>
/// password
/// </summary>
protected string passwd { get; set; } = "";
/// <summary>
/// Username
/// </summary>
protected string userName { get; set; } = "";
#endregion Protected Properties
+1 -1
View File
@@ -1232,7 +1232,7 @@ namespace SteamWare
/// <summary>
/// traduce il lemma nella lingua dell'user corrente
/// </summary>
/// <param name="lemma"></param>
/// <param name="_lemma"></param>
/// <returns></returns>
public string Traduci(string _lemma)
{
-1
View File
@@ -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;