示例#1
0
        protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update)
        {
            IsNotCertVerifiable = true;

            allErrors = new ErrorResultTO();
            IList <OutputTO> outputs = new List <OutputTO>();

            var colItr = new WarewolfListIterator();

            //get all the possible paths for all the string variables
            var inputItr = new WarewolfIterator(dataObject.Environment.Eval(InputPath, update));

            colItr.AddVariableToIterateOn(inputItr);

            var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username, update));

            colItr.AddVariableToIterateOn(unameItr);

            var passItr = new WarewolfIterator(dataObject.Environment.Eval(DecryptedPassword, update));

            colItr.AddVariableToIterateOn(passItr);

            var privateKeyItr = new WarewolfIterator(dataObject.Environment.Eval(PrivateKeyFile, update));

            colItr.AddVariableToIterateOn(privateKeyItr);

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", dataObject.Environment, update);
                AddDebugInputItem(new DebugItemStaticDataParams(GetReadType().GetDescription(), "Read"));
                AddDebugInputItemUserNamePassword(dataObject.Environment, update);
                if (!string.IsNullOrEmpty(PrivateKeyFile))
                {
                    AddDebugInputItem(PrivateKeyFile, "Private Key File", dataObject.Environment, update);
                }
            }

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();
                IActivityIOPath           ioPath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr),
                                                                                          colItr.FetchNextValue(unameItr),
                                                                                          colItr.FetchNextValue(passItr),
                                                                                          true, colItr.FetchNextValue(privateKeyItr));
                IActivityIOOperationsEndPoint endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ioPath);

                try
                {
                    IList <IActivityIOPath> listOfDir = broker.ListDirectory(endPoint, GetReadType());
                    if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) != enRecordsetIndexType.Numeric)
                    {
                        if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star)
                        {
                            string recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result);
                            string fieldName  = DataListUtil.ExtractFieldNameFromValue(Result);

                            int indexToUpsertTo = 1;
                            if (listOfDir != null)
                            {
                                foreach (IActivityIOPath pa in listOfDir)
                                {
                                    string fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName,
                                                                                                     indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
                                    outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), pa.Path));
                                    indexToUpsertTo++;
                                }
                            }
                        }
                        else if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Blank)
                        {
                            if (listOfDir != null)
                            {
                                foreach (IActivityIOPath pa in listOfDir)
                                {
                                    outputs.Add(DataListFactory.CreateOutputTO(Result, pa.Path));
                                }
                            }
                        }
                    }
                    else
                    {
                        if (listOfDir != null)
                        {
                            string xmlList = string.Join(",", listOfDir.Select(c => c.Path));
                            outputs.Add(DataListFactory.CreateOutputTO(Result));
                            outputs.Last().OutputStrings.Add(xmlList);
                        }
                    }
                }
                catch (Exception e)
                {
                    outputs.Add(DataListFactory.CreateOutputTO(null));
                    allErrors.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
        IList <IActivityIOPath> ListDirectoryStandardFtp(IActivityIOPath src)
        {
            List <IActivityIOPath> result   = new List <IActivityIOPath>();
            FtpWebResponse         response = null;

            try
            {
                FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ConvertSslToPlain(src.Path));
                request.Method    = WebRequestMethods.Ftp.ListDirectory;
                request.UseBinary = true;
                request.KeepAlive = false;
                request.EnableSsl = EnableSsl(src);

                if (src.Username != string.Empty)
                {
                    request.Credentials = new NetworkCredential(src.Username, src.Password);
                }

                if (src.IsNotCertVerifiable)
                {
                    ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications;
                }

                using (response = (FtpWebResponse)request.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        if (responseStream != null)
                        {
                            using (StreamReader reader = new StreamReader(responseStream))
                            {
                                while (!reader.EndOfStream)
                                {
                                    string uri = BuildValidPathForFtp(src, reader.ReadLine());
                                    result.Add(ActivityIOFactory.CreatePathFromString(uri, src.Username, src.Password, true));
                                }
                            }
                        }
                    }
                }
            }
            catch (WebException webEx)
            {
                FtpWebResponse webResponse = webEx.Response as FtpWebResponse;
                if (webResponse != null)
                {
                    if (webResponse.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
                    {
                        throw new DirectoryNotFoundException(string.Format("Directory '{0}' was not found", src.Path));
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                Dev2Logger.Log.Error(this, ex);
                throw;
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }

            return(result);
        }
示例#3
0
        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;

            ColItr = Dev2ValueObjectFactory.CreateIteratorCollection();

            //get all the possible paths for all the string variables
            IBinaryDataListEntry inputPathEntry = compiler.Evaluate(executionId, enActionType.User, InputPath, false,
                                                                    out errors);

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator inputItr = Dev2ValueObjectFactory.CreateEvaluateIterator(inputPathEntry);

            ColItr.AddIterator(inputItr);

            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);

            IBinaryDataListEntry destinationUsernameEntry = compiler.Evaluate(executionId, enActionType.User, DestinationUsername, false,
                                                                              out errors);

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator desunameItr = Dev2ValueObjectFactory.CreateEvaluateIterator(destinationUsernameEntry);

            ColItr.AddIterator(desunameItr);

            IBinaryDataListEntry destinationPasswordEntry = compiler.Evaluate(executionId, enActionType.User, DestinationPassword, false,
                                                                              out errors);

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator despassItr = Dev2ValueObjectFactory.CreateEvaluateIterator(destinationPasswordEntry);

            ColItr.AddIterator(despassItr);

            var iteratorsErrors = new List <ErrorResultTO>();

            AddItemsToIterator(executionId, compiler, iteratorsErrors);
            ErrorResultTO to = allErrors;

            iteratorsErrors.ForEach(to.MergeErrors);

            outputs.Add(DataListFactory.CreateOutputTO(Result));

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(new DebugItemVariableParams(InputPath, "Source Path", inputPathEntry, executionId));
                AddDebugInputItemUserNamePassword(executionId, usernameEntry);
                AddDebugInputItem(new DebugItemVariableParams(OutputPath, "Destination Path", outputPathEntry, executionId));
                AddDebugInputItemDestinationUsernamePassword(executionId, destinationUsernameEntry, DestinationPassword, DestinationUsername);
                AddDebugInputItem(new DebugItemStaticDataParams(Overwrite.ToString(), "Overwrite"));
                AddDebugInputItems(executionId);
            }

            while (ColItr.HasMoreData())
            {
                var             hasError = false;
                IActivityIOPath src      = null;
                IActivityIOPath dst      = null;
                try
                {
                    src = ActivityIOFactory.CreatePathFromString(ColItr.FetchNextRow(inputItr).TheValue,
                                                                 ColItr.FetchNextRow(unameItr).TheValue,
                                                                 ColItr.FetchNextRow(passItr).TheValue,
                                                                 true);
                }
                catch (IOException ioException)
                {
                    allErrors.AddError("Source: " + ioException.Message);
                    hasError = true;
                }
                try
                {
                    dst = ActivityIOFactory.CreatePathFromString(ColItr.FetchNextRow(outputItr).TheValue,
                                                                 ColItr.FetchNextRow(desunameItr).TheValue,
                                                                 ColItr.FetchNextRow(despassItr).TheValue,
                                                                 true);
                }
                catch (IOException ioException)
                {
                    allErrors.AddError("Destination:" + ioException.Message);
                    hasError = true;
                }

                if (hasError)
                {
                    outputs[0].OutputStrings.Add(null);
                    MoveRemainingIterators();
                    continue;
                }
                IActivityIOOperationsEndPoint scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(src);
                IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);

                try
                {
                    IActivityOperationsBroker broker = GetOperationBroker();
                    var result = ExecuteBroker(broker, scrEndPoint, dstEndPoint);
                    outputs[0].OutputStrings.Add(result);
                }
                catch (Exception e)
                {
                    allErrors.AddError(e.Message);
                    outputs[0].OutputStrings.Add(null);
                }
            }

            return(outputs);
        }
        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 inputItr = new WarewolfIterator(context.Environment.Eval(InputPath, update));

            colItr.AddVariableToIterateOn(inputItr);

            var userItr = new WarewolfIterator(context.Environment.Eval(Username, update));

            colItr.AddVariableToIterateOn(userItr);

            var passItr = new WarewolfIterator(context.Environment.Eval(DecryptedPassword, update));

            colItr.AddVariableToIterateOn(passItr);

            var privateKeyItr = new WarewolfIterator(context.Environment.Eval(PrivateKeyFile ?? string.Empty, update));

            colItr.AddVariableToIterateOn(privateKeyItr);

            outputs.Add(DataListFactory.CreateOutputTO(Result));

            if (context.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", context.Environment, update);
                AddDebugInputItemUserNamePassword(context.Environment, update);
                if (!string.IsNullOrEmpty(PrivateKeyFile))
                {
                    AddDebugInputItem(PrivateKeyFile, "Private Key File", context.Environment, update);
                }
                if (IsResultBase64)
                {
                    AddDebugInputItem(IsResultBase64.ToString(), "Result As Base64", context.Environment, update);
                }
            }

            while (colItr.HasMoreData())
            {
                var broker = ActivityIOFactory.CreateOperationsBroker();
                var ioPath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr),
                                                                    colItr.FetchNextValue(userItr),
                                                                    colItr.FetchNextValue(passItr),
                                                                    true, colItr.FetchNextValue(privateKeyItr));
                var endpoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ioPath);
                try
                {
                    if (IsResultBase64)
                    {
                        var result = broker.GetBytes(endpoint);
                        outputs[0].OutputStrings.Add(result.ToBase64String());
                    }
                    else
                    {
                        var result = broker.Get(endpoint);
                        outputs[0].OutputStrings.Add(result);
                    }
                }
                catch (Exception e)
                {
                    outputs[0].OutputStrings.Add(null);
                    error.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
示例#5
0
        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 inputItr = new WarewolfIterator(context.Environment.Eval(OutputPath, update));

            colItr.AddVariableToIterateOn(inputItr);

            var userItr = new WarewolfIterator(context.Environment.Eval(Username, update));

            colItr.AddVariableToIterateOn(userItr);

            var passItr = new WarewolfIterator(context.Environment.Eval(DecryptedPassword, update));

            colItr.AddVariableToIterateOn(passItr);

            var privateKeyItr = new WarewolfIterator(context.Environment.Eval(PrivateKeyFile, update));

            colItr.AddVariableToIterateOn(privateKeyItr);

            var contentItr = new WarewolfIterator(context.Environment.Eval(FileContents, update));

            colItr.AddVariableToIterateOn(contentItr);

            outputs.Add(DataListFactory.CreateOutputTO(Result));


            if (context.IsDebugMode())
            {
                AddDebugInputItem(OutputPath, "Output Path", context.Environment, update);
                AddDebugInputItem(new DebugItemStaticDataParams(GetMethod(), "Method"));
                AddDebugInputItemUserNamePassword(context.Environment, update);
                if (!string.IsNullOrEmpty(PrivateKeyFile))
                {
                    AddDebugInputItem(PrivateKeyFile, "Private Key File", context.Environment, update);
                }
                AddDebugInputItem(FileContents, "File Contents", context.Environment, update);
                if (FileContentsAsBase64)
                {
                    AddDebugInputItem(FileContentsAsBase64.ToString(), "File Contents As Base64", context.Environment, update);
                }
            }

            while (colItr.HasMoreData())
            {
                var broker    = ActivityIOFactory.CreateOperationsBroker();
                var writeType = GetCorrectWriteType();
                var putTo     = ActivityIOFactory.CreatePutRawOperationTO(writeType, TextUtils.ReplaceWorkflowNewLinesWithEnvironmentNewLines(colItr.FetchNextValue(contentItr)), FileContentsAsBase64);
                var opath     = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr), colItr.FetchNextValue(userItr),
                                                                       colItr.FetchNextValue(passItr),
                                                                       true, colItr.FetchNextValue(privateKeyItr));
                var endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(opath);


                try
                {
                    if (error.HasErrors())
                    {
                        outputs[0].OutputStrings.Add(null);
                    }
                    else
                    {
                        var result = broker.PutRaw(endPoint, putTo);
                        outputs[0].OutputStrings.Add(result);
                    }
                }
                catch (Exception e)
                {
                    outputs[0].OutputStrings.Add(null);
                    error.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
        public void CreatePathFromString_NonRootedPath_ExpectArgumentNullException()

        {
            ActivityIOFactory.CreatePathFromString(null, "", "");
        }
示例#7
0
        protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors)
        {
            IList <OutputTO> outputs = new List <OutputTO>();

            allErrors = new ErrorResultTO();
            var colItr = new WarewolfListIterator();

            //get all the possible paths for all the string variables
            var inputItr = new WarewolfIterator(dataObject.Environment.Eval(OutputPath));

            colItr.AddVariableToIterateOn(inputItr);

            var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username));

            colItr.AddVariableToIterateOn(unameItr);

            var passItr = new WarewolfIterator(dataObject.Environment.Eval(Password));

            colItr.AddVariableToIterateOn(passItr);

            var contentItr = new WarewolfIterator(dataObject.Environment.Eval(FileContents));

            colItr.AddVariableToIterateOn(contentItr);

            outputs.Add(DataListFactory.CreateOutputTO(Result));

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(OutputPath, "Output Path", dataObject.Environment);
                AddDebugInputItem(new DebugItemStaticDataParams(GetMethod(), "Method"));
                AddDebugInputItemUserNamePassword(dataObject.Environment);
                AddDebugInputItem(FileContents, "File Contents", dataObject.Environment);
            }

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();
                var writeType = GetCorrectWriteType();
                Dev2PutRawOperationTO putTo = ActivityIOFactory.CreatePutRawOperationTO(writeType, TextUtils.ReplaceWorkflowNewLinesWithEnvironmentNewLines(colItr.FetchNextValue(contentItr)));
                IActivityIOPath       opath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr),
                                                                                     colItr.FetchNextValue(unameItr),
                                                                                     colItr.FetchNextValue(passItr),
                                                                                     true);
                IActivityIOOperationsEndPoint endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(opath);

                try
                {
                    if (allErrors.HasErrors())
                    {
                        outputs[0].OutputStrings.Add(null);
                    }
                    else
                    {
                        string result = broker.PutRaw(endPoint, putTo);
                        outputs[0].OutputStrings.Add(result);
                    }
                }
                catch (Exception e)
                {
                    outputs[0].OutputStrings.Add(null);
                    allErrors.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
        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, tempFileName);
                Assert.IsTrue(File.Exists(tempFile));

                File.Delete(tempFile);
                File.Delete(newFilePath);
            }
        }
        public void Create_Should()
        {
            var tempPath = Path.GetTempPath() + "SomeName.zip";
            IActivityIOOperationsEndPoint scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(tempPath, string.Empty, null, true, ""));
            var activityOperationsBroker = ActivityIOFactory.CreateOperationsBroker();
            var create = activityOperationsBroker.Create(scrEndPoint, new Dev2CRUDOperationTO(false, false), false);

            Assert.AreEqual("Success", create);
        }
        protected override IList <OutputTO> TryExecuteConcreteAction(IDSFDataObject context, out ErrorResultTO error, int update)
        {
            IList <OutputTO> outputs = new List <OutputTO>();

            error  = new ErrorResultTO();
            ColItr = new WarewolfListIterator();

            //get all the possible paths for all the string variables
            var inputItr = new WarewolfIterator(context.Environment.Eval(InputPath, update));

            ColItr.AddVariableToIterateOn(inputItr);


            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);

            var despassItr = new WarewolfIterator(context.Environment.Eval(DecryptedDestinationPassword, update));

            ColItr.AddVariableToIterateOn(despassItr);

            var destPrivateKeyItr = new WarewolfIterator(context.Environment.Eval(DestinationPrivateKeyFile, update));

            ColItr.AddVariableToIterateOn(destPrivateKeyItr);

            AddItemsToIterator(context.Environment, update);

            outputs.Add(DataListFactory.CreateOutputTO(Result));

            if (context.IsDebugMode())
            {
                AddDebugInputItem(new DebugEvalResult(InputPath, "Source Path", context.Environment, update));
                AddDebugInputItemUserNamePassword(context.Environment, update);
                if (!string.IsNullOrEmpty(PrivateKeyFile))
                {
                    AddDebugInputItem(new DebugEvalResult(PrivateKeyFile, "Source Private Key File", context.Environment, update));
                }
                AddDebugInputItem(new DebugEvalResult(OutputPath, "Destination Path", context.Environment, update));
                AddDebugInputItemDestinationUsernamePassword(context.Environment, DestinationPassword, DestinationUsername, update);
                if (!string.IsNullOrEmpty(DestinationPrivateKeyFile))
                {
                    AddDebugInputItem(new DebugEvalResult(DestinationPrivateKeyFile, "Destination Private Key File", context.Environment, update));
                }
                AddDebugInputItem(new DebugItemStaticDataParams(Overwrite.ToString(), "Overwrite"));
                AddDebugInputItems(context.Environment, update);
            }

            while (ColItr.HasMoreData())
            {
                var             hasError = false;
                IActivityIOPath src      = null;
                IActivityIOPath dst      = null;
                try
                {
                    src = ActivityIOFactory.CreatePathFromString(ColItr.FetchNextValue(inputItr),
                                                                 Username,
                                                                 ColItr.FetchNextValue(passItr),
                                                                 true, ColItr.FetchNextValue(privateKeyItr));
                }
                catch (IOException ioException)
                {
                    error.AddError("Source: " + ioException.Message);
                    hasError = true;
                }
                try
                {
                    dst = ActivityIOFactory.CreatePathFromString(ColItr.FetchNextValue(outputItr),
                                                                 DestinationUsername,
                                                                 ColItr.FetchNextValue(despassItr),
                                                                 true, ColItr.FetchNextValue(destPrivateKeyItr));
                }
                catch (IOException ioException)
                {
                    error.AddError("Destination:" + ioException.Message);
                    hasError = true;
                }

                if (hasError)
                {
                    outputs[0].OutputStrings.Add(null);
                    MoveRemainingIterators();
                    continue;
                }
                var scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(src);
                var dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);

                try
                {
                    var broker = GetOperationBroker?.Invoke();
                    var result = ExecuteBroker(broker, scrEndPoint, dstEndPoint);
                    outputs[0].OutputStrings.Add(result);
                }
                catch (Exception e)
                {
                    error.AddError(e.Message);
                    outputs[0].OutputStrings.Add(null);
                }
            }

            return(outputs);
        }
        // ReSharper disable InconsistentNaming
        public void ActivityIOFactory_CreateOperationEndPointFromIOPath_WithSftp_ShouldSetTypeTpSFtp()
        // ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            const string Path = "sftp://sftp.theunlimited.co.za/text.txt";
            //------------Execute Test---------------------------
            IActivityIOOperationsEndPoint scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(Path, string.Empty, null, true));

            //------------Assert Results-------------------------
            Assert.AreEqual(enActivityIOPathType.SFTP, scrEndPoint.IOPath.PathType);
        }
