示例#1
0
        void ExecuteService(IWarewolfListIterator itrCollection,
                            IEnumerable <IWarewolfIterator> itrs, out ErrorResultTO errors, int update, IOutputFormatter formater = null)
        {
            errors = new ErrorResultTO();
            if (Inputs.Any())
            {
                // Loop iterators
                var pos = 0;
                foreach (var itr in itrs)
                {
                    var injectVal = itrCollection.FetchNextValue(itr);
                    var param     = Inputs.ToList()[pos];
                    param.Value = param.EmptyIsNull &&
                                  (injectVal == null ||
                                   string.Compare(injectVal, string.Empty,
                                                  StringComparison.InvariantCultureIgnoreCase) == 0)
                        ? null
                        : injectVal;

                    pos++;
                }
            }

            try
            {
                ExecuteService(out var invokeErrors, update, formater);
                errors.MergeErrors(invokeErrors);
            }
            catch (Exception ex)
            {
                errors.AddError(string.Format(ErrorResource.ServiceExecutionError, ex.StackTrace));
            }
        }
示例#2
0
        public string SendEmail(IExchange runtimeSource, IWarewolfListIterator colItr, IWarewolfIterator toItr, IWarewolfIterator ccItr, IWarewolfIterator bccItr, IWarewolfIterator subjectItr, IWarewolfIterator bodyItr, IWarewolfIterator attachmentsItr, out ErrorResultTO errors, bool isHtml)
        {
            InitializeService();
            errors = new ErrorResultTO();
            var toValue          = colItr.FetchNextValue(toItr);
            var ccValue          = colItr.FetchNextValue(ccItr);
            var bccValue         = colItr.FetchNextValue(bccItr);
            var subjectValue     = colItr.FetchNextValue(subjectItr);
            var bodyValue        = colItr.FetchNextValue(bodyItr);
            var attachmentsValue = colItr.FetchNextValue(attachmentsItr);
            var mailMessage      = new EmailMessage(ExchangeService)
            {
                Subject = subjectValue
            };

            AddToAddresses(toValue, mailMessage);

            mailMessage.Body = bodyValue;
            if (isHtml)
            {
                mailMessage.Body.BodyType = BodyType.HTML;
            }
            else
            {
                mailMessage.Body.BodyType = BodyType.Text;
            }

            if (!string.IsNullOrEmpty(ccValue))
            {
                AddCcAddresses(ccValue, mailMessage);
            }
            if (!string.IsNullOrEmpty(bccValue))
            {
                AddBccAddresses(bccValue, mailMessage);
            }
            if (!string.IsNullOrEmpty(attachmentsValue))
            {
                AddAttachmentsValue(attachmentsValue, mailMessage);
            }
            string result;

            try
            {
                EmailSender = new ExchangeEmailSender(runtimeSource);

                EmailSender.Send(ExchangeService, mailMessage);

                result = "Success";
            }
            catch (Exception e)
            {
                result = "Failure";
                errors.AddError(e.Message);
            }

            return(result);
        }
        public void TestInitialize()
        {
            _environment          = new ExecutionEnvironment();
            _warewolfListIterator = new WarewolfListIterator();

            _environment.Assign(Result, "Success", 0);
            _expr1 = new WarewolfIterator(_environment.Eval(Result, 0));
            _expr2 = new WarewolfIterator(_environment.Eval("[[@Parent()]]", 0));

            _warewolfListIterator.AddVariableToIterateOn(_expr1);
            _warewolfListIterator.AddVariableToIterateOn(_expr2);
        }
        public MySqlBulkLoader SetupMySqlBulkCopy(IWarewolfIterator batchItr, IWarewolfListIterator parametersIteratorCollection, IWarewolfIterator timeoutItr, DbSource runtimeDatabase, SqlBulkCopyOptions copyOptions)
        {
            var batchSize = -1;
            var timeout   = -1;

            GetParameterValuesForBatchSizeAndTimeOut(batchItr, parametersIteratorCollection, timeoutItr, ref batchSize, ref timeout);
            var sqlBulkCopy = new MySqlBulkLoader(new MySqlConnection(runtimeDatabase.ConnectionString))
            {
                TableName = TableName, FieldTerminator = ",", LineTerminator = "\n"
            };

            return(sqlBulkCopy);
        }
 void GetTimeOut(IWarewolfListIterator parametersIteratorCollection, IWarewolfIterator timeoutItr, ref int timeout)
 {
     if (timeoutItr != null)
     {
         var timeoutString = parametersIteratorCollection.FetchNextValue(timeoutItr);
         if (!string.IsNullOrEmpty(timeoutString) && int.TryParse(timeoutString, out int parsedValue))
         {
             timeout = parsedValue;
         }
     }
     else
     {
         int.TryParse(Timeout, out timeout);
     }
 }
 void GetBatchSize(IWarewolfIterator batchItr, IWarewolfListIterator parametersIteratorCollection, ref int batchSize)
 {
     if (batchItr != null)
     {
         var batchSizeString = parametersIteratorCollection.FetchNextValue(batchItr);
         if (!string.IsNullOrEmpty(batchSizeString) && int.TryParse(batchSizeString, out int parsedValue))
         {
             batchSize = parsedValue;
         }
     }
     else
     {
         int.TryParse(BatchSize, out batchSize);
     }
 }
        public SqlBulkCopy SetupSqlBulkCopy(IWarewolfIterator batchItr, IWarewolfListIterator parametersIteratorCollection, IWarewolfIterator timeoutItr, DbSource runtimeDatabase, SqlBulkCopyOptions copyOptions)
        {
            var batchSize = -1;
            var timeout   = -1;

            GetParameterValuesForBatchSizeAndTimeOut(batchItr, parametersIteratorCollection, timeoutItr, ref batchSize, ref timeout);
            var sqlBulkCopy = new SqlBulkCopy(runtimeDatabase.ConnectionString, copyOptions)
            {
                DestinationTableName = TableName
            };

            if (batchSize != -1)
            {
                sqlBulkCopy.BatchSize = batchSize;
            }
            if (timeout != -1)
            {
                sqlBulkCopy.BulkCopyTimeout = timeout;
            }
            return(sqlBulkCopy);
        }
