// Implement the Run method of IRunnableWorkflowTask
        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // In Umbraco the workflowInstance should always be castable to an UmbracoWorkflowInstance
            var wf = (UmbracoWorkflowInstance) workflowInstance;

            // UmbracoWorkflowInstance has a list of node Ids that are associated with the workflow in the CmsNodes property
            foreach(var nodeId in wf.CmsNodes)
            {
                // We'll assume that only documents are attached to this workflow
                var doc = new Document(nodeId);

                var property = doc.getProperty(DocumentTypeProperty);
                
                if (!String.IsNullOrEmpty((string) property.Value)) continue;

                var host = HttpContext.Current.Request.Url.Host;
                var pageUrl = "http://" + host + umbraco.library.NiceUrl(nodeId);

                var shortUrl = API.Bit(BitLyLogin, BitLyApiKey, pageUrl, "Shorten");

                property.Value = shortUrl;
            }
            
            // The run method of a workflow task is responsible for informing the runtime of the outcome.
            // The outcome should be one of the items in the AvailableTransitions list.
            runtime.Transition(workflowInstance, this, "done");
        }
        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // Cast to Umbraco worklow instance.
            var umbracoWorkflowInstance = (UmbracoWorkflowInstance)workflowInstance;

            var count       = 0;
            var newCmsNodes = new List <int>();

            foreach (var nodeId in umbracoWorkflowInstance.CmsNodes)
            {
                var n = new CMSNode(nodeId);
                if (!n.IsMedia())
                {
                    continue;
                }

                var d = new Media(nodeId);
                if (!MediaTypes.Contains(d.ContentType.Id))
                {
                    continue;
                }

                newCmsNodes.Add(nodeId);
                count++;
            }

            umbracoWorkflowInstance.CmsNodes = newCmsNodes;

            var transition = (count > 0) ? "contains_media" : "does_not_contain_media";

            runtime.Transition(workflowInstance, this, transition);
        }
Esempio n. 3
0
        // Implement the Run method of IRunnableWorkflowTask
        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // In Umbraco the workflowInstance should always be castable to an UmbracoWorkflowInstance
            var wf = (UmbracoWorkflowInstance)workflowInstance;

            // UmbracoWorkflowInstance has a list of node Ids that are associated with the workflow in the CmsNodes property
            foreach (var nodeId in wf.CmsNodes)
            {
                // We'll assume that only documents are attached to this workflow
                var doc = new Document(nodeId);

                var property = doc.getProperty(DocumentTypeProperty);

                if (!String.IsNullOrEmpty((string)property.Value))
                {
                    continue;
                }

                var host    = HttpContext.Current.Request.Url.Host;
                var pageUrl = "http://" + host + umbraco.library.NiceUrl(nodeId);

                var shortUrl = API.Bit(BitLyLogin, BitLyApiKey, pageUrl, "Shorten");

                property.Value = shortUrl;
            }

            // The run method of a workflow task is responsible for informing the runtime of the outcome.
            // The outcome should be one of the items in the AvailableTransitions list.
            runtime.Transition(workflowInstance, this, "done");
        }
        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // Cast to Umbraco worklow instance.
            var umbracoWorkflowInstance = (UmbracoWorkflowInstance) workflowInstance;

            var count = 0;
            var newCmsNodes = new List<int>();

            foreach(var nodeId in umbracoWorkflowInstance.CmsNodes)
            {
                var n = new CMSNode(nodeId);
                if(!n.IsDocument()) continue;

                var d = new Document(nodeId);
                if (!DocumentTypes.Contains(d.ContentType.Id)) continue;
                
                newCmsNodes.Add(nodeId);
                count++;
            }

            umbracoWorkflowInstance.CmsNodes = newCmsNodes;

            var transition = (count > 0) ? "contains_docs" : "does_not_contain_docs";
            runtime.Transition(workflowInstance, this, transition);
        }
        public override void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            base.Run(workflowInstance, runtime);

            var body = Helper.Instance.RenderTemplate(RenderTemplate);
            
            IList<string> files = new List<string>();

            foreach(var nodeId in ((UmbracoWorkflowInstance) workflowInstance).CmsNodes)
            {
                var node = new CMSNode(nodeId);
                if(node.IsMedia())
                {
                    files.Add(IOHelper.MapPath((string) new Media(nodeId).getProperty("umbracoFile").Value));
                }
            }

            var f = new User(From).Email;
            foreach(var r in GetRecipients())
            {
                var mail = new MailMessage(f, r) {Subject = Subject, IsBodyHtml = true, Body = body};

                foreach(var file in files)
                {
                    var attach = new Attachment(file);
                    mail.Attachments.Add(attach);
                }

                var smtpClient = new SmtpClient();
                smtpClient.Send(mail);
            }

            runtime.Transition(workflowInstance, this, "done");
        }
        public override void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            base.Run(workflowInstance, runtime);

            var nodes = ((UmbracoWorkflowInstance)workflowInstance).CmsNodes;

            SendMail(Body + Environment.NewLine + GetAttachmentLinks(nodes));
            runtime.Transition(workflowInstance, this, "done");
        }
        public override void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            base.Run(workflowInstance, runtime);

            var nodes = ((UmbracoWorkflowInstance) workflowInstance).CmsNodes;

            SendMail(Body + Environment.NewLine + GetAttachmentLinks(nodes));
            runtime.Transition(workflowInstance, this, "done");
        }
