I created a workflow using umbraco and what I am trying to do is:
create a workflow that get the html created by a razor template (umbraco.forms
).
Here is the locations where is the templates of umbraco.forms
Views\Partials\Forms\Emails This template is what I want to send by email when this workflow is called.
public class SendMail : WorkflowType
{
//Here I get the path where the razor template is
[Umbraco.Forms.Core.Attributes.Setting("Path to template",
Description = "Path to template",
View = "TextField")]
public string Template{ get; set; }
public SendMail()
{
this.Id = new Guid("ccbeb0d5-adaa-4729-8b4c-4bb439dc0204");
this.Name = "Send Mail";
this.Description = "Send Mail";
this.Icon = "icon-plugin";
this.Group = "Services";
}
//When workflow get called this method is executed
public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
{
//here I'm trying to get the template converted to string however isn't work
// string template = html.Raw(Template).ToString();
}
}
I tried string template = html.Raw(Template);
but I have no access to the html.Raw("");
I've tried this solutions but seems that record.ParseWithRazorView(filePath);
doesn't exists
There is a workflow that do something close but seems I can't re-write or get access to this code
If you don't understand exactly what I pretend please comment and I will update the question with all details
I created a View and a umbraco controller
namespace name.Core.Controllers
{
public class TemplateController : Umbraco.Web.Mvc.SurfaceController
{
public ActionResult Template()
{
return View();
}
}
}
The I pass the URL into "pathtoTemplate"
public static class TemplateHTML
{
public static string GetTemplate(string pathtoTemplate)
{
using (WebClient client = new WebClient())
{
var encodingbody = client.DownloadData(CaminhoTemplate);
return Encoding.UTF8.GetString(encodingbody);
}
}
}
var body = TemplateHTML.GetTemplate("http://example.com/umbraco/surface/Template/Template")