示例#12
0
        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 inputPathEntry = compiler.Evaluate(executionId, enActionType.User, InputPath, false, out errors);

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator inputItr = Dev2ValueObjectFactory.CreateEvaluateIterator(inputPathEntry);

            colItr.AddIterator(inputItr);

            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);

            outputs.Add(DataListFactory.CreateOutputTO(Result));

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", inputPathEntry, executionId);
                AddDebugInputItemUserNamePassword(executionId, usernameEntry);
            }

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();
                IActivityIOPath           IOpath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextRow(inputItr).TheValue,
                                                                                          colItr.FetchNextRow(unameItr).TheValue,
                                                                                          colItr.FetchNextRow(passItr).TheValue,
                                                                                          true);

                IActivityIOOperationsEndPoint endpoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(IOpath);
                try
                {
                    string result = broker.Get(endpoint);
                    outputs[0].OutputStrings.Add(result);
                }
                catch (Exception e)
                {
                    outputs[0].OutputStrings.Add(null);
                    allErrors.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
示例#13
0
        public void ActivityIOBroker_Zip_WhenOverwriteSetTrue_ShouldOverwriteFile()
        {
            //------------Setup for test--------------------------
            tempFile = Path.GetTempFileName();
            var zipPathName = Path.GetTempPath() + NewFileName + ".zip";
            IActivityIOOperationsEndPoint scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(tempFile, string.Empty, null, true));
            IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(zipPathName, string.Empty, null, true));
            Dev2ZipOperationTO            zipTO       = ActivityIOFactory.CreateZipTO(null, null, null, true);

            File.WriteAllText(zipPathName, "");
            //------------Assert Preconditions-------------------
            Assert.IsTrue(zipTO.Overwrite);
            Assert.IsTrue(File.Exists(zipPathName));
            var readAllBytes = File.ReadAllBytes(zipPathName);

            Assert.AreEqual(0, readAllBytes.Count());
            //------------Execute Test---------------------------
            ActivityIOFactory.CreateOperationsBroker().Zip(scrEndPoint, dstEndPoint, zipTO);
            //------------Assert Results-------------------------
            Assert.IsTrue(File.Exists(zipPathName));
            readAllBytes = File.ReadAllBytes(zipPathName);
            Assert.AreNotEqual(0, readAllBytes.Count());
            File.Delete(tempFile);
            File.Delete(zipPathName);
        }
        public void GivenNullDestination_AddMissingFileDirectoryParts_ShouldRetunError()
        {
            var          commonDataUtils = new CommonDataUtils();
            var          tempFile        = Path.GetTempFileName();
            const string newFileName     = "ZippedTempFile";
            var          zipPathName     = Path.GetTempPath() + newFileName + ".zip";
            IActivityIOOperationsEndPoint scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(tempFile, string.Empty, null, true, ""));
            IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(zipPathName, string.Empty, null, true, ""));

            Assert.IsNotNull(commonDataUtils);
            dstEndPoint.IOPath.Path = string.Empty;
            commonDataUtils.AddMissingFileDirectoryParts(scrEndPoint, dstEndPoint);
        }
        protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject,
                                                                  out ErrorResultTO allErrors)
        {
            IList <OutputTO> outputs = new List <OutputTO>();

            allErrors = new ErrorResultTO();
            ColItr    = new WarewolfListIterator();

            //get all the possible paths for all the string variables
            var inputItr = new WarewolfIterator(dataObject.Environment.Eval(InputPath));

            ColItr.AddVariableToIterateOn(inputItr);


            var outputItr = new WarewolfIterator(dataObject.Environment.Eval(OutputPath));

            ColItr.AddVariableToIterateOn(outputItr);


            var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username));

            ColItr.AddVariableToIterateOn(unameItr);


            var passItr = new WarewolfIterator(dataObject.Environment.Eval(Password));

            ColItr.AddVariableToIterateOn(passItr);


            var desunameItr = new WarewolfIterator(dataObject.Environment.Eval(DestinationUsername));

            ColItr.AddVariableToIterateOn(desunameItr);


            var despassItr = new WarewolfIterator(dataObject.Environment.Eval(DestinationPassword));

            ColItr.AddVariableToIterateOn(despassItr);

            AddItemsToIterator(dataObject.Environment);

            outputs.Add(DataListFactory.CreateOutputTO(Result));

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(new DebugEvalResult(InputPath, "Source Path", dataObject.Environment));
                AddDebugInputItemUserNamePassword(dataObject.Environment);
                AddDebugInputItem(new DebugEvalResult(OutputPath, "Destination Path", dataObject.Environment));
                AddDebugInputItemDestinationUsernamePassword(dataObject.Environment, DestinationPassword, DestinationUsername);
                AddDebugInputItem(new DebugItemStaticDataParams(Overwrite.ToString(), "Overwrite"));
                AddDebugInputItems(dataObject.Environment);
            }

            while (ColItr.HasMoreData())
            {
                var             hasError = false;
                IActivityIOPath src      = null;
                IActivityIOPath dst      = null;
                try
                {
                    src = ActivityIOFactory.CreatePathFromString(ColItr.FetchNextValue(inputItr),
                                                                 ColItr.FetchNextValue(unameItr),
                                                                 ColItr.FetchNextValue(passItr),
                                                                 true);
                }
                catch (IOException ioException)
                {
                    allErrors.AddError("Source: " + ioException.Message);
                    hasError = true;
                }
                try
                {
                    dst = ActivityIOFactory.CreatePathFromString(ColItr.FetchNextValue(outputItr),
                                                                 ColItr.FetchNextValue(desunameItr),
                                                                 ColItr.FetchNextValue(despassItr),
                                                                 true);
                }
                catch (IOException ioException)
                {
                    allErrors.AddError("Destination:" + ioException.Message);
                    hasError = true;
                }

                if (hasError)
                {
                    outputs[0].OutputStrings.Add(null);
                    MoveRemainingIterators();
                    continue;
                }
                IActivityIOOperationsEndPoint scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(src);
                IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);

                try
                {
                    IActivityOperationsBroker broker = GetOperationBroker();
                    var result = ExecuteBroker(broker, scrEndPoint, dstEndPoint);
                    outputs[0].OutputStrings.Add(result);
                }
                catch (Exception e)
                {
                    allErrors.AddError(e.Message);
                    outputs[0].OutputStrings.Add(null);
                }
            }

            return(outputs);
        }
示例#16
0
        public void PutRaw_Should()
        {
            const string newFileName = "tempTextFile";
            var          tempPath    = Path.GetTempPath() + newFileName + ".txt";
            var          scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(tempPath, string.Empty, null, true, ""));
            var          activityOperationsBroker = ActivityIOFactory.CreateOperationsBroker();
            var          raw = activityOperationsBroker.PutRaw(scrEndPoint,
                                                               new Dev2PutRawOperationTO(WriteType.Overwrite, "Some content to write"));

            Assert.AreEqual("Success", raw);
        }
 // ReSharper disable InconsistentNaming
 public void CreatePathFromString_NonRootedPath_ExpectArgumentNullException()
 // ReSharper restore InconsistentNaming
 {
     ActivityIOFactory.CreatePathFromString(null, "", "");
 }
示例#18
0
        public void CreatePathFromString_NonRootedPath_ExpectException()

        {
            ActivityIOFactory.CreatePathFromString("", "", "");
        }