Monday 21 April 2014

How to access a SYSPRO Executive Dashboard from an iPad or Android

Here’s how to view SYSPRO’s Executive Dashboards on your iPad or Android or similar device.

High-level summary

  1. On your iPad or Android, you need an app that can display Shockwave files.
  2. VBScript calls to SYSPRO BUsiness Objects need to be changed to go via SYSPRO’s e.Net service, either via web services or via COM or DCOM. You’ll need a programmer to make these changes.

Technical summary

  1. On your iPad, install an app that can display Shockwave (.swf) files.
    Photon is one such app; see below for a list of others.
  2. Copy the dashboard files into IIS.
  3. If you are going to access Syspro’s Business Objects via Interop.Encore.dll (i.e. via COM), then you will need to set the IIS application’s Application Pool to be 32-bit enabled.
  4. Create a .aspx file from the dashboard’s .txt file.
  5. Edit the VB code in the .aspx file so that:
    1. It is a valid .aspx file
    2. It creates the XML file with the dashboard’s data in the SAME directory as the .aspx file.
    3. It calls any SYSPRO Business Objects via web services instead of directly via CallBO.
  6. Remove the final call to COMGET. You don’t need this because you have already manually copied the file into IIS.

Detail

1. Set up IIS: Add an Application in IIS; give it an Alias and a Physical Path of your choosing, similar to the screen shot below.
Your existing Executive Dashboard will need to be modified, so you will need to make a copy of it; place those copied files (.xlf, .swf, .txt and .xls) in a directory accessible from IIS.

Select an appropriate Application Pool, as shown in the previous screen shot. For the Application Pool, you must select one that is 32-bit enabled so that your dashboard will be able to run 32-bit applications such as Encore.Interop, which it will need to use to access Syspro’s Business Objects. To find an Application Pool that is 32-bit enabled, or to enable one, in IIS go to Connections / Application Pools; select the desired Application Pool, click Advanced Settings, and set Enable 32-bit Applications to True, as shown in the two screen-shots below.


If you do not do this, then when you try to view your dashboard, you will get an error such as Cannot create ActiveX component.
Rename the copied the Executive Dashboard’s .txt file to .aspx, e.g.
rename exec_gl_turnover_actual_year_rate.txt exec_gl_turnover_actual_year_rate.aspx
Edit the .aspx file:
  1. Convert the RTF code to VB comments.
  2. Add these two lines at the top of the file:
    <%@ Page Language="VB" aspcompat=true Debug="true" validateRequest="false" %>
    <%
  3. Add this line at the bottom of the file:
    %>
  4. Add initial code near the top, such as:
    ' This is the directory where the dashboard files will go in IIS.
    Private Const BASE_DIR "C:\inetpub\wwwroot\xcelsius"
    
    ' This is the base filename for the dashboard files.
    ' This filename should NOT have an extension:
    Private Const BASE_FILENAME "exec_gl_turnover_actual_year_rate"
    
    ' SYSPRO Login details:
    Private Const SysproOperator = "ADMIN"
    Private Const operatorPassword = ""
    Private Const companyId = "0"
    Private Const companyPassword = ""
    
    Private Const languageCode = "05"
    Private Const logLevel = "0"
    Private Const encoreInstance = "0"
    
    Dim utilities as Object
    utilities = CreateObject("Encore.Utilities")
    
    Dim GUID
    GUID = utilities.Logon(SysproOperator, operatorPassword, companyId, companyPassword, languageCode, logLevel, encoreInstance, XmlIn)
    
    Dim query
    query = CreateObject("Encore.query")
  5. Remove the function declaration for CustomisedPane_OnRefresh, i.e. remove this line of code, but LEAVE THE CONTENTS of the function:
    Function CustomisedPane_OnRefresh()
  6. Remove the corresponding “End Function” line.
  7. Avoid Cross-Domain Policy errors: Note that the BASE_DIR will be the directory where all of the the dashboard’s need to be placed: the .swf file, the .aspx file, and the .xml file that is updated each time the dashboard is served up by IIS. In particular, note that your .aspx file will create an XML file that is read by the Shockwave file; this XML file MUST live in the same directory as the Shockwave file; otherwise you will get a cross-domain error when shockwave tries to access the XML file, as shown in the screen shot below:
  8. Change this line, near the end of the CustomizedPane_OnRefresh function:
    dashfile = SystemVariables.CodeObject.baseSettingsFolder & "Dashboards\exec_gl_turnover_actual_year_rate_output.xml"
    Replace it with this line:
    dashfile = BASE_DIR & "\" & BASE_FILENAME & "_output.xml"
    (This output filename, the dashfile, should match the output file that your Dashboard looks for in its Data Connection as set in Excel or Xcelsius under Data / Connections.)
  9. Delete any “Set” commands; just leave them as basic assign statements.
    E.g. Change lines like these:
    Set xmlDoc = createobject("Msxml2.FreeThreadedDOMDocument.3.0")
    ...
    Set Dom = createobject("MSXML.DOMDocument")
    to these:
    xmlDoc = createobject("Msxml2.FreeThreadedDOMDocument.3.0")
    ...
    Dom = createobject("MSXML.DOMDocument")
  10. Delete the entire function, CustomizedPane_OnLoad().
  11. Add code to serve the Shockwafe file:
    ' Output the SWF file.
    ' Reference: https://help.maximumasp.com/KB/a330/binarywrite-to-response-object-does-not-work-when-binary.aspx
    Dim chunkSize, stream
    
    chunkSize = 262144 ' Read the stream in 256K chunks
    stream = Server.CreateObject("ADODB.Stream")
    stream.Open
    stream.Type = 1
    stream.LoadFromFile (BASE_DIR & "\" & BASE_FILENAME & ".swf")
    Response.Expires = 0
    
    'Turn off buffering
    Response.Buffer = False
    Response.ContentType = "application/x-shockwave-flash"
    
    ' Enclose the binarywrite statement in a loop
    ' that will read your stream in a specified chunk size.
    While Response.IsClientConnected And (stream.Position < stream.Size)
     Response.BinaryWrite(stream.Read(chunkSize))
    End While
    
    stream.Close
    stream = Nothing
  12. Update all calls to Business Objects:
    The VBScript, when it was running inside SYSPRO, had direct access to all the Business Objects via the function, CallBO. As the VBScript will now be running in IIS, it will not have direct internal access to the Business Objects. To resolve this, we can call Syspro’s .Net Interop object (Encore.dll). To do this, replace lines such as the following:
    on error resume next
    XMLOut = CallBO("COMGRW",XMLIn,"auto")
    if err then
     msgbox err.Description, vBCritical, "Calling Business Object COMGRW"
     exit function
    end if
    Replace it with code such as this:
    XmlOut = query.Query(GUID, "COMGRW", XmlIn)
    Do this for all calls to CallBO.
You should now be able to open the Dashboard in any web browser that has the Addon for Shockwave installed; you will need the URL that takes you to the .swf file.

iPad setup

Install some software that can display Shockwave files, i.e. stream Flash, such as:
  • Appsverse Photon - costs around $5.
  • Inovista – this is possibly the best one; the reader is free but you have to get the appropriate plugin which costs around $20.
Here are some more possibilities but I do not know if these work:
Enter the URL for the .swf file into your app and view the dashboard.

No comments:

Post a Comment