Exemple #1
0
        // This could be invoked by external applications and services to trigger an event within the workflows.
        public ActionResult Trigger(string nonce)
        {
            int    contentItemId;
            string signal;

            if (!_genericEventService.DecryptNonce(nonce, out contentItemId, out signal))
            {
                Logger.Debug("Invalid nonce provided: " + nonce);
                return(HttpNotFound());
            }

            var contentItem = _contentManager.Get(contentItemId, VersionOptions.Latest);

            if (contentItem == null)
            {
                Logger.Debug("Could not find specified content item in none: " + contentItemId);
                return(HttpNotFound());
            }

            // Right now, all workflow instances that are at the WebRequest activity node would continue as soon as a request
            // to this action comes in, but that should not happen; it should be controlled by activity configuration and evaluations.
            _workflowManager.TriggerEvent(SignalActivity.SignalEventName, contentItem, () => {
                var dictionary = new Dictionary <string, object> {
                    { "Content", contentItem }, { SignalActivity.SignalEventName, signal }
                };

                // Let's include query string stuff, so that the WebRequest activity can
                // potentially match against certain parameters to decide whether or not it should execute,
                // based on its configuration (yet to be defined).
                Request.QueryString.CopyTo(dictionary);
                Request.Form.CopyTo(dictionary);

                return(dictionary);
            });

            // 200
            return(new EmptyResult());
        }