Using TableRelation with Microsoft Script

Everything to do with the DnpUtils plugin for MyGeneration

Using TableRelation with Microsoft Script

Postby dnparsons on Wed Feb 15, 2006 9:32 pm

Adrian Tanase emailed me and asked if DnpUtils TableRelation worked with templates using Microsoft script (JScript in particular.) I've used TrimSpaces and caching, but never tried TableRelation in an older template. I was experimenting a bit with VBScript, but can't seem to get around the namespace. I've tried quite a few variations of this, but keep getting Class not found errors:

Code: Select all
...
For Each foreignKey In tableMeta.ForeignKeys
   Dim tr
   Set tr = New Dnp.Utils.TableRelation(tableMeta, foreignKey)
...

Perhaps someone more familiar with Microsoft script could point me in the right direction. I'm starting to think it would require a modification to the plugin.
David Neal Parsons
EntitySpaces
User avatar
dnparsons
Lieutenant General
 
Posts: 292
Joined: Sun Jan 09, 2005 2:10 pm
Location: Miami, Florida

Postby justin.greenwood on Wed Feb 15, 2006 10:32 pm

The easiest thing to do is add a few methods on the dnputils intrinsic object that will instantiate all object types. like:

JSCRIPT
Code: Select all
var tableRel = dnputils.CreateTableRelation(tableMeta, foreignKey);
User avatar
justin.greenwood
Site Admin
 
Posts: 441
Joined: Sat Apr 03, 2004 6:10 am
Location: Indianapolis, IN

Postby dnparsons on Fri Feb 17, 2006 6:57 am

Thanks, Justin. I suspected as much. Seems like the best way to support them without risk of breaking something. Maybe this weekend.
David Neal Parsons
EntitySpaces
User avatar
dnparsons
Lieutenant General
 
Posts: 292
Joined: Sun Jan 09, 2005 2:10 pm
Location: Miami, Florida

More specific example

Postby bdeline on Sun Jun 18, 2006 11:32 pm

Hi,
So i'm trying to follow along with creating an intrinsic object so I can create a tablerelation in a vbscript template. I believe I am supposed to create a reference in the zeusconfig.xml file like so

Code: Select all
<IntrinsicObject assembly=\"%ZEUSHOME%\\Dnp.Utils.dll\" classpath=\"Dnp.Utils.TableRelation\" varname=\"CreateTableRelation\" />


However, I'm getting a TargetParameterCountException when running my template. I'm assuming this is because the TableRelation contructor requires input parameters. Any idea how I get this to work?
Thanks.
Brett
bdeline
Lurker
 
Posts: 4
Joined: Mon Oct 03, 2005 12:36 am

Postby dnparsons on Mon Jun 19, 2006 5:26 am

Hmmm... I did not try anything like that. Perhaps I mis-understood Justin's post, but what I did was add a method to the Utils class:

Code: Select all
public TableRelation CreateTableRelation(ITable tableMeta, IForeignKey foreignKey)
{
   TableRelation tr = new TableRelation(tableMeta, foreignKey);
   return tr;
}


I was able to get it working in a JScript template, but never did get that, or anything else, to work in a VBScript template. If you, or anyone else, is interested in taking this further, I added DnpUtils_116Beta.zip to the DnpUtils Plugin Archive. There is a message posted at the bottom of the archive that describes its contents.
David Neal Parsons
EntitySpaces
User avatar
dnparsons
Lieutenant General
 
Posts: 292
Joined: Sun Jan 09, 2005 2:10 pm
Location: Miami, Florida

Postby bdeline on Mon Jun 19, 2006 10:57 am

It didn't cross my mind to actually update the dnp class, though it seems to make sense to do. I will give that a shot and let you know if I can get it working in my vbscript template.
Thanks.
bdeline
Lurker
 
Posts: 4
Joined: Mon Oct 03, 2005 12:36 am

Use of TableRelation in Javascript

Postby monroecheeseman on Wed Dec 13, 2006 1:50 pm

Can't seem to get the TableRelation to work in JavaScript. Here's my code

Code: Select all
      for (var i = 0; i < objTable.ForeignKeys.Count; i++)
   {
      var objColumn = objTable.ForeignKeys.Item(i);
      var tr = new DnpUtils.TableRelation(objTable, objColumn);
      CreateForiegnDropDown(objColumn.PrimaryTable.Name,objColumn.PrimaryColumns.Item(0).Name );
      output.autotabln(objColumn.PrimaryColumns.Item(0).Name + \":\" + objColumn.PrimaryTable.Name);
      output.autotabln(objTable.Name);
   }


I get a runtime error \"object expected\" on the TableRelation, even though it seems that objColumn and objTable work for the output statements. Ideas? I have been using SetCamelCase with no problems.
monroecheeseman
Private First Class
 
Posts: 12
Joined: Thu Jun 30, 2005 10:37 pm

Postby justin.greenwood on Wed Dec 13, 2006 2:00 pm

Let me end this thread by answering your question. Building an API that is compatible with the Microsoft Script Control has to be done consciously. DNPUtils was not written with MicrosoftScript in mind. In order to make it available in mygeneration at all, I had to make the non-compatable types and members invisable to COM like so:
Code: Select all
[ComVisible(false)]
public Hashtable ReadUserMap(string mapFileName, string mapGroupType, MyMeta.dbRoot myMeta)
...
[ComVisible(false)]
public TableRelation CreateTableRelation(ITable tableMeta, IForeignKey foreignKey)
...
[ComVisible(false)]
public class TableRelation


If Mr Parsons or yourself would like to make a complimentary COM compatible API for the table relation stuff, I would be happy to update the mygeneration installer with the new files. I'm sure we'll be doing a small service release in the next month or two with bug fixes. If you take out the ComVisible(false) attributes in the currect build, all MicrosoftScript templates will crash all the time. Not good!
User avatar
justin.greenwood
Site Admin
 
Posts: 441
Joined: Sat Apr 03, 2004 6:10 am
Location: Indianapolis, IN


Return to DnpUtils Plugin

Who is online

Users browsing this forum: No registered users and 0 guests

cron