本文整理汇总了C#中NativeActivityContext.GetExtension方法的典型用法代码示例。如果您正苦于以下问题:C# NativeActivityContext.GetExtension方法的具体用法?C# NativeActivityContext.GetExtension怎么用?C# NativeActivityContext.GetExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeActivityContext
的用法示例。
在下文中一共展示了NativeActivityContext.GetExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
sealed protected override void Execute(NativeActivityContext context)
{
//HACK:节点执行时总是首先设置当前节点索引
context.GetExtension<DataFieldExtension>().SetCurrentNode(this.FlowNodeIndex);
var e = context.GetExtension<CustomExtension>();
var setting = e.GetActivitySetting(this.DisplayName);
if (setting == null)
{
this.InternalExecuteBody(context);
return;
}
var at = setting.StartRule != null && setting.StartRule.IsValid
? setting.StartRule.GetStartTime()
: _emptyTime;
//触发节点开始规则,创建延迟书签
if (at.HasValue)
e.AddDelay(this.DisplayName
, context.CreateBookmark(this.GenerateBookmarkName(context)
, this.OnDelayBookmarkCallback).Name
, at.Value);
else
this.InternalExecuteBody(context);
}
示例2: ExecuteBody
protected override void ExecuteBody(NativeActivityContext context)
{
var log = context.Resolve<ILoggerFactory>() == null
? null
: context.Resolve<ILoggerFactory>().Create(typeof(Server));
//创建server节点实例
var server = context.GetExtension<ServerExtension>().AddServer(context, this.DisplayName, this.FlowNodeIndex);
var data = context.GetExtension<DataFieldExtension>();
//设置当前节点索引
data.SetCurrentNode(this.FlowNodeIndex);
var serverScript = this.Script == null ? null : this.Script.Get(context);
var parser = context.Resolve<IScriptParser>();
#region 执行内容解析
if (!string.IsNullOrEmpty(serverScript))
{
var result = parser == null
? serverScript
: parser.Evaluate(serverScript, context.GetExtension<DataFieldExtension>());
if (this.To != null)
{
this.To.Set(context, result);
//更新到流程变量中
data.Set(this._to, result);
}
log.InfoFormat("Server节点执行内容:{0},返回:{1} {2}"
, serverScript
, result
, this.To == null ? "" : "将返回值写入流程变量" + this._to);
}
#endregion
#region 完成规则解析
if (this.Result != null
&& parser != null
&& this.FinishRule != null
&& this.FinishRule.Count > 0)
{
foreach (var i in this.FinishRule)
if (parser.EvaluateRule(i.Value, data))
{
this.Result.Set(context, i.Key);
log.InfoFormat("Server节点完成规则“{0}”测试通过,将进入节点“{1}”", i.Value, i.Key);
break;
}
}
#endregion
//置为完成
server.SetAsComplete();
}
示例3: InternalExecute
void InternalExecute(NativeActivityContext context, ActivityInstance completedInstance)
{
CompensationExtension compensationExtension = context.GetExtension<CompensationExtension>();
if (compensationExtension == null)
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.ConfirmWithoutCompensableActivity(this.DisplayName)));
}
CompensationToken token = Target.Get(context);
CompensationTokenData tokenData = token == null ? null : compensationExtension.Get(token.CompensationId);
Fx.Assert(tokenData != null, "CompensationTokenData must be valid");
if (tokenData.ExecutionTracker.Count > 0)
{
if (this.onChildConfirmed == null)
{
this.onChildConfirmed = new CompletionCallback(InternalExecute);
}
this.toConfirmToken.Set(context, new CompensationToken(tokenData.ExecutionTracker.Get()));
Fx.Assert(Body != null, "Body must be valid");
context.ScheduleActivity(Body, this.onChildConfirmed);
}
}
示例4: Execute
protected override void Execute(NativeActivityContext context)
{
CorrelationHandle correlationHandle = (this.Correlation == null) ? null : this.Correlation.Get(context);
if (correlationHandle == null)
{
//throw only if ambient correlation handle is also null
correlationHandle = context.Properties.Find(CorrelationHandle.StaticExecutionPropertyName) as CorrelationHandle;
if (correlationHandle == null)
{
throw FxTrace.Exception.AsError(
new InvalidOperationException(SR2.NullCorrelationHandleInInitializeCorrelation(this.DisplayName)));
}
}
CorrelationExtension extension = context.GetExtension<CorrelationExtension>();
if (extension != null)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach ( KeyValuePair<string, InArgument<string>> pair in this.CorrelationData )
{
Fx.Assert(pair.Value != null, "pair.Value should be validated during cache metadata");
dictionary.Add(pair.Key, pair.Value.Get(context));
}
correlationHandle.InitializeBookmarkScope(context, extension.GenerateKey(dictionary));
}
else
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.InitializeCorrelationRequiresWorkflowServiceHost(this.DisplayName)));
}
}
示例5: OnBookmarkCallback
private void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark)
{
var log = context.Resolve<ILoggerFactory>() != null
? context.Resolve<ILoggerFactory>().Create(typeof(SubProcess))
: null;
var parser = context.Resolve<IScriptParser>();
var extension = context.GetExtension<DataFieldExtension>();
//完成规则解析
if (this.Result != null
&& parser != null
&& this.FinishRule != null
&& this.FinishRule.Count > 0)
{
foreach (var i in this.FinishRule)
if (parser.EvaluateRule(i.Value, extension))
{
this.Result.Set(context, i.Key);
if (log != null)
log.InfoFormat("SubProcess节点完成规则“{0}”测试通过,将进入节点“{1}”", i.Value, i.Key);
break;
}
}
//所有逻辑完成才可删除,若上述逻辑失败则将此书签用于错误恢复
context.RemoveBookmark(bookmark);
}
示例6: Execute
protected override void Execute(NativeActivityContext context)
{
var countModel = context.GetExtension<CountModel>();
if (countModel.CountCompleted != null)
{
countModel.CountCompleted();
}
}
示例7: Execute
protected override void Execute(NativeActivityContext context)
{
Bookmark bookmark = context.CreateBookmark(new BookmarkCallback(this.OnMainRootComplete), BookmarkOptions.NonBlocking);
context.RegisterMainRootCompleteCallback(bookmark);
CompensationExtension extension = context.GetExtension<CompensationExtension>();
extension.WorkflowCompensation = context.CreateBookmark(new BookmarkCallback(this.OnCompensate));
extension.WorkflowConfirmation = context.CreateBookmark(new BookmarkCallback(this.OnConfirm));
context.ResumeBookmark(extension.WorkflowCompensationScheduled, null);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:WorkflowCompensationBehavior.cs
示例8: Execute
protected override void Execute(NativeActivityContext context)
{
var bookMarkName = Guid.NewGuid().ToString();
var content = new WfContent() { Path = ContentPath.Get(context) };
notificationId.Set(context, context.GetExtension<ContentWorkflowExtension>().RegisterWait(content, bookMarkName));
context.CreateBookmark(bookMarkName, new BookmarkCallback(Continue));
}
示例9: ExecuteBody
protected override void ExecuteBody(NativeActivityContext context)
{
//创建子流程节点实例信息
context.GetExtension<SubProcessExtension>().AddSubProcess(context
, context.CreateBookmark(this.GenerateBookmarkName(context)
, this.OnBookmarkCallback)
, this.DisplayName
, this.FlowNodeIndex);
}
示例10: Execute
protected override void Execute(NativeActivityContext context)
{
CompensationExtension extension = context.GetExtension<CompensationExtension>();
CompensationToken token = this.Target.Get(context);
CompensationTokenData data = extension.Get(token.CompensationId);
data.BookmarkTable[CompensationBookmarkName.Compensated] = context.CreateBookmark(new BookmarkCallback(this.OnCompensated));
data.CompensationState = CompensationState.Compensating;
extension.NotifyMessage(context, data.CompensationId, CompensationBookmarkName.OnCompensation);
}
示例11: Execute
protected override void Execute(NativeActivityContext context)
{
var twilio = context.GetExtension<ITwilioContext>();
var url = Url.Get(context);
var loop = Loop.Get(context);
GetElement(context).Add(new XElement("Play",
loop != null ? new XAttribute("loop", loop) : null,
url));
}
示例12: Execute
protected override void Execute(NativeActivityContext context)
{
var countModel = context.GetExtension<ICountModel>();
if (countModel.CountUpdated != null)
{
countModel.CountUpdated(
this.CurrentCount.Get(context));
}
}
示例13: Execute
protected override void Execute(NativeActivityContext context)
{
var twilio = context.GetExtension<ITwilioContext>();
var duration = Duration.Get(context);
GetElement(context).Add(
new XElement("Pause",
new XAttribute("length", (int)duration.TotalSeconds)),
new XElement("Redirect",
twilio.ResolveBookmarkUrl(context.CreateTwilioBookmark(this))));
}
示例14: OnHasCompleted
protected override void OnHasCompleted(NativeActivityContext context, ActivityInstance completedInstance)
{
base.OnHasCompleted(context, completedInstance);
//HACK:重写并行节点满足条件退出逻辑
var e = context.GetExtension<ParallelExtension>();
e.Cancelled(context.GetChildren()
.Where(o => o.ID != completedInstance.ID)
.Select(o => o.ID)
.ToArray());
}
示例15: OnConfirm
private void OnConfirm(NativeActivityContext context, Bookmark bookmark, object value)
{
CompensationExtension extension = context.GetExtension<CompensationExtension>();
CompensationToken token = (CompensationToken) value;
this.currentCompensationToken.Set(context, token);
if (extension.Get(token.CompensationId).ExecutionTracker.Count > 0)
{
context.ScheduleActivity(this.DefaultConfirmation, new CompletionCallback(this.OnConfirmationComplete));
}
else
{
this.OnConfirmationComplete(context, null);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:WorkflowCompensationBehavior.cs