SPSecurity.RunWithElevatedPrivileges(delegate()
{
web = site.OpenWeb();
SPWorkflowManager manager = site.WorkflowManager;
SPList list = web.Lists["mySPList"];
SPQuery q = new SPQuery();
q.Query = "<Where><Eq><FieldRef Name='EmpId'/><Value Type='Number'>" +Convert.ToInt32(lblEmpId.Text) + "</Value></Eq></Where>";
SPListItemCollection collection = list.GetItems(q);
foreach (SPListItem item in collection)
{
foreach (SPWorkflow workflow in manager.GetItemActiveWorkflows(item))
{
foreach (SPWorkflowTask t in workflow.Tasks)
{
t["Status"] = "Canceled";
t.Update();
}
SPWorkflowManager.CancelWorkflow(workflow);
}
break;
}
});
No comments:
Post a Comment