Working with .NET Lists



General Dashboard configuration

Working with the user name

#Username looks like '[email protected]@[email protected]' shortUser, objType , provider , providerType = Username.split("@") 

Working with the user roles

  • Modifying the Host list based on the user roles
#Roles is a List that contains things such as "Administrator", "Creator", "Viewer" if len(Roles) == 0: #for the AccessServer Admin, Roles seems to be empty ! pass # do not modify list of Hosts elif len(Roles)==0 or "Administrator" in Roles: #Administrator pass # do not modify list of Hosts elif "Creator" in Roles: #not an Administrator, but has Creator Role #remove some Hosts for h in ['TEST-SERVER','SERVER2']: Hosts.Remove(h) elif "Viewer" in Roles: #not an Administrator, not a Creator but has Viewer Role #remove some Hosts for h in ['TEST-SERVER','SERVER2','OTHER-SERVER','TDESODT']: Hosts.Remove(h) else: #no permission -> empty list Hosts.RemoveAll() 

Other example:

#when we go trough the Hosts list it is not possible to Remove element : bannedHosts=[] for host in Hosts: if host.startswith('Win'): bannedHosts.append(h) for h in bannedHosts: Hosts.Remove(h) 

Import custom module in the Dashboards

As the python in Dashboards is not the normal python but IronPython, we needs some tricks to import a file.

import sys #we add the path where is our module and import it sys.path.append(r"C:\Program Files (x86)\Tango04\Dashboards\t04custom") import my_module 

%Program Files%\Tango04\Dashboards\t04custom is the recommended folder to put specific python files.

Passing other Parameters to a Dashboards or Table

you can add any parameters to an url to acces a dashboard or a table and get the value of these parameteres in any python script of this dashboard or table

http://ps-dashboards//serverpages/dashboards/_b44c1c3c_03f7_4c27_a271_677b80bb04b8/dashboard.aspx?hostName=PS-REPORTS&timeInterval=0&timeScale=0&viewTimeOffset=0&Disk=C%3a Nope the '&disk=C:' at the end of the url

In a python script you can get the value like this:

import clr clr.AddReference("System.Data") clr.AddReference("System.Web") from System.Web import * if Serie.ElementID==HttpContext.Current.Request.Params["Disk"]: ShowSerie = True else: ShowSerie = False 

Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: October 18, 2018