本文整理汇总了C#中WorkflowServicesManager.GetWorkflowInstanceService方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowServicesManager.GetWorkflowInstanceService方法的具体用法?C# WorkflowServicesManager.GetWorkflowInstanceService怎么用?C# WorkflowServicesManager.GetWorkflowInstanceService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkflowServicesManager
的用法示例。
在下文中一共展示了WorkflowServicesManager.GetWorkflowInstanceService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessOneWayEvent
public void ProcessOneWayEvent(SPRemoteEventProperties properties)
{
if (properties.EventType != SPRemoteEventType.ItemAdded)
return;
// build client context using S2S
using (ClientContext context = TokenHelper.CreateRemoteEventReceiverClientContext(properties)) {
Web web = context.Web;
// create a collection of name/value pairs to pass to the workflow upon starting
var args = new Dictionary<string, object>();
args.Add("RemoteEventReceiverPassedValue", "Hello from the Remote Event Receiver! - " + DateTime.Now.ToString());
// get reference to Workflow Service Manager (WSM) in SP...
WorkflowServicesManager wsm = new WorkflowServicesManager(context, web);
context.Load(wsm);
context.ExecuteQuery();
// get reference to subscription service
WorkflowSubscriptionService subscriptionService = wsm.GetWorkflowSubscriptionService();
context.Load(subscriptionService);
context.ExecuteQuery();
// get the only workflow association on item's list
WorkflowSubscription association = subscriptionService.EnumerateSubscriptionsByList(properties.ItemEventProperties.ListId).FirstOrDefault();
// get reference to instance service (to start a new workflow)
WorkflowInstanceService instanceService = wsm.GetWorkflowInstanceService();
context.Load(instanceService);
context.ExecuteQuery();
// start the workflow
instanceService.StartWorkflowOnListItem(association, properties.ItemEventProperties.ListItemId, args);
// execute the CSOM request
context.ExecuteQuery();
}
}
示例2: GetWorkflowDefinition
protected WorkflowDefinition GetWorkflowDefinition(object host,
SPWeb web,
SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
{
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Resolving workflow definition by DisplayName: [{0}]", workflowSubscriptionModel.WorkflowDisplayName);
var workflowServiceManager = new WorkflowServicesManager(web);
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();
var tgtwis = workflowServiceManager.GetWorkflowInstanceService();
var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(true);
var result = publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowSubscriptionModel.WorkflowDisplayName);
if (result == null)
{
TraceService.ErrorFormat((int)LogEventId.ModelProvisionCoreCall,
"Cannot find workflow definition with DisplayName: [{0}]. Provision might break.",
workflowSubscriptionModel.WorkflowDisplayName);
}
return result;
}
示例3: StartWorkflowInstance
/// <summary>
/// Starts a new instance of a workflow definition against the current web site
/// </summary>
/// <param name="web">The target web site</param>
/// <param name="subscriptionId">The ID of the workflow subscription to start</param>
/// <param name="payload">Any input argument for the workflow instance</param>
public static void StartWorkflowInstance(this Web web, Guid subscriptionId, IDictionary<String, Object> payload)
{
var clientContext = web.Context as ClientContext;
var servicesManager = new WorkflowServicesManager(clientContext, clientContext.Web);
var workflowSubscriptionService = servicesManager.GetWorkflowSubscriptionService();
var subscriptions = workflowSubscriptionService.EnumerateSubscriptions();
clientContext.Load(subscriptions, subs => subs.Where(sub => sub.Id == subscriptionId));
clientContext.ExecuteQueryRetry();
var subscription = subscriptions.FirstOrDefault();
if (subscription != null)
{
var workflowInstanceService = servicesManager.GetWorkflowInstanceService();
workflowInstanceService.StartWorkflow(subscription, payload);
clientContext.ExecuteQueryRetry();
}
}
示例4: DeployWebWorkflowSubscriptionDefinition
private void DeployWebWorkflowSubscriptionDefinition(
object host,
SPWeb web,
SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
{
var workflowServiceManager = new WorkflowServicesManager(web);
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();
var tgtwis = workflowServiceManager.GetWorkflowInstanceService();
var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(true);
var currentWorkflowDefinition = publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowSubscriptionModel.WorkflowDisplayName);
if (currentWorkflowDefinition == null)
throw new Exception(string.Format("Cannot lookup workflow definition with display name: [{0}] on web:[{1}]", workflowSubscriptionModel.WorkflowDisplayName, web.Url));
// EnumerateSubscriptionsByEventSource() somehow throws an exception
//var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByEventSource(web.ID);
var subscriptions = workflowSubscriptionService.EnumerateSubscriptions().Where(s => s.EventSourceId == web.ID);
InvokeOnModelEvent<SP2013WorkflowSubscriptionDefinition, WorkflowSubscription>(null, ModelEventType.OnUpdating);
var currentSubscription = subscriptions.FirstOrDefault(s => s.Name == workflowSubscriptionModel.Name);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = currentSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
if (currentSubscription == null)
{
var taskList = GetTaskList(web, workflowSubscriptionModel);
var historyList = GetHistoryList(web, workflowSubscriptionModel);
TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new SP2013 workflow subscription");
var newSubscription = new WorkflowSubscription();
TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Setting subscription properties");
newSubscription.Name = workflowSubscriptionModel.Name;
newSubscription.DefinitionId = currentWorkflowDefinition.Id;
newSubscription.EventTypes = new List<string>(workflowSubscriptionModel.EventTypes);
newSubscription.EventSourceId = web.ID;
newSubscription.SetProperty("HistoryListId", historyList.ID.ToString());
newSubscription.SetProperty("TaskListId", taskList.ID.ToString());
newSubscription.SetProperty("WebId", web.ID.ToString());
newSubscription.SetProperty("Microsoft.SharePoint.ActivationProperties.WebId", web.ID.ToString());
// to be able to change HistoryListId, TaskListId, ListId
InvokeOnModelEvent<SP2013WorkflowSubscriptionDefinition, WorkflowSubscription>(newSubscription, ModelEventType.OnUpdated);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = newSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Calling PublishSubscription()");
var currentSubscriptionId = workflowSubscriptionService.PublishSubscription(newSubscription);
}
else
{
TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing SP2013 workflow subscription");
currentSubscription.EventTypes = new List<string>(workflowSubscriptionModel.EventTypes);
InvokeOnModelEvent<SP2013WorkflowSubscriptionDefinition, WorkflowSubscription>(currentSubscription, ModelEventType.OnUpdated);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = currentSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Calling PublishSubscription()");
workflowSubscriptionService.PublishSubscription(currentSubscription);
}
}
示例5: GetItemWorkflowInstance
public WorkflowInstance GetItemWorkflowInstance(Guid subscriptionId, int itemId)
{
var workflowServicesManager = new WorkflowServicesManager(clientContext, clientContext.Web);
var instanceService = workflowServicesManager.GetWorkflowInstanceService();
var instances = instanceService.EnumerateInstancesForListItem(list.Id, itemId);
clientContext.Load(instances);
clientContext.ExecuteQuery();
return instances
.Where(i => i.WorkflowSubscriptionId == subscriptionId)
.FirstOrDefault();
}
示例6: DeployWorkflowSubscriptionDefinition
private void DeployWorkflowSubscriptionDefinition(
SP2013WorkflowSubscriptionModelHost host,
ClientContext hostClientContext, List list, SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
{
// hostClientContext - it must be ClientContext, not ClientRuntimeContext - won't work and would give some weirs error with wg publishing
// use only ClientContext instance for the workflow pubnlishing, not ClientRuntimeContext
var context = list.Context;
var web = list.ParentWeb;
var workflowServiceManager = new WorkflowServicesManager(hostClientContext, hostClientContext.Web);
context.Load(web);
context.Load(list);
context.ExecuteQuery();
hostClientContext.Load(workflowServiceManager);
hostClientContext.ExecuteQuery();
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();
var tgtwis = workflowServiceManager.GetWorkflowInstanceService();
hostClientContext.Load(workflowSubscriptionService);
hostClientContext.Load(workflowDeploymentService);
hostClientContext.Load(tgtwis);
hostClientContext.ExecuteQuery();
var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(true);
hostClientContext.Load(publishedWorkflows);
hostClientContext.ExecuteQuery();
var currentWorkflowDefinition = publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowSubscriptionModel.WorkflowDisplayName);
if (currentWorkflowDefinition == null)
throw new Exception(string.Format("Cannot lookup workflow definition with display name: [{0}] on web:[{1}]", workflowSubscriptionModel.WorkflowDisplayName, web.Url));
var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByList(list.Id);
hostClientContext.Load(subscriptions);
hostClientContext.ExecuteQuery();
InvokeOnModelEvent<SP2013WorkflowSubscriptionDefinition, WorkflowSubscription>(null, ModelEventType.OnUpdating);
var currentSubscription = subscriptions.FirstOrDefault(s => s.Name == workflowSubscriptionModel.Name);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = currentSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
if (currentSubscription == null)
{
var newSubscription = new WorkflowSubscription(hostClientContext);
newSubscription.Name = workflowSubscriptionModel.Name;
newSubscription.DefinitionId = currentWorkflowDefinition.Id;
newSubscription.EventTypes = workflowSubscriptionModel.EventTypes;
newSubscription.EventSourceId = list.Id;
// lookup task and history lists, probaly need to think ab otehr strategy
var taskList = WebExtensions.QueryAndGetListByUrl(web, workflowSubscriptionModel.TaskListUrl);
var historyList = WebExtensions.QueryAndGetListByUrl(web, workflowSubscriptionModel.HistoryListUrl);
newSubscription.SetProperty("HistoryListId", historyList.Id.ToString());
newSubscription.SetProperty("TaskListId", taskList.Id.ToString());
newSubscription.SetProperty("ListId", list.Id.ToString());
newSubscription.SetProperty("Microsoft.SharePoint.ActivationProperties.ListId", list.Id.ToString());
// to be able to change HistoryListId, TaskListId, ListId
InvokeOnModelEvent<SP2013WorkflowSubscriptionDefinition, WorkflowSubscription>(newSubscription, ModelEventType.OnUpdated);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = newSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
var currentSubscriptionId = workflowSubscriptionService.PublishSubscription(newSubscription);
hostClientContext.ExecuteQuery();
}
else
{
currentSubscription.EventTypes = workflowSubscriptionModel.EventTypes;
//.........这里部分代码省略.........
示例7: GetWorkflowInstances
/// <summary>
/// Returns alls workflow instances for a site
/// </summary>
/// <param name="web"></param>
/// <returns></returns>
public static WorkflowInstanceCollection GetWorkflowInstances(this Web web)
{
var servicesManager = new WorkflowServicesManager(web.Context, web);
var workflowInstanceService = servicesManager.GetWorkflowInstanceService();
var instances = workflowInstanceService.EnumerateInstancesForSite();
web.Context.Load(instances);
web.Context.ExecuteQuery();
return instances;
}
示例8: GetWorkflowDefinition
protected WorkflowDefinition GetWorkflowDefinition(object host,
ClientContext hostclientContext,
Web web,
SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
{
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Resolving workflow definition by DisplayName: [{0}]", workflowSubscriptionModel.WorkflowDisplayName);
var context = hostclientContext;
//var web = list.ParentWeb;
var workflowServiceManager = new WorkflowServicesManager(hostclientContext, web);
//context.Load(web);
//context.Load(list);
context.ExecuteQueryWithTrace();
hostclientContext.Load(workflowServiceManager);
hostclientContext.ExecuteQueryWithTrace();
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();
var tgtwis = workflowServiceManager.GetWorkflowInstanceService();
hostclientContext.Load(workflowSubscriptionService);
hostclientContext.Load(workflowDeploymentService);
hostclientContext.Load(tgtwis);
hostclientContext.ExecuteQueryWithTrace();
var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(true);
hostclientContext.Load(publishedWorkflows);
hostclientContext.ExecuteQueryWithTrace();
var result = publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowSubscriptionModel.WorkflowDisplayName);
if (result == null)
{
TraceService.ErrorFormat((int)LogEventId.ModelProvisionCoreCall,
"Cannot find workflow definition with DisplayName: [{0}]. Provision might break.",
workflowSubscriptionModel.WorkflowDisplayName);
}
return result;
}
示例9: DeployListWorkflowSubscriptionDefinition
private void DeployListWorkflowSubscriptionDefinition(
object host,
ClientContext hostclientContext, List list, SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
{
// hostclientContext - it must be clientContext, not ClientRuntimeContext - won't work and would give some weirs error with wg publishing
// use only clientContext instance for the workflow publishing, not ClientRuntimeContext
var context = list.Context;
var web = list.ParentWeb;
//This WorkflowServiceManager object is created for current web from client context,
//but actually it has to be created for parent web of current web.
//Otherwise it uses wrong web for provisions with multiple webs
//var workflowServiceManager = new WorkflowServicesManager(hostclientContext, hostclientContext.Web);
context.Load(web);
context.Load(list);
context.ExecuteQueryWithTrace();
//This is creation of WorkflowServiceManager with right web
var workflowServiceManager = new WorkflowServicesManager(hostclientContext, web);
hostclientContext.Load(workflowServiceManager);
hostclientContext.ExecuteQueryWithTrace();
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();
var tgtwis = workflowServiceManager.GetWorkflowInstanceService();
hostclientContext.Load(workflowSubscriptionService);
hostclientContext.Load(workflowDeploymentService);
hostclientContext.Load(tgtwis);
hostclientContext.ExecuteQueryWithTrace();
var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(true);
hostclientContext.Load(publishedWorkflows);
hostclientContext.ExecuteQueryWithTrace();
var currentWorkflowDefinition = publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowSubscriptionModel.WorkflowDisplayName);
if (currentWorkflowDefinition == null)
throw new Exception(string.Format("Cannot lookup workflow definition with display name: [{0}] on web:[{1}]", workflowSubscriptionModel.WorkflowDisplayName, web.Url));
var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByEventSource(list.Id);
hostclientContext.Load(subscriptions);
hostclientContext.ExecuteQueryWithTrace();
var currentSubscription = subscriptions.FirstOrDefault(s => s.Name == workflowSubscriptionModel.Name);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = currentSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
if (currentSubscription == null)
{
var taskList = GetTaskList(web, workflowSubscriptionModel);
var historyList = GetHistoryList(web, workflowSubscriptionModel);
TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new SP2013 workflow subscription");
var newSubscription = new WorkflowSubscription(hostclientContext);
TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Setting subscription properties");
newSubscription.Name = workflowSubscriptionModel.Name;
newSubscription.DefinitionId = currentWorkflowDefinition.Id;
newSubscription.EventTypes = workflowSubscriptionModel.EventTypes;
newSubscription.EventSourceId = list.Id;
newSubscription.SetProperty("HistoryListId", historyList.Id.ToString());
newSubscription.SetProperty("TaskListId", taskList.Id.ToString());
newSubscription.SetProperty("ListId", list.Id.ToString());
newSubscription.SetProperty("Microsoft.SharePoint.ActivationProperties.ListId", list.Id.ToString());
MapProperties(currentSubscription, workflowSubscriptionModel);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = newSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Calling PublishSubscription()");
//.........这里部分代码省略.........
示例10: PublishCustomEvent
public void PublishCustomEvent(Guid instanceId, string eventName, string payload)
{
var workflowServicesManager = new WorkflowServicesManager(clientContext, clientContext.Web);
var instanceService = workflowServicesManager.GetWorkflowInstanceService();
var instance = instanceService.GetInstance(instanceId);
instanceService.PublishCustomEvent(instance, eventName, payload);
clientContext.ExecuteQuery();
}
示例11: StartWorkflow
public void StartWorkflow(Guid subscriptionId, int itemId, Dictionary<string, object> payload)
{
var workflowServicesManager = new WorkflowServicesManager(clientContext, clientContext.Web);
var subscriptionService = workflowServicesManager.GetWorkflowSubscriptionService();
var subscription = subscriptionService.GetSubscription(subscriptionId);
var instanceService = workflowServicesManager.GetWorkflowInstanceService();
instanceService.StartWorkflowOnListItem(subscription, itemId, payload);
clientContext.ExecuteQuery();
}
示例12: GetWorkflowInstance
public WorkflowInstance GetWorkflowInstance(Guid instanceId)
{
var workflowServicesManager = new WorkflowServicesManager(clientContext, clientContext.Web);
var instanceService = workflowServicesManager.GetWorkflowInstanceService();
var instance = instanceService.GetInstance(instanceId);
clientContext.Load(instance);
clientContext.ExecuteQuery();
return instance;
}
示例13: ResumeWorkflow
/// <summary>
/// Resumes a workflow
/// </summary>
/// <param name="instance"></param>
public static void ResumeWorkflow(this WorkflowInstance instance)
{
var clientContext = instance.Context as ClientContext;
var servicesManager = new WorkflowServicesManager(clientContext, clientContext.Web);
var workflowInstanceService = servicesManager.GetWorkflowInstanceService();
workflowInstanceService.ResumeWorkflow(instance);
clientContext.ExecuteQueryRetry();
}
示例14: DeployWorkflowSubscriptionDefinition
private void DeployWorkflowSubscriptionDefinition(
object host,
SPList list,
SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
{
var web = list.ParentWeb;
var workflowServiceManager = new WorkflowServicesManager(list.ParentWeb);
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();
var tgtwis = workflowServiceManager.GetWorkflowInstanceService();
var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(true);
var currentWorkflowDefinition = publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowSubscriptionModel.WorkflowDisplayName);
if (currentWorkflowDefinition == null)
throw new Exception(string.Format("Cannot lookup workflow definition with display name: [{0}] on web:[{1}]", workflowSubscriptionModel.WorkflowDisplayName, web.Url));
var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByList(list.ID);
InvokeOnModelEvent<SP2013WorkflowSubscriptionDefinition, WorkflowSubscription>(null, ModelEventType.OnUpdating);
var currentSubscription = subscriptions.FirstOrDefault(s => s.Name == workflowSubscriptionModel.Name);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = currentSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
if (currentSubscription == null)
{
var newSubscription = new WorkflowSubscription();
newSubscription.Name = workflowSubscriptionModel.Name;
newSubscription.DefinitionId = currentWorkflowDefinition.Id;
newSubscription.EventTypes = workflowSubscriptionModel.EventTypes.ToList();
newSubscription.EventSourceId = list.ID;
// lookup task and history lists, probaly need to think ab otehr strategy
var taskList = web.GetList(SPUrlUtility.CombineUrl(web.Url, workflowSubscriptionModel.TaskListUrl));
var historyList = web.GetList(SPUrlUtility.CombineUrl(web.Url, workflowSubscriptionModel.HistoryListUrl));
newSubscription.SetProperty("HistoryListId", historyList.ID.ToString());
newSubscription.SetProperty("TaskListId", taskList.ID.ToString());
newSubscription.SetProperty("ListId", list.ID.ToString());
newSubscription.SetProperty("Microsoft.SharePoint.ActivationProperties.ListId", list.ID.ToString());
// to be able to change HistoryListId, TaskListId, ListId
InvokeOnModelEvent<SP2013WorkflowSubscriptionDefinition, WorkflowSubscription>(newSubscription, ModelEventType.OnUpdated);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = newSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
var currentSubscriptionId = workflowSubscriptionService.PublishSubscription(newSubscription);
}
else
{
currentSubscription.EventTypes = workflowSubscriptionModel.EventTypes.ToList();
InvokeOnModelEvent<SP2013WorkflowSubscriptionDefinition, WorkflowSubscription>(currentSubscription, ModelEventType.OnUpdated);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = currentSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
workflowSubscriptionService.PublishSubscription(currentSubscription);
}
}
示例15: GetWorkflowInstances
/// <summary>
/// Returns alls workflow instances for a list item
/// </summary>
/// <param name="web"></param>
/// <param name="item"></param>
/// <returns></returns>
public static WorkflowInstanceCollection GetWorkflowInstances(this Web web, ListItem item)
{
var servicesManager = new WorkflowServicesManager(web.Context, web);
var workflowInstanceService = servicesManager.GetWorkflowInstanceService();
var instances = workflowInstanceService.EnumerateInstancesForListItem(item.ParentList.Id, item.Id);
web.Context.Load(instances);
web.Context.ExecuteQueryRetry();
return instances;
}