Process Mapping Logo

Process Mapping - Forums

Sharing 19 years of knowledge and experience

 
Metastorm BPM forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
jmodell

New Member
Registered:
Posts: 4
Reply with quote  #1 
I am currently working on migrating some V7 code to V9, and I have run into some server-side script functions that clear variables by passing the variable name as a string to the javascript eval() command, essentially something like this (simplified for readability, the actual functions take lists of variable names and clear them all):

function clearVar(varName)
{
    eval("ework." + varName + " = ework.EMPTY();");
}

Since C# has no eval() command, this is proving hard to translate. There is a method to run text strings as C# code using the CSharpCodeProvider class, which can dynamically compile and execute code, but I have a feeling the performance overhead involved is pretty large and it will probably be slow to execute, since that code has to be compiled every time the function is called. So I am wondering:

1. Has anyone successfully used the CSharpCodeProvider class inside a Metastorm project, and if so was the performance ok?
2. Is there a better way to accomplish what they're doing here? I know I could just set those variables directly in the code that would be calling this function but I do like the elegance of having a script to do it... if it can remain elegant in C#, that is.

TIA for any suggestions.
0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #2 
Yes, it is kinda possible.

In our Change History library we managed to retrieve the data from a Process BO at run time. This is the equivalent of using ework.Variable in version 7, the syntax is like this:

x = process.MapMBO.GetField( "Variable" );

The return is an object, so you may have to convert to a string or cast it as required.

You can also use SetField() on this BO.

The trick was to find the actual type of the Process BO. Once we found that it was Metastorm.Runtime.Core.Maps.Map, the rest was easy. Note that Metastorm, when they saw this code of ours, tried to claim it was unsupported. As it is the ONLY way to access a generic Process at run time without binding to a specific one at compile time, their stand was ridiculous to me.

To pass the process BO to this function, use the object Current from within a process. Unfortunately it appears that you cannot pass a process BO instance from a form in this way, however, so the functionality is not available from a form, only within a process event. If anyone finds a workaround to that, I'd be grateful.

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
jmodell

New Member
Registered:
Posts: 4
Reply with quote  #3 
Helpful as ever Jerome, thanks so much. I will try to look into calling this from a form as well, although if you couldn't get it going my hopes are not high.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:


Create your own forum with Website Toolbox!