Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > WinFX General

Dynamic XOML Workflows

Update your Vista Drivers Update Your Drivers Now!!
 
 
Thread Tools Display Modes
Old 12-04-2006   #1 (permalink)
Ed
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 SpecsSystem Spec
Old 03-13-2007   #2 (permalink)
Bryan Phillips
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 SpecsSystem Spec
 

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


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51