Exemplo n.º 1
0
 private void SetupSqlServer(IErrorResultTO errors)
 {
     try
     {
         var connected = _sqlServer.Connect(Source.ConnectionString, CommandType.StoredProcedure, ProcedureName);
         if (!connected)
         {
             Dev2Logger.Error(string.Format(ErrorResource.FailedToConnectWithConnectionString,
                                            Source.ConnectionString));
         }
     }
     catch (SqlException sex)
     {
         var errorMessages = new StringBuilder();
         for (var i = 0; i < sex.Errors.Count; i++)
         {
             errorMessages.Append("Index #" + i + Environment.NewLine +
                                  "Message: " + sex.Errors[i].Message + Environment.NewLine +
                                  "LineNumber: " + sex.Errors[i].LineNumber + Environment.NewLine +
                                  "Source: " + sex.Errors[i].Source + Environment.NewLine +
                                  "Procedure: " + sex.Errors[i].Procedure + Environment.NewLine);
         }
         errors.AddError(errorMessages.ToString());
         Dev2Logger.Error(errorMessages.ToString());
     }
     catch (Exception ex)
     {
         errors.AddError($"{ex.Message}{Environment.NewLine}{ex.StackTrace}");
         Dev2Logger.Error(ex);
     }
 }
Exemplo n.º 2
0
 public QueueResource(string name, QueueStatus status, string workflowName, string resourceId)
 {
     WorkflowName = workflowName;
     _status      = status;
     Name         = history.First();
     IsDirty      = false;
     _errors      = new ErrorResultTO();
     if (!String.IsNullOrEmpty(resourceId))
     {
         ResourceId = Guid.Parse(resourceId);
     }
 }
