Table of Contents

Class Session

Namespace
PolarStudio
Assembly
PolarStudio.dll

This class is created for each (Web)session.

public class Session : PolarWeakEventListener
Inheritance
Session
Implements
Inherited Members
Extension Methods

Fields

BodyCssClass

This property can be used to set a specific class to the body of html pages.

public string BodyCssClass

Field Value

string

Buttons

The custom buttons is a collection that contains all custom buttons that are defined within polar studio and have the session as context.

public CustomButtons Buttons

Field Value

CustomButtons

DefaultResponseHeaders

This property set the default HTTP headers that are added to each web-response. It is a dictionary and headers can be added 'by name', like: Context.WebSession.DefaultResponseHeaders("Cache-Control") = "private"

public Dictionary DefaultResponseHeaders

Field Value

Dictionary

EnableFirstControlToActivate

This property enables/disables the feature to set the focus in the first control. For some mobile applications it can give unexpected behaviours, for example to always show the on-screen keyboard because the application activates the first text box.

public bool EnableFirstControlToActivate

Field Value

bool

FrameLess

This property can be set to indicate the application is not using frames. It changes the way the main.js and browsersettings are loaded (for they are normally loaded in the parent frame).

public bool FrameLess

Field Value

bool

FrameLessContentWindowTemplate

This property contains the HTML template to use for FrameLess sessions.

public string FrameLessContentWindowTemplate

Field Value

string

FramedContentWindowTemplate

This property contains the HTML template to use for not-FrameLess (thus Framed) sessions.

public string FramedContentWindowTemplate

Field Value

string

HasOldStyleMenu

This property is to enable the old style menu for as long it is still supported.

public bool HasOldStyleMenu

Field Value

bool

SelectItemPopupHTMLtemplate

Used to set the HTML template for 'Select item popup' controls. (editable and folow allowed)

public string SelectItemPopupHTMLtemplate

Field Value

string

SelectItemPopupHTMLtemplate_NF

Used to set the HTML template for 'Select item popup' controls. (editable and folow not allowed)

public string SelectItemPopupHTMLtemplate_NF

Field Value

string

SelectItemPopupHTMLtemplate_RO

Used to set the HTML template for 'Select item popup' controls. (read only and folow allowed)

public string SelectItemPopupHTMLtemplate_RO

Field Value

string

SelectItemPopupHTMLtemplate_RONF

Used to set the HTML template for 'Select item popup' controls. (read only and folow not allowed)

public string SelectItemPopupHTMLtemplate_RONF

Field Value

string

SendMessage_AlignButtonsRight

This property can be used to align the OK and Cancel buttons to the right within the dialog.

public bool SendMessage_AlignButtonsRight

Field Value

bool

SendMessage_ReverseButtons

This property can be used to reverse the OK and Cancel buttons in SendMessage dialogs.

public bool SendMessage_ReverseButtons

Field Value

bool

ShowTabSheetCloseButtons

This property enables/disables displaying the close-buttons in the tabsheets

public bool ShowTabSheetCloseButtons

Field Value

bool

SupportDetectFrameSetUnloaded

This property allows detection of unloading the frameset. When a user closes the browser or navigates to another site, the session is instantly (after one minute) closed.

public bool SupportDetectFrameSetUnloaded

Field Value

bool

TextButtonTemplate

This property sets the template as is used for enabled text buttons in the web application.

public string TextButtonTemplate

Field Value

string

TextButtonTemplate_Disabled

This property sets the template as is used for disabled text buttons in the web application.

public string TextButtonTemplate_Disabled

Field Value

string

UsePopupsForStateTransitions

This boolean property sets the behaviour to use popups for state transitions. Is outdated when the newer custom control is used for StateTransitions

public bool UsePopupsForStateTransitions

Field Value

bool

Properties

AcceptCompression

Returns a boolean indicating if this session accepts compressed responses.

public bool AcceptCompression { get; set; }

Property Value

bool

ActiveApplication

Returns the current active application.

public Application ActiveApplication { get; }

Property Value

Application

Applications

This method returns the web applications open in this web session.

public IndexedCollection<Application> Applications { get; }

