Announcement

Collapse
No announcement yet.

[email protected] Com declarations

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scott Turchin
    replied
    This is Visual basic code to retrieve an XML document from the database.
    I found the include file, some 2000 lines - NOT going to be fun.

    I think I need a translation application to convert it to PB - it would take me MONTHS to do it..

    Code:
    Attribute VB_Name = "AIM"
    Option Explicit
    
    '   Objects you almost always need
        Dim pcmConnect As PCMClientLib.PCMConnection
        Dim pcmCommand As PCMTOOLSAPILib.pcmCommand
        Dim pcmData As PCMTOOLSAPILib.pcmData
        
    '   Objects related to search, e-mail, and some other things that came later
        Dim pcmDebugOut2 As PCMTOOLSAPILib.pcmDebugOut2
        Dim pcmSearch As PCMTOOLSAPILib.pcmSearch
        Dim pcmData2 As PCMTOOLSAPILib.pcmData2
        
    '   Objects needed for XML
        Dim pcmSet As PCMTOOLSAPILib.pcmSet
        Dim pcmCompound As PCMTOOLSAPILib.pcmCompound
        Dim pcmSlice As PCMTOOLSAPILib.pcmSlice
        
    '   Some hard-codes and other flotsam and jetsam
        Const socket As Integer = 8888
        Const sNode As String = "xyserver"
        Const sDB As String = "s1000d_loaded"
        Const sUser As String = "sysadmin"
        Const sPW As String = "manager"
        Const sRegString As String = "AIM"
        Const iHist As Integer = 0
        Const sConfigID As String = "#6"
        Const sDesktopIDPath As String = "/#1/#2"
        Dim nRecs As Integer, r As Integer
        
    Sub GetStatus()
    
        Dim sDMC As String
        Dim sSQL As String
        Dim sObjectID As String
        Dim sInwork As String
        Dim sIssno As String
        Dim sIDPath As String
        Dim sXML As String
        
        '   Get some metadata on a particular DM
        sDMC = "S92-A-49-00-00-01A-042A-A"
        sSQL = "select distinct pdm_blobid, issue_inwork, issue_issno from dmodule, parent_list where dmc='" & sDMC & "' and pdm_blobid=child and pdm_current=1 and pdm_deleted=0"
        
        '   Connect to Contenta using hard-coded arguments
        Set pcmConnect = New PCMClientLib.PCMConnection
        Set pcmCommand = pcmConnect.ConnectGetCommand(socket, sNode, sDB, sUser, sPW, sRegString, iHist)
        Debug.Print "Connected"
        
        '   Execute query
        Debug.Print "Query string is " & sSQL
        Set pcmData = pcmCommand.ExecCmd("procedure " & sSQL)
        nRecs = pcmData.RecordCount
        Debug.Print "Returned " & nRecs
        
        If nRecs = 0 Then
            Debug.Print "Did not find"
        Else
        '   Recover values from the query
            sObjectID = "#" & pcmData.GetValueByIndex(0, 0)
            sInwork = pcmData.GetValueByIndex(0, 1)
            sIssno = pcmData.GetValueByIndex(0, 2)
            Debug.Print "Object ID" & vbTab & sObjectID
            Debug.Print "Inwork" & vbTab & sInwork
            Debug.Print "Issue number" & vbTab & sIssno
        End If
        
        '   Find an IDPath to this DM
        sIDPath = GetIDPath(sObjectID)
        Debug.Print "IDPath is " & sIDPath
        
        '   Get its XML
        sXML = GetXML(sIDPath)
        Debug.Print "XML is " & vbCrLf & sXML
        
        pcmConnect.Disconnect
        Debug.Print "Disconnected"
    
    End Sub
    
    Function GetIDPath(ByRef sObjectID As String) As String
    
    '   Get IDPath to an object based on its object ID
    '   Need first to instantiate a PCMdebugOut2 object, since this is needed
    '   to get a search object. Arguments are user, some string, and an optional date-time.
    '   Since Contenta doesn't care, always use "sysadmin," and never use date-time
        Set pcmDebugOut2 = pcmCommand.GetPCMdebugOut2("sysadmin", "AIM", "")
        
    '   Get a search object
        Set pcmSearch = pcmCommand.GetPCMSearch(pcmDebugOut2)
        
    '   SearchByName method takes as an argument "Paul" or "#12345"
    '   This search is searching for a particular object id within the hard-coded
    '   stable data configuration. The "1" means relpath, meaning don't bother
    '   to find on multiple desktops. Note that search returns to a pcmData2 object, which
    '   is different than a pcmData, but effectively it works the same way
        Set pcmData2 = pcmSearch.SearchByName(sObjectID, 1, sConfigID, "")
        
    '   Get the first idpath you find, since any idpath that gets you there is fine.
    '   Note this assumes the object was in fact found, and this should be tested and
    '   trapped in real code
        GetIDPath = sDesktopIDPath & "/" & pcmData2.GetValueByLabel(0, "ID_PATH")
    
    End Function
    
    Function GetXML(ByRef sIDPath As String) As String
    
    '   Get XML of a DM for which an idpath is known
        Dim nSlices As Integer
        
    '   To use compound objects, must first get a pcmSet and use that to do an open
        Set pcmSet = pcmCommand.CompoundSetNew()
        Set pcmCompound = pcmSet.CompoundOpen(sIDPath, "nolock", "read", "binary")
        
    '   Although we expect object to be a single slice since it is a leaf node, let's plan
    '   for case where it's multiple, such as start tag + content + end tag
        nSlices = pcmCompound.SliceCount
        GetXML = ""
        
    '   Iterate over slices, and append content to a string for each slice that is a content slice,
    '   as opposed to a child slice pointing to another object
        Set pcmSlice = pcmCompound.SliceFirst
        For r = 0 To nSlices - 1
            If pcmSlice.IsContent Then
                GetXML = GetXML & pcmSlice.ReadContent
            End If
            If r < nSlices - 1 Then
                Set pcmSlice = pcmCompound.SliceNext
            End If
        Next r
        
        pcmSet.CompoundClose
    
    End Function

    Leave a comment:


  • Dominic Mitchell
    replied
    What do I need to start this?
    Well it is NEWCOM/GETCOM/ANYCOM.

    What sample code? You have not showed what you are trying to do with the server.

    Leave a comment:


  • Scott Turchin
    replied
    And the declarations from the sample code:

    Code:
    Attribute VB_Name = "AIM"
    Option Explicit
    
    '   Objects you almost always need
        Dim pcmConnect As PCMClientLib.PCMConnection
        Dim pcmCommand As PCMTOOLSAPILib.pcmCommand
        Dim pcmData As PCMTOOLSAPILib.pcmData
        
    '   Objects related to search, e-mail, and some other things that came later
        Dim pcmDebugOut2 As PCMTOOLSAPILib.pcmDebugOut2
        Dim pcmSearch As PCMTOOLSAPILib.pcmSearch
        Dim pcmData2 As PCMTOOLSAPILib.pcmData2
        
    '   Objects needed for XML
        Dim pcmSet As PCMTOOLSAPILib.pcmSet
        Dim pcmCompound As PCMTOOLSAPILib.pcmCompound
        Dim pcmSlice As PCMTOOLSAPILib.pcmSlice
        
    '   Some hard-codes and other flotsam and jetsam
        Const socket As Integer = 8888
        Const sNode As String = "xyserver"
        Const sDB As String = "s1000d_loaded"
        Const sUser As String = "sysadmin"
        Const sPW As String = "manager"
        Const sRegString As String = "AIM"
        Const iHist As Integer = 0
        Const sConfigID As String = "#6"
        Const sDesktopIDPath As String = "/#1/#2"
        Dim nRecs As Integer, r As Integer

    Leave a comment:


  • Scott Turchin
    started a topic [email protected] Com declarations

    [email protected] Com declarations

    Anyone use [email protected] explorer by chance?

    There are two primary com objects, I've got the API and some VB sample code but not sure where to start to access this.

    Fraid they just haven't given enough info for native coders....


    What do I need to start this?

    Code:
     PCMTOOLSAPILib  
    
     
    
     Groups
    
    COM Classes 
    
     PCMcommand   
     PCMcommand2   
     PCMcompound   
     PCMdata   
     PCMdata2   
     PCMdebugOut   
     PCMdebugOut2   
     PCMEmail   
     PCMfs   
     PCMLinkCommand   
     PCMProject   
     PCMSearch   
     PCMset   
     PCMslice   
     PCMstatus   
     PCMtoolReturn   
     PCMtree   
     PCMutils   
     PCMutils2   
     Record
Working...
X