Esempio n. 8
0
        public override void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            base.Run(workflowInstance, runtime);

            var nodes = ((UmbracoWorkflowInstance)workflowInstance).CmsNodes;

            var body = Helper.Instance.RenderTemplate(RenderTemplate) + GetAttachmentLinks(nodes);

            SendMail(body);
            runtime.Transition(workflowInstance, this, "done");
        }
        public override void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            base.Run(workflowInstance, runtime);

            var nodes = ((UmbracoWorkflowInstance) workflowInstance).CmsNodes;

            var body = Helper.Instance.RenderTemplate(RenderTemplate) + GetAttachmentLinks(nodes);

            SendMail(body);
            runtime.Transition(workflowInstance, this, "done");
        }
        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // Cast to Umbraco worklow instance.
            var umbracoWorkflowInstance = (UmbracoWorkflowInstance) workflowInstance;

            foreach(var nodeId in umbracoWorkflowInstance.CmsNodes)
            {
                var n = new CMSNode(nodeId);
                if(!n.IsDocument()) continue;

                var d = new Document(nodeId);
                d.Publish(User.GetUser(0));

                umbraco.library.UpdateDocumentCache(d.Id);
            }

            runtime.Transition(workflowInstance, this, "done");
        }
        // Implement the Run method of IRunnableWorkflowTask
        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // In Umbraco the workflowInstance should always be castable to an UmbracoWorkflowInstance
            var wf = (UmbracoWorkflowInstance)workflowInstance;

            var accessToken = new OAuthTokens
            {
                AccessToken       = AccessToken,
                AccessTokenSecret = AccessTokenSecret,
                ConsumerKey       = ConsumerKey,
                ConsumerSecret    = ConsumerSecret
            };

            foreach (var nodeId in wf.CmsNodes)
            {
                // We'll assume that only documents are attached to this workflow
                var doc = new Document(nodeId);

                string pageUrl;

                if (string.IsNullOrEmpty(ShortUrlProperty))
                {
                    // The user hasn't specified a property for a Short URL.
                    var host = HttpContext.Current.Request.Url.Host;
                    pageUrl = "http://" + host + umbraco.library.NiceUrl(nodeId);
                }
                else
                {
                    pageUrl = (string)doc.getProperty(ShortUrlProperty).Value;
                }

                var tweet = string.Format(TweetText, doc.Text, pageUrl);

                // We could do some error checking with the result here....
                var result = TwitterStatus.Update(accessToken, tweet);
            }

            // The run method of a workflow task is responsible for informing the runtime of the outcome.
            // The outcome should be one of the items in the AvailableTransitions list.
            runtime.Transition(workflowInstance, this, "done");
        }
Esempio n. 12
0
        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // Cast to Umbraco worklow instance.
            var umbracoWorkflowInstance = (UmbracoWorkflowInstance)workflowInstance;

            foreach (var nodeId in umbracoWorkflowInstance.CmsNodes)
            {
                var n = new CMSNode(nodeId);
                if (!n.IsDocument())
                {
                    continue;
                }

                var d = new Document(nodeId);
                d.Publish(User.GetUser(0));

                umbraco.library.UpdateDocumentCache(d.Id);
            }

            runtime.Transition(workflowInstance, this, "done");
        }
        // Implement the Run method of IRunnableWorkflowTask
        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // In Umbraco the workflowInstance should always be castable to an UmbracoWorkflowInstance
            var wf = (UmbracoWorkflowInstance)workflowInstance;
            
            var accessToken = new OAuthTokens
            {
                AccessToken = AccessToken,
                AccessTokenSecret = AccessTokenSecret,
                ConsumerKey = ConsumerKey,
                ConsumerSecret = ConsumerSecret
            };

            foreach (var nodeId in wf.CmsNodes)
            {
                // We'll assume that only documents are attached to this workflow
                var doc = new Document(nodeId);

                string pageUrl;

                if(string.IsNullOrEmpty(ShortUrlProperty))
                {
                    // The user hasn't specified a property for a Short URL.
                    var host = HttpContext.Current.Request.Url.Host;
                    pageUrl = "http://" + host + umbraco.library.NiceUrl(nodeId);
                } else
                {
                    pageUrl = (string)doc.getProperty(ShortUrlProperty).Value;
                }

                var tweet = string.Format(TweetText, doc.Text, pageUrl);

                // We could do some error checking with the result here....
                var result = TwitterStatus.Update(accessToken, tweet);
            }

            // The run method of a workflow task is responsible for informing the runtime of the outcome.
            // The outcome should be one of the items in the AvailableTransitions list.
            runtime.Transition(workflowInstance, this, "done");
        }
Esempio n. 14
0
        public override void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            base.Run(workflowInstance, runtime);

            var body = Helper.Instance.RenderTemplate(RenderTemplate);

            IList <string> files = new List <string>();

            foreach (var nodeId in ((UmbracoWorkflowInstance)workflowInstance).CmsNodes)
            {
                var node = new CMSNode(nodeId);
                if (node.IsMedia())
                {
                    files.Add(IOHelper.MapPath((string)new Media(nodeId).getProperty("umbracoFile").Value));
                }
            }

            var f = new User(From).Email;

            foreach (var r in GetRecipients())
            {
                var mail = new MailMessage(f, r)
                {
                    Subject = Subject, IsBodyHtml = true, Body = body
                };

                foreach (var file in files)
                {
                    var attach = new Attachment(file);
                    mail.Attachments.Add(attach);
                }

                var smtpClient = new SmtpClient();
                smtpClient.Send(mail);
            }

            runtime.Transition(workflowInstance, this, "done");
        }
Esempio n. 15
0
        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            Log.Debug("This is where my task logic would happen");

            runtime.Transition(workflowInstance, this, "done");
        }