Posted: Wed Aug 03, 2005 7:43 am
Just some follow up in case some else picks up this thread...
I did some more digging and see that there are some COM objects out there like 'DataStage Object Server' [vmdsobj.dll] which Interop can wrap around but I didn't see any methods to log into a server like DSSetServerParams().
Here's what I have so far. This will let you log into a server and get an ArrayList of Projects on that server. I got stuck at getting a list of jobs for the given project since the call to DSGetProjectInfo returns a DSPROJECTINFO C/C++ struct. Somehow there must be a way to wrap the struct which is viewable in 'dsapi.h' in the 'Ascential\DataStage\Dsdk\include' directory.
I did some more digging and see that there are some COM objects out there like 'DataStage Object Server' [vmdsobj.dll] which Interop can wrap around but I didn't see any methods to log into a server like DSSetServerParams().
Here's what I have so far. This will let you log into a server and get an ArrayList of Projects on that server. I got stuck at getting a list of jobs for the given project since the call to DSGetProjectInfo returns a DSPROJECTINFO C/C++ struct. Somehow there must be a way to wrap the struct which is viewable in 'dsapi.h' in the 'Ascential\DataStage\Dsdk\include' directory.
Code: Select all
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Text;
namespace DataStageConsole
{
/// <summary>
/// Summary description for DataStageLibrary.
/// </summary>
/// <remarks>
/// Abandoned this class after a few hour of testing. Not sure how to represent C/C++ structures
/// in .NET. See the notes in GetJobList() - follow the link to google groups.
/// </remarks>
public class DataStageLibrary
{
private const string DLLPATH = "vmdsapi.dll";
public DataStageLibrary()
{
}
public void SetServerParams(string ServerName, string UserName, string Password)
{
DSSetServerParams(ServerName, UserName, Password);
}
public ArrayList GetProjectList()
{
IntPtr p = DSGetProjectList();
return this.GetStringArrayFromApi(p);
}
[DllImport(DLLPATH)]
private static extern void DSSetServerParams(string ServerName, string UserName, string Password);
[DllImport(DLLPATH)]
private static extern IntPtr DSGetProjectList();
// public ArrayList GetJobList(string ProjectName)
// {
// // Open the project
// IntPtr project = DSOpenProject(ProjectName);
//
// // The data comes back as a struct... apparantly someone else also had trouble with this stuff:
// //
// // http://groups-beta.google.com/groups?hl=en&lr=&q=DSPROJECTINFO&qt_s=Search
//
// // Close the project
// DSCloseProject(project);
// }
// [DllImport(DLLPATH)]
// private static extern IntPtr DSGetProjectInfo(IntPrt DSPROJECT, int InfoType, );
[DllImport(DLLPATH)]
private static extern IntPtr DSOpenProject(string ProjectName);
[DllImport(DLLPATH)]
private static extern int DSCloseProject(IntPtr DSPROJECT);
private ArrayList GetStringArrayFromApi(IntPtr api)
{
ArrayList arr = new ArrayList();
int idx = 0;
bool endFound = false;
StringBuilder curr = new StringBuilder();
do
{
byte byt = Marshal.ReadByte(api,idx++);
char c = (char)byt;
if(byt!='\0')
{
curr.Append((char)byt);
}
else
{
arr.Add(curr.ToString());
curr = new StringBuilder();
byte end = Marshal.ReadByte(api,idx);
if(end=='\0') endFound = true;
}
} while (!endFound);
return arr;
}
}
}