public void SendFault(Exception exception, IDictionary <string, string> outgoingContextProperties) { if (exception == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exception"); } if (!(exception is FaultException)) //Wrap the exception if it is not FaultException. { exception = WorkflowOperationErrorHandler.CreateUnhandledException(exception); } WorkflowOperationAsyncResult asyncResult = this.GetAsyncResult(); asyncResult.SendFault(exception, outgoingContextProperties); this.SetOperationCompleted(); if (DiagnosticUtility.ShouldTraceInformation) { string traceText = SR.GetString(SR.TraceCodeWorkflowRequestContextFaultSent, asyncResult.InstanceId); TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.WorkflowRequestContextFaultSent, traceText, new StringTraceRecord("Details", traceText), this, exception); } }
public WorkflowRequestContext(WorkflowOperationAsyncResult asyncResult, object[] inputs, IDictionary<string, string> contextProperties) { if (asyncResult == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("asyncResult"); } if (inputs == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("inputs"); } this.asyncResult = asyncResult; this.inputs = new ReadOnlyCollection<object>(inputs); this.contextProperties = contextProperties ?? SerializableReadOnlyDictionary<string, string>.Empty; this.operationContext = OperationContext.Current; }
public WorkflowRequestContext(WorkflowOperationAsyncResult asyncResult, object[] inputs, IDictionary <string, string> contextProperties) { if (asyncResult == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("asyncResult"); } if (inputs == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("inputs"); } this.asyncResult = asyncResult; this.inputs = new ReadOnlyCollection <object>(inputs); this.contextProperties = contextProperties ?? SerializableReadOnlyDictionary <string, string> .Empty; this.operationContext = OperationContext.Current; }
public static object End(WorkflowOperationAsyncResult result, out object[] outputs) { if (result == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result"); } try { AsyncResult.End <WorkflowOperationAsyncResult>(result); } finally { //Application Fault's should carry Context Properties result.PromoteContextProperties(); } outputs = result.outputs; return(result.returnValue); }
public void SendReply(object returnValue, object[] outputs, IDictionary <string, string> outgoingContextProperties) { if (outputs == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("outputs"); } WorkflowOperationAsyncResult asyncResult = this.GetAsyncResult(); asyncResult.SendResponse(returnValue, outputs, outgoingContextProperties); this.SetOperationCompleted(); if (DiagnosticUtility.ShouldTraceVerbose) { string traceText = SR.GetString(SR.TraceCodeWorkflowRequestContextReplySent, asyncResult.InstanceId); TraceUtility.TraceEvent(TraceEventType.Verbose, TraceCode.WorkflowRequestContextReplySent, traceText, new StringTraceRecord("Details", traceText), this, null); } }
public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result) { bool methodThrewException = false; if (result == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result"); } WorkflowDurableInstance durableInstance = (WorkflowDurableInstance)instance; WorkflowOperationAsyncResult asyncResult = (WorkflowOperationAsyncResult)result; Fx.Assert(durableInstance.CurrentOperationInvocation != null, "At the time WorkflowOperationInvoker.InvokeEnd is called, the WorkflowDurableInstance.CurrentOperationInvocation is expected to be present."); try { return(WorkflowOperationAsyncResult.End(asyncResult, out outputs)); } catch (FaultException) { methodThrewException = true; if (PerformanceCounters.PerformanceCountersEnabled) { PerformanceCounters.MethodReturnedFault(this.operationDescription.Name); } throw; } catch (Exception e) { methodThrewException = true; if (Fx.IsFatal(e)) { throw; } if (PerformanceCounters.PerformanceCountersEnabled) { PerformanceCounters.MethodReturnedError(this.operationDescription.Name); } throw; } finally { durableInstance.CurrentOperationInvocation = null; if (!methodThrewException) { if (PerformanceCounters.PerformanceCountersEnabled) { long currentTime = 0; long duration = 0; if ((asyncResult.BeginTime >= 0) && (UnsafeNativeMethods.QueryPerformanceCounter(out currentTime) != 0)) { duration = currentTime - asyncResult.BeginTime; } PerformanceCounters.MethodReturnedSuccess(this.operationDescription.Name, duration); } } } }
public static object End(WorkflowOperationAsyncResult result, out object[] outputs) { if (result == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result"); } try { AsyncResult.End<WorkflowOperationAsyncResult>(result); } finally { //Application Fault's should carry Context Properties result.PromoteContextProperties(); } outputs = result.outputs; return result.returnValue; }