CustomActivity''s properties don''t save

Hello,

I create a custom activity with somes properties, you can see the code for "Progress" here :

Code Snippet

[Designer(typeof(ProgressTaskDesigner), typeof(IDesigner))]
public partial class ProgressTask : SequenceActivity
{
public static DependencyProperty ProgressProperty = System.Workflow.ComponentModel.DependencyProperty.Register("Progress", typeof(int), typeof(ProgressTask));

[Description("Progress %")]
[ValidationOption(ValidationOption.Required)]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Progress
{
get { return ((int)(base.GetValue(ProgressTask.ProgressProperty))); }
set { base.SetValue(ProgressTask.ProgressProperty, value); }
}

...


So, I use it in a workflow and all work perfecly.
But when I save the workflow (with SqlWorkflowPersistenceService and SqlTrackingService) and i want to reload it form database with a Resume, the value of my propertie is always the default value !Sad

How can I save and load it properly ?

Thanks

[1378 byte] By [Xeron] at [2008-1-8]
# 1
How are you setting the value of properties within the workflow? Do you bind the properties to workflow level variables or set directly on the property? e.g. this.progressTask1.Progress = 10; Is your activity contained in an activity that spawns new execution contexts? e.g. WhileActivity, ConditionedActivityGroup or StateActivity. How are you persisting the workflow? Are you calling e.WorkflowInstance.Unload(); when the workflow is suspended? I used the code you posted and was not able to repro the problem you are having.
TomLake-MSFT at 2007-10-2 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2
Thanks for your reply, so :

- I set the property direcly in my activity with a handleExternalEvent with a correlation token :

Code Snippet

private void Input_Invoked(object sender, ExternalDataEventArgs e)
{
ICommunications.ProgressTaskCommunicationEventArgs __arg = e as ICommunications.ProgressTaskCommunicationEventArgs;

if (__arg != null)
{
this.Progress = __arg.Progress;
}
}


- My custom activty contain a while execution witch include an ifelse and my handleExternalEvent

- I persit workflow whith Unload when idle :

Code Snippet

private void OnWorkflowIdled(object sender, WorkflowEventArgs e)
{
_instance.Unload();
}


-> I'm not sure on this point Tongue Tied I see [PersistOnClose] but it's terminate my workflow Sad ... or UnLoadOnIdle or SaveWorkflowInstanceState but don't know the good solution ?

Hope we can find the problem,
Thanks

Xeron at 2007-10-2 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3

Your problem is that you are setting property on the template activity, for more information take a look at Nate’s blog post on Spawned Contexts found at http://blogs.msdn.com/advancedworkflow/archive/2006/03/21/557121.aspx.Assuming that you have the following hierarchy:

CustomActivity

WhileActivity

HandleExternalEventActivity

You would need code like the following:

((ProgressTask)((Activity)sender).Parent.Parent).Progress= __arg.Progress;

TomLake-MSFT at 2007-10-2 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4
Ok, it seem to work in my instance of workflow but (another problem) I don't know why I can't see it in the WorkflowMonitor. In effect, I create a CustomActivityDesigner and I want to paint in th rectangle the value of this properties. I use :

Code Snippet

private void DrawCustomActivity(ActivityDesignerPaintEventArgs e)
{

...

ProgressTask __task = this.Activity as WfTask;
if (__task != null)
__progress = __task.Progress;

...

ActivityDesignerPaint.DrawText(graphics, activityDesignerTheme.Font, this.Text + __progress ...
}


It work fine in the visual studio designer but not with he WorkflowMonitor example based on the Tracking service.

In fact I want to show the workflow to my user and interacte with it. And I would like to create this with xaml ... but actually i have a lot of problems for have informations of my instance from my laucher code Sad And now i'm wondering if the tracking is a good solution Tongue Tied

Have you any idea for this ?

Xeron at 2007-10-2 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified