'ECGridOSNewQID by Loren Data Corp.
'
'This public domain code demonstrates how to use ECGridOS add Qualifier/ID (QIDs)
'to ECGrid(r)
'
'See ECGridOS documentation at http://ecgridos.net
'Request ECGridOS credentials at http://ecgridos.com
'
'The following ECGridOS calls are used:
' Login()
' Logout()
' TPAdd()
' TPAddVAN()
'
'The syntax of this function is:
'
'ECGridOSNewQID <UserID> <Password> <Qualifier*ID> <Description> [NetworkID]
'
' UserID - must be previously registered on ECGridOS
' Password - must be previously registered on ECGridOS
' Qualifier*ID - must include * separator, start with * if no Qualifier
' Description - Place in quotes ("") if including spaces
' NetworkID - Optional, if adding QID to VAN
'
'ECGrid is a registered service mark of Loren Data Corp.
'ECGridOS is a service mark of Loren Data Corp.
Imports System.Web.Services.Protocols
Imports System.Xml
Module Module1
'ECGRIDOS: Set up an Object for the Web Service;
' this requires a Web Reference
to ' https://ecgridos.net/v2.1/prod/ecgridosv0201.asmx
Public ecgridos As New net.ecgridos.ECGridOSAPIv2
'ECGRIDOS: Have a place to store the SessionID
Public SessionID As String
Sub Main()
If My.Application.CommandLineArgs.Count < 4 Or _
My.Application.CommandLineArgs.Count > 5 Then
Syntax()
Else
Dim UserID As String = My.Application.CommandLineArgs(0)
Dim Password As String = My.Application.CommandLineArgs(1)
Dim QID As String = My.Application.CommandLineArgs(2).ToUpper
Dim Description As String = My.Application.CommandLineArgs(3)
Dim NetworkID As Integer = 0
If My.Application.CommandLineArgs.Count = 5 Then _
NetworkID = CInt(My.Application.CommandLineArgs(4))
Console.WriteLine(My.Application.Info.ProductName & ": " & _
FormatDateTime(Now, DateFormat.ShortDate))
Try
'ECGRIDOS: Always Login first
SessionID = ecgridos.Login(UserID, Password)
Dim Qualifier As String
Dim ID As String
Dim ECGridID As Integer
Qualifier = QID.Split("*")(0)
ID = QID.Split("*")(1)
If NetworkID = 0 Then 'We are adding to the User's Network/Mailbox
ECGridID = ecgridos.TPAdd(SessionID, _
Qualifier, _
ID, _
Description)
Else 'We are adding this QID to a VAN Network connection
ECGridID = ecgridos.TPAddVAN(SessionID, _
NetworkID, _
Qualifier, _
ID, _
Description)
End If
Console.WriteLine([String].Format("QID: {0} assigned ECGridID: {1}", _
QID, ECGridID))
Catch ex As SoapException
'There is good data in the InnerXML
'which can be parsed and used to processes specific exceptions
Dim doc As New XmlDocument
Dim Node As XmlNode
doc.LoadXml(ex.Detail.OuterXml)
Node = doc.DocumentElement.SelectSingleNode("ErrorInfo")
If Not Node Is Nothing Then
Console.WriteLine([String].Format("SOAP Exception: ({0}) {1}", _
Node.SelectSingleNode("ErrorCode").InnerText, _
Node.SelectSingleNode("ErrorString").InnerText))
Console.WriteLine([String].Format(" Error Item: {0}", _
Node.SelectSingleNode("ErrorItem").InnerText))
Console.WriteLine([String].Format(" Msg: {0}", _
Node.SelectSingleNode("ErrorMessage").InnerText))
Else
Console.WriteLine("ERROR: " & ex.Message.ToString)
End If
Catch ex As Exception
Console.WriteLine("ERROR: " & ex.ToString)
Finally
'ECGRIDOS: Make sure to Logout when done.
ecgridos.Logout(SessionID)
End Try
End If
ecgridos = Nothing
End Sub
Private Sub Syntax()
Console.WriteLine("ECGridOSNewQID <UserID> <Password> <Qualifier*ID>" & _
" <Description> [NetworkID]")
Console.WriteLine(" UserID - must be previously registered on ECGridOS")
Console.WriteLine(" Password - must be previously registered on ECGridOS")
Console.WriteLine( " Qualifier*ID - must include * separator, start" & _
" with * if no Qualifier")
Console.WriteLine(" Description - Place in quotes ("") if including spaces")
Console.WriteLine(" NetworkID - Optional, if adding QID to VAN")
End Sub
End Module
|