private static object[] ProcessEvent(HandleExternalEventActivity activity, ActivityExecutionContext context, object msg, Type interfaceType, string operation) { IMethodMessage message = msg as IMethodMessage; if (message == null) { Exception excp = msg as Exception; if (excp != null) { throw excp; } throw new InvalidOperationException(SR.GetString(SR.Error_InvalidLocalServiceMessage)); } CorrelationService.InvalidateCorrelationToken(activity, interfaceType, operation, message.Args); IdentityContextData identityData = (IdentityContextData)message.LogicalCallContext.GetData(IdentityContextData.IdentityContext); ValidateRoles(activity, identityData.Identity); if (ProcessEventParameters(activity.ParameterBindings, message, interfaceType, operation)) { return(message.Args); } return(null); }
protected override void PreFilterProperties(IDictionary properties) { base.PreFilterProperties(properties); object corrRefProperty = properties["CorrelationToken"]; HandleExternalEventActivity activity = base.Activity as HandleExternalEventActivity; this.AddRemoveCorrelationToken(activity.InterfaceType, properties, corrRefProperty); Type interfaceType = activity.InterfaceType; if (interfaceType != null) { this.AddRemoveCorrelationToken(interfaceType, properties, corrRefProperty); activity.GetParameterPropertyDescriptors(properties); } }
public override ValidationErrorCollection Validate(ValidationManager manager, object obj) { HandleExternalEventActivity eventSink = obj as HandleExternalEventActivity; if (eventSink == null) { throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(HandleExternalEventActivity).FullName), "obj"); } ValidationErrorCollection validationErrors = base.Validate(manager, obj); validationErrors.AddRange(CorrelationSetsValidator.Validate(manager, obj)); validationErrors.AddRange(ParameterBindingValidator.Validate(manager, obj)); return(validationErrors); }
void IActivityEventListener <QueueEventArgs> .OnEvent(object sender, QueueEventArgs e) { ActivityExecutionContext context = (ActivityExecutionContext)sender; HandleExternalEventActivity activity = context.Activity as HandleExternalEventActivity; if (activity.ExecutionStatus == ActivityExecutionStatus.Executing) { object[] args = null; if (InboundActivityHelper.ExecuteForActivity(this, context, this.InterfaceType, this.EventName, out args) == ActivityExecutionStatus.Closed) { this.RaiseEvent(args); this.UnsubscribeForActivity(context); context.CloseActivity(); } } }
internal static ActivityExecutionStatus ExecuteForActivity(HandleExternalEventActivity activity, ActivityExecutionContext context, Type interfaceType, string operation, out object[] args) { WorkflowQueuingService queueSvcs = (WorkflowQueuingService)context.GetService(typeof(WorkflowQueuingService)); args = null; IComparable queueId = CorrelationService.ResolveQueueName(activity, interfaceType, operation); if (queueId != null) { WorkflowQueue queue; object msg = DequeueMessage(queueId, queueSvcs, activity, out queue); CorrelationService.UninitializeFollowers(interfaceType, operation, queue); if (msg != null) { args = ProcessEvent(activity, context, msg, interfaceType, operation); return(ActivityExecutionStatus.Closed); } } return(ActivityExecutionStatus.Executing); }
protected override void PreFilterProperties(IDictionary properties) { base.PreFilterProperties(properties); object corrRefProperty = properties["CorrelationToken"]; HandleExternalEventActivity eventSink = Activity as HandleExternalEventActivity; AddRemoveCorrelationToken(eventSink.InterfaceType, properties, corrRefProperty); Type type = eventSink.InterfaceType; if (type == null) { return; } AddRemoveCorrelationToken(type, properties, corrRefProperty); eventSink.GetParameterPropertyDescriptors(properties); }
void IActivityEventListener <QueueEventArgs> .OnEvent(object sender, QueueEventArgs e) { ActivityExecutionContext context = (ActivityExecutionContext)sender; HandleExternalEventActivity activity = context.Activity as HandleExternalEventActivity; // if activity is not scheduled for execution do not dequeue the message if (activity.ExecutionStatus != ActivityExecutionStatus.Executing) { return; } object[] args = null; ActivityExecutionStatus status = InboundActivityHelper.ExecuteForActivity(this, context, this.InterfaceType, this.EventName, out args); if (status == ActivityExecutionStatus.Closed) { RaiseEvent(args); UnsubscribeForActivity(context); context.CloseActivity(); } }
protected override void OnActivityChanged(ActivityChangedEventArgs e) { base.OnActivityChanged(e); if (e.Member != null) { if (e.Member.Name == "InterfaceType") { if (Activity.Site != null) { Type interfaceType = e.NewValue as Type; if (interfaceType != null) { new ExternalDataExchangeInterfaceTypeFilterProvider(Activity.Site).CanFilterType(interfaceType, true); } HandleExternalEventActivity eventSinkActivity = e.Activity as HandleExternalEventActivity; PropertyDescriptorUtils.SetPropertyValue(Activity.Site, TypeDescriptor.GetProperties(Activity)["EventName"], Activity, String.Empty); IExtendedUIService extUIService = (IExtendedUIService)Activity.Site.GetService(typeof(IExtendedUIService)); if (extUIService == null) { throw new Exception(SR.GetString(SR.General_MissingService, typeof(IExtendedUIService).FullName)); } } } else if ((e.Member.Name == "EventName") && e.Activity is HandleExternalEventActivity) { (e.Activity as HandleExternalEventActivity).ParameterBindings.Clear(); } if (e.Member.Name == "InterfaceType" || e.Member.Name == "EventName" || e.Member.Name == "CorrelationToken") { TypeDescriptor.Refresh(e.Activity); } } }