9.1 API - ASP.NET / VB.NET

Post Reply
User avatar
kielmc
Posts: 22
Joined: Tue Jun 24, 2008 6:17 pm
OLAP Product: TM1
Version: 10.2.2 FP4
Excel Version: 2013
Location: Birmingham, AL

9.1 API - ASP.NET / VB.NET

Post by kielmc »

Does anyone have an example of using ASP.NET / VB.NET to connect to TM1 9.1?
AnthonyT
Posts: 42
Joined: Mon May 19, 2008 10:25 am
OLAP Product: TM1, EV
Version: 9.0 9.1 9.4 9.5 10.1 10.2
Excel Version: 2003 2007 2010 2015
Location: London, UK

Re: 9.1 API - ASP.NET / VB.NET

Post by AnthonyT »

Only via EV if that helps at all
Anthony

That's no moon - that's a space station
User avatar
kielmc
Posts: 22
Joined: Tue Jun 24, 2008 6:17 pm
OLAP Product: TM1
Version: 10.2.2 FP4
Excel Version: 2013
Location: Birmingham, AL

Re: 9.1 API - ASP.NET / VB.NET

Post by kielmc »

we've got EV, so i'd love to see your example!
AnthonyT
Posts: 42
Joined: Mon May 19, 2008 10:25 am
OLAP Product: TM1, EV
Version: 9.0 9.1 9.4 9.5 10.1 10.2
Excel Version: 2003 2007 2010 2015
Location: London, UK

Re: 9.1 API - ASP.NET / VB.NET

Post by AnthonyT »

Here is what I do

Using the code behind page, I create the EV object as a new Literal Control, setting a few variables along the way

Code: Select all

Partial Class ClientCostReport
    Inherits System.Web.UI.Page

    Dim ControlPlaceHolder As PlaceHolder
    Dim litObjectTag As LiteralControl
    Dim arrObjectTag() As Byte

    Dim evServer As EV_Web_Service_DEV64.ExecutiveViewer
    Dim SessionHeader As EV_Web_Service_DEV64.SessionHeader

    Dim ReportPath As String = "/Cost Report/Client Cost Report"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        evServer = New EV_Web_Service_DEV64.ExecutiveViewer

        evServer.Url = "http://Dev_Server/EVServer/WebService.asmx"

        evServer.Credentials = System.Net.CredentialCache.DefaultCredentials

        ControlPlaceHolder = Me.FindControl("PlaceHolder1")
        ControlPlaceHolder.Controls.Clear()

        SessionHeader = evServer.CreateSessionImpersonated("Windows", "", "", "", "")
        Session("sessionID") = SessionHeader.ID

        If Session("sessionID") <> "" Then

            Dim nvc(7) As EV_Web_Service_DEV64.NameValue

            nvc(0) = New EV_Web_Service_DEV64.NameValue
            nvc(0).Name = "ControlID"
            nvc(0).Value = "EVObject"

            nvc(1) = New EV_Web_Service_DEV64.NameValue
            nvc(1).Name = "SessionID"
            nvc(1).Value = Session("sessionID")

            nvc(2) = New EV_Web_Service_DEV64.NameValue
            nvc(2).Name = "ToolBar"
            nvc(2).Value = True

            nvc(3) = New EV_Web_Service_DEV64.NameValue
            nvc(3).Name = "TabBar"
            nvc(3).Value = True

            nvc(4) = New EV_Web_Service_DEV64.NameValue
            nvc(4).Name = "Theme"
            nvc(4).Value = "Ocean"

            nvc(5) = New EV_Web_Service_DEV64.NameValue
            nvc(5).Name = "Width"
            nvc(5).Value = "85%"

            nvc(6) = New EV_Web_Service_DEV64.NameValue
            nvc(6).Name = "Height"
            nvc(6).Value = "93%"

            nvc(7) = New EV_Web_Service_DEV64.NameValue
            nvc(7).Name = "Protocol"
            nvc(7).Value = "HTTP"

            arrObjectTag = evServer.Render(ReportPath, EV_Web_Service_DEV64.RenderType.ActiveX, nvc)

            litObjectTag = New LiteralControl
            litObjectTag.Text = System.Text.Encoding.UTF8.GetString(arrObjectTag).Replace("src=", "src=""http://Dev_Server/EVServer/CreateControl.js""")
            ControlPlaceHolder.Controls.Add(litObjectTag)

        End If

    End Sub

End Class

Then, using the aspx page I use a place holder to contain the new control

Code: Select all

<body onload = "MyLoad" >

   <asp:Table Width="100%" >
   
     <asp:TableRow id="T2r1">

            <asp:TableCell id="T2r1c1" Width="85%">
                <asp:PlaceHolder  ID="PlaceHolder1" runat="server">Control Not Loaded</asp:PlaceHolder>
            </asp:TableCell>

        </asp:TableRow>

    </asp:Table>

</body>

You can use the MyLoad procedure to set a few variables as well

Code: Select all


    Sub MyLoad()
    
        EVObject.EnableColumnHeaders = True
        EVObject.EnableToolBar = False
        EVObject.EnableTabBar = False
        EVObject.EnableOffspreadBar = False
        EVObject.AllowSaveView = False
        EVObject.AllowDataEntry = False
        
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationChangeDimensionLayout, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationChangeOffspreadSelection, True
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationChangeInspreadSelection, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationFormat, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationOptions, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationLayout, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationDynaSelect, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationCalculations, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationMemberDisplayNames, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationPrinting, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationActions, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationUndo, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationChangeNotes, False
        EVObject.Allow ActionAuthorisationType.ActionAuthorisationConnection, False
        
        '	####################################################
        '	#  COLOUR THE BACKGROUNDS                                            #
        '	####################################################
        
        EVObject.ActiveView.SetBackgroundColor BackgroundAreaType.BackgroundAreaTable, "White"
        EVObject.ActiveView.SetBackgroundColor BackgroundAreaType.BackgroundAreaRowHeaders, "White"
        EVObject.ActiveView.SetBackgroundColor BackgroundAreaType.BackgroundAreaColumnHeaders, "AliceBlue"
                
    End Sub

I also use it to start off a few procedures that populate drop-down boxes with the contents of TM1 subsets, and initialize a few things


Hope this helps

Anthony
Anthony

That's no moon - that's a space station
Post Reply