示例#8
0
        void AddInput(int update, IWarewolfListIterator itrCollection, ICollection <IWarewolfIterator> itrs, IServiceInput sai)
        {
            var    val      = sai.Name;
            string toInject = null;

            if (val != null)
            {
                toInject = sai.Value;
            }
            else
            {
                if (!sai.EmptyIsNull)
                {
                    toInject = "";
                }
            }
            var paramIterator = new WarewolfIterator(DataObj.Environment.Eval(toInject, update));

            itrCollection.AddVariableToIterateOn(paramIterator);
            itrs.Add(paramIterator);
        }
        private void ExecuteService(IList <MethodParameter> methodParameters, IWarewolfListIterator itrCollection,
                                    IEnumerable <IWarewolfIterator> itrs, out ErrorResultTO errors, IOutputFormatter formater = null)
        {
            errors = new ErrorResultTO();
            if (methodParameters.Any())
            {
                // Loop iterators
                int pos = 0;
                foreach (var itr in itrs)
                {
                    string          injectVal = itrCollection.FetchNextValue(itr);
                    MethodParameter param     = methodParameters[pos];


                    param.Value = param.EmptyToNull &&
                                  (injectVal == null ||
                                   string.Compare(injectVal, string.Empty,
                                                  StringComparison.InvariantCultureIgnoreCase) == 0)
                        ? null
                        : injectVal;

                    pos++;
                }
            }

            try
            {
                ErrorResultTO invokeErrors;
                ExecuteService(methodParameters, out invokeErrors, formater);
                errors.MergeErrors(invokeErrors);
            }
            catch (Exception ex)
            {
                errors.AddError(string.Format("Service Execution Error: {0}", ex.Message));
            }
        }
