Genpact Cora Knowledge Center

Support

Get Activity Details When Running as ESC Activity

Use the API to get activity details when you run the activity as an ESC activity.

IWorkflowEngine engine = WorkflowRuntime.Engine;
 
            ActivityExecutionContext actExeContx = ActivityExecutionContext.Current;
            WorkflowInstance wfinstance = actExeContx.WorkflowInstance;
            StringBuilder content = new StringBuilder();
 
            content.Append("Current user: " + engine.GetCurrentUser     
            ().CurrentUserInfo.DisplayName + " ");
          
                TimeSpan ts = wfinstance.CreatedAt - System.DateTime.Now;
                content.Append("Workflow Instance Duration: " + ts.Hours + " ");
                content.Append("Source Activity Alias: " + 
                actExeContx.Activity.SourceActivities[0].Alias + " ");
                content.Append("Source Activity Instance ID: " +
                actExeContx.CurrentInstance.SourceActivityInstanceId + " ");
                Write2File(content.ToString());
 
               return true;