Aggiunta metodi x copia via rete con user/pwd
This commit is contained in:
Vendored
+1
-1
@@ -11,7 +11,7 @@ pipeline {
|
||||
steps {
|
||||
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
|
||||
script {
|
||||
withEnv(['NEXT_BUILD_NUMBER=677']) {
|
||||
withEnv(['NEXT_BUILD_NUMBER=678']) {
|
||||
// env.versionNumber = VersionNumber(versionNumberString : '3.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
|
||||
env.versionNumber = VersionNumber(versionNumberString : '3.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
env.versionNumberBeta = VersionNumber(versionNumberString : '3.3.${BUILD_DATE_FORMATTED, "yyMM"}-beta.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SteamWare
|
||||
{
|
||||
public class NetworkConnection : IDisposable
|
||||
{
|
||||
string _networkName;
|
||||
|
||||
public NetworkConnection(string networkName, NetworkCredential credentials)
|
||||
{
|
||||
_networkName = networkName;
|
||||
|
||||
var netResource = new NetResource()
|
||||
{
|
||||
Scope = ResourceScope.GlobalNetwork,
|
||||
ResourceType = ResourceType.Disk,
|
||||
DisplayType = ResourceDisplaytype.Share,
|
||||
RemoteName = networkName
|
||||
};
|
||||
|
||||
var userName = string.IsNullOrEmpty(credentials.Domain)
|
||||
? credentials.UserName
|
||||
: string.Format(@"{0}\{1}", credentials.Domain, credentials.UserName);
|
||||
|
||||
var result = WNetAddConnection2(
|
||||
netResource,
|
||||
credentials.Password,
|
||||
userName,
|
||||
0);
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
throw new Win32Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
~NetworkConnection()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[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
|
||||
}
|
||||
}
|
||||
@@ -201,6 +201,7 @@
|
||||
<Compile Include="logger.cs" />
|
||||
<Compile Include="Logging.cs" />
|
||||
<Compile Include="memLayer.cs" />
|
||||
<Compile Include="NetworkConnection.cs" />
|
||||
<Compile Include="SteamWare.cs">
|
||||
<DependentUpon>SteamWare.tt</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
@@ -634,6 +634,36 @@ namespace SteamWare
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua copia files via rete con auth...
|
||||
/// </summary>
|
||||
/// <param name="pathSource"></param>
|
||||
/// <param name="pathDest"></param>
|
||||
/// <param name="credentialsSource"></param>
|
||||
/// <param name="credentialsDest"></param>
|
||||
/// <param name="fileSource"></param>
|
||||
/// <param name="fileDest"></param>
|
||||
/// <returns></returns>
|
||||
public bool copiaFileNetwork(string pathSource, string pathDest, NetworkCredential credentialsSource, NetworkCredential credentialsDest, string fileSource, string fileDest)
|
||||
{
|
||||
bool fatto = false;
|
||||
logger.lg.scriviLog($"Richiesta trasferimento files: {pathSource}\\{fileSource} --> {pathDest}\\{fileDest}", tipoLog.INFO);
|
||||
try
|
||||
{
|
||||
using (new NetworkConnection(pathSource, credentialsSource))
|
||||
using (new NetworkConnection(pathDest, credentialsDest))
|
||||
{
|
||||
File.Copy($"{pathSource}\\{fileSource}", $"{pathDest}\\{fileDest}");
|
||||
fatto = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog($"Eccezione durante trasferimento files: {pathSource}\\{fileSource} --> {pathDest}\\{fileDest}{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// imposta la dir di lavoro
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user