示例#10
0
        private void ExecuteImpl(ErrorResultTO errors, int update, IOutputFormatter outputFormatter, List <IWarewolfIterator> itrs, IWarewolfListIterator itrCollection)
        {
            var method = Service.Method;
            var inputs = method.Parameters;

            if (inputs.Count == 0)
            {
                ExecuteService(out ErrorResultTO invokeErrors, update, outputFormatter);
                errors.MergeErrors(invokeErrors);
            }
            else
            {
                BuildParameterIterators(update, inputs, itrCollection, itrs);

                while (itrCollection.HasMoreData())
                {
                    ExecuteService(itrCollection, itrs, out ErrorResultTO invokeErrors, update, outputFormatter);
                    errors.MergeErrors(invokeErrors);
                }
            }
        }
        List <IWarewolfIterator> GetIteratorsFromInputMappings(IDSFDataObject dataObject, IWarewolfListIterator iteratorCollection, out ErrorResultTO errorsResultTo)
        {
            errorsResultTo = new ErrorResultTO();
            var listOfIterators = new List <IWarewolfIterator>();
            var indexCounter    = 1;

            foreach (var row in InputMappings)
            {
                try
                {
                    ExecutionEnvironment.IsValidRecordSetIndex(row.InputColumn);
                }
                catch (Exception)
                {
                    errorsResultTo.AddError("Invalid recordset:" + row.InputColumn);
                }
                if (String.IsNullOrEmpty(row.InputColumn))
                {
                    continue;
                }
                if (dataObject.IsDebugMode())
                {
                    AddDebugInputItem(row.InputColumn, row.OutputColumn.ColumnName, dataObject.Environment, row.OutputColumn.DataTypeName, indexCounter);
                    indexCounter++;
                }

                try
                {
                    var itr = new WarewolfIterator(dataObject.Environment.Eval(row.InputColumn));
                    iteratorCollection.AddVariableToIterateOn(itr);
                    listOfIterators.Add(itr);
                }
                catch (Exception e)
                {
                    errorsResultTo.AddError(e.Message);
                }
            }

            return(listOfIterators);
        }
 void GetParameterValuesForBatchSizeAndTimeOut(IWarewolfIterator batchItr, IWarewolfListIterator parametersIteratorCollection, IWarewolfIterator timeoutItr, ref int batchSize, ref int timeout)
 {
     GetBatchSize(batchItr, parametersIteratorCollection, ref batchSize);
     GetTimeOut(parametersIteratorCollection, timeoutItr, ref timeout);
 }
