• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IActivityIOOperationsEndPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IActivityIOOperationsEndPoint的典型用法代码示例。如果您正苦于以下问题:C# IActivityIOOperationsEndPoint类的具体用法?C# IActivityIOOperationsEndPoint怎么用?C# IActivityIOOperationsEndPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IActivityIOOperationsEndPoint类属于命名空间,在下文中一共展示了IActivityIOOperationsEndPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:34,代码来源:Dev2ActivityIOBroker.cs


示例2: Create

 public string Create(IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args, bool createToFile)
 {
     CreateToFile = createToFile;
     Destination = dst;
     Dev2CRUDOperationTO = args;
     return "Successful";
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:7,代码来源:ActivityOperationBrokerMock.cs


示例3: Rename

 /// <summary>
 /// Renames a file or folder from src to dst as per the value of args
 /// </summary>
 /// <param name="src"></param>
 /// <param name="dst"></param>
 /// <param name="args"></param>
 public string Rename(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args)
 {
     Source = src;
     Destination = dst;
     Dev2CRUDOperationTO = args;
     return "Successful";
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:13,代码来源:ActivityOperationBrokerMock.cs


示例4: ExecuteBroker

 protected override string ExecuteBroker(IActivityOperationsBroker broker, IActivityIOOperationsEndPoint scrEndPoint, IActivityIOOperationsEndPoint dstEndPoint)
 {
     Dev2UnZipOperationTO zipTo =
                ActivityIOFactory.CreateUnzipTO(ColItr.FetchNextValue(_archPassItr),
                                                Overwrite);
     return broker.UnZip(scrEndPoint, dstEndPoint, zipTo);
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:7,代码来源:DsfUnZip.cs


示例5: 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);
            }
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:24,代码来源:Dev2ActivityIOBroker.cs


示例6: 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
            {
//.........这里部分代码省略.........
开发者ID:Robin--,项目名称:Warewolf,代码行数:101,代码来源:Dev2ActivityIOBroker.cs


示例7: 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);
                    }
                }
            }
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:59,代码来源:Dev2ActivityIOBroker.cs


示例8: 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


示例9: 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);
     }
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:28,代码来源:Dev2ActivityIOBroker.cs


示例10: Create

 public string Create(IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args, bool createToFile)
 {
     string result;
     try
     {
         ValidateEndPoint(dst, args);
         result = CreateEndPoint(dst, args, createToFile);
     }
     finally
     {
         _filesToDelete.ForEach(RemoveTmpFile);
     }
     return result;
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:14,代码来源:Dev2ActivityIOBroker.cs


示例11: 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;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:36,代码来源:Dev2ActivityIOBroker.cs


示例12: ExecuteBroker

 protected override string ExecuteBroker(IActivityOperationsBroker broker, IActivityIOOperationsEndPoint scrEndPoint, IActivityIOOperationsEndPoint dstEndPoint)
 {
     Dev2CRUDOperationTO opTo = new Dev2CRUDOperationTO(Overwrite);
     var result = broker.Rename(scrEndPoint, dstEndPoint, opTo);
     return result.Replace("Move", "Rename");
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:6,代码来源:DsfPathRename.cs


示例13: GetWhereToPut

 static string GetWhereToPut(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst)
 {
     if(src.IOPath.PathType == enActivityIOPathType.FileSystem)
     {
         // some silly chicken is not getting the directory correctly ?!
         return Path.GetDirectoryName(src.IOPath.Path);
     }
     if(dst.IOPath.PathType == enActivityIOPathType.FileSystem)
     {
         return Path.GetDirectoryName(src.IOPath.Path);
     }
     return null; // this means that neither the src or destination where local files
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:13,代码来源:Dev2ActivityIOBroker.cs


示例14: GetFileNameFromEndPoint

 static string GetFileNameFromEndPoint(IActivityIOOperationsEndPoint endPoint, IActivityIOPath path)
 {
     var pathSeperator = endPoint.PathSeperator();
     return path.Path.Split(pathSeperator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Last();
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:5,代码来源:Dev2ActivityIOBroker.cs


示例15: 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;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:68,代码来源:Dev2ActivityIOBroker.cs


示例16: 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;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:57,代码来源:Dev2ActivityIOBroker.cs


示例17: Move

        public string Move(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst,
                           Dev2CRUDOperationTO args)
        {
            string result;

            try
            {
                result = Copy(src, dst, args);

                if(result.Equals("Success"))
                {
                    src.Delete(src.IOPath);
                }
            }
            finally
            {
                _filesToDelete.ForEach(RemoveTmpFile);
            }

            return result;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:21,代码来源:Dev2ActivityIOBroker.cs


示例18: 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;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:49,代码来源:Dev2ActivityIOBroker.cs


示例19: Rename

 public string Rename(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst,
                      Dev2CRUDOperationTO args)
 {
     string result;
     try
     {
         result = ValidateRenameSourceAndDesinationTypes(src, dst, args);
     }
     finally
     {
         _filesToDelete.ForEach(RemoveTmpFile);
     }
     return result;
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:14,代码来源:Dev2ActivityIOBroker.cs


示例20: 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);
                }
            }
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:24,代码来源:Dev2ActivityIOBroker.cs



注:本文中的IActivityIOOperationsEndPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IActivityIOPath类代码示例发布时间:2022-05-24
下一篇:
C# IActivity类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap