本文整理汇总了C#中IActivityIOOperationsEndPoint.PathIs方法的典型用法代码示例。如果您正苦于以下问题:C# IActivityIOOperationsEndPoint.PathIs方法的具体用法?C# IActivityIOOperationsEndPoint.PathIs怎么用?C# IActivityIOOperationsEndPoint.PathIs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActivityIOOperationsEndPoint
的用法示例。
在下文中一共展示了IActivityIOOperationsEndPoint.PathIs方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureFilesDontExists
static void EnsureFilesDontExists(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst)
{
if(dst.PathExist(dst.IOPath))
{
// destination is a file
if(dst.PathIs(dst.IOPath) == enPathType.File)
{
throw new Exception(
"A file with the same name exists on the destination and overwrite is set to false");
}
//destination is a folder
var dstContents = dst.ListDirectory(dst.IOPath);
var destinationFileNames = dstContents.Select(dstFile => GetFileNameFromEndPoint(dst, dstFile));
var sourceFile = GetFileNameFromEndPoint(src);
if(destinationFileNames.Contains(sourceFile))
{
throw new Exception(
"The following file(s) exist in the destination folder and overwrite is set to false :- " +
sourceFile);
}
}
}
示例2: Zip
public string Zip(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, Dev2ZipOperationTO args)
{
string status;
try
{
status = ValidateZipSourceDestinationFileOperation(src, dst, args, () =>
{
string tempFileName;
if(src.PathIs(src.IOPath) == enPathType.Directory || Dev2ActivityIOPathUtils.IsStarWildCard(src.IOPath.Path))
{
tempFileName = ZipDirectoryToALocalTempFile(src, args);
}
else
{
tempFileName = ZipFileToALocalTempFile(src, args);
}
return TransferTempZipFileToDestination(src, dst, args, tempFileName);
});
}
finally
{
_filesToDelete.ForEach(RemoveTmpFile);
}
return status;
}
示例3: CreateEndPoint
string CreateEndPoint(IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args, bool createToFile)
{
var result = ResultOk;
// check the the dir strucutre exist
var activityIOPath = dst.IOPath;
var dirParts = MakeDirectoryParts(activityIOPath, dst.PathSeperator());
// check from lowest path part up
var deepestIndex = -1;
var startDepth = dirParts.Count - 1;
var pos = startDepth;
while(pos >= 0 && deepestIndex == -1)
{
var tmpPath = ActivityIOFactory.CreatePathFromString(dirParts[pos], activityIOPath.Username,
activityIOPath.Password, true,activityIOPath.PrivateKeyFile);
try
{
if(dst.ListDirectory(tmpPath) != null)
{
deepestIndex = pos;
}
}
// ReSharper disable EmptyGeneralCatchClause
catch(Exception)
// ReSharper restore EmptyGeneralCatchClause
{
//Note that we doing a recursive create should the directory not exists
}
finally
{
pos--;
}
}
// now create all the directories we need ;)
pos = deepestIndex + 1;
var ok = true;
var origPath = dst.IOPath;
while(pos <= startDepth && ok)
{
var toCreate = ActivityIOFactory.CreatePathFromString(dirParts[pos], dst.IOPath.Username,
dst.IOPath.Password, true, dst.IOPath.PrivateKeyFile);
dst.IOPath = toCreate;
ok = CreateDirectory(dst, args);
pos++;
}
dst.IOPath = origPath;
// dir create failed
if(!ok)
{
result = ResultBad;
}
else if(dst.PathIs(dst.IOPath) == enPathType.File && createToFile)
{
if(!CreateFile(dst, args))
{
result = ResultBad;
}
}
return result;
}
示例4: 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;
}
示例5: ValidateEndPoint
void ValidateEndPoint(IActivityIOOperationsEndPoint endPoint, Dev2CRUDOperationTO args)
{
if(endPoint.IOPath.Path.Trim().Length == 0)
{
throw new Exception("Source can not be an empty string");
}
if(endPoint.PathExist(endPoint.IOPath) && !args.Overwrite)
{
var type = endPoint.PathIs(endPoint.IOPath) == enPathType.Directory ? "Directory" : "File";
throw new Exception(string.Format("Destination {0} already exists and overwrite is set to false",
type));
}
}
示例6: 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;
}
示例7: ValidateSourceAndDestinationPaths
void ValidateSourceAndDestinationPaths(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)))
{
throw new Exception("Destination directory can not be a child of the source directory");
}
}
示例8: 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();
}
示例9: ValidateUnzipSourceDestinationFileOperation
string ValidateUnzipSourceDestinationFileOperation(IActivityIOOperationsEndPoint src,
IActivityIOOperationsEndPoint dst,
Dev2UnZipOperationTO args,
Func<string> performAfterValidation)
{
ValidateSourceAndDestinationPaths(src, dst);
if(dst.PathIs(dst.IOPath) != enPathType.Directory)
{
throw new Exception("Destination must be a directory");
}
if(src.PathIs(src.IOPath) != enPathType.File)
{
throw new Exception("Source must be a file");
}
if(!args.Overwrite && dst.PathExist(dst.IOPath))
{
throw new Exception("Destination directory already exists and overwrite is set to false");
}
return performAfterValidation();
}
示例10: ValidateCopySourceDestinationFileOperation
string ValidateCopySourceDestinationFileOperation(IActivityIOOperationsEndPoint src,
IActivityIOOperationsEndPoint dst,
Dev2CRUDOperationTO args,
Func<string> performAfterValidation)
{
var result = ResultOk;
ValidateSourceAndDestinationPaths(src, dst);
//ensures destination folder structure exists
var opStatus = CreateEndPoint(dst, args, dst.PathIs(dst.IOPath) == enPathType.Directory);
if(!opStatus.Equals("Success"))
{
throw new Exception("Recursive Directory Create Failed For [ " + dst.IOPath.Path + " ]");
}
//transfer contents to destination when the source is a directory
if(src.PathIs(src.IOPath) == enPathType.Directory)
{
if(!TransferDirectoryContents(src, dst, args))
{
result = ResultBad;
}
}
else
{
if(!args.Overwrite)
{
EnsureFilesDontExists(src, dst);
}
if(!Dev2ActivityIOPathUtils.IsStarWildCard(src.IOPath.Path))
{
return performAfterValidation();
}
// we have star wild cards to deal with
if(!TransferDirectoryContents(src, dst, args))
{
result = ResultBad;
}
}
return result;
}
示例11: ValidateRenameSourceAndDesinationTypes
string ValidateRenameSourceAndDesinationTypes(IActivityIOOperationsEndPoint src,
IActivityIOOperationsEndPoint dst,
Dev2CRUDOperationTO args)
{
//ensures that the source and destination locations are of the same type
if(src.PathIs(src.IOPath) != dst.PathIs(dst.IOPath))
{
throw new Exception("Source and destination need to be both files or directories");
}
//Rename Tool if the file/folder exists then delete it and put the source there
if(dst.PathExist(dst.IOPath))
{
if(!args.Overwrite)
{
throw new Exception("Destination directory already exists and overwrite is set to false");
}
//Clear the existing folder
dst.Delete(dst.IOPath);
}
return Move(src, dst, args);
}