Ejemplo n.º 1
0
        public void CreateDirectoryWithOverwriteFalse_Present_Expected_DirectoryNotCreated()
        {
            Dev2CRUDOperationTO           opTO          = new Dev2CRUDOperationTO(false);
            IActivityIOPath               path          = ActivityIOFactory.CreatePathFromString(_tmpdir1, "", "");
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            bool ok = FileSystemPro.CreateDirectory(path, opTO);

            Assert.IsFalse(ok);
        }
Ejemplo n.º 2
0
        public void CreateDirectoryWithOverwriteTrue_NotPresent_Expected_DirectoryCreated()
        {
            Dev2CRUDOperationTO opTO = new Dev2CRUDOperationTO(true);
            string          dir      = Path.GetTempPath() + Path.GetRandomFileName();
            IActivityIOPath path     = ActivityIOFactory.CreatePathFromString(dir, "", "");
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            bool ok = FileSystemPro.CreateDirectory(path, opTO);

            Directory.Delete(dir);

            Assert.IsTrue(ok);
        }
Ejemplo n.º 3
0
        public void CreateDirectoryUNCValidUser_WithOverwriteTrue_NotPresent_DirectoryCreated()
        {
            Dev2CRUDOperationTO opTO = new Dev2CRUDOperationTO(true);
            string          basePath = TestResource.PathOperations_UNC_Path_Secure + Guid.NewGuid();
            IActivityIOPath path     = ActivityIOFactory.CreatePathFromString(basePath, (_inDomain ? "DEV2\\" : ".\\") + TestResource.PathOperations_Correct_Username, TestResource.PathOperations_Correct_Password);
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            bool result = FileSystemPro.CreateDirectory(path, opTO);

            PathIOTestingUtils.DeleteAuthedUNCPath(basePath, _inDomain);

            Assert.IsTrue(result);
        }
Ejemplo n.º 4
0
 void RecursiveCopy(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, IDev2CRUDOperationTO args)
 {
     try
     {
         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 => !string.IsNullOrEmpty(exception?.Message)).Aggregate(string.Empty, (current, exception) => current + exception.Message + "\r\n");
         throw new Exception(message, e);
     }
 }
Ejemplo n.º 5
0
        public static string CreateFilesFTP(string basePath, string userName, string password, bool ftps,
                                            string fileName, string dataString, bool createDirectory, string testFile = "")
        {
            string remoteDirectoy = basePath + Guid.NewGuid() + "/";
            string path           = remoteDirectoy + fileName;

            if (createDirectory)
            {
                IActivityIOPath pathFromString = ActivityIOFactory.CreatePathFromString(remoteDirectoy, userName,
                                                                                        password);
                IActivityIOOperationsEndPoint FTPPro =
                    ActivityIOFactory.CreateOperationEndPointFromIOPath(pathFromString);

                FTPPro.CreateDirectory(pathFromString, new Dev2CRUDOperationTO(false));

                byte[] data;

                if (string.IsNullOrEmpty(testFile))
                {
                    data = Encoding.UTF8.GetBytes(dataString);
                }
                else
                {
                    var fs = new FileStream(testFile,
                                            FileMode.Open,
                                            FileAccess.Read);
                    var  br       = new BinaryReader(fs);
                    long numBytes = new FileInfo(testFile).Length;
                    data = br.ReadBytes((int)numBytes);
                }

                Stream dataStream = new MemoryStream(data);

                pathFromString = ActivityIOFactory.CreatePathFromString(path, userName, password);
                FTPPro         = ActivityIOFactory.CreateOperationEndPointFromIOPath(pathFromString);
                FTPPro.Put(dataStream, pathFromString, new Dev2CRUDOperationTO(true), null, new List <string>());
            }

            return(path);
        }
Ejemplo n.º 6
0
        public bool CreateDirectory(IActivityIOOperationsEndPoint dst, IDev2CRUDOperationTO args)
        {
            var result = dst.CreateDirectory(dst.IOPath, args);

            return(result);
        }
Ejemplo n.º 7
0
 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);
     }
 }
Ejemplo n.º 8
0
 bool CreateDirectory(IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args)
 {
     var result = dst.CreateDirectory(dst.IOPath, args);
     return result;
 }