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));
            }
        }
// ReSharper disable InconsistentNaming
        public void CreateOperationsBroker_Expected_IActivityOperationsBroker_FileSysytemProvider_Type()
// ReSharper restore InconsistentNaming
        {
            IActivityOperationsBroker result = ActivityIOFactory.CreateOperationsBroker();

            Assert.IsTrue(result != null);
        }
Ejemplo n.º 3
0
        public void CreateOperationsBroker_Expected_IActivityOperationsBroker_FileSysytemProvider_Type()

        {
            var result = ActivityIOFactory.CreateOperationsBroker();

            Assert.IsTrue(result != null);
        }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
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.Length);
            //------------Execute Test---------------------------
            ActivityIOFactory.CreateOperationsBroker().Zip(scrEndPoint, dstEndPoint, zipTO);
            //------------Assert Results-------------------------
            Assert.IsTrue(File.Exists(zipPathName));
            readAllBytes = File.ReadAllBytes(zipPathName);
            Assert.AreNotEqual(0, readAllBytes.Length);
            File.Delete(tempFile);
            File.Delete(zipPathName);
        }
Ejemplo n.º 6
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(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);

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

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", dataObject.Environment, update);
                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
                {
                    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);
        }
Ejemplo n.º 7
0
        protected static void RemovedFilesCreatedForTesting()
        {
            // ReSharper disable EmptyGeneralCatchClause


            Dev2Logger.Log.Debug("Cleanup");

            var    broker = ActivityIOFactory.CreateOperationsBroker();
            string destLocation;

            if (ScenarioContext.Current != null && ScenarioContext.Current.TryGetValue(CommonSteps.ActualDestinationHolder, out destLocation))
            {
                IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(destLocation,
                                                                             ScenarioContext.Current.Get <string>(CommonSteps.DestinationUsernameHolder),
                                                                             ScenarioContext.Current.Get <string>(CommonSteps.DestinationPasswordHolder),
                                                                             true);
                IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
                try
                {
                    if (dstEndPoint.PathIs(dstEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(dstEndPoint);
                    }
                }
                catch (Exception)
                {
                    Dev2Logger.Log.Debug("Cleanup Error");
                    //    throw;
                }
            }

            string sourceLocation;

            if (ScenarioContext.Current != null && ScenarioContext.Current.TryGetValue(CommonSteps.ActualSourceHolder, out sourceLocation))
            {
                IActivityIOPath source = ActivityIOFactory.CreatePathFromString(sourceLocation,
                                                                                ScenarioContext.Current.Get <string>(CommonSteps.SourceUsernameHolder),
                                                                                ScenarioContext.Current.Get <string>(CommonSteps.SourcePasswordHolder),
                                                                                true);
                IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
                try
                {
                    if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(sourceEndPoint);
                    }
                }
                catch (Exception)
                {
                    Dev2Logger.Log.Debug("Cleanup Error");
                    //The file may already be deleted
                    // throw;
                }
            }

            // SOME SILLY CHICKEN BUNDLED TWO DIS-JOIN OPERATIONS IN THIS METHOD.
            // THIS CAUSED THE SFTP SERVER TO NEVER SHUTDOWN WHEN THE COMMONSTEPS.ACTUALSOURCEHOLDER KEY WAS NOT PRESENT!
            // ;)
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Boot strap the Session
        /// </summary>
        private void InitPersistSettings()
        {
            lock (SettingsLock)
            {
                if (!_debugOptsEndPoint.PathExist(_debugPath))
                {
                    var args = new Dev2PutRawOperationTO(WriteType.Overwrite, "");
                    ActivityIOFactory.CreateOperationsBroker().PutRaw(_debugOptsEndPoint, args);
                }
                else
                {
                    // fetch from disk
                    var filesToCleanup = new List <string>();
                    using (Stream s = _debugOptsEndPoint.Get(_debugPath, filesToCleanup))
                    {
                        if (s.Length > 0)
                        {
                            var bf = new XmlSerializer(typeof(List <SaveDebugTO>));

                            try
                            {
                                var settings = (List <SaveDebugTO>)bf.Deserialize(s);
                                _debugPersistSettings.Values.ToList().ForEach(a => a.CleanUp());
                                _debugPersistSettings.Clear();
                                // now push back into the Dictionary
                                foreach (SaveDebugTO dto in settings)
                                {
                                    if (dto.ServiceName.Length > 0)
                                    {
                                        var tmp = new DebugTO();
                                        tmp.CopyFromSaveDebugTO(dto);
                                        string error;

                                        tmp.BinaryDataList = DeSerialize(tmp.XmlData, tmp.DataList,
                                                                         enTranslationTypes.XML, out error);


                                        _debugPersistSettings[dto.WorkflowID] = tmp;
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                Dev2Logger.Log.Error(e);
                            }
                        }
                        else
                        {
                            Dev2Logger.Log.Error("No debug data stream [ " + _debugPath + " ] ");
                        }

                        s.Close();
                        s.Dispose();
                        filesToCleanup.ForEach(File.Delete);
                    }
                }
            }
        }
Ejemplo n.º 9
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(InputPath));

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


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

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

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();

                try
                {
                    IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr),
                                                                                 colItr.FetchNextValue(unameItr),
                                                                                 colItr.FetchNextValue(passItr),
                                                                                 true);

                    IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
                    string result = broker.Delete(dstEndPoint);
                    outputs[0].OutputStrings.Add(result);
                }
                catch (Exception e)
                {
                    outputs.Add(DataListFactory.CreateOutputTO(Result, "Failure"));
                    //outputs[0].OutputStrings.Add(null);
                    allErrors.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
Ejemplo n.º 10
0
        protected override IList <OutputTO> TryExecuteConcreteAction(IDSFDataObject context, out ErrorResultTO error, int update)
        {
            IsNotCertVerifiable = true;

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

            using (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 unameItr = new WarewolfIterator(context.Environment.Eval(Username, update));
                colItr.AddVariableToIterateOn(unameItr);

                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(InputPath, "Input Path", context.Environment, update);
                    AddDebugInputItem(new DebugItemStaticDataParams(GetReadType().GetDescription(), "Read"));
                    AddDebugInputItemUserNamePassword(context.Environment, update);
                    if (!string.IsNullOrEmpty(PrivateKeyFile))
                    {
                        AddDebugInputItem(PrivateKeyFile, "Private Key File", context.Environment, update);
                    }
                }

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

                    try
                    {
                        ExecuteConcreteAction(outputs, broker, endPoint);
                    }
                    catch (Exception e)
                    {
                        outputs.Add(DataListFactory.CreateOutputTO(null));
                        error.AddError(e.Message);
                        break;
                    }
                }

                return(outputs);
            }
        }
