![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Dynamic XOML Workflows 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 |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Dynamic XOML Workflows 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 |
My System Specs![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dynamic MultiBinding? | Some Bloke | Avalon | 1 | 06-06-2008 10:35 AM |
| Can't set up Dynamic Drive | John Lechmanik | Vista installation & setup | 4 | 03-27-2008 04:17 PM |
| Dynamic Backgrounds | Martin | Live Messenger | 0 | 12-06-2007 12:53 PM |
| dynamic disk | scrooge | Vista performance & maintenance | 2 | 09-18-2007 03:42 AM |