Saving activity status in DB
-
Thursday, May 10, 2012 5:20 AM
Hi there,
We are using devart for Workflow Execution
I need to show the status of activities that are executing in workflow ..
What i found that WF_ACTIVITY_STATE _RECORD it put an entry related to
the activity only when it has completed the execution of that activity
that is Executed and Completed in one go .. not that executing stats
in starting and completed status only when activity has completed..
Can you guide me on this how to achieve it I am having workflow
instance id that i can use to check it...
eg
in workflow
Activity1 Executing 10 AM
Activity1 Completed 11 AM
In db it is have executing status Completed Status in one go i .e
after 11 AM. it want to have one entry "Activity1 Executing" at 10
AM and another "Activity1 Completed" at 11 AM...
i have tried using Custom Tracking but there also it is putting values in database after the activity got executed..
please help me on this...
All Replies
-
Friday, May 11, 2012 12:56 PMModerator
Hi,
How did you configure the Tracking profile? We can subscribe to the state changes of activity are: Canceled, Closed, Executing and Faulted.
ActivityStates Class
http://msdn.microsoft.com/en-us/library/system.activities.tracking.activitystates.aspx
For more information about the tracking file, please check the "ActivityStateQuery" related section in the following article:
Tracking Profiles
http://msdn.microsoft.com/en-us/library/ee513989.aspx
Hope this information helps, thanks.
Leo Tang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Edited by LeoTangModerator Friday, May 11, 2012 12:57 PM
-
Tuesday, May 15, 2012 3:27 AM
Thanks everyone for spending quality time on my issue
Scenario is i have written a custom actvity SendMail
========================================
SendMail: Native Activity
Execute(){//some piece of code to sent mail to user }
========================================
Now i want to track the status of this actvity .. I have attached the tracking with my application
But what happens it enter the the Executing and completed status in DB only when it has completed the execution
not in seperate go means if i write Threading.Sleep(2000) inside the Execute method and try to see the respective DB tables i am not able to see any related status record for that activity but as sson as that activity execution is over i am able to view the status in the respective DB table....
Please let me know whether this is happening correctly or in order to have seperate executino i need to modify some thing
With Regards
Gaurav
-
Tuesday, May 15, 2012 4:04 AM
Hi Gaurav,
It should work , Please go through following link and check ActivityStateQuery
Code should be somthing like this:-
TrackingProfile sampleTrackingProfile = new TrackingProfile(){
Name = "Sample Tracking Profile",
Queries =
{
new ActivityStateQuery(){
ActivityName = "SendEmailActivity",
States = { ActivityStates.Executing }}
}
Another way is that you can store required data in your custom tables. insert data in tables when activity is executing or completes
MB
- Edited by MadhurBhardwaj Tuesday, May 15, 2012 4:06 AM
-
Wednesday, May 16, 2012 6:06 AM
Thanks Madhur for the info
First option is not working as it is inserting data only when the activity got executed ..
I rephrase my question ....
My goal is to keep track of the activity status during execution of the long running activity .. Now whathappens it is storing the execution status(started and Completed) when the Activity gots completed .so in case long running activity is in middle of its execution how i can track what it's status ...
With Regards
Gaurav
-
Wednesday, May 16, 2012 8:47 AMModerator
Hi,
It seems that you read execution status from the persistence database directly. What Madhur and I mentioned are the features about workflow Tracking. Workflow runtime emit TrackingRecord objects, we can use Tracking Participants to subscribe TrackingRecord to track the activity status. The ActivityStateQuery is used to configure which state changes of activity we subscribed to.
WF4 provides a tracking participant that writes the tracking records to an ETW session. We can create custom tracking participant to write tracking records to text file, database end etc. You can refer to the following article for how to configure tracking:
Configuring Tracking for a Workflow
http://msdn.microsoft.com/en-us/library/ee517415
If I misunderstood you, please let me know, thanks.
Leo Tang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
Wednesday, May 16, 2012 10:58 AM
Thanks Leo for the answer...
Leo I will rephrase my problem for more clarity
I have created a CustomCodeActivity that is performing some long running job..
In this Activity Execute method i have written some sequential code eg // inserting 50000 records in dB
I have implemented tracking on it .. And it is saving the tracking information in the DB....
Problem is what i found that during execution of the above actvity it is writting its status in the db only after its completeion i.e after the activity got completed it is entering two rows in DB one with Executing state and another with completing State ..
Is this is correct behaviour..
Or something i missed out as per my understanding it should write the entry in db in two seperate go .. one when it started executing and another when it completes..
I can see the above behaviour for Sequence Activity but same is not reflected in Code or Native activity..
With Regards
Gaurav

