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); }
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); }
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); }
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); } }
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); }
public bool CreateDirectory(IActivityIOOperationsEndPoint dst, IDev2CRUDOperationTO args) { var result = dst.CreateDirectory(dst.IOPath, args); return(result); }
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); } }
bool CreateDirectory(IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args) { var result = dst.CreateDirectory(dst.IOPath, args); return result; }