Property Value

IndexedCollection<Application>

AttemptedUsedName

Returns the user name as was used to attempt to log on.

public string AttemptedUsedName { get; }

Property Value

string

AverageConcurrentUsers

Returns the average number of users. Each hit, the number of users is stored for that hit. So if a session produces 10 hits while there are 5 concurrent users and 10 hits while there are 10 concurrent users, the average concurrent users will be 7.5

public double AverageConcurrentUsers { get; }

Property Value

double

BPserver

This method returns a reference to the central server object for this project.

public BPserver BPserver { get; }

Property Value

BPserver

BackHtmlTC

This property gets/set the HTML that is shown when no applications are open.

public string BackHtmlTC { get; }

Property Value

string

BrowserType

The BrowserType was used to change behaviour for different kind of browsers in the past. Then, Microsoft Internet Explorer had way different features than Netscape. Nowadays, about all browsers are identified as 'NETSCAPE', but mobile browsers (iPad, iPhone and Android) are identified as 'MOBILE'.

public string BrowserType { get; }

Property Value

string

BrowserVersion

This method takes the version from the browser-identification. Not used anymore.

public double BrowserVersion { get; }

Property Value

double

BudaEngine

This method returns the Engine (data-layer) for this session.

public BudaEngine BudaEngine { get; }

Property Value

BudaEngine

BudaSession

This method returns a reference to the session in the data-layer (BudaSession) that is tied to this session in the presentation layer.

public BudaSession BudaSession { get; }

Property Value

BudaSession

CookiesEnabled

Returns True if cookies are detected in the users browser.

public bool CookiesEnabled { get; }

Property Value

bool

Engine

Returns the Engine that is tied to this session.

public BudaEngine Engine { get; }

Property Value

BudaEngine

ExpectedHTMLpageID

Used to protect pages agains CSRF / XSRF attacks. Each request that is processed will change the ExpectedHTMLpageID to prevent abuse for the next request.

public string ExpectedHTMLpageID { get; }

Property Value

string

ExternalPageShown

This property indicates that the user has navigated (hopefully temporary) to an external page.

public bool ExternalPageShown { get; set; }

Property Value

bool

FirstApplicationID

Returns the SysApplicationID of the first application in this project the user is allowed to use.

public int FirstApplicationID { get; set; }

Property Value

int

FrameSetQueryString

Returns the QueryString that was used when this session was initiated and the frameset was retrieved.

public clsBPwebQueryString FrameSetQueryString { get; }

Property Value

clsBPwebQueryString

Framed

This property indicates the current web application runs in a frame / an iframe. It will change the behaviour of redirecting to the correct page.

public bool Framed { get; set; }

Property Value

bool

GUID

Returns a GUID for this object.

public string GUID { get; }

Property Value

string

HTMLpageID

This HTMLpageID is a number that is increased for each page created in this session. It used to used for additional security but has been superceeded by the ExpectedHTMLpageID, which is a random string.

public long HTMLpageID { get; }

Property Value

long

HostName

Returns the IIS HostName for this session.

public string HostName { get; }

Property Value

string

InitialRequestServerVariables

This method returns a string with all server variables ('ALL_RAW') of the initial request used to start this application.

public string InitialRequestServerVariables { get; }

Property Value

string

IsWebServiceRequest

Returns True if this is a temporary session that is instantiated for processing a webservice request.

public bool IsWebServiceRequest { get; }

Property Value

bool

KeepAliveTimerMinutesResponseTime

This property can be used to alter (only to increase) the response time for a abandonned session using the KeepAliveTimer mechanism.

public int KeepAliveTimerMinutesResponseTime { get; set; }

Property Value

int

LanguageChosenByUser

This property gets/set the language as is chosen by the user. This is used if the user changes the language before loggin in; after logging in, the system knows the user has just changed the language and can store that language, else, the system can restore the last known chosen language for this user.

public object LanguageChosenByUser { get; set; }

Property Value

object

LanguageID

This property gets/sets the language for the current session.

public int LanguageID { get; set; }

Property Value

int

LastHitSeconds

This method returns the number of seconds ago a request was processed the last time for this session.

