| Subject: Dynamic XOML Workflows |
| Group: microsoft.public.windows.developer.winfx.general |
| Date: 12/4/2006 4:15:52 PM |
| From: "Ed" [Email Address Protection] |
Hi, I am relatively new to the WF and have a questions I hope someone can answer. What I want to do is load a dynamically created XOML file (from a database or other storage medium) that will use various methods/events in a class I have created (which is inherited from SequenceActivity). I want this done so that everytime someone needs the particular workflow, they can load the last saved version. This will also allow me to have multiple workflows using the same code base and build an editor to save to xoml. Now I have tried doing this but my workflow CodeActivities never run and I get no errors. So my question is is this possible? I have posted sample code below. Sorry if this is not clear enough. Workflow code: using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Collections; using System.Drawing; using System.Workflow.ComponentModel.Compiler; using System.Workflow.ComponentModel.Serialization; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Workflow.Runtime; using System.Workflow.Activities; using System.Workflow.Activities.Rules; namespace TestWorkflow { public partial class NoXAML : SequenceActivity { public void codeActivity1_ExecuteCode(object sender, EventArgs e) { System.Windows.Forms.MessageBox.Show("Execute 1"); } public void codeActivity2_ExecuteCode(object sender, EventArgs e) { System.Windows.Forms.MessageBox.Show("Execute 2"); } } } Here is my winform invoking the workflow: private void button3_Click(object sender, EventArgs e) { try { using (StreamReader sr = new StreamReader(@"..\..\XAML\testing.xoml")) { XmlReader xamlReader = new XmlTextReader(sr); WorkflowInstance inst = _WFRuntime.CreateWorkflow(xamlReader); inst.Start(); } } catch (System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException exp) { StringBuilder errors = new StringBuilder(); foreach (System.Workflow.ComponentModel.Compiler.ValidationError error in exp.Errors) { errors.AppendLine(error.ToString()); } MessageBox.Show(errors.ToString(), "Validation errors"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } and here is the xoml file I am loading: <ns0:NoXAML xmlns:ns0="clr-namespace:TestWorkflow;Assembly=TestWorkflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" x:Name="NoXAML" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow"> <CodeActivity x:Name="codeActivity1" ExecuteCode="codeActivity1_ExecuteCode" /> <CodeActivity x:Name="codeActivity2" ExecuteCode="codeActivity2_ExecuteCode" /> </ns0:NoXAML> Can anyone help? Thanks, E |
| Back |
| Subject: Re: Dynamic XOML Workflows |
| Group: microsoft.public.windows.developer.winfx.general |
| Date: 3/13/2007 6:54:04 PM |
| From: "Bryan Phillips" [Email Address Protection] |
Where is the code for the CodeActivities that you are using in the workflow? -- Bryan Phillips MCSD, MCDBA, MCSE Blog: http://bphillips76.spaces.live.com "Ed" <ede@nait.ab.ca> wrote in message news:1165274152.222909.284020@16g2000cwy.googlegroups.com: > Hi, > > I am relatively new to the WF and have a questions I hope someone can > answer. > > What I want to do is load a dynamically created XOML file (from a > database or other storage medium) that will use various methods/events > in a class I have created (which is inherited from SequenceActivity). > I want this done so that everytime someone needs the particular > workflow, they can load the last saved version. This will also allow > me to have multiple workflows using the same code base and build an > editor to save to xoml. Now I have tried doing this but my workflow > CodeActivities never run and I get no errors. So my question is is > this possible? I have posted sample code below. Sorry if this is not > clear enough. > > > > Workflow code: > > using System; > using System.ComponentModel; > using System.ComponentModel.Design; > using System.Collections; > using System.Drawing; > using System.Workflow.ComponentModel.Compiler; > using System.Workflow.ComponentModel.Serialization; > using System.Workflow.ComponentModel; > using System.Workflow.ComponentModel.Design; > using System.Workflow.Runtime; > using System.Workflow.Activities; > using System.Workflow.Activities.Rules; > > namespace TestWorkflow > { > public partial class NoXAML : SequenceActivity > { > public void codeActivity1_ExecuteCode(object sender, EventArgs > e) > { > System.Windows.Forms.MessageBox.Show("Execute 1"); > } > > public void codeActivity2_ExecuteCode(object sender, EventArgs > e) > { > System.Windows.Forms.MessageBox.Show("Execute 2"); > } > } > } > > Here is my winform invoking the workflow: > > private void button3_Click(object sender, EventArgs e) > { > try > { > using (StreamReader sr = new > StreamReader(@"..\..\XAML\testing.xoml")) > { > XmlReader xamlReader = new XmlTextReader(sr); > WorkflowInstance inst = > _WFRuntime.CreateWorkflow(xamlReader); > inst.Start(); > } > } > catch > (System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException > exp) > { > StringBuilder errors = new StringBuilder(); > foreach > (System.Workflow.ComponentModel.Compiler.ValidationError error in > exp.Errors) > { > errors.AppendLine(error.ToString()); > } > MessageBox.Show(errors.ToString(), "Validation > errors"); > } > catch (Exception ex) > { > MessageBox.Show(ex.Message); > } > > } > > > and here is the xoml file I am loading: > > <ns0:NoXAML > xmlns:ns0="clr-namespace:TestWorkflow;Assembly=TestWorkflow, > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" > x:Name="NoXAML" > xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow"> > <CodeActivity x:Name="codeActivity1" > ExecuteCode="codeActivity1_ExecuteCode" /> > <CodeActivity x:Name="codeActivity2" > ExecuteCode="codeActivity2_ExecuteCode" /> > </ns0:NoXAML> > > > > Can anyone help? > > Thanks, > > E |
| Back |