Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sample code in VB.Net in LAPI

Status
Not open for further replies.

pando

Technical User
Jun 22, 2003
7
PH
hi,

Is there anyone who can provide me a sample in LAPI using VB.NET?

I have tried LAPI in VB6 but find it hard to use it VB.Net.

Thanks,

 
Have you looked at WebServices instead of LAPI to work with .Net ?
 
Below I've pasted the sample from Livelink SDK's LAPI Help.
The code is written in C#. check it out.(I haven't tested it)

ggriffit, what webservices are you talking about?? can u please provide more information on livelink webservices??

using System;

using com.opentext.api;

namespace AddDeleteDocument
{
class AddDeleteDocument
{
[STAThread]
static void Main(string[] args)
{

try
{

LLSession session = null;
LAPI_DOCUMENTS documents = null;

int status = 0;
int nodeID = 0;
int parentID = 0;
int nodeVol = 0;
int parentVol = 0;

LLValue pwsInfo = ( new LLValue() ).setAssocNotSet();
LLValue objInfo = ( new LLValue() ).setAssocNotSet();
LLValue versionInfo = ( new LLValue() ).setAssocNotSet();

// Instantiate session object
session = new LLSession( server, port, "",
Livelink_UID, UID_pw, null );

// Instantiate documents object
documents = new LAPI_DOCUMENTS( session );

// Access the user's Personal Workspace
status = documents.AccessPersonalWS( pwsInfo );

if ( status == 0 )
{
Console.WriteLine( "Accessed Personal Workspace" );
parentVol = pwsInfo.toInteger( "VolumeID" );
parentID = pwsInfo.toInteger( "ID" );
}

if ( status == 0 )
{
// Add document
status = documents.AddDocument( parentVol, parentID,
title, file,
objInfo, versionInfo );

if ( status == 0 )
{
Console.WriteLine( "Added document" );

nodeVol = objInfo.toInteger( "VolumeID" );
nodeID = objInfo.toInteger( "ID" );
}
}

if ( status == 0 )
{
// Delete document
status = documents.DeleteObject( nodeVol, nodeID );

if ( status == 0 )
{
Console.WriteLine( "Deleted document" );
}
}

// Handle any errors
if ( status != 0 )
{
// Display status code in both integer and hex
System.Console.WriteLine( "Status=" + status +
" (0x" + Convert.ToString( status, 16 ) +")" );

// If the session handle is valid, get the session's error
// information
if ( session != null )
{
// Get the error information
int stat = session.getStatus();
string message = session.getStatusMessage();
string errMsg = session.getErrMsg();
string apiError = session.getApiError();

Console.WriteLine( "Session failure status is " + stat +
" (0x" + Convert.ToString( stat ) + ")" );

if ( message != "" || errMsg != "" || apiError != "" )
{
Console.WriteLine( "Message=" + message );
Console.WriteLine( "errMsg=" + errMsg );
Console.WriteLine( "apiError=" + apiError );
}
}
}


Console.WriteLine( "End of sample" );
}

catch ( Exception e )
{
// Display exception
Console.WriteLine( "Application encountered an exception:" );
Console.WriteLine( e.Message );
Console.WriteLine( e.StackTrace );
}

}
}
}
 
Thank you ohmyigod but I have tried already that example from Lapi Help.

Below is a sample in VB.Net that creates a Livelink user. Can you help me or anyone help me retrieve users list?