Ejemplo n.º 11
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 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);
        }
Ejemplo n.º 12
0
        public void Create_Should()
        {
            var tempPath    = Path.GetTempPath() + "SomeName.zip";
            var 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);
        }
Ejemplo n.º 13
0
        protected void RemovedFilesCreatedForTesting()
        {
            // ReSharper disable EmptyGeneralCatchClause



            var    broker = ActivityIOFactory.CreateOperationsBroker();
            string destLocation;

            if (scenarioContext != null && scenarioContext.TryGetValue(CommonSteps.ActualDestinationHolder, out destLocation))
            {
                IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(destLocation,
                                                                             scenarioContext.Get <string>(CommonSteps.DestinationUsernameHolder),
                                                                             scenarioContext.Get <string>(CommonSteps.DestinationPasswordHolder),
                                                                             true);
                IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
                try
                {
                    if (dstEndPoint.PathIs(dstEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(dstEndPoint);
                    }
                }
                catch (Exception)
                {
                    //    throw;
                }
            }

            string sourceLocation;

            if (scenarioContext != null && scenarioContext.TryGetValue(CommonSteps.ActualSourceHolder, out sourceLocation))
            {
                if (string.IsNullOrEmpty(sourceLocation))
                {
                    scenarioContext.TryGetValue(CommonSteps.SourceHolder, out sourceLocation);
                }
                if (string.IsNullOrEmpty(sourceLocation))
                {
                    return;
                }
                IActivityIOPath source = ActivityIOFactory.CreatePathFromString(sourceLocation,
                                                                                scenarioContext.Get <string>(CommonSteps.SourceUsernameHolder),
                                                                                scenarioContext.Get <string>(CommonSteps.SourcePasswordHolder),
                                                                                true);
                IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
                try
                {
                    broker.Delete(sourceEndPoint);
                }
                catch (Exception)
                {
                    //The file may already be deleted
                }
            }
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        protected static void RemovedFilesCreatedForTesting()
        {
            // ReSharper disable EmptyGeneralCatchClause


            Dev2Logger.Log.Debug("Cleanup");

            var    broker = ActivityIOFactory.CreateOperationsBroker();
            string destLocation;

            if (ScenarioContext.Current != null && ScenarioContext.Current.TryGetValue(CommonSteps.ActualDestinationHolder, out destLocation))
            {
                IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(destLocation,
                                                                             ScenarioContext.Current.Get <string>(CommonSteps.DestinationUsernameHolder),
                                                                             ScenarioContext.Current.Get <string>(CommonSteps.DestinationPasswordHolder),
                                                                             true);
                IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
                try
                {
                    if (dstEndPoint.PathIs(dstEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(dstEndPoint);
                    }
                }
                catch (Exception)
                {
                    Dev2Logger.Log.Debug("Cleanup Error");
                    //    throw;
                }
            }

            string sourceLocation;

            if (ScenarioContext.Current != null && ScenarioContext.Current.TryGetValue(CommonSteps.ActualSourceHolder, out sourceLocation))
            {
                IActivityIOPath source = ActivityIOFactory.CreatePathFromString(sourceLocation,
                                                                                ScenarioContext.Current.Get <string>(CommonSteps.SourceUsernameHolder),
                                                                                ScenarioContext.Current.Get <string>(CommonSteps.SourcePasswordHolder),
                                                                                true);
                IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
                try
                {
                    if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(sourceEndPoint);
                    }
                }
                catch (Exception)
                {
                    Dev2Logger.Log.Debug("Cleanup Error");
                    //The file may already be deleted
                }
            }
        }
Ejemplo n.º 16
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 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);
        }
