以程式設計方式註冊參與計劃中的聯絡人

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