C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 300,574 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,198 people online right now. Registration is fast and FREE... Join Now!




Workflow Foundation: Retrieve custom properties from a persisted workf

 

Workflow Foundation: Retrieve custom properties from a persisted workf

drjacky

29 Jun, 2009 - 07:32 AM
Post #1

New D.I.C Head
*

Joined: 25 Apr, 2008
Posts: 6

Hi !

I use the persistence (& tracking) services to save workflows state into a SQL Server database.
When I try to display informations about all workflows in a datagrid, I only get the "system properties" (state, instanceId...)
Other properties are empty.

How can I retrieve all (user) properties ?

(I read related threads but I don't really understand ... the MSDN samples are too complicated and sophisticated: I just want to retrieve some properties, that's all)

- How can I use the TrackingProfile (the MSDN TrackingProfileDesigner project doesn't work for me --> it can't load my workflow properly) ?
- Should I use the TrackData() method in the workflow library, to set user properties that must be accessible by the host ?
- How do I do to get these custom properties when the workflow is persisted (assuming that both persistance & tracking services are ready) ?

What is the minimum code requirements to do that ?

My current code:

CODE

        ' Récupération des WFs persistés
        persisted = WFManager.GetInstance().dbService.GetAllWorkflows()
        For Each wfPersisted As WFRH.SqlPersistenceWorkflowInstanceDescription In persisted
            If runningOnly Then
                If Not wfPersisted.Status = System.Workflow.Runtime.WorkflowStatus.Running Then
                    Continue For
                End If
            End If
            wf = wfRuntime.GetWorkflow(wfPersisted.WorkflowInstanceId).GetWorkflowDefinition()
            row = instTable.NewInstancesRow

            row.CompanyId = wf.CompanyId
            row.Id = wfPersisted.WorkflowInstanceId.ToString()
            row.StartTime = wf.StartTime.ToString()
            row.StartUserName = wf.CreatedBy
            row.State = wfPersisted.Status.ToString()
            row.StopTime = wf.StopTime.ToString()
            row.TestId = wf.TestId
            row.TestState = wf.Status.ToString()

            instTable.AddInstancesRow(row)
            row.AcceptChanges()

            If sqlDataTrackingQuery.TryGetWorkflow(wfPersisted.WorkflowInstanceId, sqlTrackingWfi) Then
                Console.WriteLine(vbLf & "Outputting data tracked from the workflow:" & vbLf)

                For Each activityDataTrackingRecord As WFRT.ActivityTrackingRecord In sqlTrackingWfi.ActivityEvents
                    For Each dataItem As WFRT.TrackingDataItem In activityDataTrackingRecord.Body
                        ' Output data queried from TrackingDataItem table in the database
                        Console.WriteLine("At the {0} event for the {1}:" & vbLf & "{2} = {3}", activityDataTrackingRecord.ExecutionStatus, activityDataTrackingRecord.QualifiedName, dataItem.FieldName, dataItem.Data)
                    Next
                Next
            Else
                Console.WriteLine("Could not retrieve data for workflow with instance id {0}", wfPersisted.WorkflowInstanceId)
            End If

        Next


Thanks a lot !

Etienne

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 08:13AM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month