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


C# IActivityIOOperationsEndPoint类代码示例

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


IActivityIOOperationsEndPoint类属于命名空间,在下文中一共展示了IActivityIOOperationsEndPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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