Ejemplo n.º 1
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);
                }
            }
        }
Ejemplo n.º 2
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);
                }
            }
        }
Ejemplo n.º 3
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);
                }
            }
        }