protected BasicBrowserDialog(Activity activity, string name) { if (activity == null) throw (new ArgumentNullException("activity")); this.activity = activity; InitializeComponent(); // set captions this.descriptionLabel.Text = DescriptionText; this.Text = TitleText; this.previewLabel.Text = PreviewLabelText; this.newRuleToolStripButton.Enabled = true; this.name = name; serviceProvider = activity.Site; //Set dialog fonts IUIService uisvc = (IUIService)activity.Site.GetService(typeof(IUIService)); if (uisvc != null) this.Font = (Font)uisvc.Styles["DialogFont"]; HelpRequested += new HelpEventHandler(OnHelpRequested); HelpButtonClicked += new CancelEventHandler(OnHelpClicked); this.rulesListView.Select(); }
public ActivityChangedEventArgs(System.Workflow.ComponentModel.Activity activity, MemberDescriptor member, object oldValue, object newValue) { this.activity = activity; this.member = member; this.oldValue = oldValue; this.newValue = newValue; }
protected override void Initialize(Activity activity) { base.Initialize(activity); HelpText = DR.GetString(DR.SequentialWorkflowHelpText); Header.Text = DR.GetString(DR.StartSequentialWorkflow); }
// Save the completed activity state. protected override void SaveCompletedContextActivity(Activity activity) { Guid contextGuid = (Guid)activity.GetValue(Activity.ActivityContextGuidProperty); Console.WriteLine("Saving completed activity context: {0}", contextGuid); SerializeToFile( WorkflowPersistenceService.GetDefaultSerializedForm(activity), contextGuid); }
protected override bool ApplyTo(Activity rootActivity) { if (rootActivity == null) return false; RuleDefinitions rules = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions; if (rules == null) { rules = new RuleDefinitions(); ((Activity)rootActivity).SetValue(RuleDefinitions.RuleDefinitionsProperty, rules); } // bool setRuntimeMode = false; if (rules.Conditions.RuntimeMode) { rules.Conditions.RuntimeMode = false; setRuntimeMode = true; } try { rules.Conditions.Add(this.ConditionDefinition); } finally { if (setRuntimeMode) rules.Conditions.RuntimeMode = true; } return true; }
protected static TypeProvider CreateTypeProvider(Activity rootActivity) { TypeProvider typeProvider = new TypeProvider(null); Type companionType = rootActivity.GetType(); typeProvider.SetLocalAssembly(companionType.Assembly); typeProvider.AddAssembly(companionType.Assembly); foreach (AssemblyName assemblyName in companionType.Assembly.GetReferencedAssemblies()) { Assembly referencedAssembly = null; try { referencedAssembly = Assembly.Load(assemblyName); if (referencedAssembly != null) { typeProvider.AddAssembly(referencedAssembly); } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } } if (referencedAssembly == null && assemblyName.CodeBase != null) { typeProvider.AddAssemblyReference(assemblyName.CodeBase); } } return typeProvider; }
public ActivityChangedEventArgs(System.Workflow.ComponentModel.Activity activity, MemberDescriptor member, object oldValue, object newValue) { this.activity = activity; this.member = member; this.oldValue = oldValue; this.newValue = newValue; }
public RuleValidation(Activity activity, ITypeProvider typeProvider, bool checkStaticType) { this.errors = new ValidationErrorCollection(); this.typesUsed = new Dictionary<string, Type>(0x10); this.activeParentNodes = new Stack<CodeExpression>(); this.expressionInfoMap = new Dictionary<CodeExpression, RuleExpressionInfo>(); this.typeRefMap = new Dictionary<CodeTypeReference, Type>(); if (activity == null) { throw new ArgumentNullException("activity"); } if (typeProvider == null) { throw new ArgumentNullException("typeProvider"); } this.thisType = ConditionHelper.GetContextType(typeProvider, activity); this.typeProvider = typeProvider; this.checkStaticType = checkStaticType; if (checkStaticType) { this.authorizedTypes = WorkflowCompilationContext.Current.GetAuthorizedTypes(); this.typesUsedAuthorized = new Dictionary<string, Type>(); this.typesUsedAuthorized.Add(voidTypeName, voidType); } }
// Methods public override bool Evaluate (Activity activity, IServiceProvider provider) { Activity parent = activity; RuleDefinitions definitions = null; while (parent != null) { definitions = (RuleDefinitions) parent.GetValue (RuleDefinitions.RuleDefinitionsProperty); if (definitions != null) break; parent = parent.Parent; } if (definitions == null) { Console.WriteLine ("No definition"); return false; } //Console.WriteLine ("Definition {0} at {1}", definitions, parent); RuleValidation validation = new RuleValidation (activity.GetType (), null); RuleExecution execution = new RuleExecution (validation, parent); RuleCondition condition = definitions.Conditions [ConditionName]; //Console.WriteLine ("Condition {0}", condition); return condition.Evaluate (execution); }
private static Activity GetActivity(Activity containerActivity, string id) { if (containerActivity != null) { Queue queue = new Queue(); queue.Enqueue(containerActivity); while (queue.Count > 0) { Activity activity = (Activity) queue.Dequeue(); if (activity.Enabled) { if (activity.QualifiedName == id) { return activity; } if (activity is CompositeActivity) { foreach (Activity activity2 in ((CompositeActivity) activity).Activities) { queue.Enqueue(activity2); } } } } } return null; }
public void AddActivityToDesigner(Activity activity) { if (activity == null) { throw new ArgumentNullException("activity"); } IDesignerHost service = base.GetService(typeof(IDesignerHost)) as IDesignerHost; if (service == null) { throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(IDesignerHost).FullName })); } if ((activity.Parent == null) && (service.RootComponent == null)) { string str = activity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string; string name = !string.IsNullOrEmpty(str) ? Helpers.GetClassName(str) : Helpers.GetClassName(activity.GetType().FullName); service.Container.Add(activity, name); this.AddTargetFrameworkProvider(activity); } else { service.Container.Add(activity, activity.QualifiedName); this.AddTargetFrameworkProvider(activity); } if (activity is CompositeActivity) { foreach (Activity activity2 in Helpers.GetNestedActivities(activity as CompositeActivity)) { service.Container.Add(activity2, activity2.QualifiedName); this.AddTargetFrameworkProvider(activity2); } } }
internal static void FilterDependencyProperties(IServiceProvider serviceProvider, Activity activity) { IExtenderListService service = serviceProvider.GetService(typeof(IExtenderListService)) as IExtenderListService; if (service != null) { Dictionary<string, DependencyProperty> dictionary = new Dictionary<string, DependencyProperty>(); foreach (DependencyProperty property in activity.MetaDependencyProperties) { dictionary.Add(property.Name, property); } List<string> list = new List<string>(); foreach (IExtenderProvider provider in service.GetExtenderProviders()) { if (!provider.CanExtend(activity)) { ProvidePropertyAttribute[] customAttributes = provider.GetType().GetCustomAttributes(typeof(ProvidePropertyAttribute), true) as ProvidePropertyAttribute[]; foreach (ProvidePropertyAttribute attribute in customAttributes) { list.Add(attribute.PropertyName); } } } foreach (string str in list) { if (dictionary.ContainsKey(str)) { activity.RemoveProperty(dictionary[str]); } } } }
internal static void GetAllMembers(Activity activity, IList<TrackingDataItem> items, TrackingAnnotationCollection annotations) { Type type = activity.GetType(); foreach (FieldInfo info in type.GetFields(BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)) { if (!IsInternalVariable(info.Name)) { TrackingDataItem item = new TrackingDataItem { FieldName = info.Name, Data = GetRuntimeValue(info.GetValue(activity), activity) }; foreach (string str in annotations) { item.Annotations.Add(str); } items.Add(item); } } foreach (PropertyInfo info2 in type.GetProperties(BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)) { if (!IsInternalVariable(info2.Name) && (info2.GetIndexParameters().Length <= 0)) { TrackingDataItem item2 = new TrackingDataItem { FieldName = info2.Name, Data = GetRuntimeValue(info2.GetValue(activity, null), activity) }; foreach (string str2 in annotations) { item2.Annotations.Add(str2); } items.Add(item2); } } }
protected override void OnValidate(ValidationErrorCollection errors) { if (!string.IsNullOrEmpty(this.rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string)) { errors.Add(new ValidationError(SR2.XomlWorkflowHasClassName, ErrorNumbers.Error_XomlWorkflowHasClassName)); } Queue compositeActivities = new Queue(); compositeActivities.Enqueue(this.rootActivity); while (compositeActivities.Count > 0) { System.Workflow.ComponentModel.Activity activity = compositeActivities.Dequeue() as System.Workflow.ComponentModel.Activity; if (activity.GetValue(WorkflowMarkupSerializer.XCodeProperty) != null) { errors.Add(new ValidationError(SR2.XomlWorkflowHasCode, ErrorNumbers.Error_XomlWorkflowHasCode)); } CompositeActivity compositeActivity = activity as CompositeActivity; if (compositeActivity != null) { foreach (System.Workflow.ComponentModel.Activity childActivity in compositeActivity.EnabledActivities) { compositeActivities.Enqueue(childActivity); } } } }
internal ActivityExecutionStatusChangedEventArgs(ActivityExecutionStatus executionStatus, ActivityExecutionResult executionResult, Activity activity) { this.status = executionStatus; this.activityExecutionResult = executionResult; this.activityQualifiedName = activity.QualifiedName; this.stateId = activity.ContextActivity.ContextId; }
/// <summary> /// Initializes a new instance of the <see cref="WorkflowLoader"/> class. /// </summary> /// <param name="workflowDefinition">The workflow definition.</param> public WorkflowLoader(Activity workflowDefinition) { if (workflowDefinition == null) throw new ArgumentNullException("workflowDefinition"); WorkflowDefinition = workflowDefinition; }
internal WorkflowCompletedEventArgs(WorkflowInstance instance, Activity workflowDefinition) : base(instance) { this._outputParameters = new Dictionary<String, Object>(); this._originalWorkflowDefinition = workflowDefinition; this._workflowDefinition = null; }
public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action) { if (activity == null) { throw new ArgumentNullException("activity"); } if (action == null) { throw new ArgumentNullException("action"); } if (((activity.ExecutionStatus != ActivityExecutionStatus.Initialized) && (activity.ExecutionStatus != ActivityExecutionStatus.Executing)) && (activity.ExecutionStatus != ActivityExecutionStatus.Closed)) { return new ValidationError(SR.GetString("Error_DynamicActivity2", new object[] { activity.QualifiedName, activity.ExecutionStatus, activity.GetType().FullName }), 0x50f); } RemovedActivityAction action2 = action as RemovedActivityAction; if (action2 != null) { StateActivity originalRemovedActivity = action2.OriginalRemovedActivity as StateActivity; if (originalRemovedActivity != null) { return new ValidationError(SR.GetError_CantRemoveState(originalRemovedActivity.QualifiedName), 0x61b); } if (activity.ExecutionStatus == ActivityExecutionStatus.Executing) { EventDrivenActivity activity3 = action2.OriginalRemovedActivity as EventDrivenActivity; if (activity3 != null) { return new ValidationError(SR.GetError_CantRemoveEventDrivenFromExecutingState(activity3.QualifiedName, activity.QualifiedName), 0x620); } } } return null; }
protected internal override bool ApplyTo(Activity rootActivity) { if (rootActivity == null) { throw new ArgumentNullException("rootActivity"); } if (!(rootActivity is CompositeActivity)) { throw new ArgumentException(SR.GetString("Error_RootActivityTypeInvalid"), "rootActivity"); } CompositeActivity activity = rootActivity.TraverseDottedPathFromRoot(base.OwnerActivityDottedPath) as CompositeActivity; if (activity == null) { return false; } if (this.removedActivityIndex >= activity.Activities.Count) { return false; } activity.DynamicUpdateMode = true; try { this.originalRemovedActivity = activity.Activities[this.removedActivityIndex]; activity.Activities.RemoveAt(this.removedActivityIndex); } finally { activity.DynamicUpdateMode = false; } return true; }
public void RegisterContextActivity(System.Workflow.ComponentModel.Activity activity) { int key = ContextId(activity); this.contextActivityMap.Add(key, activity); activity.OnActivityExecutionContextLoad(this); }
// Save the workflow instance state at the point of persistence with option of locking the instance state if it is shared // across multiple runtimes or multiple phase instance updates protected override void SaveWorkflowInstanceState(Activity rootActivity, bool unlock) { // Save the workflow Guid contextGuid = (Guid)rootActivity.GetValue(Activity.ActivityContextGuidProperty); Console.WriteLine("Saving instance: {0}\n", contextGuid); SerializeToFile( WorkflowPersistenceService.GetDefaultSerializedForm(rootActivity), contextGuid); // See when the next timer (Delay activity) for this workflow will expire TimerEventSubscriptionCollection timers = (TimerEventSubscriptionCollection)rootActivity.GetValue(TimerEventSubscriptionCollection.TimerCollectionProperty); TimerEventSubscription subscription = timers.Peek(); if (subscription != null) { // Set a system timer to automatically reload this workflow when its next timer expires TimerCallback callback = new TimerCallback(ReloadWorkflow); TimeSpan timeDifference = subscription.ExpiresAt - DateTime.UtcNow; // check to make sure timeDifference is in legal range if (timeDifference > FilePersistenceService.MaxInterval) { timeDifference = FilePersistenceService.MaxInterval; } else if (timeDifference < TimeSpan.Zero) { timeDifference = TimeSpan.Zero; } this.instanceTimers.Add(contextGuid, new System.Threading.Timer( callback, subscription.WorkflowInstanceId, timeDifference, new TimeSpan(-1))); } }
private void ApplyDynamicUpdateMode(Activity seedActivity) { Queue<Activity> queue = new Queue<Activity>(); queue.Enqueue(seedActivity); while (queue.Count > 0) { Activity activity = queue.Dequeue(); activity.Readonly = true; activity.DynamicUpdateMode = true; foreach (DependencyProperty property in activity.MetaDependencyProperties) { if (activity.IsBindingSet(property)) { ActivityBind binding = activity.GetBinding(property); if (binding != null) { binding.DynamicUpdateMode = true; } } } if (activity is CompositeActivity) { CompositeActivity activity2 = activity as CompositeActivity; activity2.Activities.ListChanged += new EventHandler<ActivityCollectionChangeEventArgs>(this.OnActivityListChanged); foreach (Activity activity3 in ((CompositeActivity) activity).Activities) { queue.Enqueue(activity3); } } } }
public RuleSetDialog(Activity activity, RuleSet ruleSet) { if (activity == null) throw (new ArgumentNullException("activity")); InitializeDialog(ruleSet); ITypeProvider typeProvider; this.serviceProvider = activity.Site; if (this.serviceProvider != null) { typeProvider = (ITypeProvider)this.serviceProvider.GetService(typeof(ITypeProvider)); if (typeProvider == null) { string message = string.Format(CultureInfo.CurrentCulture, Messages.MissingService, typeof(ITypeProvider).FullName); throw new InvalidOperationException(message); } WorkflowDesignerLoader loader = this.serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader; if (loader != null) loader.Flush(); } else { // no service provider, so make a TypeProvider that has all loaded Assemblies TypeProvider newProvider = new TypeProvider(null); foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) newProvider.AddAssembly(a); typeProvider = newProvider; } RuleValidation validation = new RuleValidation(activity, typeProvider, false); this.ruleParser = new Parser(validation); }
protected override bool ApplyTo(Activity rootActivity) { if (rootActivity == null) { return false; } RuleDefinitions definitions = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions; if ((definitions == null) || (definitions.RuleSets == null)) { return false; } if (definitions.RuleSets[this.RuleSetName] == null) { return false; } bool flag = false; if (definitions.Conditions.RuntimeMode) { definitions.Conditions.RuntimeMode = false; flag = true; } try { definitions.RuleSets.Remove(this.RuleSetName); definitions.RuleSets.Add(this.updated); } finally { if (flag) { definitions.RuleSets.RuntimeMode = true; } } return true; }
internal void Track(Activity activity, object arg, IServiceProvider provider, IList<TrackingDataItem> items) { foreach (TrackingExtract extract in this._extracts) { extract.GetData(activity, provider, items); } }
internal WalkerEventArgs(Activity currentActivity) { this.currentActivity = currentActivity; this.currentPropertyOwner = null; this.currentProperty = null; this.currentValue = null; }
internal static Type GetContextType(ITypeProvider typeProvider, Activity currentActivity) { Type contextType = null; string className = String.Empty; Activity rootActivity = null; if (Helpers.IsActivityLocked(currentActivity)) { rootActivity = Helpers.GetDeclaringActivity(currentActivity); } else { rootActivity = Helpers.GetRootActivity(currentActivity); } if (rootActivity != null) { className = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string; if (!String.IsNullOrEmpty(className)) contextType = typeProvider.GetType(className, false); if (contextType == null) contextType = typeProvider.GetType(rootActivity.GetType().FullName); // If all else fails (likely, we don't have a type provider), it's the root activity type. if (contextType == null) contextType = rootActivity.GetType(); } return contextType; }
protected override bool ApplyTo(Activity rootActivity) { bool flag2; if (rootActivity == null) { return false; } RuleDefinitions definitions = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions; if ((definitions == null) || (definitions.RuleSets == null)) { return false; } bool flag = false; if (definitions.RuleSets.RuntimeMode) { definitions.RuleSets.RuntimeMode = false; flag = true; } try { flag2 = definitions.RuleSets.Remove(this.ruleset.Name); } finally { if (flag) { definitions.RuleSets.RuntimeMode = true; } } return flag2; }
internal WalkerEventArgs(Activity currentActivity, object currentValue, PropertyInfo currentProperty, object currentPropertyOwner) : this(currentActivity) { this.currentPropertyOwner = currentPropertyOwner; this.currentProperty = currentProperty; this.currentValue = currentValue; }
public void PersistInstanceState(System.Workflow.ComponentModel.Activity activity) { this.lastExceptionThrown = null; this.abortTransaction = false; this.ScheduleDelayedItems(activity); if (this.currentAtomicActivity == null) { if ((activity == this.rootActivity) && !activity.PersistOnClose) { return; } this.ServiceProvider.Persist(); } else { TransactionalProperties transactionalProperties = null; transactionalProperties = (TransactionalProperties)activity.GetValue(WorkflowExecutor.TransactionalPropertiesProperty); if (this.CheckAndProcessTransactionAborted(transactionalProperties)) { return; } transactionalProperties.TransactionScope.Complete(); transactionalProperties.TransactionScope.Dispose(); transactionalProperties.TransactionScope = null; this.ServiceProvider.CommitTransaction(); transactionalProperties.Transaction = null; this.currentAtomicActivity = null; } this.internalCurrentActivity = activity; this.scheduler.Pause(); }
protected override bool ApplyTo(Activity rootActivity) { if (rootActivity == null) { return false; } RuleDefinitions definitions = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions; if (definitions == null) { definitions = new RuleDefinitions(); rootActivity.SetValue(RuleDefinitions.RuleDefinitionsProperty, definitions); } bool flag = false; if (definitions.Conditions.RuntimeMode) { definitions.Conditions.RuntimeMode = false; flag = true; } try { definitions.Conditions.Add(this.ConditionDefinition); } finally { if (flag) { definitions.Conditions.RuntimeMode = true; } } return true; }
public void UnregisterContextActivity(System.Workflow.ComponentModel.Activity activity) { int key = ContextId(activity); this.contextActivityMap.Remove(key); activity.OnActivityExecutionContextUnload(this); }
public override bool Evaluate(Activity ownerActivity, IServiceProvider provider) { if (provider == null) throw new ArgumentNullException("provider"); ConditionalEventArgs eventArgs = new ConditionalEventArgs(); EventHandler<ConditionalEventArgs>[] eventHandlers = base.GetInvocationList<EventHandler<ConditionalEventArgs>>(CodeCondition.ConditionEvent); IWorkflowDebuggerService workflowDebuggerService = provider.GetService(typeof(IWorkflowDebuggerService)) as IWorkflowDebuggerService; if (eventHandlers != null) { foreach (EventHandler<ConditionalEventArgs> eventHandler in eventHandlers) { if (workflowDebuggerService != null) workflowDebuggerService.NotifyHandlerInvoking(eventHandler); eventHandler(ownerActivity, eventArgs); if (workflowDebuggerService != null) workflowDebuggerService.NotifyHandlerInvoked(); } } return eventArgs.Result; }
internal static void InitializeCorrelationTokenCollection(Activity activity, CorrelationToken correlator) { if ((correlator != null) && !string.IsNullOrEmpty(correlator.OwnerActivityName)) { string ownerActivityName = correlator.OwnerActivityName; Activity activityByName = activity.GetActivityByName(ownerActivityName); if (activityByName == null) { activityByName = Helpers.ParseActivityForBind(activity, ownerActivityName); } if (activityByName == null) { throw new ArgumentException("ownerActivity"); } CorrelationTokenCollection tokens = activityByName.GetValue(CorrelationTokenCollection.CorrelationTokenCollectionProperty) as CorrelationTokenCollection; if (tokens == null) { tokens = new CorrelationTokenCollection(); activityByName.SetValue(CorrelationTokenCollection.CorrelationTokenCollectionProperty, tokens); } if (!tokens.Contains(correlator.Name)) { tokens.Add(correlator); } } }
public void SetWhenCondition(Activity activity, ActivityCondition handler) { if (activity.Parent is ConditionedActivityGroup) { activity.SetValue(ConditionedActivityGroup.WhenConditionProperty, handler); } }
public void RequestRevertToCheckpointState(System.Workflow.ComponentModel.Activity currentActivity, EventHandler <EventArgs> callbackHandler, EventArgs callbackData, bool suspendOnRevert, string suspendReason) { if (this.lastExceptionThrown != null) { this.abortTransaction = true; this.scheduler.Pause(); } }
private static System.Workflow.ComponentModel.Activity ContextActivity(System.Workflow.ComponentModel.Activity activity) { System.Workflow.ComponentModel.Activity parent = activity; while ((parent != null) && (parent.GetValue(System.Workflow.ComponentModel.Activity.ActivityExecutionContextInfoProperty) == null)) { parent = parent.Parent; } return(parent); }
public WorkflowOutlineNode(System.Workflow.ComponentModel.Activity activity) { if (activity == null) { throw new ArgumentNullException("activity"); } this.activity = activity; base.Name = activity.Name; }
public virtual void RefreshNode() { System.Workflow.ComponentModel.Activity activity = this.Activity; if (activity != null) { base.ForeColor = (!activity.Enabled || ActivityDesigner.IsCommentedActivity(activity)) ? WorkflowTheme.CurrentTheme.AmbientTheme.CommentIndicatorColor : SystemColors.WindowText; base.Text = activity.Name; } }
public void RaiseException(Exception e, System.Workflow.ComponentModel.Activity activity, string responsibleActivity) { using (this.SetCurrentActivity(activity)) { using (ActivityExecutionContext context = new ActivityExecutionContext(activity, true)) { context.FaultActivity(e); } } }
private void PrivateInitialize(System.Workflow.ComponentModel.Activity rootActivity, Guid instanceId, IList <PropertyInfo> outputProperties, System.Workflow.ComponentModel.Activity workflowDefinition) { this.instanceId = instanceId; this.rootActivity = rootActivity; this.contextActivityMap = new Dictionary <int, System.Workflow.ComponentModel.Activity>(); this.scheduler = new Scheduler(this); this.workflowQueuingService = new WorkflowQueuingService(this); this.outputProperties = outputProperties; this.resourceManager = new VolatileResourceManager(); this.rootActivity.SetValue(System.Workflow.ComponentModel.Activity.WorkflowDefinitionProperty, workflowDefinition); this.rootActivity.SetValue(WorkflowExecutor.WorkflowExecutorProperty, this); }
public void Execute(System.Workflow.ComponentModel.Activity definition, NativeActivityContext context) { try { this.executor.Initialize(definition, this.Activity.GetInputArgumentValues(context), this.Activity.HasNameCollision); this.ProcessExecutionStatus(this.executor.Execute()); } catch (Exception exception) { this.uncaughtException = exception; throw; } }
public void Run() { this.pause = false; while (!this.pause) { SchedulableItem item; System.Workflow.ComponentModel.Activity activity2; if (this.atomicActivityQueue.Count > 0) { item = this.atomicActivityQueue.Dequeue(); } else { if ((this.owner.CurrentAtomicActivity != null) || (this.schedulerQueue.Count <= 0)) { break; } item = this.schedulerQueue.Dequeue(); } System.Workflow.ComponentModel.Activity activityByName = this.owner.GetContextActivityForId(item.ContextId).GetActivityByName(item.ActivityId); TransactionalProperties transactionalProperties = null; if (this.owner.IsActivityInAtomicContext(activityByName, out activity2)) { transactionalProperties = (TransactionalProperties)activity2.GetValue(WorkflowExecutor.TransactionalPropertiesProperty); if (this.owner.CheckAndProcessTransactionAborted(transactionalProperties)) { return; } } try { item.Run(this.owner); continue; } catch (Exception exception) { if (WorkflowExecutor.IsIrrecoverableException(exception)) { throw; } if (transactionalProperties != null) { transactionalProperties.TransactionState = TransactionProcessState.AbortProcessed; this.owner.lastExceptionThrown = exception; } this.owner.RaiseException(exception, activityByName, null); continue; } } }
public bool IsActivityInAtomicContext(System.Workflow.ComponentModel.Activity activity, out System.Workflow.ComponentModel.Activity atomicActivity) { atomicActivity = null; while (activity != null) { if (activity == this.currentAtomicActivity) { atomicActivity = activity; return(true); } activity = activity.Parent; } return(false); }
public override System.Workflow.ComponentModel.Activity GetWorkflowDefinition() { if (rootActivity == null) { lock (lockObject) { if (rootActivity == null) { rootActivity = DeSerizalizeDefinition(workflowDefinition, ruleDefinition); } } } return(rootActivity); }
public void CheckpointInstanceState(System.Workflow.ComponentModel.Activity atomicActivity) { TransactionOptions transactionOptions = new TransactionOptions(); WorkflowTransactionOptions options2 = TransactedContextFilter.GetTransactionOptions(atomicActivity); transactionOptions.IsolationLevel = options2.IsolationLevel; if (transactionOptions.IsolationLevel == IsolationLevel.Unspecified) { transactionOptions.IsolationLevel = IsolationLevel.Serializable; } transactionOptions.Timeout = options2.TimeoutDuration; TransactionalProperties properties = new TransactionalProperties(); atomicActivity.SetValue(WorkflowExecutor.TransactionalPropertiesProperty, properties); this.ServiceProvider.CreateTransaction(transactionOptions); this.currentAtomicActivity = atomicActivity; this.scheduler.Pause(); }
public void ActivityStatusChanged(System.Workflow.ComponentModel.Activity activity, bool transacted, bool committed) { if (!committed) { if (this.trackingEnabled) { this.ServiceProvider.TrackActivityStatusChange(activity, this.eventCounter++); } if (activity.ExecutionStatus == ActivityExecutionStatus.Closed) { this.ScheduleDelayedItems(activity); } } if ((activity.ExecutionStatus == ActivityExecutionStatus.Closed) && (!(activity is ICompensatableActivity) || ((activity is ICompensatableActivity) && activity.CanUninitializeNow))) { CorrelationTokenCollection.UninitializeCorrelationTokens(activity); } }
public RuleExecution(RuleValidation validation, object thisObject) { if (validation == null) { throw new ArgumentNullException("validation"); } if (thisObject == null) { throw new ArgumentNullException("thisObject"); } if (validation.ThisType != thisObject.GetType()) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ValidationMismatch, new object[] { RuleDecompiler.DecompileType(validation.ThisType), RuleDecompiler.DecompileType(thisObject.GetType()) })); } this.validation = validation; this.activity = thisObject as System.Workflow.ComponentModel.Activity; this.thisObject = thisObject; this.thisLiteralResult = new RuleLiteralResult(thisObject); }
public void Initialize(System.Workflow.ComponentModel.Activity definition, IDictionary <string, object> inputs, bool hasNameCollision) { this.rootActivity.SetValue(System.Workflow.ComponentModel.Activity.ActivityExecutionContextInfoProperty, new ActivityExecutionContextInfo(this.rootActivity.QualifiedName, this.GetNewContextActivityId(), this.instanceId, -1)); this.rootActivity.SetValue(System.Workflow.ComponentModel.Activity.ActivityContextGuidProperty, this.instanceId); SetInputParameters(definition, this.rootActivity, inputs, hasNameCollision); ((IDependencyObjectAccessor)this.rootActivity).InitializeActivatingInstanceForRuntime(null, this); this.rootActivity.FixUpMetaProperties(definition); this.TimerQueue = new TimerEventSubscriptionCollection(this, this.instanceId); using (new ServiceEnvironment(this.rootActivity)) { using (this.SetCurrentActivity(this.rootActivity)) { this.RegisterContextActivity(this.rootActivity); using (ActivityExecutionContext context = new ActivityExecutionContext(this.rootActivity, true)) { context.InitializeActivity(this.rootActivity); } } } }
public object GetService(System.Workflow.ComponentModel.Activity currentActivity, Type serviceType) { if (serviceType == typeof(IWorkflowCoreRuntime)) { return(this); } if (serviceType == typeof(WorkflowQueuingService)) { this.workflowQueuingService.CallingActivity = ContextActivity(currentActivity); return(this.workflowQueuingService); } if (!(serviceType == typeof(ITimerService))) { return(((IServiceProvider)this.ServiceProvider).GetService(serviceType)); } if (this.timerSchedulerSerivce == null) { this.timerSchedulerSerivce = new TimerSchedulerService(this); } return(this.timerSchedulerSerivce); }
private void AddItemToBeScheduledLater(System.Workflow.ComponentModel.Activity atomicActivity, SchedulableItem item) { if ((atomicActivity != null) && atomicActivity.SupportsTransaction) { TransactionalProperties properties = (TransactionalProperties)atomicActivity.GetValue(WorkflowExecutor.TransactionalPropertiesProperty); if (properties != null) { lock (properties) { List <SchedulableItem> itemsToBeScheduledAtCompletion = null; itemsToBeScheduledAtCompletion = properties.ItemsToBeScheduledAtCompletion; if (itemsToBeScheduledAtCompletion == null) { itemsToBeScheduledAtCompletion = new List <SchedulableItem>(); properties.ItemsToBeScheduledAtCompletion = itemsToBeScheduledAtCompletion; } itemsToBeScheduledAtCompletion.Add(item); } } } }
private void ScheduleDelayedItems(System.Workflow.ComponentModel.Activity atomicActivity) { List <SchedulableItem> itemsToBeScheduledAtCompletion = null; TransactionalProperties properties = (TransactionalProperties)atomicActivity.GetValue(WorkflowExecutor.TransactionalPropertiesProperty); if (properties != null) { lock (properties) { itemsToBeScheduledAtCompletion = properties.ItemsToBeScheduledAtCompletion; if (itemsToBeScheduledAtCompletion != null) { foreach (SchedulableItem item in itemsToBeScheduledAtCompletion) { this.scheduler.ScheduleItem(item, false); } itemsToBeScheduledAtCompletion.Clear(); properties.ItemsToBeScheduledAtCompletion = null; } } } }
public void Reload(System.Workflow.ComponentModel.Activity definitionActivity, IList <PropertyInfo> outputProperties) { MemoryStream stream = new MemoryStream(this.persistedActivityData); System.Workflow.ComponentModel.Activity rootActivity = null; stream.Position = 0L; using (new ActivityDefinitionResolution(definitionActivity)) { rootActivity = System.Workflow.ComponentModel.Activity.Load(stream, null); } this.PrivateInitialize(rootActivity, this.instanceId, outputProperties, definitionActivity); Queue <System.Workflow.ComponentModel.Activity> queue = new Queue <System.Workflow.ComponentModel.Activity>(); queue.Enqueue(rootActivity); while (queue.Count > 0) { System.Workflow.ComponentModel.Activity activity = queue.Dequeue(); ((IDependencyObjectAccessor)activity).InitializeInstanceForRuntime(this); this.RegisterContextActivity(activity); IList <System.Workflow.ComponentModel.Activity> list = (IList <System.Workflow.ComponentModel.Activity>)activity.GetValue(System.Workflow.ComponentModel.Activity.ActiveExecutionContextsProperty); if (list != null) { foreach (System.Workflow.ComponentModel.Activity activity3 in list) { queue.Enqueue(activity3); } } } if (!string.IsNullOrEmpty(this.internalCurrentActivityName)) { this.internalCurrentActivity = this.GetContextActivityForId(this.internalCurrentActivityContextId).GetActivityByName(this.internalCurrentActivityName); } if (!string.IsNullOrEmpty(this.atomicActivityName)) { this.currentAtomicActivity = this.GetContextActivityForId(this.atomicActivityContextId).GetActivityByName(this.atomicActivityName); } this.TimerQueue.Executor = this; }
protected BasicBrowserDialog(System.Workflow.ComponentModel.Activity activity, string name) { if (activity == null) { throw new ArgumentNullException("activity"); } this.activity = activity; this.InitializeComponent(); this.descriptionLabel.Text = this.DescriptionText; this.Text = this.TitleText; this.previewLabel.Text = this.PreviewLabelText; this.newRuleToolStripButton.Enabled = true; this.name = name; this.serviceProvider = activity.Site; IUIService service = (IUIService)activity.Site.GetService(typeof(IUIService)); if (service != null) { this.Font = (Font)service.Styles["DialogFont"]; } base.HelpRequested += new HelpEventHandler(this.OnHelpRequested); base.HelpButtonClicked += new CancelEventHandler(this.OnHelpClicked); this.rulesListView.Select(); }
private static void SetInputParameters(System.Workflow.ComponentModel.Activity definition, System.Workflow.ComponentModel.Activity rootActivity, IDictionary <string, object> inputs, bool hasNameCollision) { if (inputs != null) { int length = "In".Length; foreach (KeyValuePair <string, object> pair in inputs) { PropertyInfo property; if (hasNameCollision) { string name = pair.Key.Substring(0, pair.Key.Length - length); property = definition.GetType().GetProperty(name); } else { property = definition.GetType().GetProperty(pair.Key); } if ((property != null) && property.CanWrite) { property.SetValue(rootActivity, pair.Value, null); } } } }
public ActivityDefinitionResolution(System.Workflow.ComponentModel.Activity definitionActivity) { InteropExecutor.ActivityDefinitionResolution.definitionActivity = definitionActivity; }
public IDisposable SetCurrentActivity(System.Workflow.ComponentModel.Activity activity) { System.Workflow.ComponentModel.Activity currentActivity = this.CurrentActivity; this.CurrentActivity = activity; return(new ResetCurrentActivity(this, currentActivity)); }
internal ResetCurrentActivity(InteropExecutor activityExecutor, System.Workflow.ComponentModel.Activity oldCurrentActivity) { this.activityExecutor = activityExecutor; this.oldCurrentActivity = oldCurrentActivity; }
void IDisposable.Dispose() { definitionActivity = null; }
public InteropExecutor(Guid instanceId, System.Workflow.ComponentModel.Activity rootActivity, IList <PropertyInfo> outputProperties, System.Workflow.ComponentModel.Activity activityDefinition) { this.PrivateInitialize(rootActivity, instanceId, outputProperties, activityDefinition); }