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;
}
}
});
}
這將使用系統帳戶啓動工作流。有什麼辦法可以使用列創建的列表項來啓動工作流嗎?我想使用特定用戶帳戶啓動工作流程。