void CreateSourceFileWithSomeDummyData()
 {
     try
     {
         Dev2Logger.Log.Debug(string.Format("Source File: {0}", ScenarioContext.Current.Get <string>(ActualSourceHolder)));
         var             broker = ActivityIOFactory.CreateOperationsBroker();
         IActivityIOPath source = ActivityIOFactory.CreatePathFromString(ScenarioContext.Current.Get <string>(ActualSourceHolder),
                                                                         ScenarioContext.Current.Get <string>(SourceUsernameHolder),
                                                                         ScenarioContext.Current.Get <string>(SourcePasswordHolder),
                                                                         true);
         var ops = ActivityIOFactory.CreatePutRawOperationTO(WriteType.Overwrite, Guid.NewGuid().ToString());
         IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
         if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.File)
         {
             var result = broker.PutRaw(sourceEndPoint, ops);
             if (result != "Success")
             {
                 result = broker.PutRaw(sourceEndPoint, ops);
                 if (result != "Success")
                 {
                     Dev2Logger.Log.Debug("Create Source File for file op test error");
                 }
             }
         }
     }
     catch (Exception e)
     {
         Dev2Logger.Log.Debug("Create Source File for file op test error", e);
     }
 }
Exemple #2
0
        void CreateSourceFileWithSomeDummyData()
        {
            var             broker = ActivityIOFactory.CreateOperationsBroker();
            IActivityIOPath source = ActivityIOFactory.CreatePathFromString(ScenarioContext.Current.Get <string>(ActualSourceHolder),
                                                                            ScenarioContext.Current.Get <string>(SourceUsernameHolder),
                                                                            ScenarioContext.Current.Get <string>(SourcePasswordHolder),
                                                                            true);
            var ops = ActivityIOFactory.CreatePutRawOperationTO(WriteType.Overwrite, Guid.NewGuid().ToString());
            IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);

            if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.File)
            {
                broker.PutRaw(sourceEndPoint, ops);
            }
        }
Exemple #3
0
 void CreateSourceFileWithSomeDummyData(int numberOfGuids = 1)
 {
     try
     {
         Dev2Logger.Debug(string.Format("Source File: {0}", _scenarioContext.Get <string>(ActualSourceHolder)), "Warewolf Debug");
         var broker = ActivityIOFactory.CreateOperationsBroker();
         var source = ActivityIOFactory.CreatePathFromString(_scenarioContext.Get <string>(ActualSourceHolder),
                                                             _scenarioContext.Get <string>(SourceUsernameHolder),
                                                             _scenarioContext.Get <string>(SourcePasswordHolder),
                                                             true, "");
         var sb = new StringBuilder();
         Enumerable.Range(1, numberOfGuids).ToList().ForEach(x => sb.Append(Guid.NewGuid().ToString()));
         var ops            = ActivityIOFactory.CreatePutRawOperationTO(WriteType.Overwrite, sb.ToString());
         var sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
         if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.File)
         {
             var result = broker.PutRaw(sourceEndPoint, ops);
             if (result != "Success")
             {
                 result = broker.PutRaw(sourceEndPoint, ops);
                 if (result != "Success")
                 {
                     Dev2Logger.Debug("Create Source File for file op test error", "Warewolf Debug");
                 }
             }
         }
         else if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.Directory && source.Path.Contains("emptydir"))
         {
             broker.Create(sourceEndPoint, new Dev2CRUDOperationTO(true, false), false);
         }
     }
     catch (Exception e)
     {
         Dev2Logger.Debug("Create Source File for file op test error", e, "Warewolf Debug");
     }
 }
Exemple #4
0
        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 inputItr = new WarewolfIterator(dataObject.Environment.Eval(OutputPath, 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);

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

            colItr.AddVariableToIterateOn(contentItr);

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


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

            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, colItr.FetchNextValue(privateKeyItr));
                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);
        }
Exemple #5
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, OutputPath, 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);

            IBinaryDataListEntry contentsEntry = compiler.Evaluate(executionId, enActionType.User, FileContents, false, out errors);

            if (contentsEntry == null)
            {
                errors.AddError("Contents could not be evaluated");
            }

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator contentItr = Dev2ValueObjectFactory.CreateEvaluateIterator(contentsEntry);

            colItr.AddIterator(contentItr);

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

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

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();
                var writeType = GetCorrectWriteType();
                Dev2PutRawOperationTO putTo = ActivityIOFactory.CreatePutRawOperationTO(writeType, TextUtils.ReplaceWorkflowNewLinesWithEnvironmentNewLines(colItr.FetchNextRow(contentItr).TheValue));
                IActivityIOPath       opath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextRow(inputItr).TheValue,
                                                                                     colItr.FetchNextRow(unameItr).TheValue,
                                                                                     colItr.FetchNextRow(passItr).TheValue,
                                                                                     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);
        }