AutomationMetadataProvider automationMetadataProvider = Assert.ResultNotNull(Factory.CreateObject("automation/metadataProvider", true) as AutomationMetadataProvider);
var context = AutomationManager.Provider.GetAutomationContext(ID.Parse(contact.ContactId));
context.Enroll(fromStateItem.ParentID, ID.Parse(fromState), automationMetadataProvider.CalculateWakeUpDateTime(ID.Parse(fromState), DateTime.UtcNow), null);
AutomationManager.Provider.SaveAutomationContext(context);