利用 EventHandler 觸發 MOSS 2007 流程
SPUser person = ...; // TODO: get your user // TODO: get correct list item (or use properties.ListItem inside your event handler) SPWorkflowManager manager = listItem.Web.Site.WorkflowManager; SPWorkflowAssociationCollection associationCollection = listItem.ParentList.WorkflowAssociations; foreach (SPWorkflowAssociation association in associationCollection) { // TODO: find the correct workflow association in the list: if (association.Name.ToLower().Equals("myworkflow") == true) { String data = association.AssociationData; if (person != null) { data = association.AssociationData.Replace( "<my:CC></my:CC>", "<my:CC><my:Person><my:DisplayName>" + person.Name + "</my:DisplayName><my:AccountId>" + person.LoginName + "</my:AccountId><my:AccountType>User</my:AccountType></my:Person></my:CC>"); } // Hit the go! SPWorkflow wf = manager.StartWorkflow(listItem, association, data, true); } } |