It will be like this in the class?
using CMS.Scheduler;
using CMS.EventLog;
namespace Custom
{
public class CustomTask : ITask
{
/// <summary>
/// Executes the task.
/// </summary>
/// <param name="ti">Info object representing the scheduled task</param>
public string Execute(TaskInfo ti)
{
string details = "Custom scheduled task executed. Task data: " + ti.TaskData;
// Logs the execution of the task in the event log
EventLogProvider.LogInformation("CustomTask", "Execute", details);
// Returns a null value to indicate that the task executed successfully
// Return an error message string with details in cases where the execution fails
return null;
if (formObject != null)
{
// Gets the class name of the 'ContactUs' form
DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID);
string formClassName = formClass.ClassName;
// Loads all data records from the form that have an empty value in the 'UserMessage' field
ObjectQuery<BizFormItem> data = BizFormItemProvider.GetItems(formClassName)
.WhereEmpty("UserMessage");
// Loops through the form's data records
foreach (BizFormItem item in data)
{
// Deletes all files stored in the form's fields
BizFormInfoProvider.DeleteBizFormRecordFiles(formClass.ClassFormDefinition, item, SiteContext.CurrentSiteName);
// Deletes the form record from the database
item.Delete();
}
}
}
}
}