当前位置: 首页>>代码示例>>C#>>正文


C# IActivityIOOperationsEndPoint.PathSeperator方法代码示例

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


在下文中一共展示了IActivityIOOperationsEndPoint.PathSeperator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

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

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

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

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

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

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


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