Build a Trigger from its Description String

Topics: Examples
Sep 23, 2013 at 2:18 PM

Trigger.ToString() returns a description string that represents the corresponding trigger. Is there any method that does the opposite, i.e., build a trigger given its description string?

Something like: Trigger.Build(descriptionString);


Best regards,

Sep 23, 2013 at 10:39 PM
There is not. In the 2.0 library, there is a Fluent API that allows you to kind of use word-like syntax, but there is no string parsing capability.
Sep 24, 2013 at 6:43 AM
Thanks for your reply!

Well, this is what I want to do. Maybe you could recommend a better way.

I use the Task Scheduler Managed Wrapper to schedule Windows Tasks, and save the settings in an external database (for backup reasons). I want, in case someone has deleted the Windows Tasks (by mistake), that I retrun them by recreating them from the DB-backup.

Could you maybe advise me how to do that?
Sep 24, 2013 at 7:34 AM
Is Serialization the right thing to do?
Sep 24, 2013 at 7:31 PM
You can use the Task.Export() method to save the Xml to a file or your can capture the Task.Xml property and save that elsewhere. To regenerate the task, you can use the TaskService.NewTaskFromFile() method to create a TaskDefintion from a file or you can use the TaskService.NewTask method and then assign the Xml the string you extracted from the Xml property. Either way, you will need to then register the new TaskDefinition.
Sep 26, 2013 at 9:03 AM
Thank you very much!

I used the XmlText property of TaskDefinition and it works perfectly! :)