示例#13
0
 public void TestBuildParameterIterators(int update, List <MethodParameter> inputs, IWarewolfListIterator itrCollection, List <IWarewolfIterator> itrs, IDSFDataObject dataObject)
 {
     base.BuildParameterIterators(update, inputs, itrCollection, itrs, dataObject);
 }
        void DoInsertForMySql(DbSource runtimeDatabase, SqlBulkCopyOptions currentOptions, IWarewolfListIterator parametersIteratorCollection, IWarewolfIterator batchItr, IWarewolfIterator timeoutItr, IDSFDataObject dataObject, ErrorResultTO errorResultTo, ErrorResultTO allErrors, ref bool addExceptionToErrorList)
        {
            MySqlBulkLoader sqlBulkCopy = new MySqlBulkLoader(new MySqlConnection(runtimeDatabase.ConnectionString));

            TableName = TableName.Replace("[", "").Replace("]", "");
            if (TableName.Contains("."))
            {
                TableName = TableName.Substring(TableName.IndexOf(".", StringComparison.Ordinal) + 1);
            }
            if (String.IsNullOrEmpty(BatchSize) && String.IsNullOrEmpty(Timeout))
            {
                sqlBulkCopy = new MySqlBulkLoader(new MySqlConnection(runtimeDatabase.ConnectionString))
                {
                    TableName = TableName, FieldTerminator = ",", LineTerminator = "\n"
                };
            }
            else
            {
                while (parametersIteratorCollection.HasMoreData())
                {
                    sqlBulkCopy = SetupMySqlBulkCopy(batchItr, parametersIteratorCollection, timeoutItr, runtimeDatabase, currentOptions);
                }
            }
            if (sqlBulkCopy != null)
            {
                var dataTableToInsert = BuildDataTableToInsertMySql();

                if (InputMappings != null && InputMappings.Count > 0)
                {
                    var iteratorCollection = new WarewolfListIterator();
                    var listOfIterators    = GetIteratorsFromInputMappings(dataObject, iteratorCollection, out errorResultTo);
                    allErrors.MergeErrors(errorResultTo);

                    // oh no, we have an issue, bubble it out ;)
                    if (allErrors.HasErrors())
                    {
                        addExceptionToErrorList = false;
                        throw new Exception("Problems with Iterators for SQLBulkInsert");
                    }

                    // emit options to debug as per acceptance test ;)
                    if (dataObject.IsDebugMode())
                    {
                        AddBatchSizeAndTimeOutToDebug(dataObject.Environment);
                        AddOptionsDebugItems();
                    }

                    FillDataTableWithDataFromDataList(iteratorCollection, dataTableToInsert, listOfIterators);

                    foreach (var dataColumnMapping in InputMappings)
                    {
                        if (!String.IsNullOrEmpty(dataColumnMapping.InputColumn))
                        {
                            sqlBulkCopy.Columns.Add(dataColumnMapping.OutputColumn.ColumnName);
                        }
                    }
                }

                // Pass in wrapper now ;)
                var wrapper      = new MySqlBulkCopyWrapper(sqlBulkCopy);
                var inserted     = SqlBulkInserter.Insert(wrapper, dataTableToInsert);
                var resultString = inserted ? "Success" : "Failure";

                dataObject.Environment.Assign(Result, resultString);
                if (dataObject.IsDebugMode())
                {
                    AddDebugOutputItem(new DebugItemWarewolfAtomResult(resultString, Result, ""));
                }
                allErrors.MergeErrors(errorResultTo);
                if (dataTableToInsert != null)
                {
                    dataTableToInsert.Dispose();
                }
            }
        }
        void DoInsertForSqlServer(DbSource runtimeDatabase, SqlBulkCopyOptions currentOptions, IDSFDataObject dataObject, ErrorResultTO allErrors, IWarewolfIterator batchItr, IWarewolfListIterator parametersIteratorCollection, IWarewolfIterator timeoutItr, ref ErrorResultTO errorResultTo, ref bool addExceptionToErrorList)
        {
            SqlBulkCopy sqlBulkCopy;

            if (String.IsNullOrEmpty(BatchSize) && String.IsNullOrEmpty(Timeout))
            {
                sqlBulkCopy = new SqlBulkCopy(runtimeDatabase.ConnectionString, currentOptions)
                {
                    DestinationTableName = TableName
                };
            }
            else
            {
                sqlBulkCopy = SetupSqlBulkCopy(batchItr, parametersIteratorCollection, timeoutItr, runtimeDatabase, currentOptions);
            }

            if (sqlBulkCopy != null)
            {
                var dataTableToInsert = BuildDataTableToInsert();

                var types   = GETTypesFromMappingTypes();
                var columns = GetNamesFromMappings();
                if (InputMappings != null && InputMappings.Count > 0)
                {
                    var iteratorCollection = new WarewolfListIterator();
                    var listOfIterators    = GetIteratorsFromInputMappings(dataObject, iteratorCollection, out errorResultTo);
                    iteratorCollection.Types = types;
                    iteratorCollection.Names = columns;
                    allErrors.MergeErrors(errorResultTo);
                    FillDataTableWithDataFromDataList(iteratorCollection, dataTableToInsert, listOfIterators);
                    // oh no, we have an issue, bubble it out ;)
                    if (allErrors.HasErrors())
                    {
                        addExceptionToErrorList = false;
                        throw new Exception("Problems with Iterators for SQLBulkInsert");
                    }

                    // emit options to debug as per acceptance test ;)
                    if (dataObject.IsDebugMode())
                    {
                        AddBatchSizeAndTimeOutToDebug(dataObject.Environment);
                        AddOptionsDebugItems();
                    }


                    if (InputMappings != null)
                    {
                        foreach (var dataColumnMapping in InputMappings)
                        {
                            if (!String.IsNullOrEmpty(dataColumnMapping.InputColumn))
                            {
                                sqlBulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(dataColumnMapping.OutputColumn.ColumnName, dataColumnMapping.OutputColumn.ColumnName));
                            }
                        }
                    }
                    var wrapper = new SqlBulkCopyWrapper(sqlBulkCopy);
                    SqlBulkInserter.Insert(wrapper, dataTableToInsert);
                    dataObject.Environment.Assign(Result, "Success");
                    if (dataObject.IsDebugMode())
                    {
                        AddDebugOutputItem(new DebugItemWarewolfAtomResult("Success", Result, ""));
                    }
                }
                if (dataTableToInsert != null)
                {
                    dataTableToInsert.Dispose();
                }
            }
        }
示例#16
0
        protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update)
        {
            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, update));

            ColItr.AddVariableToIterateOn(inputItr);


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


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

            ColItr.AddVariableToIterateOn(desunameItr);


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

            ColItr.AddVariableToIterateOn(despassItr);

            AddItemsToIterator(dataObject.Environment, update);

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

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

            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);
        }
示例#17
0
        void MergeErrors(ErrorResultTO errors, int update, IOutputFormatter outputFormatter, List <IWarewolfIterator> itrs, IWarewolfListIterator itrCollection)
        {
            ErrorResultTO invokeErrors;

            if (Inputs != null && Inputs.Count == 0)
            {
                ExecuteService(out invokeErrors, update, outputFormatter);
                errors.MergeErrors(invokeErrors);
            }
            else
            {
                BuildParameterIterators(update, null, itrCollection, itrs);

                while (itrCollection.HasMoreData())
                {
                    ExecuteService(itrCollection, itrs, out invokeErrors, update, outputFormatter);
                    errors.MergeErrors(invokeErrors);
                }
            }
        }
        protected override IList<OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update)
        {
            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, update));
            ColItr.AddVariableToIterateOn(inputItr);

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

            
            var desunameItr = new WarewolfIterator(dataObject.Environment.Eval(DestinationUsername, update));
            ColItr.AddVariableToIterateOn(desunameItr);

            
            var despassItr = new WarewolfIterator(dataObject.Environment.Eval(DecryptedDestinationPassword,update));
            ColItr.AddVariableToIterateOn(despassItr);

            AddItemsToIterator(dataObject.Environment, update);

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

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

            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;

        }
示例#19
0
 public string SendEmail(IExchange runtimeSource, IWarewolfListIterator colItr, IWarewolfIterator toItr, IWarewolfIterator ccItr, IWarewolfIterator bccItr, IWarewolfIterator subjectItr, IWarewolfIterator bodyItr, IWarewolfIterator attachmentsItr, out ErrorResultTO errors) => SendEmail(runtimeSource, colItr, toItr, ccItr, bccItr, subjectItr, bodyItr, attachmentsItr, out errors, true);
