How to define workflow data by usind GUI?

Greetings,

I am a beginner in the field of WWF. I am about re-hosting the designer in windows application. The end-user will take the responsibility of designing the business process. but I need your help.

I got some questions:

tWhen I tried the re-hosted lab. The program doesn't allow me to rename the workflow and an error massage appeared and stop execution at this point

publicvoid UpdateTypeName(string oldClassName,string newClassName)

{

àthrownewNotImplementedException();

}

tI want the user to be able to define parameters (variables to be used within workflow) for all workflow at the beginning then he can assign each properties to the corresponding activities as in or out properties, or even allow an activity to change its value..

tI want to change the appearance of activityBind dialog and ruleSet dialog to filter out some of its fields…

tWith if else activity I just the rule condition appear without letting user to select between code or rule condition.

tI want to save the workflow definitions in database. If any one has a suggestion of how to do it. If there is a sample?

Can I do this?!! Pls help me

[6034 byte] By [NMM] at [2007-12-27]
# 1

The official abbreviation for Windows Workflow Foundation is WF, please do not use WWF since it is already taken.

NMM wrote:

t When I tried the re-hosted lab. The program doesn't allow me to rename the workflow and an error massage appeared and stop execution at this point

public void UpdateTypeName(string oldClassName, string newClassName)

{

à throw new NotImplementedException();

}

Try the following:

public void UpdateTypeName(string oldClassName, string newClassName)

{

// Get the code type declaration.

int loc = oldClassName.LastIndexOf('.');

CodeTypeDeclaration codeTypeDecl = GetCodeTypeDeclFromCodeCompileUnit(oldClassName.Substring(0, loc), oldClassName.Substring(loc + 1));

ITypeProvider typeProvider = this.ServiceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;

((TypeProvider)typeProvider).RefreshCodeCompileUnit(this.loader.CodeBesideCCU, new EventHandler(RefreshCCU));

}

If the GetCodeTypeDeclFromCodeCompileUnit method does not exist download the version from Vihang’s article here.

NMM wrote:

t I want the user to be able to define parameters (variables to be used within workflow) for all workflow at the beginning then he can assign each properties to the corresponding activities as in or out properties, or even allow an activity to change its value..

You will need to come up with some kind of dialog for adding properties / variables. Once you know the name and type you can add using the following code:

// Get the code type declaration associated with the workflow’s class.

int loc = className.LastIndexOf('.');

CodeTypeDeclaration codeTypeDecl = GetCodeTypeDeclFromCodeCompileUnit(className.Substring(0, loc), className.Substring(loc + 1));

// Create and add variable.

CodeMemberField variable = new CodeMemberField(typeof(string), "paramOne");

codeTypeDecl.Members.Add(variable);

// Create and add property

CodeMemberProperty prop = new CodeMemberProperty();

prop.Name = "ParamOne";

prop.Attributes = MemberAttributes.Public;

prop.Type = new CodeTypeReference(typeof(string));

prop.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression(variable.Name)));

prop.SetStatements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(variable.Name), new CodeVariableReferenceExpression("value")));

codeTypeDecl.Members.Add(prop);

NMM wrote:

t I want to change the appearance of activityBind dialog and ruleSet dialog to filter out some of its fields…

t With if else activity I just the rule condition appear without letting user to select between code or rule condition.

Neither of these can be done. None of the built in dialogs are configurable and you can only filter which conditions can be displayed for properties on your own custom activities with ActivityCondition properties. See my blog post here for more information on how to do this.

NMM wrote:

t I want to save the workflow definitions in database. If any one has a suggestion of how to do it. If there is a sample?

Take a look at the External Ruleset demo found here.

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

I designed a form that gathers the workflow's properties. But the problem is that I don't know where I should place this code. A lot of compilation errors had been occurred.