Ejemplo n.º 17
0
        public void GivenExistingFile_PutRawAppendTop_ShouldShouldAppendContent()
        {
            const string newFileName = "tempTextFile";
            var          path        = Path.GetTempPath() + newFileName + ".txt";
            var          scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(
                ActivityIOFactory.CreatePathFromString(path, string.Empty, null, true));
            var activityOperationsBroker = ActivityIOFactory.CreateOperationsBroker();
            var raw = activityOperationsBroker.PutRaw(scrEndPoint,
                                                      new Dev2PutRawOperationTO(WriteType.AppendTop, "Some content to write"));

            Assert.AreEqual("Success", raw);
        }
 void InitPersistSettings(DebugTO to)
 {
     if (!_debugOptsEndPoint.PathExist(_debugPath))
     {
         var args = new Dev2PutRawOperationTO(WriteType.Overwrite, "");
         ActivityIOFactory.CreateOperationsBroker().PutRaw(_debugOptsEndPoint, args);
     }
     else
     {
         FetchFromDisk(to);
     }
 }
Ejemplo n.º 19
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);
            }
        }
Ejemplo n.º 20
0
        public void ThenTheOutputContentsFromAFile(string fileName)
        {
            string resourceName = string.Format("Dev2.Activities.Specs.Toolbox.FileAndFolder.Write_File.testfiles.{0}",
                                                fileName);
            var expectedContents = ReadFile(resourceName);

            var             broker = ActivityIOFactory.CreateOperationsBroker();
            IActivityIOPath source = ActivityIOFactory.CreatePathFromString(ScenarioContext.Current.Get <string>(CommonSteps.ActualSourceHolder),
                                                                            ScenarioContext.Current.Get <string>(CommonSteps.SourceUsernameHolder),
                                                                            ScenarioContext.Current.Get <string>(CommonSteps.SourcePasswordHolder),
                                                                            true);

            IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);

            var fileContents = broker.Get(sourceEndPoint);

            bool does = fileContents.Contains(expectedContents);

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(does);
        }
