Table of Contents

Class Context

Namespace
PolarStudio
Assembly
PolarStudio.dll

This class is the generic interface to the items in the context. Depending on the source of the context, some properties may be Nothing/null.

public class Context
Inheritance
Context
Inherited Members
Extension Methods

Properties

Application

Returns the current application (data layer)

public BudaApplication Application { get; }

Property Value

BudaApplication

BPserver

Returns the current server (presentation layer).

public BPserver BPserver { get; }

Property Value

BPserver

CurrentContext

This method returns a new Transaction-object for easier programming.

public object CurrentContext { get; }

Property Value

object

A new Transaction object

DataSet

Returns the current dataset.

public BudaDataSet DataSet { get; }

Property Value

BudaDataSet

Engine

Returns the engine. This propery is always available.

public BudaEngine Engine { get; }

Property Value

BudaEngine

Field

Returns the current field.

public BudaField Field { get; }

Property Value

BudaField

Group

Returns the group for the current logged in user.

public BudaGroup Group { get; }

Property Value

BudaGroup

Request

Returns the current request that is being processed.

public Request Request { get; }

Property Value

Request

Session

Returns the current session (data layer).

public BudaSession Session { get; }

Property Value

BudaSession

User

Returns the current user.

public BudaUser User { get; }

Property Value

BudaUser

WebApplication

Returns the current web applicatioin (data layer).

public Application WebApplication { get; }

Property Value

Application

WebControl

Returns the current web control.

public Control WebControl { get; }

Property Value

Control

WebForm

Returns the current web form.

public Form WebForm { get; }

Property Value

Form

WebSession

Returns the current web session (presentation layer).

public Session WebSession { get; }

Property Value

Session

Methods

CreateTransaction()

public Transaction CreateTransaction()

Returns

Transaction

Exceptions

Exception

DateToString(object, PolarTimeZone, bool)

This method is a helper to convert a date/time value to a string using the most appropriate settings for this context.

public string DateToString(object pDate, PolarTimeZone pTimeZone = null, bool pForceIncludeSeconds = false)

Parameters

pDate object

The date/time to convert

pTimeZone PolarTimeZone

The time zone the result must be in (if a time zone is specified, the given pDate is expected to be a UTC date/time)

pForceIncludeSeconds bool

This boolean property can be set to True to force the seconds to be included (even if :00)

Returns

string

Execute(string)

This method executes a SQL statetment on the current database. The by-ref parameter pErrorMessage will be filled with an errormessage if applicable.

public void Execute(string pSQLstring)

Parameters

pSQLstring string

The SQL statement to execute. The statement can start with an exclamation mark to send the statement 'raw' to the connection without any translation to the current dialect. If the statement starts with a tilde (~), this conversion is also suppressed and logging the query in Polar Studio will be suppressed.

Execute(string, ref int)

This method executes a SQL statetment on the current database. The by-ref parameter pErrorMessage will be filled with an errormessage if applicable.

public void Execute(string pSQLstring, ref int pRecordsAffected)

Parameters

pSQLstring string

The SQL statement to execute. The statement can start with an exclamation mark to send the statement 'raw' to the connection without any translation to the current dialect. If the statement starts with a tilde (~), this conversion is also suppressed and logging the query in Polar Studio will be suppressed.

pRecordsAffected int

This by-ref int parameter will return the number of affected records as reported by the database.

Execute(string, ref int, ref string)

This method executes a SQL statetment on the current database. The by-ref parameter pErrorMessage will be filled with an errormessage if applicable.

public void Execute(string pSQLstring, ref int pRecordsAffected, ref string pErrorMessage)

Parameters

pSQLstring string

The SQL statement to execute. The statement can start with an exclamation mark to send the statement 'raw' to the connection without any translation to the current dialect. If the statement starts with a tilde (~), this conversion is also suppressed and logging the query in Polar Studio will be suppressed.

pRecordsAffected int

This by-ref int parameter will return the number of affected records as reported by the database.

pErrorMessage string

A by-ref parameter to receive the errormessage.

Execute(string, ref string)

This method executes a SQL statetment on the current database. The by-ref parameter pErrorMessage will be filled with an errormessage if applicable.

public void Execute(string pSQLstring, ref string pErrorMessage)

Parameters

pSQLstring string

The SQL statement to execute. The statement can start with an exclamation mark to send the statement 'raw' to the connection without any translation to the current dialect. If the statement starts with a tilde (~), this conversion is also suppressed and logging the query in Polar Studio will be suppressed.

pErrorMessage string

A by-ref parameter to receive the errormessage.

Lookup(string)

This method will execute the given query and return the first field of the first record. If no data is found or an exception was raised, NULL will be returned.

public object Lookup(string pQuery)

Parameters

pQuery string

The query to execute, like 'SELECT COUNT(*) FROM Customer'

Returns

object

The value of the first field of the first record returned by the query or NULL in all other cases.

NumberToString(object, int, bool)

This method is a helper to convert a number value to a string using the most appropriate settings for this context.

public string NumberToString(object pNumber, int pDecimals = -1, bool pThousandsSeparators = false)

Parameters

pNumber object

The number to convert.

pDecimals int

The number of decimals to display.

pThousandsSeparators bool

This boolean can be set to True to visually separate the thousands.

Returns

string

OpenDynamicRecordSet(string, bool)

This method returns a dynamic recordset. Dynamic recordsets use a server-side cursor. They are slower in processing but offer more updating features and multiple dynamic recordsets can be opened while in a transaction.

