internal override void Evaluate(T instance) { if (_activity != null) { _activity.Execute(instance); } base.Evaluate(instance); }
public ActivityResult Execute( Guid activityExecutionId, IActivityFactory factory, TContext context, IActivityInputProvider inputProvider, out object activityOutput, Action <object> beforeExecute) { IActivity <TInput, TOutput, TFailOutput> activity = null; try { activity = m_ActivityCreation(factory); object actout = null; TInput activityInput = null; try { if (inputProvider != null) { activityInput = inputProvider.GetInput <TInput>(); } if (activityInput == null) { activityInput = m_GetActivityInput(context); } beforeExecute(activity.IsInputSerializable ? activityInput : null); } catch (Exception e) { beforeExecute("Failed to get activity input: " + e); throw; } var result = activity.Execute( activityExecutionId, activityInput, output => { actout = output; m_ProcessOutput(context, output); }, output => { actout = output; m_ProcessFailOutput(context, output); }); activityOutput = actout; return(result); } finally { if (activity != null) { factory.Release(activity); } } }
public override bool Evaluate <T>(T context) { if (base.Evaluate(context)) { _activity.Execute(context); return(true); } return(false); }
public static IActivity <TOtherResult, TData> Then <TResult, TData, TOtherResult>(this IActivity <TResult, TData> activity, IActivity <TOtherResult, TResult> otherActivity) { if (activity == null) { throw new ArgumentNullException(nameof(activity)); } if (otherActivity == null) { throw new ArgumentNullException(nameof(otherActivity)); } return(new Activity <TOtherResult, TData>(async(data, cancellationToken) => { TResult result = await activity.Execute(data, cancellationToken).ConfigureAwait(false); return await otherActivity.Execute(result, cancellationToken).ConfigureAwait(false); })); }
private void RunActivity(IActivity activity) { try { if (activity.Status != ActivityStatus.Initialized) { activity.Initialize(); } if (activity.Status != ActivityStatus.Initialized) { throw new InvalidOperationException("Can't initialize activity: " + activity); } while (activity.Status != ActivityStatus.Finished) { activity.Execute(); if (activity.Status != ActivityStatus.Executed) { return; // finished } } } catch (Exception e) { var message = e.Message; if (e is SEHException) { message = String.Format("Exception during call '{0}' in external component. Activity failed.", e.TargetSite != null ? e.TargetSite.Name : "<unknown>"); } log.Error(message, e); throw; } }
object Execute(IActivity activity, object inputs, IUser dealer, Context context) { //正在处理/已处理还未完成的活动可以被执行 if (this.Status != ActivityStates.Dealing && this.Status != ActivityStates.Dealed) { return(null); } var executeResults = activity.Execute(inputs, dealer, this, context); if (executeResults == null) { return(null); } var jobj = JObject.FromObject(executeResults); foreach (var pair in jobj) { this.State(pair.Key, pair.Value); } this.Status = ActivityStates.Dealed; this.SaveChanges(); return(executeResults); }
public void Execute(IActivityRunContext context) { _baseActivity.Execute(context); }
public void Run() { _activity.Execute(); }