本文整理汇总了C#中IActivityIOOperationsEndPoint.Combine方法的典型用法代码示例。如果您正苦于以下问题:C# IActivityIOOperationsEndPoint.Combine方法的具体用法?C# IActivityIOOperationsEndPoint.Combine怎么用?C# IActivityIOOperationsEndPoint.Combine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActivityIOOperationsEndPoint
的用法示例。
在下文中一共展示了IActivityIOOperationsEndPoint.Combine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateSourceAndDestinationContents
/// <summary>
/// Transfer the contents of the directory
/// </summary>
/// <param name="src"></param>
/// <param name="dst"></param>
/// <param name="args"></param>
void ValidateSourceAndDestinationContents(IActivityIOOperationsEndPoint src,
IActivityIOOperationsEndPoint dst,
Dev2CRUDOperationTO args)
{
if(!args.Overwrite)
{
var srcContentsFolders = src.ListFoldersInDirectory(src.IOPath);
foreach(var sourcePath in srcContentsFolders)
{
var sourceEndPoint =
ActivityIOFactory.CreateOperationEndPointFromIOPath(sourcePath);
IList<string> dirParts =
sourceEndPoint.IOPath.Path.Split(sourceEndPoint.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
var directory = dirParts.Last();
var destinationPath =
ActivityIOFactory.CreatePathFromString(dst.Combine(directory),
dst.IOPath.Username,
dst.IOPath.Password, true, dst.IOPath.PrivateKeyFile);
var destinationEndPoint =
ActivityIOFactory.CreateOperationEndPointFromIOPath(destinationPath);
if(destinationEndPoint.PathExist(destinationEndPoint.IOPath))
{
ValidateSourceAndDestinationContents(sourceEndPoint, destinationEndPoint, args);
}
}
var srcContents = src.ListFilesInDirectory(src.IOPath);
var dstContents = dst.ListFilesInDirectory(dst.IOPath);
var sourceFileNames = srcContents.Select(srcFile => GetFileNameFromEndPoint(src, srcFile)).ToList();
var destinationFileNames = dstContents.Select(dstFile => GetFileNameFromEndPoint(dst, dstFile)).ToList();
if(destinationFileNames.Count > 0)
{
var commonFiles = sourceFileNames.Where(destinationFileNames.Contains).ToList();
if(commonFiles.Count > 0)
{
var fileNames = commonFiles.Aggregate("",
(current, commonFile) =>
current + "\r\n" + commonFile);
throw new Exception(
"The following file(s) exist in the destination folder and overwrite is set to false:- " +
fileNames);
}
}
}
}
示例2: RecursiveCopy
void RecursiveCopy(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args)
{
try
{
// List directory contents
var srcContentsFolders = src.ListFoldersInDirectory(src.IOPath);
Task.WaitAll(srcContentsFolders.Select(sourcePath => Task.Run(() =>
{
var sourceEndPoint =
ActivityIOFactory.CreateOperationEndPointFromIOPath(sourcePath);
IList<string> dirParts =
sourceEndPoint.IOPath.Path.Split(sourceEndPoint.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
var destinationPath =
ActivityIOFactory.CreatePathFromString(dst.Combine(dirParts.Last()), dst.IOPath.Username,
dst.IOPath.Password, true, dst.IOPath.PrivateKeyFile);
var destinationEndPoint =
ActivityIOFactory.CreateOperationEndPointFromIOPath(destinationPath);
dst.CreateDirectory(destinationPath, args);
TransferDirectoryContents(sourceEndPoint, destinationEndPoint, args);
})).ToArray());
}
catch(AggregateException e)
{
var message = e.InnerExceptions.Where(exception => exception != null && !string.IsNullOrEmpty(exception.Message)).Aggregate("", (current, exception) => current + exception.Message + "\r\n");
throw new Exception(message, e);
}
}
示例3: AddMissingFileDirectoryParts
void AddMissingFileDirectoryParts(IActivityIOOperationsEndPoint src,
IActivityIOOperationsEndPoint dst)
{
if(src.IOPath.Path.Trim().Length == 0)
{
throw new Exception("Source can not be an empty string");
}
var sourceParts = src.IOPath.Path.Split(src.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries).ToList();
if(dst.IOPath.Path.Trim().Length == 0)
{
dst.IOPath.Path = src.IOPath.Path;
}
else
{
if(!Path.IsPathRooted(dst.IOPath.Path) && IsNotFtpTypePath(dst.IOPath) && IsUncFileTypePath(dst.IOPath))
{
var lastPart = sourceParts.Last();
dst.IOPath.Path =
Path.Combine(src.PathIs(dst.IOPath) == enPathType.Directory
? src.IOPath.Path
: src.IOPath.Path.Replace(lastPart, ""), dst.IOPath.Path);
}
}
var destinationParts = dst.IOPath.Path.Split(dst.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries).ToList();
while(destinationParts.Count > sourceParts.Count)
{
destinationParts.Remove(destinationParts.Last());
}
if(destinationParts.OrderBy(i => i).SequenceEqual(sourceParts.OrderBy(i => i)))
{
if(dst.PathIs(dst.IOPath) == enPathType.Directory)
{
var strings = src.IOPath.Path.Split(src.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
var lastPart = strings.Last();
dst.IOPath.Path = src.PathIs(src.IOPath) == enPathType.Directory
? Path.Combine(dst.IOPath.Path, lastPart)
: dst.IOPath.Path.Replace(lastPart, "");
}
}
else
{
if(dst.PathIs(dst.IOPath) == enPathType.Directory && src.PathIs(src.IOPath) == enPathType.Directory)
{
var strings = src.IOPath.Path.Split(src.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
var lastPart = strings.Last();
dst.IOPath.Path = dst.Combine(lastPart);
}
}
}
示例4: Copy
public string Copy(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst,
Dev2CRUDOperationTO args)
{
string status;
try
{
status = ValidateCopySourceDestinationFileOperation(src, dst, args, () =>
{
if(src.RequiresLocalTmpStorage())
{
if(dst.PathIs(dst.IOPath) == enPathType.Directory)
{
dst.IOPath.Path = dst.Combine(GetFileNameFromEndPoint(src));
}
using(var s = src.Get(src.IOPath, _filesToDelete))
{
// for flips sake quite putting short-hand notation in-line it causes bugs!!! ;)
dst.Put(s, dst.IOPath, args, Path.IsPathRooted(src.IOPath.Path) ? Path.GetDirectoryName(src.IOPath.Path) : null, _filesToDelete);
s.Close();
s.Dispose();
}
}
else
{
var sourceFile = new FileInfo(src.IOPath.Path);
if(dst.PathIs(dst.IOPath) == enPathType.Directory)
{
dst.IOPath.Path = dst.Combine(sourceFile.Name);
}
using(var s = src.Get(src.IOPath, _filesToDelete))
{
if(sourceFile.Directory != null)
{
dst.Put(s, dst.IOPath, args, sourceFile.Directory.ToString(), _filesToDelete);
}
}
}
return ResultOk;
});
}
finally
{
_filesToDelete.ForEach(RemoveTmpFile);
}
return status;
}
示例5: ValidateZipSourceDestinationFileOperation
string ValidateZipSourceDestinationFileOperation(IActivityIOOperationsEndPoint src,
IActivityIOOperationsEndPoint dst,
Dev2ZipOperationTO args,
Func<string> performAfterValidation)
{
AddMissingFileDirectoryParts(src, dst);
if(dst.PathIs(dst.IOPath) == enPathType.Directory)
{
var sourcePart =
src.IOPath.Path.Split(src.PathSeperator().ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.Last();
if(src.PathIs(src.IOPath) == enPathType.File)
{
var fileInfo = new FileInfo(sourcePart);
dst.IOPath.Path = dst.Combine(sourcePart.Replace(fileInfo.Extension, ".zip"));
}
else
{
dst.IOPath.Path = dst.IOPath.Path + ".zip";
}
}
else
{
var sourcePart =
dst.IOPath.Path.Split(dst.PathSeperator().ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.Last();
var fileInfo = new FileInfo(sourcePart);
dst.IOPath.Path = dst.IOPath.Path.Replace(fileInfo.Extension, ".zip");
}
if(!args.Overwrite && dst.PathExist(dst.IOPath))
{
throw new Exception("Destination file already exists and overwrite is set to false");
}
//ensures destination folder structure exists
var opStatus = CreateEndPoint(dst, new Dev2CRUDOperationTO(args.Overwrite),
dst.PathIs(dst.IOPath) == enPathType.Directory);
if(!opStatus.Equals("Success"))
{
throw new Exception("Recursive Directory Create Failed For [ " + dst.IOPath.Path + " ]");
}
return performAfterValidation();
}