0
目前正在使用下面的C#代码启动工作流启动工作流通过使用用户帐户
private static void StartWorkflow(SPListItem listItem)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite elevatedSite = new SPSite(listItem.Web.Site.ID))
{
using (SPWeb elevatedWeb = elevatedSite.OpenWeb(listItem.Web.ID))
{
elevatedWeb.AllowUnsafeUpdates = true;
SPWorkflowManager manager = elevatedSite.WorkflowManager;
SPListItem elevatedListItem = elevatedWeb.Lists.TryGetList(listItem.ParentList.Title).GetItemById(listItem.ID);
foreach (SPWorkflow workflow in manager.GetItemWorkflows(elevatedListItem))
{
SPWorkflowAssociation wfAssoc = elevatedListItem.ParentList.WorkflowAssociations.GetAssociationByName(workflow.ParentAssociation.Name, System.Globalization.CultureInfo.CurrentCulture);
elevatedListItem.Web.Site.WorkflowManager.StartWorkflow(elevatedListItem, wfAssoc, wfAssoc.AssociationData, true);
elevatedListItem.Update();
}
// Get the workflow by name that's associated with the list item
elevatedWeb.AllowUnsafeUpdates = false;
}
}
});
}
这将使用系统帐户启动工作流。有什么办法可以使用列创建的列表项来启动工作流吗?我想使用特定用户帐户启动工作流程。