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); }
public virtual string GetAttachmentLinks(IEnumerable <int> attachedNodes) { var s = new StringBuilder(); s.Append("<br/><br/>"); var host = HttpContext.Current.Request.Url.Host; if (HttpContext.Current.Request.Url.Port != 80) { host += ":" + HttpContext.Current.Request.Url.Port; } foreach (var nodeId in attachedNodes) { var node = new CMSNode(nodeId); if (node.IsDocument()) { s.Append(string.Format("{2} ({1}): <a href='http://{0}/umbraco/dialogs/preview.aspx?id={1}'>[" + GlobalisationService.Instance.GetString("preview") + "]</a> ", host, nodeId, node.Text) + Environment.NewLine); s.Append(string.Format("<a href='http://{0}/umbraco/actions/editContent.aspx?id={1}'>[" + GlobalisationService.Instance.GetString("edit") + "]</a><br/>", host, nodeId) + Environment.NewLine); } else if (node.IsMedia()) { s.Append(string.Format("{2} ({1}): <a href='http://{0}/umbraco/dialogs/preview.aspx?id={1}'>{2}</a> ", host, nodeId, node.Text) + Environment.NewLine); } else { s.Append(node.Text + "<br/>" + Environment.NewLine); } } return(s.ToString()); }
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 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); }
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 virtual string GetAttachmentLinks(IEnumerable<int> attachedNodes) { var s = new StringBuilder(); s.Append("<br/><br/>"); var host = HttpContext.Current.Request.Url.Host; if (HttpContext.Current.Request.Url.Port != 80) host += ":" + HttpContext.Current.Request.Url.Port; foreach(var nodeId in attachedNodes) { var node = new CMSNode(nodeId); if(node.IsDocument()) { s.Append(string.Format("{2} ({1}): <a href='http://{0}/umbraco/dialogs/preview.aspx?id={1}'>[" + GlobalisationService.Instance.GetString("preview") + "]</a> ", host, nodeId, node.Text) + Environment.NewLine); s.Append(string.Format("<a href='http://{0}/umbraco/actions/editContent.aspx?id={1}'>[" + GlobalisationService.Instance.GetString("edit") + "]</a><br/>", host, nodeId) + Environment.NewLine); } else if(node.IsMedia()) { s.Append(string.Format("{2} ({1}): <a href='http://{0}/umbraco/dialogs/preview.aspx?id={1}'>{2}</a> ", host, nodeId, node.Text) + Environment.NewLine); } else { s.Append(node.Text + "<br/>" + Environment.NewLine); } } return s.ToString(); }