Jump to content
Sign in to follow this  
Xenobiologist

IBM Cognos SDK

Recommended Posts

Xenobiologist

Hi,

anybody out there, who tried to use/convert the vb(6.0) examples within/to Autoit?

I will give it a try. Otherwise I have to stick to Java.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Xenobiologist

HI,

is someone able to translate this to Autoit?

VERSION 5.00
Begin VB.Form frmMain 
   Caption       =   "Form1"
   ClientHeight =   5790
   ClientLeft     =   60
   ClientTop       =   450
   ClientWidth   =   9090
   LinkTopic       =   "Form1"
   ScaleHeight   =   5790
   ScaleWidth     =   9090
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton btnCancel 
      Caption        =   "Cancel"
      Height          =   495
      Left          =   7320
      TabIndex      =   3
      Top            =   840
      Width        =   1335
   End
   Begin VB.ListBox lstReports 
      BeginProperty Font 
         Name           =   "Tahoma"
         Size           =   9
         Charset         =   0
         Weight       =   400
         Underline     =   0   'False
         Italic       =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4050
      ItemData      =   "frmMain.frx":0000
      Left          =   15
      List          =   "frmMain.frx":0002
      TabIndex      =   2
      Top            =   1470
      Width        =   8805
   End
   Begin VB.CommandButton cmdQuery 
      Caption        =   "Query Content Manager"
      BeginProperty Font 
         Name           =   "Tahoma"
         Size           =   8.25
         Charset         =   0
         Weight       =   400
         Underline     =   0   'False
         Italic       =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left          =   5160
      TabIndex      =   1
      Top            =   840
      Width        =   1965
   End
   Begin VB.TextBox txtEndPointURL 
      BeginProperty Font 
         Name           =   "Tahoma"
         Size           =   8.25
         Charset         =   0
         Weight       =   400
         Underline     =   0   'False
         Italic       =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   360
      Left          =   15
      TabIndex      =   0
      Text          =   "http://localhost/crn/cgi-bin/cognos.cgi"
      Top            =   210
      Width        =   8775
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' *
' * ListOfGroupsPerUser.vbp
' *
' * Copyright © 2006 Cognos Incorporated. All Rights Reserved.
' * Cognos and the Cognos logo are trademarks of Cognos Incorporated.
' *
' * Description: KB documebt #1003222 - Extract all the groups that a user belongs to
' * using the SDK from the user namespace

Private oCrn As New CognosReportNetService
 
Private userPassword As String
Private userID As String
Private namespaceID As String


Private Sub btnCancel_Click()
    Unload Me
End Sub

Private Sub cmdQuery_Click()

    On Error GoTo ReportNetException:

    '-------------------------
    'Re-initialize so that the object is not null when the button is click more than once
    '-------------------------
    Call reinitialize
    
    '-------------------------
    'Verify if the endPointURL has changed and if so set the BiBusHeader
    'to Nothing then retrieve the string that's in the txtEndPointURL textbox
    'and assigning it to the oCRN.endPointUrl
    '-------------------------
    If Not Me.txtEndPointURL = oCrn.endPointUrl Then
        oCrn.endPointUrl = Me.txtEndPointURL
    End If
   
    '-------------------------
    'Set logon credentials
    '-------------------------
    userID = "admin"
    userPassword = "Education1!"
    namespaceID = "SDK"
             
    '-------------------------
    'Clear the list
    '-------------------------
    lstReports.Clear
    
    '-------------------------
    'A system administrator user needs to login to ReportNet using the same namespace that will be queried
    'Call the logon method and pass it the userID, userPassword, strNamespc in an XML encoded string
    '-------------------------
    Call oCrn.logon(XMLEncode("<credential><namespace>" & namespaceID & "</namespace><username>" & userID & "</username><password>" & userPassword & "</password></credential>"), Nothing)

    Call ListOfGroupsPerUser
    
    Exit Sub
    
ReportNetException:

    'Handle exceptions.
    'Use the Exception Handler to find out what caused the problem.
    
    lstReports.AddItem "An error occurred:"
    lstReports.AddItem Err.Description
    
      
End Sub