public Recordset OpenDynamicRecordSet(string pSQLstring, bool pRemoveBpTags = false)

Parameters

pSQLstring string

The SQL statement to execute. The statement can start with an exclamation mark to send the statement 'raw' to the connection without any translation to the current dialect. If the statement starts with a tilde (~), this conversion is also suppressed and logging the query in Polar Studio will be suppressed.

pRemoveBpTags bool

When this parameter is set to True, the 'Blue Polar tags' are removed. These tags are sometimes within Polar Studio added to queries to easily identify parts and are like ^<#>'

Returns

Recordset

A dynamic recordset.

OpenStaticRecordSet(string, bool, bool)

This method opens a static recordset. Static recordsets are fast for reading, but use a forward-only cursor. Also, they do not return the recordcount. Exceptions will be thrown.

public Recordset OpenStaticRecordSet(string pQuery, bool pRemoveBpTags = false, bool pOpenInNewConnection = false)

Parameters

pQuery string

The SQL statement to execute. The statement can start with an exclamation mark to send the statement 'raw' to the connection without any translation to the current dialect. If the statement starts with a tilde (~), this conversion is also suppressed and logging the query in Polar Studio will be suppressed.

pRemoveBpTags bool

When this parameter is set to True, the 'Blue Polar tags' are removed. These tags are sometimes within Polar Studio added to queries to easily identify parts and are like ^<#>'

pOpenInNewConnection bool

This boolean can be set to True, to make sure the recordset is opened in a new (cloned) connection.

Returns

Recordset

A static recordset.

OpenStaticRecordSet(string, bool, int, bool, ref PolarConnection)

This method opens a static recordset. Static recordsets are fast for reading, but use a forward-only cursor. Also, they do not return the recordcount. Exceptions will be thrown.

public Recordset OpenStaticRecordSet(string pQuery, bool pRemoveBpTags, int pRecordsAffected, bool pOpenInNewConnection, ref PolarConnection pReturnedConnection)

Parameters

pQuery string

The SQL statement to execute. The statement can start with an exclamation mark to send the statement 'raw' to the connection without any translation to the current dialect. If the statement starts with a tilde (~), this conversion is also suppressed and logging the query in Polar Studio will be suppressed.

pRemoveBpTags bool

When this parameter is set to True, the 'Blue Polar tags' are removed. These tags are sometimes within Polar Studio added to queries to easily identify parts and are like ^<#>'

pRecordsAffected int

This by-ref int parameter will return the number of affected records as reported by the database.

pOpenInNewConnection bool

This boolean can be set to True, to make sure the recordset is opened in a new (cloned) connection.

pReturnedConnection PolarConnection

This by-ref parameter returns the connection used to open the query in.

Returns

Recordset

A static recordset.

OpenStaticRecordSet(string, bool, ref int, bool)

This method opens a static recordset. Static recordsets are fast for reading, but use a forward-only cursor. Also, they do not return the recordcount. Exceptions will be thrown.

public Recordset OpenStaticRecordSet(string pQuery, bool pRemoveBpTags, ref int pRecordsAffected, bool pOpenInNewConnection = false)

Parameters

pQuery string

The SQL statement to execute. The statement can start with an exclamation mark to send the statement 'raw' to the connection without any translation to the current dialect. If the statement starts with a tilde (~), this conversion is also suppressed and logging the query in Polar Studio will be suppressed.

pRemoveBpTags bool

When this parameter is set to True, the 'Blue Polar tags' are removed. These tags are sometimes within Polar Studio added to queries to easily identify parts and are like ^<#>'

pRecordsAffected int

This by-ref int parameter will return the number of affected records as reported by the database.

pOpenInNewConnection bool

This boolean can be set to True, to make sure the recordset is opened in a new (cloned) connection.

Returns

Recordset

A static recordset.

RecordExists(string)

This method runs a query and returns True if at least one record was returned. If an exception was raised, this method returns False.

public bool RecordExists(string pQuery)

Parameters

pQuery string

The query to execute, like 'SELECT TOP 1 * FROM Customer WHERE Status = 9'

Returns

bool

True if the given query returned at least one record.

ScriptActionURL(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(string pOnActionScript, string pUpdateMode = "Update", bool pReturnAsPlainJavascriptExpression = false, string pConfirmationQuestion = "", bool pInteractive = false)

Parameters

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)

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 = "")

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.

StringToDate(string)

This method is a helper to convert a string to a date/time value using the most appropriate settings for this context.

public DateTime StringToDate(string pInputString)

Parameters

pInputString string

The string to convert to a date time

Returns

DateTime

A date/time value.

StringToDate(string, ref string, PolarTimeZone)

This method is a helper to convert a string to a date/time value using the most appropriate settings for this context.

public DateTime StringToDate(string pInputString, ref string pErrorMessage, PolarTimeZone pTimeZone = null)

Parameters

pInputString string

The string to convert to a date time

pErrorMessage string

This by ref string will be set to an error message if applicable.

pTimeZone PolarTimeZone

If a time zone is specified, the resulting date time is converted to the UTC date time that corresponds to the given date time in the given time zone.

Returns

DateTime

A date/time value.

StringToNumber(string)

This method is a helper to convert a string to a number value using the most appropriate settings for this context.

public double StringToNumber(string pInputString)

Parameters

pInputString string

The number to convert

Returns

double

A double.