public long LastHitSeconds { get; }

Property Value

long

LocalSession

Returns True if the session is called from the local computer (127.0.0.1 or ::1)

public bool LocalSession { get; }

Property Value

bool

LockSessionTimeOutMinutes

This property gets/set time timeout (in minutes) before the lock screen is automatically shown. Use 0 for 'never'.

public int LockSessionTimeOutMinutes { get; set; }

Property Value

int

LogonAttemptCounter

This property counts the number of (failed) logon attempts. It is reset when the user logs off (after a successful log on)

public int LogonAttemptCounter { get; }

Property Value

int

LogonDateTime

Returns the UTC date/time the user logged on.

public DateTime LogonDateTime { get; }

Property Value

DateTime

MainJSscriptVersion

Returns the version of the Main.JS script.

public string MainJSscriptVersion { get; }

Property Value

string

MaxLogonAttempts

This property gets/sets the maximum number of logon attempts before the session is locked out.

public int MaxLogonAttempts { get; set; }

Property Value

int

Messages

Returns the messages that are queued to be sent out to the user's browser.

public BrowserMessages Messages { get; }

Property Value

BrowserMessages

MessagesProfile

This property gets/sets the messages profile. A messages profile can be used to create a sub-set of messages. For example for a mobile browser, this profile can be set to 'mobile'. For all messages that are then retrieved, first a version is looked up in which the name ends on '.mobile'. If that message is not found, the name without '.mobile' is used.

public string MessagesProfile { get; set; }

Property Value

string

PageNumber

Used internally to detect moveback actions.

public int PageNumber { get; }

Property Value

int

ProcessRequestLockTimeoutSeconds

Although the server is multi-threading, for a single session all requests are handled sequentially. This timeout (in seconds) sets the maximum number of seconds to wait for processing a request when another request is already processed.

public int ProcessRequestLockTimeoutSeconds { get; set; }

Property Value

int

ReconnectURLqueryString

Used internally for reconnecting after a session is expired. This feature preserves url-parameters that were used for the initial request after the reconnect. For example required if a uses goes to application with 'CustomerID=88' in the url. After disconnect and reconnect, the user still wants to see the application for customer 88, not for custer 1.

public string ReconnectURLqueryString { get; set; }

Property Value

string

RemoteIP

Returns the IP address of the session (based on the first request). This can be in ip-4 format or ip-6 format.

public string RemoteIP { get; }

Property Value

string

Request

This method returns the current Request object that is used to process a request from the browser. Can be Nothing if a script runs while no request is being processed.

public Request Request { get; }

Property Value

Request

ScreenHeight

Returns the known height of the user's browser in css pixels (may be different from the actual pixels).

public int ScreenHeight { get; set; }

Property Value

int

ScreenReservedBorderHeight

Used to reserve a border for some custom sized controls (like the zoomed memo box). Is hardly used anymore and superceeded by using CSS.

public int ScreenReservedBorderHeight { get; set; }

Property Value

int

ScreenReservedBorderWidth

Used to reserve a border for some custom sized controls (like the zoomed memo box). Is hardly used anymore and superceeded by using CSS.

public int ScreenReservedBorderWidth { get; set; }

Property Value

int

ScreenWidth

Returns the known width of the user's browser in css pixels (may be different from the actual pixels).

public int ScreenWidth { get; set; }

Property Value

int

SessionDuration

This method returns the total session duration.

public DateTime SessionDuration { get; }

Property Value

DateTime

SessionIDcode

Returns the SessionIDcode for this web-session. The SessionIDcode is added to the URL of all requests in this session for additional safety and is part of the session management.

public string SessionIDcode { get; }

Property Value

string

ShowChangePasswordDialog

Used to show the change password dialog. Use... 0: Do not show: '+1: Show the dialog'; '+2': LogOffIfNotSuccessful ; '+4: required old password'

public enumShowChangePasswordDialog ShowChangePasswordDialog { get; set; }

Property Value

enumShowChangePasswordDialog

ShowChangePasswordDialog_PasswordExpiryTime

The expiration-date/time of the current entered password. Is used to prevent the dialog to be on screen for a long time, in which someone else can enter a new password when the computer is left alone. Use the local time for this property.

public DateTime ShowChangePasswordDialog_PasswordExpiryTime { get; set; }

Property Value

DateTime

ShowChangePasswordDialog_PasswordExpiryTimeX

As property ShowChangePasswordDialog_PasswordExpiryTime, but instead of the local time, this property uses the SystemTime (UTC)

public DateTime ShowChangePasswordDialog_PasswordExpiryTimeX { get; set; }

Property Value

DateTime

TextButtons

Returns the TextButtons for this application. The TextButtons object can be used to create or change custom text buttons.

public TextButtons TextButtons { get; }

Property Value

TextButtons

TimeOut

This property gets/sets the Timeout in minutes. If the user is not active for the specified number of minutes, the user is logged off. The value must be between 5 and 1440 minutes.

public int TimeOut { get; set; }

Property Value

int

TotalBytes

Returns the total number of bytes for all processed requests in this session.

public double TotalBytes { get; }

Property Value

double

TotalHits

This method returns the total number of hits that are processed in this session.

public int TotalHits { get; }

Property Value

int

TotalTicks

This method returns the total ticks used to process requests for this session.

public long TotalTicks { get; }

Property Value

long

UIbuttons

Returns all session-buttons that are created in Polar Studio. The buttons are indexed on their name.

public Buttons UIbuttons { get; }

Property Value

Buttons

UserAgent

Returns the string sent by the browser to identify the UserAgent

public string UserAgent { get; }

Property Value

string

Variables

The Variables can be used to store custom information in the (Web)Session

public Dictionary Variables { get; }

Property Value

Dictionary

Methods

CreateDeleteButton(string)

This helper function is meant to create the HTML to show the standard delete button for a given RecordID. This helper is meant for custom controls.

public string CreateDeleteButton(string pRecordID)

Parameters

pRecordID string

The RecordID

Returns

string

The html for the delete button.

CreateSelectItemPopupHTML(string, object, string, string, string, string)

This method can be used by scripts to create the HTML to show a select-item popup control.

public string CreateSelectItemPopupHTML(string pFieldName, object pRepostFormOnChange, string pValue, string pDisplayValue, string pStyleAndClassExpression, string pFollowLinkHTML = "")

Parameters

pFieldName string

The HTML name of the field

pRepostFormOnChange object

Set this parameter to True if a repost must be applied when the user selects another value.

pValue string

The initial value of this control

pDisplayValue string

The initial display value of the control.

pStyleAndClassExpression string

A full string with: class='...' style='...'

pFollowLinkHTML string

The html for the follow-link button.

Returns

string

The html for the SelectItemPopup control.

HistoryClear()

This method clears the history of actions. This history is used to determine the behaviour if the user presses the back button in the browser.

public void HistoryClear()

HistoryGoBack()

This method is to invoke a 'go back in history' action and brings the user back one step in the application (if possible).

public void HistoryGoBack()

LogOff()

This method is used to log off from the web session. It is possible to directly let this be followed by a Logon, to logon as a different user for example.

public void LogOff()

LogOn(string, string)

This method tries to log on in this session with the given credentials. Give an empty string for both the UserID and the password to let the 'Automatic logon' run.

public bool LogOn(string pUserID, string pPassword)

Parameters

pUserID string

The UserID to log on with.

pPassword string

The password to log on with.

Returns

bool

OpenApplication(string)

This method will open a web-application for the current session. If the application is already open, it will be moved to the foreground.

public void OpenApplication(string pApplicationPID)

Parameters

pApplicationPID string

The PID, Name or SysApplicationID of the application to open.

RequestOneTimePassword()

This method is meant to start the request for a new One Time Password. A number of events must be implemented to let this work. Please use the documentation for more info.

public string RequestOneTimePassword()

Returns

string

ScriptActionURL(Context, string, string, bool, string, bool)

This property allows a script action to be registered in the session and to be initiated by an URL. This way, there is less need for adding 'Unprotected'-scripts.

public string ScriptActionURL(Context pContext, string pOnActionScript, string pUpdateMode = "Update", bool pReturnAsPlainJavascriptExpression = false, string pConfirmationQuestion = "", bool pInteractive = false)