The problem is with className from where should I assign its value and again in with file should I place this code (in the re-hosted sample.

Thanks a lot

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

I assume you don't know where to put the code for adding the properties? If so, the code I gave previously was the generic code for adding a property and variable once you have the CodeTypeDeclaration.The MemberCreationService already has a method for adding a Property:

memberCreationService.CreateProperty(className, "ParamOne", typeof(string), null, true, false, false, workflow.GetType(), false);

Which will generate the following:

public static System.Workflow.ComponentModel.DependencyProperty ParamOneProperty = DependencyProperty.Register("ParamOne", typeof(System.String), typeof(foo.Workflow1));

public string ParamOne

{

get

{

return ((string)(base.GetValue(foo.Workflow1.ParamOneProperty)));

}

set

{

base.SetValue(foo.Workflow1.ParamOneProperty, value);

}

}

So what you need to do is expose the MemberCreationService which you can get in the WorkflowDesignerControl class with the following:

MemberCreationService memberCreationService = GetService(typeof(IMemberCreationService)) as MemberCreationService;

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

the property name, type and class name are compulsory to call create property and get accurate results. My problem is I don't know what is wrong about setting the class name

the code that I wrote to handle adding new properties is as follow:

in WorkflowDesignerControl.cs

public void AssignProp()

{

string name, className;

className = TypeName;

MemberCreationService memberCreationService =

GetService(typeof(IMemberCreationService)) as MemberCreationService;

WorkflowProporeties prop = new WorkflowProporeties();

// the dialog that collect the new properties

prop.ShowDialog();

name = prop.Name;

memberCreationService.CreateProperty(

className, name, typeof(string), null, true, false, false,workflow.GetType(), false);

}

when I set calssName = TypeName;

the program hanged in the statement

private bool DoesPropertyExist(string className, string propertyName, Type propertyType)

{

... ...

àType typeDeclaration = typeProvider.GetType(className, true);

... ...

}

and I got the following error massage

System.Exception was unhandled

Message="Type name 'Workflow1' could not be resolved to a valid Type."

Source="System.Workflow.ComponentModel"

StackTrace:at System.Workflow.ComponentModel.Compiler.TypeProvider.GetType(String name, Boolean throwOnError)

at WorkflowDesignerControl.MemberCreationService.DoesPropertyExist(String className, String propertyName, Type propertyType) in C:\Documents and Settings\Nada \My Documents\myTestLab\WorkflowDesignerControl\Designer Rehosting\WorkflowDesignerControl\MemberCreationService.cs:line 574

at WorkflowDesignerControl.MemberCreationService.CreateProperty(String className, String propertyName, Type propertyType, AttributeInfo[] attributes, Boolean emitDependencyProperty, Boolean isMetaProperty, Boolean isAttached, Type ownerType, Boolean isReadOnly) in C:\Documents and Settings\Nada \My Documents\myTestLab\WorkflowDesignerControl\Designer Rehosting\WorkflowDesignerControl\MemberCreationService.cs:line 184

at WorkflowDesignerControl.WorkflowDesignerControl.AssignProp() in C:\Documents and Settings\Nada \My Documents\myTestLab\WorkflowDesignerControl\Designer Rehosting\WorkflowDesignerControl\WorkflowDesignerControl.cs:line 238

at WorkflowDesignerExample.WindowsFormApp.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Nada \My Documents\myTestLab\WorkflowDesignerControl\Designer Rehosting\WorkflowDesignerExample\WindowsFormApp.cs:line 318

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(Form mainForm)

at WorkflowDesignerExample.Program.Main() in C:\Documents and Settings\Nada \My Documents\myTestLab\WorkflowDesignerControl\Designer Rehosting\WorkflowDesignerExample\Program.cs:line 31

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

what's wrong in this? How can I solve it... Pls help me as you always do

NMM at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5
You need to pass the fully qualified class name, namespace + class name. If you are using the default namespace that the sample has it should be foo.Workflow1 instead of Workflow1.
TomLake-MSFT at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified