overload methods in WF

Hi all,
i would like to know how can methods(activity) be overloaded in WF. For example i have a if-else activity, a sendMail() method. If the ToName is XXX then doSomthing() and then sendMail(XXX), else if ToName is YYY then doSomthing() and then sendMail(YYY). How can the parameter be handed over? Should i use a queue for the parameter (or Dependence Property)? But how can i choose at runtime the right parameter?

Thanks

[471 byte] By [Emy_P] at [2007-12-28]
# 1

Emy_P,

Just so I can understand what you have here, let me take a shot at describing what you have based on your description...

You have created a custom If/Else activity: Is this derived from CompositeActivity or is this a SequentialActivity and you've dropped a base class If/Else activity into it?

So, in your rule (code or declarative?) for the If statement, you check the ToName, which should be a parameter (Dep prop) passed into the activity. After this, no matter who the email is from, you doSomething() and then pass in the email address of the person to the SendMail method.

Based on this, in your if/else branch, you would have a code activity and in that code activity you would grab the value of the dep property (ToName) and call the SendMail method passing it that property.

Sound feasible?

Etowah_man at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2

You can define workflow parameters and bind the parameter to an activity's dependency property. At runtime you could set the value for the workflow property possibly from another activity/from local service by reading in user input. The activity would simply use the value in the dependency property and do the method invocation.

Is this what you are looking for?

Vignesh

VigneshKannappan-MSFT at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3
Hi Etowah_man, Vignesh. Thank you for your responses.

The whole situation is, i muss read from a directory all the files and then if the file is Compressed es must be decompressed and move to an directory1, and then send an email to the admin(with subject1), if the file is Err, must be sent in another directory (directory2 ) and then an email to the admin(with subject2).
I have 2 custom activities, one as sendMail() and one as moveFile(), and they should place in the if-else branch. Each activity has Property, sendMail with To, From, Subject( like the example of SDK).
Vignesh, acording to you, that means i should define for the workflow also From,To.. properties? And in the local service, i should define a method, with 2 events, if Compressed is true then the subject is subject1 and goal directoy ist directory1, is that right? But if the scenario is bigger, and i have more if-case (more type of files), could i use a queue for these parameter?
Could you give me more details ?

thanks in advance
EP

Emy_P at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4

Hi Emy -

The solution I proposed doesn't suit your actual scenario. You should define Directory dependency property for the moveFile activity and To, From dependency properties for the sendMail activity. Then in the workflow you could add the two activities [moveFile and sendMail] on each branch of the if-else activity and bind the properties to static values/parameters from the workflow. If you know that all the variable values From, To, Directory for both situations won't change, static initialization with values for the dependency properties would work. If you need to initialize them with values at runtime, then you could bind the properties to workflow level parameters: in that case you would have 6 workflow level parameters which are all bound to the activity properties.

Let me know if you need more clarification.

Thanks,

Vignesh

VigneshKannappan-MSFT at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5
Hi Vignesh, thank you for your guidance. With normal workflow parameter i need only a dictionary in the host and bind name of parameter with the name of property and initialize the parameter of the wf, but with "workflow level parameters", how can i create them, could you please give me an example?

Regards
Emy

Emy_P at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6

Emy - I meant the workflow parameters you are talking about. You can send the parameters dictionary when you create an instance using an overload of CreateWorkflow() method. Sorry for the confusion.

Thanks!

Vignesh

VigneshKannappan-MSFT at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 7
Vignesh, thank you very much for your help !

Regards
Emy

Emy_P at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified