Example #1
0
 public override IEnumerable <StateVariable> GetState()
 {
     return(new[] {
         new StateVariable
         {
             Name = nameof(OutputPath),
             Value = OutputPath,
             Type = StateVariable.StateType.Output
         },
         new StateVariable
         {
             Name = nameof(Overwrite),
             Value = Overwrite.ToString(),
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(AppendTop),
             Value = AppendTop.ToString(),
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(AppendBottom),
             Value = AppendBottom.ToString(),
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(FileContents),
             Value = FileContents,
             Type = StateVariable.StateType.InputOutput
         },
         new StateVariable
         {
             Name = nameof(FileContentsAsBase64),
             Value = FileContentsAsBase64.ToString(),
             Type = StateVariable.StateType.InputOutput
         },
         new StateVariable
         {
             Name = nameof(Username),
             Value = Username,
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(PrivateKeyFile),
             Value = PrivateKeyFile,
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(Result),
             Value = Result,
             Type = StateVariable.StateType.Output
         }
     });
 }
Example #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ Append.GetHashCode();
         hashCode = (hashCode * 397) ^ (FileContents != null ? FileContents.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OutputPath != null ? OutputPath.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ FileContentsAsBase64.GetHashCode();
         hashCode = (hashCode * 397) ^ Overwrite.GetHashCode();
         hashCode = (hashCode * 397) ^ AppendTop.GetHashCode();
         hashCode = (hashCode * 397) ^ AppendBottom.GetHashCode();
         return(hashCode);
     }
 }
Example #3
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);
        }