Process Mapping Logo

Process Mapping - Forums

Sharing 19 years of knowledge and experience

 
Metastorm BPM forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #1 
The lack of a script debug mode often makes it nescessary to 'trace' what is happening in a sever side script. You cannot use dialogs as it happens in a service process, so writing to a text file is the only way to do this effectively.

This can be a nusiance, and sometimes 'trace' statements remain in production code, which can cause performance loss and may cause the procedure to fail if the directory used does not exist.

We use the following method:

We use the following snippet in a common library:
                                       
Code:
///////////////////////////////////////////////
// set this to one so each new run starts a new trace file
var iNewTraceFile = 1;
// set the maximum trace level, eg if set to 2, level 1 & 2 will be output
var iMaxTraceLevel = 1;
///////////////////////////////////////////////
function Trace( sText, iLevel )
{
    if ( arguments.length < 2 )
        iLevel = 1;
       
    if ( iLevel <= iMaxTraceLevel )   
        ework.WriteText( sText,"c:\\test.txt", iNewTraceFile );
    // set to 0 after the first statement
    iNewTraceFile = 0;
}

Then we just add something like:
                                       
Code:
Trace( "myVariable = " + myVariable, 1);

When we want to turn of tracing you can just set the iMaxTraceLevel to 0. It is actually even simpler to release files, as we have a 'Release Library' of the same name published on the production database (or sent to a customer) which has a dummy Trace function like:
                                       
Code:
// dummy function for Release files
function Trace( sText, iLevel )
{
}

and whenever the procedure is published to the production server (or sent to a customer to publish) all trace statements inadvertantly left in just do nothing.

The Trace function and levels I must attribute to PresuminEd, the dummy function was my approach to implementing in e-work his method of disabling tracing in the Release version of the Engine.

BTW, this may be redundant if you can get dot net debugging up and going.

__________________
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
Meatstorm

Member
Registered:
Posts: 34
Reply with quote  #2 

another approach which i've used a few times is to write to the Windows Application Log...it can be done in your script via 2 lines of code:

 

var gobjShell = new ActiveXObject("WScript.Shell");
gobjShell.LogEvent(2, "test error message");

 

changing the number from 2 to 1 will make it show up as an "Error" rather than a "Warning"

0
infomaven

Member
Registered:
Posts: 22
Reply with quote  #3 
"...BTW, this may be redundant if you can get dot net debugging up and going."

How do you do this with Metastorm? I'd be interested in doing this.


__________________
without software, your computer would be a mighty expensive doorstop....
0
Doogal

Avatar / Picture

Guru
Registered:
Posts: 1,564
Reply with quote  #4 
It depends. Do you want to debug JScript.NEt or assmblies you're using from JScript.NET? The latter is pretty simple (providing you've got debug versions of your assemblies), just add a call to debugger; in your JScript.NET code somewhere and this should kick off Visual Studio when it gets hit and if you're lucky Visual Studio will locate your source code.

I'm not sure if debugging JScript.NET code is possible. I did get debugging of server-side code working once, but I can't remember if it was JScript or JScript.NET and I've no idea how I got it working
0
infomaven

Member
Registered:
Posts: 22
Reply with quote  #5 
Actually I was hoping to debug my serverside VBScripts. We don't use JScript very much.



__________________
without software, your computer would be a mighty expensive doorstop....
0
Doogal

Avatar / Picture

Guru
Registered:
Posts: 1,564
Reply with quote  #6 

VBScript will be pretty much like JScript I'd imagine, but I don't know of a reliable way of getting debugging to work. If anybody knows, I am all ears!

0


Registered:
Posts: N/A
Reply with quote  #7 
If you're referencing a c# assembly from a JScript.NET script, you can attach to the dllhost (if the engine is running) and debug your assembly.

Cheers
0
infomaven

Member
Registered:
Posts: 22
Reply with quote  #8 
I wish we were using C#... but no such luck.
I'm having to learn vb.net and vbscript    >:(

Can you reference vb.net assemblies in the same manner?

__________________
without software, your computer would be a mighty expensive doorstop....
0
Doogal

Avatar / Picture

Guru
Registered:
Posts: 1,564
Reply with quote  #9 

You can reference .NET assemblies written in any .NET language, but you have to call them from JScript.NET, since it's the only .NET langauge supported in the Designer 

0
Sanatan

Member
Registered:
Posts: 31
Reply with quote  #10 
Hi folks, I am interested to learn about this debugging technique when using a .Net Assembly.

I have a C# assemply deployed as a .dll in the Metastorm Engine\dotnetlib folder. I have also added this to the GAC.

Now the DLL class method is invoked from an form button code using JScript.Net Server Script.

I want to know how to step-through-debug the DLL code when clicking on the form button on my client? Please assist.
0
Doogal

Avatar / Picture

Guru
Registered:
Posts: 1,564
Reply with quote  #11 
Well you can learn all about this on our Metastorm/.NET training course...

But blatant advertising aside, the best approach I find is to attach to the engine process (dllhost.exe) from Visual Studio when I've got the assmebly project open. Then add a breakpoint in your code. Not sure whether this works with assemblies installed in the GAC though.
0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #12 
Quote:
Originally Posted by vicky
Hi,

Context of the problem:

I have a Command button with Button action set to "Client operation" and "server operation"
I have a server side script that inserts data in database is executed on server event as well as client extension scripts that redirects to another applicaion url.

Description of the Probelm:

on button click,client scripts executed first by redirecting to url and then inserts values in database.

Is it possible to insert data in database first and then redirect to url using client script. ?
Or Is there any way to redirect to url from server script ?

If anybody had came across similar scenario please suggest somthing.

Thanks in advance.


Set a timed client script to run a couple of seconds after the first click with SetTimeout(), I think, in the first button client script. That script can click a second button.

You can search here for starting client scripts after server scripts to find an example of two.

You would be better off starting a new thread rather then adding to an unrelated thread.

__________________
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
Previous Topic | Next Topic
Print
Reply

Quick Navigation:


Create your own forum with Website Toolbox!