Ejemplo n.º 21
0
        public void ThenTheOutputContentsFromAFile(string fileName)
        {
            var resourceName = string.Format("Dev2.Activities.Specs.Toolbox.FileAndFolder.Write_File.testfiles.{0}",
                                             fileName);
            var expectedContents = ReadFile(resourceName);

            var broker = ActivityIOFactory.CreateOperationsBroker();
            var source = ActivityIOFactory.CreatePathFromString(_scenarioContext.Get <string>(CommonSteps.ActualSourceHolder),
                                                                _scenarioContext.Get <string>(CommonSteps.SourceUsernameHolder),
                                                                _scenarioContext.Get <string>(CommonSteps.SourcePasswordHolder),
                                                                true);

            var sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);

            var fileContents = broker.Get(sourceEndPoint);

            var does = fileContents.Contains(expectedContents.Replace("\n", "\r\n"));

            Assert.IsTrue(does);
        }
Ejemplo n.º 22
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");
     }
 }
Ejemplo n.º 23
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);

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", dataObject.Environment, update);
                AddDebugInputItem(new DebugItemStaticDataParams(GetReadType().GetDescription(), "Read"));
                AddDebugInputItemUserNamePassword(dataObject.Environment, update);
            }

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();
                IActivityIOPath           ioPath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr),
                                                                                          colItr.FetchNextValue(unameItr),
                                                                                          colItr.FetchNextValue(passItr),
                                                                                          true);
                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);
        }
Ejemplo n.º 24
0
        protected override IList <OutputTO> ExecuteConcreteAction(NativeActivityContext context, out ErrorResultTO allErrors)
        {
            IsNotCertVerifiable = true;

            allErrors = new ErrorResultTO();
            IList <OutputTO> outputs    = new List <OutputTO>();
            IDSFDataObject   dataObject = context.GetExtension <IDSFDataObject>();

            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();

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

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", inputPathEntry, executionId);
                AddDebugInputItem(new DebugItemStaticDataParams(GetReadType().GetDescription(), "Read"));
                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
                {
                    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);
        }
Ejemplo n.º 25
0
        public void Dev2ActivityIOBroker_CreateInstance_GivenThrowsNoExpetion_ShouldBeIActivityOperationsBroker()
        {
            var broker = ActivityIOFactory.CreateOperationsBroker();

            Assert.IsInstanceOfType(broker, typeof(IActivityOperationsBroker));
        }
Ejemplo n.º 26
0
 private static IActivityOperationsBroker CreateBroker(IFile file, ICommon common)
 {
     return(ActivityIOFactory.CreateOperationsBroker(file, common));
 }
Ejemplo n.º 27
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 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);
        }
Ejemplo n.º 28
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);
        }
Ejemplo n.º 29
0
 private static IActivityOperationsBroker CreateBroker()
 {
     return(ActivityIOFactory.CreateOperationsBroker());
 }
Ejemplo n.º 30
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(InputPath, update));

            colItr.AddVariableToIterateOn(inputItr);

            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),
                                                                    Username,
                                                                    colItr.FetchNextValue(passItr),
                                                                    true, colItr.FetchNextValue(privateKeyItr));
                var endpoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ioPath);
                try
                {
                    if (IsResultBase64)
                    {
                        var result = broker.GetBytes(endpoint);
                        outputs[0].OutputStrings.Add(Convert.ToBase64String(result, Base64FormattingOptions.InsertLineBreaks));
                    }
                    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);
        }