本文整理汇总了C#中IActivityIOOperationsEndPoint.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IActivityIOOperationsEndPoint.Get方法的具体用法?C# IActivityIOOperationsEndPoint.Get怎么用?C# IActivityIOOperationsEndPoint.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActivityIOOperationsEndPoint
的用法示例。
在下文中一共展示了IActivityIOOperationsEndPoint.Get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
// See interfaces summary's for more detail
public string Get(IActivityIOOperationsEndPoint path, bool deferredRead = false)
{
string result;
try
{
// TODO : we need to chunk this in
if(!deferredRead)
{
byte[] bytes;
using(var s = path.Get(path.IOPath, _filesToDelete))
{
bytes = new byte[s.Length];
s.Position = 0;
s.Read(bytes, 0, (int)s.Length);
}
// TODO : Remove the need for this ;(
return Encoding.UTF8.GetString(bytes);
}
// If we want to defer the read of data, just return the file name ;)
// Serialize to binary and return
BinaryDataListUtil bdlUtil = new BinaryDataListUtil();
result = bdlUtil.SerializeDeferredItem(path);
}
finally
{
_filesToDelete.ForEach(RemoveTmpFile);
}
return result;
}
示例2: Get
// See interfaces summary's for more detail
public string Get(IActivityIOOperationsEndPoint path, bool deferredRead = false)
{
try
{
byte[] bytes;
using(var s = path.Get(path.IOPath, _filesToDelete))
{
bytes = new byte[s.Length];
s.Position = 0;
s.Read(bytes, 0, (int)s.Length);
}
// TODO : Remove the need for this ;(
return Encoding.UTF8.GetString(bytes);
}
finally
{
_filesToDelete.ForEach(RemoveTmpFile);
}
}
示例3: ZipFileToALocalTempFile
string ZipFileToALocalTempFile(IActivityIOOperationsEndPoint src, Dev2ZipOperationTO args)
{
// normal not wild char file && not directory
var packFile = src.IOPath.Path;
var tempFileName = CreateTmpFile();
if(src.RequiresLocalTmpStorage())
{
string tempDir = CreateTmpDirectory();
var tmpFile = Path.Combine(tempDir,
src.IOPath.Path.Split(src.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries)
.Last());
packFile = tmpFile;
using(var s = src.Get(src.IOPath, _filesToDelete))
{
File.WriteAllBytes(tmpFile, s.ToByteArray());
}
}
using(var zip = new ZipFile())
{
// set password if exist
if(args.ArchivePassword != string.Empty)
{
zip.Password = args.ArchivePassword;
}
// compression ratio
zip.CompressionLevel = ExtractZipCompressionLevel(args.CompressionRatio);
// add all files to archive
zip.AddFile(packFile, ".");
zip.Save(tempFileName);
}
return tempFileName;
}
示例4: PutRaw
public string PutRaw(IActivityIOOperationsEndPoint dst, Dev2PutRawOperationTO args)
{
var result = ResultOk;
// directory put?
// wild char put?
try
{
_fileLock.EnterWriteLock();
if(dst.RequiresLocalTmpStorage())
{
var tmp = CreateTmpFile();
switch(args.WriteType)
{
case WriteType.AppendBottom:
using(var s = dst.Get(dst.IOPath, _filesToDelete))
{
File.WriteAllBytes(tmp, s.ToByteArray());
File.AppendAllText(tmp, args.FileContents);
}
break;
case WriteType.AppendTop:
using(var s = dst.Get(dst.IOPath, _filesToDelete))
{
File.WriteAllText(tmp, args.FileContents);
AppendToTemp(s, tmp);
}
break;
default:
if(IsBase64(args.FileContents))
{
var data = Convert.FromBase64String(args.FileContents.Replace("Content-Type:BASE64", ""));
File.WriteAllBytes(tmp, data);
}
else
{
File.WriteAllText(tmp, args.FileContents);
}
break;
}
result = MoveTmpFileToDestination(dst, tmp, result);
}
else
{
if(File.Exists(dst.IOPath.Path))
{
var tmp = CreateTmpFile();
switch(args.WriteType)
{
case WriteType.AppendBottom:
File.AppendAllText(dst.IOPath.Path, args.FileContents);
result = ResultOk;
break;
case WriteType.AppendTop:
using(var s = dst.Get(dst.IOPath, _filesToDelete))
{
File.WriteAllText(tmp, args.FileContents);
AppendToTemp(s, tmp);
result = MoveTmpFileToDestination(dst, tmp, result);
RemoveTmpFile(tmp);
}
break;
default:
if(IsBase64(args.FileContents))
{
var data = Convert.FromBase64String(args.FileContents.Replace("Content-Type:BASE64", ""));
File.WriteAllBytes(tmp, data);
}
else
{
File.WriteAllText(tmp, args.FileContents);
}
result = MoveTmpFileToDestination(dst, tmp, result);
RemoveTmpFile(tmp);
break;
}
}
else
{
// we can write directly to the file
Dev2CRUDOperationTO newArgs = new Dev2CRUDOperationTO(true);
CreateEndPoint(dst, newArgs, true);
if(IsBase64(args.FileContents))
{
var data = Convert.FromBase64String(args.FileContents.Replace("Content-Type:BASE64", ""));
File.WriteAllBytes(dst.IOPath.Path, data);
}
else
{
File.WriteAllText(dst.IOPath.Path, args.FileContents);
}
}
}
}
finally
{
//.........这里部分代码省略.........
示例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;
}
示例6: UnZip
public string UnZip(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst,
Dev2UnZipOperationTO args)
{
string status;
try
{
status = ValidateUnzipSourceDestinationFileOperation(src, dst, args, () =>
{
ZipFile zip;
var tempFile = "";
if(src.RequiresLocalTmpStorage())
{
var tmpZip = CreateTmpFile();
using(var s = src.Get(src.IOPath, _filesToDelete))
{
File.WriteAllBytes(tmpZip, s.ToByteArray());
}
tempFile = tmpZip;
zip = ZipFile.Read(tempFile);
}
else
{
zip = ZipFile.Read(src.Get(src.IOPath, _filesToDelete));
}
if(dst.RequiresLocalTmpStorage())
{
// unzip locally then Put the contents of the archive to the dst end-point
var tempPath = CreateTmpDirectory();
ExtractFile(args, zip, tempPath);
var endPointPath = ActivityIOFactory.CreatePathFromString(tempPath, "", "","");
var endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(endPointPath);
Move(endPoint, dst, new Dev2CRUDOperationTO(args.Overwrite));
}
else
{
ExtractFile(args, zip, dst.IOPath.Path);
}
if(src.RequiresLocalTmpStorage())
{
File.Delete(tempFile);
}
return ResultOk;
});
}
finally
{
_filesToDelete.ForEach(RemoveTmpFile);
}
return status;
}
示例7: 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;
}
示例8: ReadFile
public static string ReadFile(IActivityIOOperationsEndPoint endpoint)
{
var stream = endpoint.Get(endpoint.IOPath, new List<string>());
stream.Position = 0;
using (var reader = new StreamReader(stream, Encoding.UTF8))
{
return reader.ReadToEnd();
}
}