This project has moved. For the latest updates, please go here.

Build a Trigger from its Description String

Topics: Examples
Sep 23, 2013 at 3:18 PM
Hi,

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);

Thanks!

Best regards,

MuhaNERD
Coordinator
Sep 23, 2013 at 11: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 7: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 8:34 AM
Is Serialization the right thing to do?
Coordinator
Sep 24, 2013 at 8: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 10:03 AM
Thank you very much!

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