Programmatically using map file doesn't do what I expect

Support for DataSlave

Moderators: Tom, ian

Programmatically using map file doesn't do what I expect

Postby cjs_pro » Mon Aug 14, 2006 5:06 am

Here is what I tried to do:

Phase 1 -- I used DataSlave UI to create a map which contains loading of tables from dbase, validation, transfromation and writing output to SQL server. I saved it as a map file after I tested it working.

Phase 2 -- I expect to use DataSlave SDK APIs to execute the map file generated from Phase 1 to write the output to the SQL server programmatically. So, I wrote a little test code to execute the map file after reading the class library help chm file. The code segment is like:
{
Map map = Runtime.OpenMap(\"C:\\\\Test\\\\Map1.dbm\");
bool result = map.Execute(null);
}
I ran the code and the result is true. However, when I look into the SQL server table, there is no any record. So, I then changed code to the following
{
Map map = Runtime.OpenMap(\"C:\\\\Test\\\\Map1.dbm\");
Guid func_guid = new Guid(\"d1e755fd-1a44-4d37-9af8-366e80831693\");
Functions funcs = map.get_Functions();
Function write_func = (Function)funcs.get_Item(func_guid);
if (write_func != null)
{
bool res = write_func.Execute(null);
}
}
The guid identifies the function (in the map file) that writes to SQL server. However, write_func is always null (checked with debugging) even if the function giud does appear in the map file. I'm just wondering If I misused APIs or something else is going wrong.

By the way, the class API help doesn't detail very well. As an example, public virtual bool Execute(OutputStream output). There is no explanation on the parameter. I guess it status info. Nonetheless, it'd better detail the class library help for a developer to adopt the products easily.

Thanks
cjs_pro
 
Posts: 6
Joined: Thu Aug 10, 2006 11:48 pm

DataSlave Loader and SDK documentation

Postby ian » Mon Aug 14, 2006 6:21 am

I will get you an answer to your specific question, but you may also want to consider using the DataSlave Loader.

Please email support@baycastle.co.uk with your contact details. We will send you information on the Loader and documentation for the SDK.
ian
 
Posts: 364
Joined: Sat Dec 18, 2004 8:13 am
Location: UK

Postby Tom » Wed Aug 16, 2006 9:18 am

The DataSlave SDK documentation and sample projects provide examples of embedding the DataSlave runtime engine into your own applications. Here is a very simple example of how to open then execute a map that has been created using the Map Editor:

    1. Create a new console application.
    2. Reference the baycastle.common.dll and dataslave.runtime.dll assemblies.
    3. Add the following using statements:
    Code: Select all
    using Baycastle.DataSlave;
    using Baycastle.DataSlave.Extensibility;
    using Baycastle.DataSlave.Mapping;
    4. To open and then execute a map use the following
    Code: Select all
    // load available add-ins
    // this must be done before loading any maps!
    Runtime.get_AddIns().ScanAndLoad();

    // open map
    Map map = Runtime.OpenMap(\"c:\\\\temp\\\\map1.dbm\");

    // execute map
    map.Execute(null);
    5. To open and execute a map and examine output use the following
    Code: Select all
    // load available add-ins
    // this must be done before loading any maps!
    Runtime.get_AddIns().ScanAndLoad();

    // open map
    Map map = Runtime.OpenMap(\"c:\\\\temp\\\\map1.dbm\");

    // create output stream to capture map output
    OutputStream output = new OutputStream();

    // execute map
    map.Execute(output);

    // display map output
    foreach (string line in output)
       Console.WriteLine(line);

NOTE: A valid DataSlave licence file (*.lic) must be placed into the same folder where the dataslave.runtime.dll assembly is located, for example when using MS Visual Studio this will normally default to the <Project Folder>\\Bin\\Debug folder.
Tom
Site Admin
 
Posts: 30
Joined: Sat Dec 18, 2004 8:21 am

Postby cjs_pro » Fri Aug 18, 2006 12:10 am

Thanks. ScanAndLoad does make it work for my test case now. The API didn't catch my attention at first look because it doesn't seem to be relavant and lack of description in the API document.
cjs_pro
 
Posts: 6
Joined: Thu Aug 10, 2006 11:48 pm

Re: Programmatically using map file doesn't do what I expect

Postby ian » Sun Jun 06, 2010 8:26 am

You will need to also make sure that the DataSlave Add-Ins needed by the map are in the same location as the application. When running from Visual Studio this will be the bin\debug folder.

You will need at least:

DataSlave.Runtime.dll
DataSlave.UI.dll
DeployLX.Licensing.v3.dll
DotNetMagic2005.dll
apidll.dll
Interop.ADOX.dll
DataSlave.AddIn.TextFile.dll (if reading or writing to text files)
DataSlave.AddIn.MSSQLServer.dll (if reading and writing to SQL Server databases)
Other Add-Ins for data that you are using
Other Add-Ins you use like the Transform, De-Dup, Validate etc.

You may need to experiment a bit.
ian
 
Posts: 364
Joined: Sat Dec 18, 2004 8:13 am
Location: UK

Re: Programmatically using map file doesn't do what I expect

Postby ian » Fri Aug 27, 2010 3:12 pm

The code above is a little old now and since then we have stopped obfuscating the Runtime assembly. Therefore with the latest Runtime assembly please use the following code:-

Code: Select all
 // load available add-ins
            // this must be done before loading any maps!
            Runtime.AddIns.ScanAndLoad();
ian
 
Posts: 364
Joined: Sat Dec 18, 2004 8:13 am
Location: UK

Re: Programmatically using map file doesn't do what I expect

Postby AndyS » Fri Nov 05, 2010 7:57 pm

I was attempting to open\execute a map from a .Net app and hooked it up as suggested.
When I Executed, I get back true on the Execute method which indicates it succeeded.

However, I see no records added to my Database\Table.
If I execute the same Map from DataSlave.MapEditor, it succeeds and my Database\Table gets new records.

Someone mentioned, in a previous post, that...
"A valid DataSlave licence file (*.lic) must be placed into the same folder where the dataslave.runtime.dll assembly ..."

Is this true?
If so, where do I get that .lic file?
I registered DataSlave online.
Thank You.
AndyS
 
Posts: 4
Joined: Mon Nov 01, 2010 2:53 pm

Re: Programmatically using map file doesn't do what I expect

Postby ian » Mon Nov 08, 2010 6:54 pm

Could you please send us, to the support email address, your serial number and we will send you a physical licence file so that you can put this in, for example, in the debug folder.
ian
 
Posts: 364
Joined: Sat Dec 18, 2004 8:13 am
Location: UK


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron