How to create an activity that allows multiple exit paths similar to FlowSwitch and FlowDecision
-
06 Ocak 2010 Çarşamba 12:31
There have been several threads around this type of request but none have provided a definitive outcome for my requirements:
I am looking to emulate the FlowSwitch or FlowDecision in a custom activity so as to simplify end user workflow authoring in a rehosted environment.
Currenty I am limited to linking my custom activity to a FlowSwitch or FlowDecision to allow for simple logic to be visually composed. This creates additional
complexity that I am trying to avoid.
I understand that these are sealed types and even the abstract FlowNode base class of these types does not have any overridable types by design as WF 4.0 favours composition over inheritance.
What options do I have to accomplish my objective?
If activity composition is the response to my question then could I kindly request that some samples or links to samples are provided?
Tüm Yanıtlar
-
06 Ocak 2010 Çarşamba 18:34
you can use WorkflowViewElement instead of ActivityDesigner to implement such custom activity.
-
06 Ocak 2010 Çarşamba 18:49Thanks for the reply.
Do you have any samples of how I could use WorkflowViewElement? -
06 Ocak 2010 Çarşamba 19:37
Please give me some time.
let me create a sample for you.
in fact to create a custom activity like this, it also depends on its container. -
06 Ocak 2010 Çarşamba 23:26
I created a simple designer. the behavior is when this designer is dropped into the container designer, it will find two assign activities and setup the links to those two activities from its leftside and rightside, and the condition properties of the designer will be set value. if there is no assign activities, the links won't be setup.
let me explain the steps here
the behavior of flowswtch in flowchart is controlled by flowchart designer.
if you want to create a designer like flowswitch, you need to create the container, too.
1. create a designer with ICompositeView where you can set up links among activity designers(in this xaml.cs part, you at least need to implement the OnDrop function)
2. create a designer like flowswitch use workflowviewelement.
xaml part:
<sap:WorkflowViewElement x:Class="ActivityDesignerLibrary2.ActivityDesigner2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation">
<Grid>
<Rectangle x:Uid="Rectangle_2" HorizontalAlignment="Center" Width="40" Height="40" Margin="0,5,0,20" Fill="Green" />
</Grid>
</sap:WorkflowViewElement>
no change for xaml.cs part
CodeActivity part
[Designer(typeof(ActivityDesigner2))]
public class Activity2:CodeActivity
{
int condition1;
int condition2;
public int Condition1
{
get
{
return condition1;
}
set
{
condition1 = value;
}
}public int Condition2
{
get
{
return condition1;
}
set
{
condition2 = value;
}
}protected override void Execute(CodeActivityContext context)
{
throw new NotImplementedException();
}
}
3. now go back to ICompositeView designer, add some code when you update the view of the ICompositeView Designer
if there is flowswitch like designer in it, set up links to the first two dragged-in activity designers, and set the Condition1 and Condition2 property value.
so this is the simple implementation, for more complicated implementation, you can modify the logic at step 3. -
07 Ocak 2010 Perşembe 15:00Ye Yu - Thanks for your sample. However i think i have missed something - could you detail Step 1 a little more. What do you need to create a designer for which impliments ICompositeView? Can you not just use FlowChart or do you have to reimpliment the whole designer?
Many thanks for any help you can provide on this.
AJ. -
08 Ocak 2010 Cuma 01:14ModeratörI've started posting some info on ICompositeView you might find useful, but it's still a long way off from complete. Flowchart is probably not easily reusable for this kind of customization because the classes are sealed (on the activity side) and internal (on the designer side)
http://blogs.msdn.com/tilovell/archive/2009/12/31/freeform-custom-activity-designers-using-icompositeview.aspx
Tim -
08 Ocak 2010 Cuma 08:23Moderatör
Can you not just use FlowChart or do you have to reimpliment the whole designer?
AJ, I don't think flowchart in this release allow you customize this kind of designer.
thanks,
Anders
This posting is provided "AS IS" and confers no rights or warranties.- Yanıt Olarak Öneren Anders Liu - MSFTModerator 08 Ocak 2010 Cuma 08:24
-
08 Ocak 2010 Cuma 13:30
Ye Yu - I appreciate your time taken to assist me in my endeavour.
I have a few questions regarding your sample.
1. Do I need to create a custom activity that I need to attach the ICompositeView designer to?
2. How do I enable a custom activity to allow items to be dropped into it?
3. In the implementation of the OnDrop method do I need to add the dropped items to the children collection of the ICompositeView designer?
4. How do I programmatically set up links between 2 activities? -
08 Ocak 2010 Cuma 23:00AJ, sorry for the late response.
here as I mentioned, if you want to create some activities whose behavior is like FlowSwitch, you need to reimplement the whole deisnger I mentioned in step 1. -
08 Ocak 2010 Cuma 23:24
1. Do I need to create a custom activity that I need to attach the ICompositeView designer to?
yes, you need to. and for this custom activity, you need to create a property to allow you drop the activity designers
public Collection<Activity> Activities
{
get
{
if (activities == null)
{
activities = new Collection<Activity>();
}
return activities;
}
set
{
activities = value;
}
}
2. How do I enable a custom activity to allow items to be dropped into it?
you can use DragDropHelper.AllowDrop, e.Effects and e.handles to implement this. e is DragEventArgs e
3. In the implementation of the OnDrop method do I need to add the dropped items to the children collection of the ICompositeView designer?
protected override void OnDrop(DragEventArgs e)
{
this.AllowDrop = true;
object droppedObject = DragDropHelper.GetDroppedObject(this, e, Context);
ModelItem droppedModelItem = droppedObject as ModelItem;
Object srcContainer = DragDropHelper.GetCompositeView(e);
DragDropHelper.SetDragDropCompletedEffects(e, DragDropEffects.None);
Point point = e.GetPosition(this);
//move the activity designer inside the Icompositeview deisnger(just as what you see in flowchart deisnger)
if (droppedModelItem != null && srcContainer != null && srcContainer.Equals(this))
{
this.ViewStateService.StoreViewState(droppedModelItem, shapeLocation, point);
//update the view of designer surface
UpdateView();
}
//drag a activity designer from toolbox into the designer surface
else
{
//add the new added activity designer into modelitem collection, and you need to add a modelitem change event to update the view automatically
//when you add the new activity designer
UpdateItem(droppedObject, point);
}
e.Handled = true;
DragDropHelper.SetDragDropCompletedEffects(e, DragDropEffects.Move);
base.OnDrop(e);
}
4. How do I programmatically set up links between 2 activities?
I'm not sure whether there is better way to implement this view effect.
I use System.Windows.Shapes.Line to implement this. you can put the set-up-links code in UpdateView(), and when you set up the links, you could set the property value to the activity you created to simulate FlowSwitch as needed.
Conlusion: here you need to create two designers, one is the container deisnger, which is like Flowchart designer(because some of the behaviors of flowswitch you see is implemented by flowchart designer)
the other designer is the designer to simulate flowswitch. the implementation code I have pasted last time on this thread. -
19 Ocak 2010 Salı 10:04My problem is (hopefully) the same. However I could not reproduce the steps previously described in this topic.Besides I am very new to WF.I suspect that is because i didn't use rehosted environment. Is that a problem? I prefer not to.So literally I want the same as the topic title states: a custom activity with multiple exit paths. It would be good to use it in the same way as at FlowDecission (pick an end and draw the arrow to the next box)Is that even possible?Ok. I know the answer is probably already given still I find it confusing. Perhaps I'm missing the basics. Anyway I would be very great full for a noob-like explanation. If I could resolve this issue my company would use WF in long term.
-
20 Ocak 2010 Çarşamba 04:50
So literally I want the same as the topic title states: a custom activity with multiple exit paths. It would be good to use it in the same way as at FlowDecission (pick an end and draw the arrow to the next box)
definitely, it's possible.
this flowswitch-like custom activity can be used both in VS and rehost.
first you need to create an custom activity designer inherited compositeview.
I have pasted part of code above you can refer to.
after that, use workflowviewelement to create the flowswitch-like activity, and the multiple-exit behavior is controlled in the compositeview designer.
for any more detail, you may contact me, I can mail you some simple sample code.- Yanıt Olarak İşaretleyen Scott Mason - MSFTModerator 29 Mart 2010 Pazartesi 21:44
-
21 Ocak 2010 Perşembe 00:44
Can someone please post some full sample code?
I need to do the same thing and am struggling to understand how to even get started on this. If someone has done this already and we can see how that was done then I think that would be a great help.
Cheers -
21 Ocak 2010 Perşembe 00:46you may leave your mail here, I can mail you the simple sample code, not that complicated as flowswitch.
-
21 Ocak 2010 Perşembe 01:04Cheers. Can you please send to Matthew.vanBoheemen [at] Gmail.com
-
21 Ocak 2010 Perşembe 01:45I can't send the sample to you, it's said invalid address.
-
21 Ocak 2010 Perşembe 01:47
Seems weird. How about Matthew.vanBoheemen@PayGlobal.com
-
22 Ocak 2010 Cuma 17:24Thank you for your answer! I think i`m getting it. Monday I shall work and try it out.
-
05 Mart 2010 Cuma 21:41
you may leave your mail here, I can mail you the simple sample code, not that complicated as flowswitch.
Ye Yu, could you send me the sample code? gwinn@fairpaysolutions.comthanks -
06 Mart 2010 Cumartesi 10:02Ye Yu,I have has some success with your assistance although I am still having issues around setting up links to other activities in the same way as the flowchart container allows you to do.could you send me the sample code as well please, thanks and much appreciated. My address is sameerx8@gmail.com.Thanks
-
07 Mart 2010 Pazar 05:08I have sent you the sample code.
-
09 Mart 2010 Salı 12:08Hi Ye Yu
Thanks for your responses you really have helped me grasped this particular topic.
I haven't yet received your sample code. perhaps you could send it to schunilall@theunlimitedworld.co.za
Maybe there was an issue sending it to my gmail account.
Thanks once again for all you assistance.
Sameer -
09 Mart 2010 Salı 19:01I have sent to your mail box schunilall@theunlimitedworld.co.za
-
18 Mayıs 2010 Salı 12:57
I have has some success with your assistance, but there are still some problems pending by creating my custom activity with multiple exit paths. (like FlowDecision)
could you send me the sample code as well please?
Mail: bdietric@hsr.ch
Thanks a lot
-
18 Mayıs 2010 Salı 14:43
-
25 Mayıs 2010 Salı 13:53
Hi,
I have the same problem for a custom activity in my master thesis implementation.
Is it possible to share the code with me too?
babak.niknia@gmail
Thanks
-
26 Mayıs 2010 Çarşamba 08:10
By my research, the WF4 flowchart have no extension ability. all the class - FlowNode, FlowStep, FlowNode, FlowDecision is sealed.
The only way to resolve such problem like this thread is to develop a new whole Workflow Designer Container like the flowchart designer.
the WF4 state machine in codeplex (http://wf.codeplex.com/) is a good example, the state machine development team write many code
to implement a Flowchart style designer.
we can see, to implement such a designer container is very complex. we have to use WPF to handle everything, include the drag and drop, drawing connector .
Why did the WF4 team design like this?
this is another example, but don't implement the connector:
WF4 is not good in everything! in WF3, we can easily implement a free form designer, like this:
http://quickflow.codeplex.com/
I hope the WF4's state machine workflow designer can support such extensibility .
-
17 Haziran 2010 Perşembe 13:58
Can anybody share the code with me to - ivan_zdravkov@abv.bg
Thanks
-
17 Haziran 2010 Perşembe 14:20
Can anybody share the code with me to as well? - paras21@o2.pl
-
14 Temmuz 2010 Çarşamba 19:20
-
16 Temmuz 2010 Cuma 08:45
Helo Ye Yu
is 't Possible to send me the sample code: nicolas@essaddam.com .
Thank you
-
16 Temmuz 2010 Cuma 14:29
Hello,
I to would like to get a hold of the source code for your example. could you please email it to lance_wynn@hotmail.com
thanks
Lance
-
20 Temmuz 2010 Salı 13:03
Hi!
Is this thread still alive? I need this exact piece of code so I would be happy if someone could send the sample to me as well - anze@studiopesec.com
Greatly appreciate it!
Regards,
Anže
-
21 Temmuz 2010 Çarşamba 01:56
you can not do this in Flowchart.
if you want it ,the only way it to develop you own flowchart activity.
the StateMachie Workflow in WF4 in a good code example if you want it : http://wf.codeplex.com/
but I think to implement such workflow is very complex.
-
02 Ağustos 2010 Pazartesi 05:11I need it too! May I have one? umaxfun[O]gmail.com
-
02 Ağustos 2010 Pazartesi 13:40I think this thread must be dead... I have not received a reply to my request for the code yet.
-
02 Ağustos 2010 Pazartesi 23:29
Guy:
there is no such code example!
You have no way to extend Flowchart. all it's core classes are sealed.
-
03 Ağustos 2010 Salı 00:36
Jianyi,
I think you are maybe not understanding the proposed solution. The solution as put forth by Ye Yu -MSFT is not to attempt to extend the flowchart, rather to create the functionallity using a WorkflowViewElement to create the same behavior. From Ye YUu's post, it seems like it may be a fairly simple task to do. And he seems to indicate that he has sample code for it, everyone here is just asking for the complete sample that is referenced in the answer to this thread.
-
27 Ağustos 2010 Cuma 08:13
I have sent you the sample code.
Hi Ye Yu,I am trying hard to find out
Can you please send me the sample code also? sharma_swagata@rediffmail.com
-
27 Ağustos 2010 Cuma 08:18
Trust me ,brother.
it's very complex to give the complete code example.
using WorkflowViewElement to implement the same behabvior is very complex.
haha, any one see the complete code example???
NONE!
-
27 Ağustos 2010 Cuma 08:44
Hi Jianyi, Thanx for reply. I am trying out workflowelement.Trust me ,brother.
it's very complex to give the complete code example.
using WorkflowViewElement to implement the same behabvior is very complex.
haha, any one see the complete code example???
NONE!
-
08 Eylül 2010 Çarşamba 06:35Moderatör
I have no problem opening it using link you paste as of now, but it redirects me to a slightly different uri (+b/):
Or possibly blogs.msdn.com had some temporary technical issues...
-
12 Eylül 2010 Pazar 09:07
-
13 Eylül 2010 Pazartesi 11:33
So literally I want the same as the topic title states: a custom activity with multiple exit paths. It would be good to use it in the same way as at FlowDecission (pick an end and draw the arrow to the next box)
definitely, it's possible.
this flowswitch-like custom activity can be used both in VS and rehost.
first you need to create an custom activity designer inherited compositeview.
I have pasted part of code above you can refer to.
after that, use workflowviewelement to create the flowswitch-like activity, and the multiple-exit behavior is controlled in the compositeview designer.
for any more detail, you may contact me, I can mail you some simple sample code.Hi my friend :)
your answer was so helpfull :)
Wuld you please email the sample code for me?
or put it here
thanks a lot.
-
17 Eylül 2010 Cuma 19:56
I would like this sample code as wel, can someone send it to me?
shankarthanu[at]gmail.com
thanks
- Yanıt Olarak Öneren Mohammadreza Taheri 06 Ekim 2010 Çarşamba 10:22
-
06 Ekim 2010 Çarşamba 10:24
- Yanıt Olarak Öneren brook peng 17 Kasım 2010 Çarşamba 03:14
-
17 Kasım 2010 Çarşamba 03:15
hello Ye Yu,
I would like this sample code as wel, can someone send it to me?
thanks
-
10 Mart 2011 Perşembe 23:45Can you please email me the sample code at gilani.irfan@gmail.com
-
08 Nisan 2011 Cuma 10:49
Hi Ye Yu, hi everyone,
I'm interested in getting this famous sample code too :-)
If you want to make someone smile, please send it to engelmatt[at]googlemail[dot]com
Thanks a lot
Matthew
-
29 Nisan 2011 Cuma 13:42
Hello Ye Yu,
can you plaese send me the complete code sample to my email address: sger_wf4@hotmail.de
Thanks a lot
-
29 Nisan 2011 Cuma 14:50
Hello @ all,
does anyone else got the sample code from Ye Yu. If 'yes' could one please send the code to sger_wf4@hotmail.de or publish it in this thread, it would be very helpful.
Thanks and nice weekend
-
11 Mayıs 2011 Çarşamba 01:35
Thank you for the sample. If posisble please send it to hlandry@laskoproducts.com
-
24 Mayıs 2011 Salı 23:51
Hi Ye Yu,
I am also hunting for "Activity that allows multiple exit paths similar to FlowSwitch and FlowDecision" and everytime i look in google you are the star.
Can you please send me the source code for this to anilkrishnagiri@gmail.com
Thanks
Anil
-
25 Mayıs 2011 Çarşamba 18:18
Hi Ye Yu:
I am an student of Cumputer Science in Cuba and I'm working with WF 4 on my thesis. Please, if you could, send me the source code to octavioccl@gmail.con
Thanks
Octavio
Octavio Cesar -
03 Haziran 2011 Cuma 16:43
Hi Ye Yu:
I am also very interested to know how this works. Can you send me the source code? my email address is lchen1999@yahoo.com.
Thanks,
Lanny
- Yanıt Olarak Öneren Imaginesony 22 Haziran 2011 Çarşamba 05:16
-
22 Haziran 2011 Çarşamba 05:18
Hi Ye Yu:
I am also very interested to know how this works. Can you send me the source code please ?
My email address is imaginesony@hotmail.com
Thanks,
Vincent
-
19 Ağustos 2011 Cuma 13:38
Hi Ye Yu, could you send the sample code for this problem.
apbarry At hotmail.com
Cheers
-
31 Ağustos 2011 Çarşamba 14:23
Ye Yu - any chance you can e-mail me a working sample?
Thanks in advance.
David V. Corbin
Microsoft MVP / ALM Ranger
Microsoft MVP / ALM Ranger -
14 Ekim 2011 Cuma 07:29
-
18 Ekim 2011 Salı 11:19Hi, how can I contact you for the sample code of how to create a custom flowchart activity with multiple exit paths?
-
24 Ekim 2011 Pazartesi 06:57
-
24 Ekim 2011 Pazartesi 15:32Rather than emailing a sample to everyone...why not make it a blog post?
-
09 Şubat 2012 Perşembe 10:23
Hi Ye Yu,
Can I also have the sample code? radu.crisan[ at} hotmail. com
Thank you.
-
06 Mart 2012 Salı 12:56
Hi,
I am also interested in this topic.
Could anyone send the sample code to me?
bubbenboy@gmail.com
Or do as Frank said and do a blog post about it =)
Thanks!
-
11 Haziran 2012 Pazartesi 18:26
Anyone willing to send me the sample from YeYu? Thanks!
rparas@albaspectrum.com
Thanks again.
-
12 Haziran 2012 Salı 12:51Anyone?
-
02 Temmuz 2012 Pazartesi 02:57
Anyone willing to send me the sample from YeYu? Thanks!
liaotongquan@foxmail.com
Thanks again.
-
12 Eylül 2012 Çarşamba 08:04
I have bean puzzled by the problem"
create an activity that allows multiple exit paths" for a long time,can you send some sample to me,please.Email:langzixin@outlook.com
-
15 Ekim 2012 Pazartesi 17:52Can you send me the code sample please? ipman76@yahoo.com
-
19 Ekim 2012 Cuma 15:52
Hello Ye Yu,
I'm also interested in this topic. Could you send me this code to jatrans@outlook.com?
Thank you very much.
Jordi
-
07 Aralık 2012 Cuma 16:27