Example #1
0
        private void MarkRunInternalError(IRunState runState, Exception ex)
        {
            using (new SecurityBypassContext())
            {
                var safeDescription = GetSafeWfDescription(runState);
                var stateString     = GetStateString(runState);

                var logEntry = new WorkflowRunLogEntry
                {
                    Name        = "Workflow run internal error",
                    Description = string.Format("Workflow failed with an internal error at {0}.\nState: {1}", safeDescription, stateString)
                };


                var msg = string.Format("Workflow run ({0}): {1}. Exception occurred on run.\n{2}\n{3}\nState:\n{4}",
                                        runState != null ? runState.WorkflowRunId : -1L,
                                        safeDescription,
                                        ex.Message,
                                        ex.StackTrace,
                                        stateString);

                EventLog.Application.WriteError(msg);

                if (runState != null)
                {
                    runState.RunStatus = WorkflowRunState_Enumeration.WorkflowRunFailed;
                    runState.LogError(logEntry);
                }
            }
        }
Example #2
0
        void MarkRunFailed(IRunState runState, WorkflowRunException ex)
        {
            using (new SecurityBypassContext())
            {
                var stateString = GetStateString(runState);

                var sb = new StringBuilder("");
                sb.Append(ex.InnerException is PlatformSecurityException ? "Security violation " : "Failed ");
                sb.Append("at ");
                sb.Append(GetSafeWfDescription(runState));
                sb.Append(Environment.NewLine + "With message: ");
                sb.Append(Environment.NewLine + ex.Message);
                sb.AppendFormat("\nState: {0}", stateString);

                var log = sb.ToString();

                var shortMessage  = ex.Message ?? "";
                var maxNameLength = (int)Resource.Name_Field.MaxLength; // why bother?

                if (shortMessage.Length > maxNameLength)                // The name field is a max of 200 characters
                {
                    shortMessage = shortMessage.Substring(0, maxNameLength);
                }

                var logEntry = new WorkflowRunFailedLogEntry
                {
                    Name             = shortMessage,
                    Description      = log,
                    ActivityBeingRun = runState.CurrentActivity,
                };

#if DEBUG
                log += Environment.NewLine + ex.StackTrace;
#endif

                // error in how the workflow is configured by the user.
                EventLog.Application.WriteInformation("Workflow: {0}", log);

                if (runState != null)
                {
                    runState.RunStatus = WorkflowRunState_Enumeration.WorkflowRunFailed;
                    runState.LogError(logEntry);
                }
            }
        }
Example #3
0
        void MarkRunFailedTriggerDepth(IRunState runState)
        {
            using (new SecurityBypassContext())
            {
                const string msg      = "Failed to start because the trigger depth has been exceeded. Check triggers on workflow for looping.";
                var          logEntry = new WorkflowRunFailedLogEntry
                {
                    Name        = "Workflow exceeded trigger depth",
                    Description = msg,
                };

                // error in how the workflow is configured by the user.
                EventLog.Application.WriteInformation(string.Format("Workflow: {0}. {1}", runState.GetSafeWorkflowDescription(), msg));

                if (runState != null)
                {
                    runState.RunStatus = WorkflowRunState_Enumeration.WorkflowRunFailed;
                    runState.LogError(logEntry);
                }
            }
        }
Example #4
0
        void MarkRunFailedHasErrors(IRunState runState)
        {
            using (new SecurityBypassContext())
            {
                string msg = $"Failed to start because it is misconfigured: \n{string.Join(", \n", runState.Metadata.ValidationMessages)}";

                var logEntry = new WorkflowRunFailedLogEntry
                {
                    Name        = "Workflow misconfigured",
                    Description = msg,
                };

                // error in how the workflow is configured by the user.
                EventLog.Application.WriteInformation(string.Format("Workflow: {0}. {1}", runState.GetSafeWorkflowDescription(), msg));

                if (runState != null)
                {
                    runState.RunStatus = WorkflowRunState_Enumeration.WorkflowRunFailed;
                    runState.LogError(logEntry);
                }
            }
        }