code_junkie

WF Access the workflow instance variables from load and unload

Nov 13th, 2011
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. SqlTrackingWorkflowInstance instance = null;
  2. //wfServiceHost is an instance of WorkflowServiceHost
  3. WorkflowRuntimeBehavior workflowRuntimeBehaviour = wfServiceHost.Description.Behaviors.Find<WorkflowRuntimeBehavior>();
  4. WorkflowRuntime wfRuntime = workflowRuntimeBehaviour.WorkflowRuntime;
  5.  
  6. if (wfRuntime != null)
  7. {
  8. SqlTrackingService trackingService = (SqlTrackingService)wfRuntime.GetService(typeof(SqlTrackingService));
  9. SqlTrackingQuery sqlTrackingQuery = new SqlTrackingQuery(trackingService.ConnectionString);
  10.  
  11. sqlTrackingQuery.TryGetWorkflow(instanceId, out instance);
  12. }
  13.  
  14. this.TrackData("name", myObject)
  15.  
  16. foreach (UserTrackingRecord userTrackingRecord in
  17. sqlTrackingWorkflowInstance.UserEvents)
  18. {
  19. Console.WriteLine("Key : {0} Data : {1}",
  20. userTrackingRecord.UserDataKey,
  21. userTrackingRecord.UserData.ToString());
  22. if (userTrackingRecord.UserDataKey == "Job")
  23. {
  24. OrderRequest request = userTrackingRecord.UserData as OrderRequest;
  25. if (request != null)
  26. {
  27. Console.WriteLine("nJob ID: {0}", request.JobID);
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment