本文整理汇总了C#中IActivityIOPath类的典型用法代码示例。如果您正苦于以下问题:C# IActivityIOPath类的具体用法?C# IActivityIOPath怎么用?C# IActivityIOPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IActivityIOPath类属于命名空间,在下文中一共展示了IActivityIOPath类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ReadFromFtp
void ReadFromFtp(IActivityIOPath path, ref Stream result)
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ConvertSslToPlain(path.Path));
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.UseBinary = true;
request.KeepAlive = true;
request.EnableSsl = EnableSsl(path);
if(path.IsNotCertVerifiable)
{
ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications;
}
if(path.Username != string.Empty)
{
request.Credentials = new NetworkCredential(path.Username, path.Password);
}
using(var response = (FtpWebResponse)request.GetResponse())
{
using(var ftpStream = response.GetResponseStream())
{
if(ftpStream != null && ftpStream.CanRead)
{
byte[] data = ftpStream.ToByteArray();
result = new MemoryStream(data);
}
else
{
throw new Exception("Fail");
}
}
}
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:35,代码来源:Dev2FTPProvider.cs
示例2: Get
public Stream Get(IActivityIOPath path, List<string> filesToCleanup)
{
Stream result = null;
try
{
if(IsStandardFtp(path))
{
ReadFromFtp(path, ref result);
}
else
{
Dev2Logger.Log.Debug(String.Format("SFTP_GET:{0}", path.Path));
ReadFromSftp(path, ref result, filesToCleanup);
}
}
catch(Exception ex)
{
Dev2Logger.Log.Error(this, ex);
var message = string.Format("{0} , [{1}]", ex.Message, path.Path);
throw new Exception(message, ex);
}
return result;
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:26,代码来源:Dev2FTPProvider.cs
示例3: Get
public Stream Get(IActivityIOPath path, List<string> filesToCleanup)
{
Stream result;
if (!RequiresAuth(path))
{
if (File.Exists(path.Path))
{
result = new MemoryStream(File.ReadAllBytes(path.Path));
}
else
{
throw new Exception("File not found [ " + path.Path + " ]");
}
}
else
{
try
{
// handle UNC path
SafeTokenHandle safeTokenHandle;
string user = ExtractUserName(path);
string domain = ExtractDomain(path);
bool loginOk = LogonUser(user, domain, path.Password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, out safeTokenHandle);
if (loginOk)
{
using (safeTokenHandle)
{
WindowsIdentity newID = new WindowsIdentity(safeTokenHandle.DangerousGetHandle());
using (WindowsImpersonationContext impersonatedUser = newID.Impersonate())
{
// Do the operation here
result = new MemoryStream(File.ReadAllBytes(path.Path));
impersonatedUser.Undo(); // remove impersonation now
}
}
}
else
{
// login failed
throw new Exception("Failed to authenticate with user [ " + path.Username + " ] for resource [ " + path.Path + " ] ");
}
}
catch (Exception ex)
{
Dev2Logger.Log.Error(ex);
throw new Exception(ex.Message, ex);
}
}
return result;
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:59,代码来源:Dev2FileSystemProvider.cs
示例4: IsStandardFtp
static bool IsStandardFtp(IActivityIOPath path)
{
return path.PathType == enActivityIOPathType.FTP || path.PathType == enActivityIOPathType.FTPES || path.PathType == enActivityIOPathType.FTPS;
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:4,代码来源:Dev2FTPProvider.cs
示例5: TransferFile
static bool TransferFile(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args, string path, IActivityIOPath p, bool result)
{
var tmpPath = ActivityIOFactory.CreatePathFromString(path, dst.IOPath.Username, dst.IOPath.Password, true, dst.IOPath.PrivateKeyFile);
var tmpEp = ActivityIOFactory.CreateOperationEndPointFromIOPath(tmpPath);
var whereToPut = GetWhereToPut(src, dst);
using(var s = src.Get(p, _filesToDelete))
{
if(tmpEp.Put(s, tmpEp.IOPath, args, whereToPut, _filesToDelete) < 0)
{
result = false;
}
s.Close();
s.Dispose();
}
return result;
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:16,代码来源:Dev2ActivityIOBroker.cs
示例6: PerformTransfer
static bool PerformTransfer(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args, string origDstPath, IActivityIOPath p, bool result)
{
try
{
if(dst.PathIs(dst.IOPath) == enPathType.Directory)
{
var cpPath =
ActivityIOFactory.CreatePathFromString(
string.Format("{0}{1}{2}", origDstPath, dst.PathSeperator(),
Dev2ActivityIOPathUtils.ExtractFileName(p.Path)),
dst.IOPath.Username,
dst.IOPath.Password, true,dst.IOPath.PrivateKeyFile);
var path = cpPath.Path;
DoFileTransfer(src, dst, args, cpPath, p, path, ref result);
}
else if(args.Overwrite || !dst.PathExist(dst.IOPath))
{
var tmp = origDstPath + "\\" + Dev2ActivityIOPathUtils.ExtractFileName(p.Path);
var path = ActivityIOFactory.CreatePathFromString(tmp, dst.IOPath.Username, dst.IOPath.Password, dst.IOPath.PrivateKeyFile);
DoFileTransfer(src, dst, args, path, p, path.Path, ref result);
}
}
catch(Exception ex)
{
Dev2Logger.Log.Error(ex);
}
return result;
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:28,代码来源:Dev2ActivityIOBroker.cs
示例7: IsUncFileTypePath
static bool IsUncFileTypePath(IActivityIOPath src)
{
return src.Path.StartsWith(@"\\");
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:4,代码来源:Dev2ActivityIOBroker.cs
示例8: RequiresAuth
private bool RequiresAuth(IActivityIOPath path)
{
bool result = path.Username != string.Empty;
return result;
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:6,代码来源:Dev2FileSystemProvider.cs
示例9: IsFilePresentStandardFtp
bool IsFilePresentStandardFtp(IActivityIOPath path)
{
FtpWebResponse response = null;
bool isAlive;
try
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ConvertSslToPlain(path.Path));
request.Method = WebRequestMethods.Ftp.GetFileSize;
request.UseBinary = true;
request.KeepAlive = false;
request.EnableSsl = EnableSsl(path);
if(path.Username != string.Empty)
{
request.Credentials = new NetworkCredential(path.Username, path.Password);
}
if(path.IsNotCertVerifiable)
{
ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications;
}
using(response = (FtpWebResponse)request.GetResponse())
{
using(Stream responseStream = response.GetResponseStream())
{
if(responseStream != null)
{
using(StreamReader reader = new StreamReader(responseStream))
{
if(reader.EndOfStream)
{
// just check for exception, slow I know, but not sure how else to tackle this
}
}
}
}
}
// exception will be thrown if not present
isAlive = true;
}
catch(WebException wex)
{
Dev2Logger.Log.Error(this, wex);
isAlive = false;
}
catch(Exception ex)
{
Dev2Logger.Log.Error(this, ex);
throw;
}
finally
{
if(response != null)
{
response.Close();
}
}
return isAlive;
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:66,代码来源:Dev2FTPProvider.cs
示例10: IsFilePresent
private bool IsFilePresent(IActivityIOPath path)
{
var isFilePresent = IsStandardFtp(path) ? IsFilePresentStandardFtp(path) : IsFilePresentSftp(path);
return isFilePresent;
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:5,代码来源:Dev2FTPProvider.cs
示例11: EnableSsl
private static bool EnableSsl(IActivityIOPath path)
{
var result = path.PathType == enActivityIOPathType.FTPS || path.PathType == enActivityIOPathType.FTPES;
return result;
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:5,代码来源:Dev2FTPProvider.cs
示例12: DeleteUsingSftp
bool DeleteUsingSftp(IActivityIOPath src)
{
var sftp = BuildSftpClient(src);
try
{
var fromPath = ExtractFileNameFromPath(src.Path);
if(PathIs(src) == enPathType.Directory)
{
sftp.DeleteDirectory(fromPath);
}
else
{
sftp.DeleteFile(fromPath);
}
}
catch(Exception)
{
throw new Exception(string.Format("Could not delete {0}. Please check the path exists.", src.Path));
}
finally
{
sftp.Dispose();
}
return true;
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:25,代码来源:Dev2FTPProvider.cs
示例13: DeleteUsingStandardFtp
bool DeleteUsingStandardFtp(IActivityIOPath src)
{
FtpWebResponse response = null;
try
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ConvertSslToPlain(src.Path));
request.Method = PathIs(src) == enPathType.Directory ? WebRequestMethods.Ftp.RemoveDirectory : WebRequestMethods.Ftp.DeleteFile;
request.UseBinary = true;
request.KeepAlive = false;
request.EnableSsl = EnableSsl(src);
if(src.IsNotCertVerifiable)
{
ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications;
}
if(src.Username != string.Empty)
{
request.Credentials = new NetworkCredential(src.Username, src.Password);
}
using(response = (FtpWebResponse)request.GetResponse())
{
if(response.StatusCode != FtpStatusCode.FileActionOK)
{
throw new Exception("Fail");
}
}
}
catch(Exception exception)
{
throw new Exception(string.Format("Could not delete {0}. Please check the path exists.", src.Path), exception);
}
finally
{
if(response != null)
{
response.Close();
}
}
return true;
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:45,代码来源:Dev2FTPProvider.cs
示例14: DeleteOp
internal bool DeleteOp(IActivityIOPath src)
{
return IsStandardFtp(src) ? DeleteUsingStandardFtp(src) : DeleteUsingSftp(src);
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:4,代码来源:Dev2FTPProvider.cs
示例15: FileExist
private bool FileExist(IActivityIOPath path)
{
bool result = File.Exists(path.Path);
return result;
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:6,代码来源:Dev2FileSystemProvider.cs
示例16: DirectoryExist
private bool DirectoryExist(IActivityIOPath dir)
{
bool result = Directory.Exists(dir.Path);
return result;
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:5,代码来源:Dev2FileSystemProvider.cs
示例17: Put
public int Put(Stream src, IActivityIOPath dst, Dev2CRUDOperationTO args, string whereToPut, List<string> filesToCleanup)
{
int result = -1;
using (src)
{
//2013.05.29: Ashley Lewis for bug 9507 - default destination to source directory when destination is left blank or if it is not a rooted path
if (!Path.IsPathRooted(dst.Path))
{
//get just the directory path to put into
if (whereToPut != null)
{
//Make the destination directory equal to that directory
dst = ActivityIOFactory.CreatePathFromString(whereToPut + "\\" + dst.Path, dst.Username, dst.Password,dst.PrivateKeyFile);
}
}
if (args.Overwrite || !args.Overwrite && !FileExist(dst))
{
_fileLock.EnterWriteLock();
try
{
if (!RequiresAuth(dst))
{
using (src)
{
File.WriteAllBytes(dst.Path, src.ToByteArray());
result = (int)src.Length;
}
}
else
{
// handle UNC path
SafeTokenHandle safeTokenHandle;
bool loginOk = LogonUser(ExtractUserName(dst), ExtractDomain(dst), dst.Password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, out safeTokenHandle);
if (loginOk)
{
using (safeTokenHandle)
{
WindowsIdentity newID = new WindowsIdentity(safeTokenHandle.DangerousGetHandle());
using (WindowsImpersonationContext impersonatedUser = newID.Impersonate())
{
// Do the operation here
using (src)
{
File.WriteAllBytes(dst.Path, src.ToByteArray());
result = (int)src.Length;
}
// remove impersonation now
impersonatedUser.Undo();
}
}
}
else
{
// login failed
throw new Exception("Failed to authenticate with user [ " + dst.Username + " ] for resource [ " + dst.Path + " ] ");
}
}
}
finally
{
_fileLock.ExitWriteLock();
}
}
}
return result;
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:70,代码来源:Dev2FileSystemProvider.cs
示例18: ListDirectoriesAccordingToType
private IList<IActivityIOPath> ListDirectoriesAccordingToType(IActivityIOPath src, ReadTypes type)
{
IList<IActivityIOPath> result = new List<IActivityIOPath>();
string path = src.Path;
if (!path.EndsWith("\\") && PathIs(src) == enPathType.Directory)
{
path += "\\";
}
if (!RequiresAuth(src))
{
try
{
IEnumerable<string> dirs;
if (!Dev2ActivityIOPathUtils.IsStarWildCard(path))
{
if (Directory.Exists(path))
{
dirs = GetDirectoriesForType(path, string.Empty, type);
}
else
{
throw new Exception("The Directory does not exist.");
}
}
else
{
// we have a wild-char path ;)
string baseDir = Dev2ActivityIOPathUtils.ExtractFullDirectoryPath(path);
string pattern = Dev2ActivityIOPathUtils.ExtractFileName(path);
dirs = GetDirectoriesForType(baseDir, pattern, type);
}
if (dirs != null)
{
foreach (string d in dirs)
{
result.Add(ActivityIOFactory.CreatePathFromString(d, src.Username, src.Password, true,src.PrivateKeyFile));
}
}
}
catch (Exception)
{
throw new Exception("Directory not found [ " + src.Path + " ] ");
}
}
else
{
try
{
// handle UNC path
SafeTokenHandle safeTokenHandle;
bool loginOk = LogonUser(ExtractUserName(src), ExtractDomain(src), src.Password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, out safeTokenHandle);
if (loginOk)
{
using (safeTokenHandle)
{
WindowsIdentity newID = new WindowsIdentity(safeTokenHandle.DangerousGetHandle());
using (WindowsImpersonationContext impersonatedUser = newID.Impersonate())
{
// Do the operation here
try
{
IEnumerable<string> dirs;
if (!Dev2ActivityIOPathUtils.IsStarWildCard(path))
{
dirs = GetDirectoriesForType(path, string.Empty, type);
}
else
{
// we have a wild-char path ;)
string baseDir = Dev2ActivityIOPathUtils.ExtractFullDirectoryPath(path);
string pattern = Dev2ActivityIOPathUtils.ExtractFileName(path);
dirs = GetDirectoriesForType(baseDir, pattern, type);
}
if (dirs != null)
{
foreach (string d in dirs)
{
result.Add(ActivityIOFactory.CreatePathFromString(d, src.Username, src.Password, src.PrivateKeyFile));
}
}
}
catch (Exception)
{
throw new Exception("Directory not found [ " + src.Path + " ] ");
//.........这里部分代码省略.........
开发者ID:Robin--,项目名称:Warewolf,代码行数:101,代码来源:Dev2FileSystemProvider.cs
示例19: Delete
public bool Delete(IActivityIOPath src)
{
bool result;
try
{
if (!RequiresAuth(src))
{
// We need sense check the value passed in ;)
result = DeleteHelper.Delete(src.Path);
}
else
{
// handle UNC path
SafeTokenHandle safeTokenHandle;
bool loginOk = LogonUser(ExtractUserName(src), ExtractDomain(src), src.Password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, out safeTokenHandle);
if (loginOk)
{
using (safeTokenHandle)
{
WindowsIdentity newID = new WindowsIdentity(safeTokenHandle.DangerousGetHandle());
using (WindowsImpersonationContext impersonatedUser = newID.Impersonate())
{
// Do the operation here
result = DeleteHelper.Delete(src.Path);
// remove impersonation now
impersonatedUser.Undo();
}
}
}
else
{
// login failed
throw new Exception("Failed to authenticate with user [ " + src.Username + " ] for resource [ " + src.Path + " ] ");
}
}
}
catch (Exception)
{
//File is not found problem during delete
result = false;
}
return result;
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:50,代码来源:Dev2FileSystemProvider.cs
示例20: IsNotFtpTypePath
static bool IsNotFtpTypePath(IActivityIOPath src)
{
return !src.Path.StartsWith("ftp://") && !src.Path.StartsWith("ftps://") && !src.Path.StartsWith("sftp://");
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:4,代码来源:Dev2ActivityIOBroker.cs
注:本文中的IActivityIOPath类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论