Private Sub ListOfGroupsPerUser()
    On Error GoTo ReportNetException

    Dim props As New PropEnumC
    Dim query_options As New QueryOptions
    Dim sortOptionArray As New SortC
    Dim baseClass As BaseClassC
    Dim group As New CRN.group
    Dim member As New CRN.BaseClassC
    
    Dim user1SearchPath As String
    
    Dim strObjectClass As String
    Dim bUserNameDescrip As Boolean
  
    '-------------------------
    'Search path of the user that we search for
    'Ensure that a valid search path of the user is used by changing the following
    '-------------------------
    user1SearchPath = "CAMID(""SDK:u=S-1-5-21-746137067-1078145449-1343024091-1038"")"
    
    '-------------------------
    'Search properties; these are the properties we want returned.
    '-------------------------
    props.Add defaultName
    props.Add searchPath
    props.Add hasChildren
    props.Add permissions
    props.Add members
    props.Add objectClass
      
    'query for all users
    Set baseClass = oCrn.Query("CAMID(""" & namespaceID & """)//*", props, sortOptionArray, query_options)
      
    If baseClass.Count > 0 Then
        
        For i = 1 To baseClass.Count
            strObjectClass = baseClass.Item(i).objectClass.Value
                      
            If (strObjectClass = CRN.ClassEnum_.group) Then
            
                Set group = baseClass.Item(i)
                Set member = group.members.Value
                
                If (member.Count > 0) Then
                     
                     For j = 1 To member.Count
                        
                        If (user1SearchPath = member.Item(j).searchPath.Value) Then
                            If Not (bUserNameDescrip) Then
                                bUserNameDescrip = True
                                lstReports.AddItem "User [ " & userID & " ] is a member of: "
                            End If
                           
                           lstReports.AddItem baseClass.Item(i).searchPath.Value
                        End If
                        
                    Next
                End If
            End If
        Next
    End If
     
    Exit Sub

ReportNetException:
    'Handle exceptions.
    'Use the Exception Handler to find out what caused the problem.
    
    frmMain.lstReports.AddItem "An error occurred:"
    frmMain.lstReports.AddItem Err.Description
    
End Sub

Private Sub Form_Load()

    '-------------------------
    'Creating the CRN API object and setting it to the oCRN variable
    '-------------------------
    Set oCrn = New CognosReportNetService

    '-------------------------
    'Retrieving the string that's in the txtEndPointURL textbox and
    'assigning it to the oCRN.endPointUrl
    'The endPointUrl has to be a valid ReportNet Gateway URL, and all
    'communications will be sent through this URL
    '-------------------------
    oCrn.endPointUrl = Me.txtEndPointURL.Text
    lstReports.AddItem "<Query results will be displayed here.>"
    
End Sub


Private Sub Quick_Logon()

   On Error GoTo ReportNetException:
      
    '-------------------------
    'Call the logon method and pass it the userID, userPassword, strNamespc in
    'an XML encoded string
    '-------------------------
    Call frmMain.oCrn.logon(XMLEncode("<credential><namespace>" & strNamespc & "</namespace><username>" & userID & "</username><password>" & userPassword & "</password></credential>"), Nothing)
    
    Call ListOfGroupsPerUser
    
    Exit Sub
    
ReportNetException:

    'Handle exceptions.
    'Use the Exception Handler to find out what caused the problem.
    
    frmMain.lstReports.AddItem "An error occurred:"
    frmMain.lstReports.AddItem Err.Description
      
End Sub
 
Private Function XMLEncode(strSpec As String)
'********************************************************
'* Replace tags for encoding
'*
'*  strSpec  String
'*
'********************************************************
    strSpec = Replace(strSpec, "&", "&amp;")
    strSpec = Replace(strSpec, "<", "&lt;")
    strSpec = Replace(strSpec, ">", "&gt;")
    strSpec = Replace(strSpec, "'", "&apos;")
    strSpec = Replace(strSpec, """", "&quot;")
    XMLEncode = strSpec
    
End Function

Private Sub reinitialize()
    '-------------------------
    'Creating the CRN API object and setting it to the oCRN variable
    '-------------------------
    Set oCrn = New CognosReportNetService
    
End Sub

The API dll is called cdk.dll

Thanks in advance

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.