#5003 not implemented
I am trying to create a scheduled task but get not implemented error when I try to run it.
Class PICIS.Core.Tasks.CleanEntry Extends %RegisteredObject
{
ClassMethod ClearTasks(pBackupFile As %String = "d:\Temp\BackupTasks.xml", pDelete As %Boolean = 0)
{
// Create backup file
Set tBackup = ##class(%Stream.FileCharacter).%New()
Set tBackup.Filename = pBackupFile
Do tBackup.WriteLine("<?xml version=""1.0"" encoding=""UTF-8""?>")
Do tBackup.WriteLine("<Tasks>")
// Delete loop
Set tCount = 0
Set tSC = $$$OK
Set tRS = ##class(%SQL.Statement).%ExecDirect(, "Select ID From %SYS.Task Where Namespace = ? And TaskClass = ?", PICIS, "picis.core.tasks.senddelayedtrigger")
While tRS.%Next() {
Set tTask = ##class(%SYS.Task).%OpenId(tRS.ID)
Set tSC = tTask.XMLExportToString(.tExport)
If $$$ISERR(tSC) {
Write !,"Problem trying to export TASK ID ",tRS.ID
Do $System.Status.DisplayError(tSC)
Quit
}
Do tBackup.WriteLine($ZConvert(tExport, "O", "UTF8"))
// Delete?
If pDelete {
Set tSC = ##class(%SYS.Task).%DeleteId(tRS.ID)
If $$$ISERR(tSC) {
Write !,"Problem trying to delete TASK ID ",tRS.ID
Do $System.Status.DisplayError(tSC)
Quit
}
}
Set tCount = tCount + 1
}
// Close backup file
Do tBackup.WriteLine("</Tasks>")
Set tSC = tBackup.%Save()
If $$$ISERR(tSC) {
Write !,"Problem saving backup file"
Do $System.Status.DisplayError(tSC)
Quit
}
Write !!,"Backed up ",$Select(pDelete:"and Deleted ", 1:""),tCount," Tasks"
}
}