示例#20
0
        // ReSharper disable TooManyArguments
        string SendEmail(EmailSource runtimeSource, IWarewolfListIterator colItr, IWarewolfIterator fromAccountItr, IWarewolfIterator passwordItr, IWarewolfIterator toItr, IWarewolfIterator ccItr, IWarewolfIterator bccItr, IWarewolfIterator subjectItr, IWarewolfIterator bodyItr, IWarewolfIterator attachmentsItr, out ErrorResultTO errors)
        // ReSharper restore TooManyArguments
        {
            errors = new ErrorResultTO();
            var          fromAccountValue = colItr.FetchNextValue(fromAccountItr);
            var          passwordValue    = colItr.FetchNextValue(passwordItr);
            var          toValue          = colItr.FetchNextValue(toItr);
            var          ccValue          = colItr.FetchNextValue(ccItr);
            var          bccValue         = colItr.FetchNextValue(bccItr);
            var          subjectValue     = colItr.FetchNextValue(subjectItr);
            var          bodyValue        = colItr.FetchNextValue(bodyItr);
            var          attachmentsValue = colItr.FetchNextValue(attachmentsItr);
            MailMessage  mailMessage      = new MailMessage();
            MailPriority priority;

            if (Enum.TryParse(Priority.ToString(), true, out priority))
            {
                mailMessage.Priority = priority;
            }
            mailMessage.Subject = subjectValue;
            AddToAddresses(toValue, mailMessage);
            try
            {
                // Always use source account unless specifically overridden by From Account
                if (!string.IsNullOrEmpty(fromAccountValue))
                {
                    runtimeSource.UserName = fromAccountValue;
                    runtimeSource.Password = passwordValue;
                }
                mailMessage.From = new MailAddress(runtimeSource.UserName);
            }
            catch (Exception)
            {
                errors.AddError(string.Format("From address is not in the valid format: {0}", fromAccountValue));
                return("Failure");
            }
            mailMessage.Body = bodyValue;
            if (!String.IsNullOrEmpty(ccValue))
            {
                AddCcAddresses(ccValue, mailMessage);
            }
            if (!String.IsNullOrEmpty(bccValue))
            {
                AddBccAddresses(bccValue, mailMessage);
            }
            if (!String.IsNullOrEmpty(attachmentsValue))
            {
                AddAttachmentsValue(attachmentsValue, mailMessage);
            }
            string result;

            try
            {
                EmailSender.Send(runtimeSource, mailMessage);
                result = "Success";
            }
            catch (Exception e)
            {
                result = "Failure";
                errors.AddError(e.Message);
            }

            return(result);
        }
示例#21
0
        protected void BuildParameterIterators(int update, List <MethodParameter> inputs, IWarewolfListIterator itrCollection, List <IWarewolfIterator> itrs, IDSFDataObject dataObject)
        {
            if (inputs != null)
            {
                foreach (var sai in inputs)
                {
                    var    val      = sai.Name;
                    string toInject = null;

                    if (val != null)
                    {
                        toInject = sai.Value;
                    }

                    var paramIterator = new WarewolfIterator(dataObject.Environment.Eval(toInject, update));
                    itrCollection.AddVariableToIterateOn(paramIterator);
                    itrs.Add(paramIterator);
                }
            }
        }
示例#22
0
        void BuildParameterIterators(int update, IEnumerable <MethodParameter> inputs, IWarewolfListIterator itrCollection, ICollection <IWarewolfIterator> itrs)
        {
            if (string.IsNullOrEmpty(InstanceInputDefinitions))
            {
                if (Inputs != null)
                {
                    foreach (var sai in Inputs)
                    {
                        AddInput(update, itrCollection, itrs, sai);
                    }
                }

                return;
            }

            var inputDefs = DataListFactory.CreateInputParser().Parse(InstanceInputDefinitions);

            foreach (MethodParameter sai in inputs)
            {
                var val      = sai.Name;
                var toInject = "NULL";

                if (val != null)
                {
                    var sai1            = sai;
                    var dev2Definitions = inputDefs.Where(definition => definition.Name == sai1.Name);
                    var definitions     = dev2Definitions as IDev2Definition[] ?? dev2Definitions.ToArray();
                    if (definitions.Length == 1)
                    {
                        toInject = DataListUtil.IsEvaluated(definitions[0].RawValue) ? DataListUtil.AddBracketsToValueIfNotExist(definitions[0].RawValue) : definitions[0].RawValue;
                    }
                }
                else
                {
                    if (!sai.EmptyToNull)
                    {
                        toInject = sai.DefaultValue;
                    }
                }

                var paramIterator = new WarewolfIterator(DataObj.Environment.Eval(toInject, update));
                itrCollection.AddVariableToIterateOn(paramIterator);
                itrs.Add(paramIterator);
            }
        }
