public void Rename_GivenSoureAndDestinationSamePathTypePathExistsOverwriteFalse_ShouldThrowException() { //Rename(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst,Dev2CRUDOperationTO args) //---------------Set up test pack------------------- var activityOperationsBroker = CreateBroker(); var args = new Dev2CRUDOperationTO(false); var src = new Mock <IActivityIOOperationsEndPoint>(); var dst = new Mock <IActivityIOOperationsEndPoint>(); src.Setup(point => point.PathIs(It.IsAny <IActivityIOPath>())).Returns(enPathType.File); dst.Setup(point => point.PathIs(It.IsAny <IActivityIOPath>())).Returns(enPathType.File); dst.Setup(point => point.PathExist(It.IsAny <IActivityIOPath>())).Returns(true); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { activityOperationsBroker.Rename(src.Object, dst.Object, args); } catch (Exception exc) { Assert.AreEqual(ErrorResource.DestinationDirectoryExist, exc.Message); } //---------------Test Result ----------------------- }
public bool CreateDirectory(IActivityIOPath dst, Dev2CRUDOperationTO args) { bool result = false; bool ok; if (args.Overwrite) { // delete if it already present if (IsDirectoryAlreadyPresent(dst)) { Delete(dst); } ok = true; } else { // does not exist, ok to create ok = !(IsDirectoryAlreadyPresent(dst)); } if (ok) { result = IsStandardFtp(dst) ? CreateDirectoryStandardFtp(dst) : CreateDirectorySftp(dst); } return(result); }
public string Move(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args) { Source = src; Destination = dst; Dev2CRUDOperationTO = args; return("Successful"); }
public void Rename_GivenSoureAndDestinationSamePathTypePathExistsOverwriteTrue_ShouldDeleteDestFile() { //Rename(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst,Dev2CRUDOperationTO args) //---------------Set up test pack------------------- var activityOperationsBroker = CreateBroker(); var args = new Dev2CRUDOperationTO(true); var src = new Mock <IActivityIOOperationsEndPoint>(); var dst = new Mock <IActivityIOOperationsEndPoint>(); src.Setup(point => point.PathIs(It.IsAny <IActivityIOPath>())).Returns(enPathType.File); dst.Setup(point => point.PathIs(It.IsAny <IActivityIOPath>())).Returns(enPathType.File); dst.Setup(point => point.PathExist(It.IsAny <IActivityIOPath>())).Returns(true); dst.Setup(point => point.Delete(It.IsAny <IActivityIOPath>())).Returns(true); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { activityOperationsBroker.Rename(src.Object, dst.Object, args); } catch (Exception) { // ignored } finally { //---------------Test Result ----------------------- dst.Verify(point => point.Delete(It.IsAny <IActivityIOPath>())); } }
public void ValidateSourceAndDestinationPaths_GivenIsPathRooted_ShouldReturnFalse() { const string txt = "C:\\Home\\a.txt"; var srcPath = new Mock <IActivityIOPath>(); srcPath.Setup(path => path.Path).Returns(txt); var dstPath = new Mock <IActivityIOPath>(); dstPath.Setup(path => path.Path).Returns("some relative path"); var dev2CrudOperationTO = new Dev2CRUDOperationTO(true); var src = new Mock <IActivityIOOperationsEndPoint>(); src.Setup(p => p.CreateDirectory(It.IsAny <IActivityIOPath>(), dev2CrudOperationTO)).Returns(true); src.Setup(p => p.IOPath).Returns(srcPath.Object); src.Setup(p => p.PathSeperator()).Returns("\\"); var dst = new Mock <IActivityIOOperationsEndPoint>(); dst.Setup(p => p.CreateDirectory(It.IsAny <IActivityIOPath>(), dev2CrudOperationTO)).Returns(true); dst.Setup(p => p.IOPath).Returns(dstPath.Object); dst.Setup(p => p.PathSeperator()).Returns("\\"); var commonDataUtils = new CommonDataUtils(); commonDataUtils.ValidateSourceAndDestinationPaths(src.Object, dst.Object); }
public void CopyFileWithPathsExpectedRecursiveCopy() { var innerDir = Guid.NewGuid().ToString(); var tempPath = Path.GetTempPath(); var tempFileName = Path.GetFileName(Path.GetTempFileName()); const string TempData = "some string data"; if (tempFileName != null) { var tempFile = Path.Combine(tempPath, innerDir, innerDir, tempFileName); string directoryName = Path.GetDirectoryName(tempFile); if (directoryName != null) { Directory.CreateDirectory(directoryName); } var upperLevelDir = Path.Combine(tempPath, innerDir); File.WriteAllText(tempFile, TempData); var dst = Path.Combine(tempPath, Guid.NewGuid().ToString()); var scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(upperLevelDir, string.Empty, null, true)); var dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(dst, string.Empty, null, true)); var moveTO = new Dev2CRUDOperationTO(true); ActivityIOFactory.CreateOperationsBroker().Copy(scrEndPoint, dstEndPoint, moveTO); var newFilePath = Path.Combine(dst, innerDir, tempFileName); Assert.IsTrue(File.Exists(newFilePath)); Assert.IsTrue(File.Exists(tempFile)); } }
public string Create(IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args, bool createToFile) { CreateToFile = createToFile; Destination = dst; Dev2CRUDOperationTO = args; return("Successful"); }
public void PutWithOverwriteTrue_FileNot_Present_Expect_FileReadAndDataInputToStream() { Dev2CRUDOperationTO opTO = new Dev2CRUDOperationTO(true); string tmp = Path.GetTempFileName(); File.Delete(tmp); IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(tmp, "", ""); IActivityIOPath src = ActivityIOFactory.CreatePathFromString(_tmpfile2, "", ""); IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst); Stream stream = FileSystemPro.Get(src, new List <string>()); var directoryInfo = new FileInfo(src.Path).Directory; if (directoryInfo != null) { int len = FileSystemPro.Put(stream, dst, opTO, directoryInfo.ToString(), new List <string>()); stream.Close(); File.Delete(tmp); Assert.IsTrue(len > 0); } else { Assert.Fail(); } }
public void AddMissingFileDirectoryParts_GivenDestinationPathIsDirectory_SourcePathIsDirectory() { const string file = "C:\\Parent\\a.txt"; const string dstfile = "C:\\Parent\\Child\\"; var srcPath = new Mock <IActivityIOPath>(); srcPath.Setup(path => path.Path).Returns(file); var dstPath = new Mock <IActivityIOPath>(); dstPath.Setup(path => path.Path).Returns(dstfile); var dev2CrudOperationTO = new Dev2CRUDOperationTO(true); var src = new Mock <IActivityIOOperationsEndPoint>(); src.Setup(p => p.CreateDirectory(It.IsAny <IActivityIOPath>(), dev2CrudOperationTO)).Returns(true); src.Setup(p => p.IOPath).Returns(srcPath.Object); src.Setup(p => p.PathSeperator()).Returns("\\"); src.Setup(p => p.PathIs(srcPath.Object)).Returns(enPathType.Directory); var dst = new Mock <IActivityIOOperationsEndPoint>(); dst.Setup(p => p.CreateDirectory(It.IsAny <IActivityIOPath>(), dev2CrudOperationTO)).Returns(true); dst.Setup(p => p.IOPath).Returns(dstPath.Object); dst.Setup(p => p.PathSeperator()).Returns("\\"); dst.Setup(p => p.PathIs(dstPath.Object)).Returns(enPathType.Directory); var commonDataUtils = new CommonDataUtils(); commonDataUtils.AddMissingFileDirectoryParts(src.Object, dst.Object); dstPath.VerifySet(p => p.Path = @"C:\Parent\Child\a.txt"); }
public void PutWithOverwriteTrue_UNCPathValidUser_File_Present_FileInStream() { Dev2CRUDOperationTO opTO = new Dev2CRUDOperationTO(true); string tmp = TestResource.PathOperations_UNC_Path_Secure + Guid.NewGuid() + ".test"; string tmp2 = TestResource.PathOperations_UNC_Path_Secure + Guid.NewGuid() + ".test"; PathIOTestingUtils.CreateAuthedUNCPath(tmp, false, _inDomain); IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(tmp, (_inDomain ? "DEV2\\" : ".\\") + TestResource.PathOperations_Correct_Username, TestResource.PathOperations_Correct_Password); IActivityIOPath src = ActivityIOFactory.CreatePathFromString(tmp2, (_inDomain ? "DEV2\\" : ".\\") + TestResource.PathOperations_Correct_Username, TestResource.PathOperations_Correct_Password); IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst); Stream stream = new MemoryStream(File.ReadAllBytes(_tmpfile1)); var directoryInfo = new FileInfo(src.Path).Directory; if (directoryInfo != null) { int len = FileSystemPro.Put(stream, dst, opTO, directoryInfo.ToString(), new List <string>()); stream.Close(); PathIOTestingUtils.DeleteAuthedUNCPath(tmp); PathIOTestingUtils.DeleteAuthedUNCPath(tmp2); Assert.IsTrue(len > 0); } else { Assert.Fail(); } }
public void Create_GivenDestination_ShouldCreateFileCorrectly() { //Create(IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args, bool createToFile) //---------------Set up test pack------------------- var activityOperationsBroker = CreateBroker(); var dstPath = new Mock <IActivityIOPath>(); var args = new Dev2CRUDOperationTO(true); var dst = new Mock <IActivityIOOperationsEndPoint>(); dst.Setup(point => point.IOPath.Username).Returns("userName"); dst.Setup(point => point.IOPath.Password).Returns("Password"); dst.Setup(point => point.PathSeperator()).Returns(","); dst.Setup(point => point.IOPath.Path).Returns("path"); dst.Setup(point => point.PathExist(dstPath.Object)).Returns(true); PrivateObject privateObject = new PrivateObject(activityOperationsBroker); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { privateObject.Invoke("Create", dst.Object, args, true); } catch (Exception ex) { //---------------Test Result ----------------------- Assert.AreEqual(ErrorResource.InvalidPath, ex.Message); var tempFileName = Path.GetTempFileName(); dst.Setup(point => point.IOPath.Path).Returns(tempFileName); var success = privateObject.Invoke("Create", dst.Object, args, true); Assert.AreEqual("Success".ToUpper(), success.ToString().ToUpper()); File.Delete(tempFileName); } }
protected override string ExecuteBroker(IActivityOperationsBroker broker, IActivityIOOperationsEndPoint scrEndPoint, IActivityIOOperationsEndPoint dstEndPoint) { var opTo = new Dev2CRUDOperationTO(Overwrite); var result = broker.Rename(scrEndPoint, dstEndPoint, opTo); return(result.Replace("Move", "Rename")); }
protected override IList <OutputTO> TryExecuteConcreteAction(IDSFDataObject context, out ErrorResultTO error, int update) { IList <OutputTO> outputs = new List <OutputTO>(); error = new ErrorResultTO(); var colItr = new WarewolfListIterator(); //get all the possible paths for all the string variables var outputItr = new WarewolfIterator(context.Environment.Eval(OutputPath, update)); colItr.AddVariableToIterateOn(outputItr); var passItr = new WarewolfIterator(context.Environment.Eval(DecryptedPassword, update)); colItr.AddVariableToIterateOn(passItr); var privateKeyItr = new WarewolfIterator(context.Environment.Eval(PrivateKeyFile, update)); colItr.AddVariableToIterateOn(privateKeyItr); if (context.IsDebugMode()) { AddDebugInputItem(new DebugEvalResult(OutputPath, "File or Folder", context.Environment, update)); AddDebugInputItem(new DebugItemStaticDataParams(Overwrite.ToString(), "Overwrite")); AddDebugInputItemUserNamePassword(context.Environment, update); if (!string.IsNullOrEmpty(PrivateKeyFile)) { AddDebugInputItem(PrivateKeyFile, "Destination Private Key File", context.Environment, update); } } while (colItr.HasMoreData()) { var broker = ActivityIOFactory.CreateOperationsBroker(); var opTo = new Dev2CRUDOperationTO(Overwrite); try { var dst = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(outputItr), Username, colItr.FetchNextValue(passItr), true, colItr.FetchNextValue(privateKeyItr)); var dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst); var result = broker.Create(dstEndPoint, opTo, true); outputs.Add(DataListFactory.CreateOutputTO(Result, result)); } catch (Exception e) { outputs.Add(DataListFactory.CreateOutputTO(Result, "Failure")); error.AddError(e.Message); break; } } return(outputs); }
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); }
protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update) { IList <OutputTO> outputs = new List <OutputTO>(); allErrors = new ErrorResultTO(); var colItr = new WarewolfListIterator(); //get all the possible paths for all the string variables var outputItr = new WarewolfIterator(dataObject.Environment.Eval(OutputPath, update)); colItr.AddVariableToIterateOn(outputItr); var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username, update)); colItr.AddVariableToIterateOn(unameItr); var passItr = new WarewolfIterator(dataObject.Environment.Eval(DecryptedPassword, update)); colItr.AddVariableToIterateOn(passItr); if (dataObject.IsDebugMode()) { AddDebugInputItem(new DebugEvalResult(OutputPath, "File or Folder", dataObject.Environment, update)); AddDebugInputItem(new DebugItemStaticDataParams(Overwrite.ToString(), "Overwrite")); AddDebugInputItemUserNamePassword(dataObject.Environment, update); } while (colItr.HasMoreData()) { IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker(); Dev2CRUDOperationTO opTo = new Dev2CRUDOperationTO(Overwrite); try { IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(outputItr), colItr.FetchNextValue(unameItr), colItr.FetchNextValue(passItr), true); IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst); string result = broker.Create(dstEndPoint, opTo, true); outputs.Add(DataListFactory.CreateOutputTO(Result, result)); } catch (Exception e) { outputs.Add(DataListFactory.CreateOutputTO(Result, "Failure")); allErrors.AddError(e.Message); break; } } return(outputs); }
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); }
public void ActivityIOBrokerBaseDriver_CreateDirectory_GivenValidInterfaces_ShouldCallsCreateDirectoryCorrectly() { var dev2CrudOperationTO = new Dev2CRUDOperationTO(true); var endPoint = new Mock <IActivityIOOperationsEndPoint>(); var ioPath = new Mock <IActivityIOPath>().Object; endPoint.Setup(o => o.IOPath).Returns(ioPath); endPoint.Setup(o => o.CreateDirectory(It.IsAny <IActivityIOPath>(), dev2CrudOperationTO)).Returns(true); var driver = new ActivityIOBrokerBaseDriver(); var result = driver.CreateDirectory(endPoint.Object, dev2CrudOperationTO); Assert.IsTrue(result); endPoint.Verify(o => o.CreateDirectory(ioPath, dev2CrudOperationTO)); }
public void PutWithOverwriteTrue_UNCPathValidUser_FileNot_Present_Expected_NewFileCreated() { Dev2CRUDOperationTO opTO = new Dev2CRUDOperationTO(true); string tmp = TestResource.PathOperations_UNC_Path_Secure + Guid.NewGuid() + ".test"; IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(tmp, (_inDomain ? "DEV2\\" : ".\\") + TestResource.PathOperations_Correct_Username, TestResource.PathOperations_Correct_Password); IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst); Stream stream = new MemoryStream(File.ReadAllBytes(_tmpfile1)); int len = FileSystemPro.Put(stream, dst, opTO, null, new List <string>()); stream.Close(); PathIOTestingUtils.DeleteAuthedUNCPath(tmp); Assert.IsTrue(len > 0); }
public void CreateDirectory_GivenValidInterfaces_ShouldCallsCreateDirectoryCorrectly() { //---------------Set up test pack------------------- var activityOperationsBroker = CreateBroker(); var dev2CrudOperationTO = new Dev2CRUDOperationTO(true); var endPoint = new Mock <IActivityIOOperationsEndPoint>(); endPoint.Setup(point => point.CreateDirectory(It.IsAny <IActivityIOPath>(), dev2CrudOperationTO)).Returns(true); PrivateObject privateObject = new PrivateObject(activityOperationsBroker); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var invoke = privateObject.Invoke("CreateDirectory", endPoint.Object, dev2CrudOperationTO); //---------------Test Result ----------------------- Assert.IsTrue(bool.Parse(invoke.ToString())); endPoint.Verify(point => point.CreateDirectory(It.IsAny <IActivityIOPath>(), dev2CrudOperationTO)); }
public void DoFileTransfer_GivenValidArgs_ShouldtransferCorrectly() { //---------------Set up test pack------------------- var activityOperationsBroker = CreateBroker(); var dstPath = new Mock <IActivityIOPath>(); var p = new Mock <IActivityIOPath>(); var args = new Dev2CRUDOperationTO(true); var src = new Mock <IActivityIOOperationsEndPoint>(); var dst = new Mock <IActivityIOOperationsEndPoint>(); dst.Setup(point => point.IOPath.Username).Returns("userName"); dst.Setup(point => point.IOPath.Password).Returns("Password"); dst.Setup(point => point.IOPath.PrivateKeyFile).Returns("PKFile"); dst.Setup(point => point.PathExist(dstPath.Object)).Returns(true); src.Setup(point => point.Get(It.IsAny <IActivityIOPath>(), It.IsAny <List <string> >())).Returns(new MemoryStream()); src.Setup(point => point.IOPath.PathType).Returns(enActivityIOPathType.FileSystem); PrivateObject privateObject = new PrivateObject(activityOperationsBroker); var path = ""; bool result = false; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { var invoke = privateObject.Invoke("DoFileTransfer", src.Object, dst.Object, args, dstPath.Object, p.Object, path, result); } catch (Exception e) { //---------------Test Result ----------------------- Assert.IsTrue(e.Message == "Invalid Path. Please ensure that the path provided is an absolute path, if you intended to access the local file system."); try { path = Path.GetTempFileName(); privateObject.Invoke("DoFileTransfer", src.Object, dst.Object, args, dstPath.Object, p.Object, path, result); File.Delete(path); } catch (Exception e1) { var error = $"Failed to authenticate with user [ userName ] for resource [ {path} ] "; var actualError = e1.Message; //---------------Test Result ----------------------- Assert.AreEqual(actualError, error); } } }
public int Put(Stream src, IActivityIOPath dst, Dev2CRUDOperationTO args, string whereToPut, List <string> filesToCleanup) { var result = -1; bool ok; if (args.Overwrite) { ok = true; } else { // try and fetch the file, if not found ok because we not in Overwrite mode try { using (Get(dst, filesToCleanup)) { ok = false; } } catch (Exception ex) { Dev2Logger.Log.Error(this, ex); ok = true; } } if (ok) { try { result = IsStandardFtp(dst) ? WriteToFtp(src, dst) : WriteToSftp(src, dst); } catch (Exception ex) { Dev2Logger.Log.Debug("Exception in Put command"); Dev2Logger.Log.Debug(ex.Message); Dev2Logger.Log.Debug(ex.StackTrace); Dev2Logger.Log.Error(this, ex); throw; } } return(result); }
public void ValidateEndPoint_GivenEmptyPath_ShouldThrowValidExc() { //---------------Set up test pack------------------- var dev2CrudOperationTO = new Dev2CRUDOperationTO(true); var endPoint = new Mock <IActivityIOOperationsEndPoint>(); endPoint.Setup(point => point.IOPath.Path).Returns(""); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { Util.CommonDataUtils commonDataUtils = new Util.CommonDataUtils(); commonDataUtils.ValidateEndPoint(endPoint.Object, dev2CrudOperationTO); } catch (Exception e) { Assert.AreEqual(ErrorResource.SourceCannotBeAnEmptyString, e.Message); } //---------------Test Result ----------------------- }
public void ValidateEndPoint_GivenPathAndOverwriteFalse_ShouldThrowValidExc() { //---------------Set up test pack------------------- var activityOperationsBroker = CreateBroker(); var dev2CrudOperationTO = new Dev2CRUDOperationTO(false); var endPoint = new Mock <IActivityIOOperationsEndPoint>(); endPoint.Setup(point => point.IOPath.Path).Returns("somepath"); endPoint.Setup(point => point.PathExist(It.IsAny <IActivityIOPath>())).Returns(true); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { Dev2.Data.Util.CommonDataUtils commonDataUtils = new Util.CommonDataUtils(); commonDataUtils.ValidateEndPoint(endPoint.Object, dev2CrudOperationTO); } catch (Exception e) { Assert.AreEqual(ErrorResource.DestinationDirectoryExist, e.Message); } //---------------Test Result ----------------------- }
public void PutWithOverwriteFalse_UNCPath_File_Not_Present_FileDataReadIntoStream() { Dev2CRUDOperationTO opTO = new Dev2CRUDOperationTO(false); File.Delete(_uncfile1); // remove it is not there IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(_uncfile1, "", ""); IActivityIOPath src = ActivityIOFactory.CreatePathFromString(_tmpfile2, "", ""); IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst); Stream stream = FileSystemPro.Get(src, new List <string>()); var directoryInfo = new FileInfo(src.Path).Directory; if (directoryInfo != null) { int len = FileSystemPro.Put(stream, dst, opTO, directoryInfo.ToString(), new List <string>()); stream.Close(); File.Delete(_uncfile1); Assert.IsTrue(len > 0); } else { Assert.Fail(); } }
protected override string ExecuteBroker(IActivityOperationsBroker broker, IActivityIOOperationsEndPoint scrEndPoint, IActivityIOOperationsEndPoint dstEndPoint) { Dev2CRUDOperationTO opTO = new Dev2CRUDOperationTO(Overwrite); return(broker.Copy(scrEndPoint, dstEndPoint, opTO)); }
protected override IList <OutputTO> ExecuteConcreteAction(NativeActivityContext context, out ErrorResultTO allErrors) { IList <OutputTO> outputs = new List <OutputTO>(); IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); allErrors = new ErrorResultTO(); ErrorResultTO errors; Guid executionId = dataObject.DataListID; IDev2IteratorCollection colItr = Dev2ValueObjectFactory.CreateIteratorCollection(); //get all the possible paths for all the string variables IBinaryDataListEntry outputPathEntry = compiler.Evaluate(executionId, enActionType.User, OutputPath, false, out errors); allErrors.MergeErrors(errors); IDev2DataListEvaluateIterator outputItr = Dev2ValueObjectFactory.CreateEvaluateIterator(outputPathEntry); colItr.AddIterator(outputItr); IBinaryDataListEntry usernameEntry = compiler.Evaluate(executionId, enActionType.User, Username, false, out errors); allErrors.MergeErrors(errors); IDev2DataListEvaluateIterator unameItr = Dev2ValueObjectFactory.CreateEvaluateIterator(usernameEntry); colItr.AddIterator(unameItr); IBinaryDataListEntry passwordEntry = compiler.Evaluate(executionId, enActionType.User, Password, false, out errors); allErrors.MergeErrors(errors); IDev2DataListEvaluateIterator passItr = Dev2ValueObjectFactory.CreateEvaluateIterator(passwordEntry); colItr.AddIterator(passItr); if (dataObject.IsDebugMode()) { AddDebugInputItem(new DebugItemVariableParams(OutputPath, "File or Folder", outputPathEntry, executionId)); AddDebugInputItem(new DebugItemStaticDataParams(Overwrite.ToString(), "Overwrite")); AddDebugInputItemUserNamePassword(executionId, usernameEntry); } while (colItr.HasMoreData()) { IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker(); Dev2CRUDOperationTO opTo = new Dev2CRUDOperationTO(Overwrite); try { IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(colItr.FetchNextRow(outputItr).TheValue, colItr.FetchNextRow(unameItr).TheValue, colItr.FetchNextRow(passItr).TheValue, true); IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst); string result = broker.Create(dstEndPoint, opTo, true); outputs.Add(DataListFactory.CreateOutputTO(Result, result)); } catch (Exception e) { outputs.Add(DataListFactory.CreateOutputTO(Result, (string)null)); allErrors.AddError(e.Message); break; } } return(outputs); }