コード例 #1
0
        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 }
                                                             );
        }
コード例 #2
0
        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 }
                                                                     );
                }
            }
        }