Tasks Executed from Request Body
Products: FastReport Cloud, FastReport Corporate Server, FastReport Publisher
As mentioned in the previous section, Service solutions has the ability to run tasks without prior saving. To do this, you should use the RunTask method, passing a model inherited from UpdateTaskBaseVM into it.
For example, to build a PDF document and send it via FTP, you need to pass data such as template identifier (EntityId) or the template itself (Content) to the InputFile object in the RunTask method, as well as data for connecting to the FTP server.
Let's take a closer look at how to work with such tasks using the C# SDK.
About ViewModels and Types
When working, you will pass different ViewModels (View Models) to SDK methods. Let's consider which view models can be used.
View Models for Running Tasks On-the-Fly (Without Saving)
View Models for running transformer tasks on-the-fly:
- RunPrepareTaskVM
- RunExportTemplateTaskVM
- RunExportReportTaskVM
View Models for running transport tasks on-the-fly:
- RunEmailTaskVM
- RunWebhookTaskVM
- RunFTPUploadTaskVM
- RunS3UploadTaskVM
View Models for running other tasks on-the-fly:
- RunFetchTaskVM
Running Task On-the-Fly (from Request Body)
Let's consider running a report export task with subsequent email sending:
var runTask = await tasksClient.RunTaskAsync(new RunExportTemplateTaskVM
{
SubscriptionId = subscriptionId,
InputFile = new RunInputFileVM
{
EntityId = template.Id,
FileName = "Document"
//Content = new byte[] { }
},
Format = ExportFormat.Docx,
Transports = new List<RunTransportTaskBaseVM>
{
new RunEmailTaskVM
{
From = "admin@company.com",
To = ["user@company.com", "seller@company.com"],
Subject = "Important Report",
Body = "An important report is attached to this email.",
EnableSsl = true,
Username = "admin@company.com",
Password = "password123",
Server = "smtp.company.com",
Port = 587
}
}
});
Real object identifiers should be entered in the EntityId field. Otherwise, the task will be aborted with an error.
Also, instead of it, you can pass the template content in the Content field as a byte array in the InputFile object.