Exemplo n.º 3
0
        public void MergeErrors(IErrorResultTO toMerge)
        {
            if (toMerge != null && toMerge.HasErrors())
            {
                foreach (string wtf in toMerge.FetchErrors())
                {
                    _errorList.Add(wtf);
                }

                toMerge.ClearErrors();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Merges the errors.
        /// </summary>
        /// <param name="toMerge">To merge.</param>
        public void MergeErrors(IErrorResultTO toMerge)
        {
            if (toMerge != null && toMerge.HasErrors())
            {
                // Flipping Union does not appear to work
                foreach (string wtf in toMerge.FetchErrors())
                {
                    _errorList.Add(wtf);
                }

                toMerge.ClearErrors();
            }
        }
        /// <summary>
        /// Merges the errors.
        /// </summary>
        /// <param name="toMerge">To merge.</param>
        public void MergeErrors(IErrorResultTO toMerge)
        {
            if(toMerge != null && toMerge.HasErrors())
            {
                // Flipping Union does not appear to work
                foreach(string wtf in toMerge.FetchErrors())
                {
                    _errorList.Add(wtf);
                }

                toMerge.ClearErrors();
            }
        }
Exemplo n.º 6
0
        public ScheduledResource(string name, SchedulerStatus status, DateTime nextRunDate, IScheduleTrigger trigger, string workflowName)
        {

            var history = name.Split('~');

            WorkflowName = workflowName;
            Trigger = trigger;

            NextRunDate = nextRunDate;
            Status = status;
            Name = history.First();
            if(history.Length == 2)
                NumberOfHistoryToKeep = int.Parse(history[1]);
            IsDirty = false;
            _errors = new ErrorResultTO();
        }
Exemplo n.º 7
0
        public ScheduledResource(string name, SchedulerStatus status, DateTime nextRunDate, IScheduleTrigger trigger, string workflowName)
        {
            var history = name.Split('~');

            WorkflowName = workflowName;
            Trigger      = trigger;

            NextRunDate = nextRunDate;
            Status      = status;
            Name        = history.First();
            if (history.Length == 2)
            {
                NumberOfHistoryToKeep = int.Parse(history[1]);
            }
            IsDirty = false;
            _errors = new ErrorResultTO();
        }
 private void HandleErrors(IDSFDataObject dataObject, IErrorResultTO allErrors)
 {
     if (allErrors.HasErrors())
     {
         dataObject.ParentInstanceID = _previousParentId;
         dataObject.ForEachNestingLevel--;
         dataObject.IsDebugNested = false;
         if (allErrors.HasErrors())
         {
             foreach (var fetchError in allErrors.FetchErrors())
             {
                 dataObject.Environment.AddError(fetchError);
             }
             dataObject.ParentInstanceID = _previousParentId;
             DisplayAndWriteError(dataObject, DisplayName, allErrors);
         }
     }
 }
Exemplo n.º 9
0
        private void HandleErrors(IDSFDataObject dataObject, IErrorResultTO allErrors)
        {
            if (allErrors.HasErrors())
            {
                dataObject.ParentInstanceID = _previousParentId;
                dataObject.ForEachNestingLevel--;
                dataObject.IsDebugNested = false;
                // Handle Errors
                if (allErrors.HasErrors())
                {
                    DisplayAndWriteError(nameof(SuspendExecutionActivity), allErrors);
                    foreach (var fetchError in allErrors.FetchErrors())
                    {
                        dataObject.Environment.AddError(fetchError);
                    }

                    dataObject.ParentInstanceID = _previousParentId;
                }
            }
        }
Exemplo n.º 10
0
#pragma warning disable S1541 // Methods and properties should not be too complex
#pragma warning disable S3776 // Cognitive Complexity of methods should not be too high
        private void ExecuteEachField(IDSFDataObject dataObject, int update, IDev2ReplaceOperation replaceOperation, ref IErrorResultTO errors, IErrorResultTO allErrors, ref int replacementCount, ref int replacementTotal, ref int counter, string findValue, string replaceWithValue, string s)
#pragma warning restore S3776 // Cognitive Complexity of methods should not be too high
#pragma warning restore S1541 // Methods and properties should not be too complex
        {
            if (!string.IsNullOrEmpty(findValue))
            {
                if (!string.IsNullOrEmpty(Result) && !DataListUtil.IsValueScalar(Result) && !dataObject.Environment.HasRecordSet(DataListUtil.ExtractRecordsetNameFromValue(Result)))
                {
                    dataObject.Environment.AssignDataShape(Result);
                }

                try
                {
                    var replacementTotalInner = replacementTotal;
                    var errorsInner           = errors;
                    var counterInner          = counter;
                    dataObject.Environment.ApplyUpdate(s, a =>
                    {
                        var replacementCountInner = 0;
                        var replace = replaceOperation.Replace(a.ToString(), findValue, replaceWithValue, CaseMatch, out errorsInner, ref replacementCountInner);
                        if (!string.IsNullOrEmpty(Result) && !DataListUtil.IsValueScalar(Result))
                        {
                            dataObject.Environment.Assign(Result, replacementCountInner.ToString(CultureInfo.InvariantCulture), update == 0 ? counterInner : update);
                        }
                        replacementTotalInner += replacementCountInner;
                        counterInner++;
                        return(DataStorage.WarewolfAtom.NewDataString(replace));
                    }, update);
                    replacementTotal = replacementTotalInner;
                    errors           = errorsInner;
                    counter          = counterInner;
                }
                catch (Exception)
                {
                    replacementCount = 0;
                    var toReplaceIn = dataObject.Environment.Eval(s, update);
                    var a           = ExecutionEnvironment.WarewolfEvalResultToString(toReplaceIn);
                    var replace     = replaceOperation.Replace(a, findValue, replaceWithValue, CaseMatch, out errors, ref replacementCount);
                    if (!string.IsNullOrEmpty(Result) && !DataListUtil.IsValueScalar(Result))
                    {
                        dataObject.Environment.AssignStrict(Result, replacementCount.ToString(CultureInfo.InvariantCulture), update == 0 ? counter : update);
                    }
                    replacementTotal += replacementCount;
                    counter++;
                    dataObject.Environment.AssignStrict(s, replace, update == 0 ? counter : update);
                }
            }
            if (DataListUtil.IsValueScalar(Result))
            {
                dataObject.Environment.Assign(Result, replacementTotal.ToString(CultureInfo.InvariantCulture), update == 0 ? counter : update);
            }

            if (dataObject.IsDebugMode() && !allErrors.HasErrors() && !string.IsNullOrEmpty(Result) && replacementTotal > 0)
            {
                AddDebugOutputItem(new DebugEvalResult(s, "", dataObject.Environment, update));
            }
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Replaces a value in and entry with a new value.
        /// </summary>
        /// <param name="stringToSearch">The old string.</param>
        /// <param name="findString">The old string.</param>
        /// <param name="replacementString">The new string.</param>
        /// <param name="caseMatch">if set to <c>true</c> [case match].</param>
        /// <param name="errors">The errors.</param>
        /// <param name="replaceCount">The replace count.</param>
        /// <returns></returns>
        public string Replace(string stringToSearch, string findString, string replacementString, bool caseMatch, out IErrorResultTO errors, ref int replaceCount)
        {
            var oldString = stringToSearch;
            var allErrors = new ErrorResultTO();

            errors = new ErrorResultTO();
            allErrors.MergeErrors(errors);

            var regexOptions = caseMatch ? NoneCompiled : IgnoreCaseCompiled;

            var regex  = new Regex(Regex.Escape(findString), regexOptions);
            var tmpVal = oldString;

            replaceCount += regex.Matches(tmpVal).Count;
            var replaceValue = regex.Replace(tmpVal, replacementString);

            errors = allErrors;
            return(replaceValue);
        }