public static void RaiseWorkflowEvent(SPWeb web, Guid workflowInstanceId, string data, string correlationToken) { //var workflow = web.Workflows[workflowInstanceId]; //if (workflow == null) //{ // throw new System.IO.FileNotFoundException(String.Format("Workflow Instance with ID {0} could not be found!", workflowInstanceId.ToString())); //} //if(workflow.InternalState!=SPWorkflowState.Running) //{ // throw new InvalidOperationException(String.Format("Workflow Instance with ID {0} is not in running state!", workflowInstanceId.ToString())); //} SPWorkflowExternalDataExchangeService.RaiseEvent(web, workflowInstanceId, typeof(IWaitForExternalEventService), "OnExternalEvent", new object[] { correlationToken, data } ); }
public void SendDataToWorkflow(string workflowId, string correlationToken, string data, string siteId, string webId) { if (String.IsNullOrEmpty(siteId) || String.IsNullOrEmpty(webId)) { SPWorkflowExternalDataExchangeService.RaiseEvent(SPContext.Current.Web, new Guid(workflowId), typeof(IWaitForExternalEventService), "OnExternalEvent", new object[] { correlationToken, data } ); } else { using (SPSite site = new SPSite(new Guid(siteId))) { SPWeb web = site.OpenWeb(new Guid(webId)); SPWorkflowExternalDataExchangeService.RaiseEvent(web, new Guid(workflowId), typeof(IWaitForExternalEventService), "OnExternalEvent", new object[] { correlationToken, data } ); } } }