Parameters

pContext Context

The Context the script must run in.

pOnActionScript string

The action to perform, like 'CallMyAction(Context, 55)'

pUpdateMode string

Must the action be carried out with out without update. Use one of 'update' (changes sent to server and updated. If update fails, the action is not performed), 'noupdate' (al changes are discarded), 'quickupdate' (changes sent to the server but not yet saved)

pReturnAsPlainJavascriptExpression bool

If this parameter is passed as True, a plain javascript expression is returned. Else, an expression is returned as can be used for an anchor (A) html element, like 'javascript;GetParent().DoAction..'

pConfirmationQuestion string

An optional question to ask the user for confirmation before

pInteractive bool

A boolean indicating the action must be carried out 'interactive' (instead of posting the whole form).

Returns

string

An URL containing a javascript expression or only the play javascript expression.

SendMessage(string, bool, string, string, string, string, string, string, string, object, string, Context)

This method sends a message to a user that is shown in a popup in the browser.

public void SendMessage(string pMessage, bool pMessageIsHtmlFormatted = false, string pCaption = "", string pIconURL = "", string pOnOkScript = "", string pOnCancelScript = "", string pOkButtonCaption = "", string pCancelButtonCaption = "", string pStyle = "", object pReverseButtons = null, string pOnCloseScript = "", Context pContext = null)

Parameters

pMessage string

The message to send to the user.

pMessageIsHtmlFormatted bool

A boolean parameter indicating the passed message contains HTML. Only pass as true if your own code makes sure al variable data is converted to HTML.

pCaption string

An optional caption for the caption of the popup dialog

pIconURL string

The URL to use for the icon that is shown in the popup.

pOnOkScript string

The script-expression to execute server side when the users clicks the OK button. The expression can be preceeded by an exclamation-mark to run the given script-expression 'interactively'. When an expression is given that starts with a @, this expression is fired as javascript in the browser.

pOnCancelScript string

The Cancel button will be hidden if this parameter is empty. Use only a minus character to show the cancel button but to take no action. Else, this paramater contains the script-expression to execute server side when the users clicks the OK button. The expression can be preceeded by an exclamation-mark to run the given script-expression 'interactively'. When an expression is given that starts with a @, this expression is fired as javascript in the browser.

pOkButtonCaption string

The caption of the OK button if it should be differen than OK. Specify as '---' (3x minus) to completely hide the OK button.

pCancelButtonCaption string

The caption of the Cancel button if it should be differen than Cancel.

pStyle string

A css-class that is applied to the elements in the Popup and that can be used to style popups using your custom CSS.

pReverseButtons object

A boolean parameter to indicate that the OK and Cancel buttons must trade places (thus Cancel / OK)

pOnCloseScript string

The Close-cross button in the top-right corner of the dialog will be hidden if this parameter is empty. Use only a minus character to show the close button but to take no action. Else, this paramater contains the script-expression to execute server side when the users clicks the OK button. The expression can be preceeded by an exclamation-mark to run the given script-expression 'interactively'. When an expression is given that starts with a @, this expression is fired as javascript in the browser.

pContext Context

The context to use for the action-scripts. In particular in a multiple document environment this can be important.

SendSSEmessage(string, string, int)

This method is used to send a SSE (server side event) message to the browser. In the browser, the receiver must have registered itself first. The message is queued, so all messages are sent sequentially to the browser.

public void SendSSEmessage(string pReceiver, string pPayload, int pValidLifeTimeSeconds = 60)

Parameters

pReceiver string

The name of the receiver as was used in the browser.

pPayload string

The payload to send to the receiver. Preferably a JSON string.

pValidLifeTimeSeconds int

The time in seconds this message is valid. Defaults to 60. If the message expires before it could be delivered, it will be removed.

SetLanguageBasedOnBrowser()

This method will set the language of the session based on the Accept-language http header sent by the browser.

public void SetLanguageBasedOnBrowser()

ShowLockScreen()

This method shows the LockScreen. The user must than re-enter the (one time) password to reactivate the session.

public void ShowLockScreen()