Orchard 获取默认租户独家新闻
Orchard Get Default Tenant scoop
我正在尝试访问属于新租户设置中的默认租户的事件工作流。
所以在 SetupService (Orchard.Setup) 中我调用 shell :
var shellContext = _orchardHost.GetShellContext(_shellSettingsManager.LoadSettings().Where(x => x.Name == "Default").FirstOrDefault());
using (var _environment = shellContext.LifetimeScope.Resolve<IWorkContextAccessor>().CreateWorkContextScope())
{
var Subscriber = environment.Resolve<ISetupCompletEventHandler>();
Subscriber.SetupCompleted(new TenantContext
{
Name = context.SiteName,
Email = context.SiteEmail,
user = user
});
}
我的活动:
public class WorkflowSetupEventHandler : ISetupCompletEventHandler
{
private readonly IWorkflowManager _workflowManager;
public WorkflowSetupEventHandler(IWorkflowManager workflowManager)
{
_workflowManager = workflowManager;
}
public void SetupCompleted(TenantContext context)
{
_workflowManager.TriggerEvent("SetupCompleted",
context.user,
() => new Dictionary<string, object> {
{"Email", context.Email},
{"Name", context.Name}
});
}
}
出于某种原因,从未触发 SetupCompleted。
我错过了什么吗?
感谢
问题是我正在尝试获取默认租户,而 "Default" 租户不存在但他的状态在 shellsettings
上不是 running
我正在尝试访问属于新租户设置中的默认租户的事件工作流。
所以在 SetupService (Orchard.Setup) 中我调用 shell :
var shellContext = _orchardHost.GetShellContext(_shellSettingsManager.LoadSettings().Where(x => x.Name == "Default").FirstOrDefault());
using (var _environment = shellContext.LifetimeScope.Resolve<IWorkContextAccessor>().CreateWorkContextScope())
{
var Subscriber = environment.Resolve<ISetupCompletEventHandler>();
Subscriber.SetupCompleted(new TenantContext
{
Name = context.SiteName,
Email = context.SiteEmail,
user = user
});
}
我的活动:
public class WorkflowSetupEventHandler : ISetupCompletEventHandler
{
private readonly IWorkflowManager _workflowManager;
public WorkflowSetupEventHandler(IWorkflowManager workflowManager)
{
_workflowManager = workflowManager;
}
public void SetupCompleted(TenantContext context)
{
_workflowManager.TriggerEvent("SetupCompleted",
context.user,
() => new Dictionary<string, object> {
{"Email", context.Email},
{"Name", context.Name}
});
}
}
出于某种原因,从未触发 SetupCompleted。
我错过了什么吗?
感谢
问题是我正在尝试获取默认租户,而 "Default" 租户不存在但他的状态在 shellsettings
running