示例#23
0
        private void TryExecute(int update, IDSFDataObject dataObject, List <IWarewolfIterator> itrs, IWarewolfListIterator itrCollection, List <MethodParameter> methodParameters, PluginInvokeArgs args)
        {
            while (itrCollection.HasMoreData())
            {
                var pos = 0;
                foreach (var itr in itrs)
                {
                    var injectVal = itrCollection.FetchNextValue(itr);
                    var param     = methodParameters.ToList()[pos];

                    param.Value = param.EmptyToNull &&
                                  (injectVal == null ||
                                   string.Compare(injectVal, string.Empty,
                                                  StringComparison.InvariantCultureIgnoreCase) == 0)
                        ? null
                        : injectVal;

                    pos++;
                }
                if (!IsObject)
                {
                    var i = 0;
                    foreach (var serviceOutputMapping in Outputs)
                    {
                        OutputDescription.DataSourceShapes[0].Paths[i].OutputExpression = DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo);
                        i++;
                    }
                    var outputFormatter = OutputFormatterFactory.CreateOutputFormatter(OutputDescription);
                    args.OutputFormatter = outputFormatter;
                }
                var result = PluginServiceExecutionFactory.InvokePlugin(args).ToString();
                ResponseManager = new ResponseManager {
                    OutputDescription = OutputDescription, Outputs = Outputs, IsObject = IsObject, ObjectName = ObjectName
                };
                ResponseManager.PushResponseIntoEnvironment(result, update, dataObject, false);
            }
        }
示例#24
0
        IErrorResultTO TryExecute(IDSFDataObject dataObject, int update, IDev2ReplaceOperation replaceOperation, ref IErrorResultTO errors, IErrorResultTO allErrors, ref int replacementCount, ref int replacementTotal, IList <string> toSearch, IWarewolfListIterator iteratorCollection, WarewolfIterator itrFind, WarewolfIterator itrReplace)
        {
            var counter = 1;

            while (iteratorCollection.HasMoreData())
            {
                // now process each field for entire evaluated Where expression....
                var findValue        = iteratorCollection.FetchNextValue(itrFind);
                var replaceWithValue = iteratorCollection.FetchNextValue(itrReplace);
                foreach (string s in toSearch)
                {
                    ExecuteEachField(dataObject, update, replaceOperation, ref errors, allErrors, ref replacementCount, ref replacementTotal, ref counter, findValue, replaceWithValue, s);
                }
            }
            return(allErrors);
        }
示例#25
0
        private void TryExecute(int update, IDSFDataObject dataObject, List <IWarewolfIterator> itrs, IWarewolfListIterator itrCollection, List <MethodParameter> methodParameters, ComPluginInvokeArgs args)
        {
            if (Inputs == null || Inputs.Count == 0)
            {
                PerfromExecution(update, dataObject, args);
            }
            else
            {
                while (itrCollection.HasMoreData())
                {
                    var pos = 0;
                    foreach (var itr in itrs)
                    {
                        var injectVal = itrCollection.FetchNextValue(itr);
                        var param     = methodParameters.ToList()[pos];


                        param.Value = param.EmptyToNull &&
                                      (injectVal == null ||
                                       string.Compare(injectVal, string.Empty,
                                                      StringComparison.InvariantCultureIgnoreCase) == 0)
                            ? null
                            : injectVal;

                        pos++;
                    }
                    PerfromExecution(update, dataObject, args);
                }
            }
        }