Imports com.opentext.api

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents btnConnect As System.Windows.Forms.Button
Friend WithEvents lblStatus As System.Windows.Forms.Label
Friend WithEvents txtPassword As System.Windows.Forms.TextBox
Friend WithEvents txtUserName As System.Windows.Forms.TextBox
Friend WithEvents txtDatabaseName As System.Windows.Forms.TextBox
Friend WithEvents txtPortNo As System.Windows.Forms.TextBox
Friend WithEvents txtServerName As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.btnConnect = New System.Windows.Forms.Button()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.txtPassword = New System.Windows.Forms.TextBox()
Me.txtUserName = New System.Windows.Forms.TextBox()
Me.txtDatabaseName = New System.Windows.Forms.TextBox()
Me.txtPortNo = New System.Windows.Forms.TextBox()
Me.txtServerName = New System.Windows.Forms.TextBox()
Me.Label5 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.lblStatus = New System.Windows.Forms.Label()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'btnConnect
'
Me.btnConnect.Location = New System.Drawing.Point(328, 16)
Me.btnConnect.Name = &quot;btnConnect&quot;
Me.btnConnect.Size = New System.Drawing.Size(75, 24)
Me.btnConnect.TabIndex = 0
Me.btnConnect.Text = &quot;Connect&quot;
'
'GroupBox1
'
Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtPassword, Me.txtUserName, Me.txtDatabaseName, Me.txtPortNo, Me.txtServerName, Me.Label5, Me.Label4, Me.Label3, Me.Label2, Me.Label1})
Me.GroupBox1.Name = &quot;GroupBox1&quot;
Me.GroupBox1.Size = New System.Drawing.Size(312, 184)
Me.GroupBox1.TabIndex = 1
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = &quot;GroupBox1&quot;
'
'txtPassword
'
Me.txtPassword.Location = New System.Drawing.Point(112, 152)
Me.txtPassword.Name = &quot;txtPassword&quot;
Me.txtPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtPassword.TabIndex = 9
Me.txtPassword.Text = &quot;lando&quot;
'
'txtUserName
'
Me.txtUserName.Location = New System.Drawing.Point(112, 120)
Me.txtUserName.Name = &quot;txtUserName&quot;
Me.txtUserName.TabIndex = 8
Me.txtUserName.Text = &quot;lando&quot;
'
'txtDatabaseName
'
Me.txtDatabaseName.Location = New System.Drawing.Point(112, 88)
Me.txtDatabaseName.Name = &quot;txtDatabaseName&quot;
Me.txtDatabaseName.Size = New System.Drawing.Size(192, 20)
Me.txtDatabaseName.TabIndex = 7
Me.txtDatabaseName.Text = &quot;Livelink&quot;
'
'txtPortNo
'
Me.txtPortNo.Location = New System.Drawing.Point(112, 56)
Me.txtPortNo.Name = &quot;txtPortNo&quot;
Me.txtPortNo.Size = New System.Drawing.Size(56, 20)
Me.txtPortNo.TabIndex = 6
Me.txtPortNo.Text = &quot;2099&quot;
'
'txtServerName
'
Me.txtServerName.Location = New System.Drawing.Point(112, 24)
Me.txtServerName.Name = &quot;txtServerName&quot;
Me.txtServerName.Size = New System.Drawing.Size(192, 20)
Me.txtServerName.TabIndex = 5
Me.txtServerName.Text = &quot;landz&quot;
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(8, 152)
Me.Label5.Name = &quot;Label5&quot;
Me.Label5.Size = New System.Drawing.Size(56, 16)
Me.Label5.TabIndex = 4
Me.Label5.Text = &quot;Password&quot;
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(8, 120)
Me.Label4.Name = &quot;Label4&quot;
Me.Label4.Size = New System.Drawing.Size(64, 16)
Me.Label4.TabIndex = 3
Me.Label4.Text = &quot;Username&quot;
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 88)
Me.Label3.Name = &quot;Label3&quot;
Me.Label3.Size = New System.Drawing.Size(100, 16)
Me.Label3.TabIndex = 2
Me.Label3.Text = &quot;Database Name&quot;
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 56)
Me.Label2.Name = &quot;Label2&quot;
Me.Label2.Size = New System.Drawing.Size(48, 16)
Me.Label2.TabIndex = 1
Me.Label2.Text = &quot;Port No&quot;
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 24)
Me.Label1.Name = &quot;Label1&quot;
Me.Label1.Size = New System.Drawing.Size(72, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = &quot;Server Name&quot;
'
'lblStatus
'
Me.lblStatus.Location = New System.Drawing.Point(0, 192)
Me.lblStatus.Name = &quot;lblStatus&quot;
Me.lblStatus.Size = New System.Drawing.Size(312, 16)
Me.lblStatus.TabIndex = 2
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(416, 213)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblStatus, Me.GroupBox1, Me.btnConnect})
Me.MaximizeBox = False
Me.Name = &quot;Form1&quot;
Me.Text = &quot;LAPI Test&quot;
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Dim session As LLSession
Dim users As LAPI_USERS

Dim userlist As LLValue
Dim userdata As LLValue
Dim userAttributes As LLValue
Dim ID As LLValue

Dim status As Long
Dim stat As Long
Dim message As String
Dim errMsg As String
Dim apiError As String


session = New LLSession(txtServerName.Text, txtPortNo.Text, txtDatabaseName.Text, txtUserName.Text, txtPassword.Text)
users = New LAPI_USERS(session)
userlist = New LLValue().setAssocNotSet
ID = New LLValue().setAssocNotSet

status = users.ListUsers(userlist)
If (status = 0) Then
Console.WriteLine(&quot;users listed!!!&quot;)
End If
userAttributes = New LLValue().setAssocNotSet

status = users.CreateUser(&quot;Pando&quot;, &quot;mypassword&quot;, 0, userdata, 1, &quot;DefaultGroup&quot;, userAttributes, ID)
stat = session.getStatus
message = session.getStatusMessage
errMsg = session.getErrMsg
apiError = session.getApiError
Console.WriteLine(&quot;Session failure status is &quot; + stat.ToString + &quot; (0x&quot; + stat.ToString)
If (message <> &quot;&quot;) And (errMsg <> &quot;&quot;) And (apiError <> &quot;&quot;) Then
Console.WriteLine(&quot;Message=&quot; + message)
Console.WriteLine(&quot;errMsg=&quot; + errMsg)
Console.WriteLine(&quot;apiError=&quot; + apiError)
End If

End Sub
End Class
 
More info on WebServices & Livelink at :

thread862-578138
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top