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
BPserver
Returns the current server (presentation layer).
public BPserver BPserver { get; }
Property Value
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
Engine
Returns the engine. This propery is always available.
public BudaEngine Engine { get; }
Property Value
Field
Returns the current field.
public BudaField Field { get; }
Property Value
Group
Returns the group for the current logged in user.
public BudaGroup Group { get; }
Property Value
Request
Returns the current request that is being processed.
public Request Request { get; }
Property Value
Session
Returns the current session (data layer).
public BudaSession Session { get; }
Property Value
User
Returns the current user.
public BudaUser User { get; }
Property Value
WebApplication
Returns the current web applicatioin (data layer).
public Application WebApplication { get; }
Property Value
WebControl
Returns the current web control.
public Control WebControl { get; }
Property Value
WebForm
Returns the current web form.
public Form WebForm { get; }
Property Value
WebSession
Returns the current web session (presentation layer).
public Session WebSession { get; }
Property Value
Methods
CreateTransaction()
public Transaction CreateTransaction()
Returns
Exceptions
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
objectThe date/time to convert
pTimeZone
PolarTimeZoneThe 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
boolThis boolean property can be set to True to force the seconds to be included (even if :00)
Returns
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
stringThe 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
stringThe 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
intThis 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
stringThe 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
intThis by-ref int parameter will return the number of affected records as reported by the database.
pErrorMessage
stringA 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
stringThe 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
stringA 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
stringThe 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
objectThe number to convert.
pDecimals
intThe number of decimals to display.
pThousandsSeparators
boolThis boolean can be set to True to visually separate the thousands.
Returns
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
stringThe 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
boolWhen 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
stringThe 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
boolWhen 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
boolThis 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
stringThe 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
boolWhen 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
intThis by-ref int parameter will return the number of affected records as reported by the database.
pOpenInNewConnection
boolThis boolean can be set to True, to make sure the recordset is opened in a new (cloned) connection.
pReturnedConnection
PolarConnectionThis 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
stringThe 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
boolWhen 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
intThis by-ref int parameter will return the number of affected records as reported by the database.
pOpenInNewConnection
boolThis 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
stringThe 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
stringThe action to perform, like 'CallMyAction(Context, 55)'
pUpdateMode
stringMust 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
boolIf 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
stringAn optional question to ask the user for confirmation before
pInteractive
boolA 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
stringThe message to send to the user.
pMessageIsHtmlFormatted
boolA 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
stringAn optional caption for the caption of the popup dialog
pIconURL
stringThe URL to use for the icon that is shown in the popup.
pOnOkScript
stringThe 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
stringThe 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
stringThe caption of the OK button if it should be differen than OK. Specify as '---' (3x minus) to completely hide the OK button.
pCancelButtonCaption
stringThe caption of the Cancel button if it should be differen than Cancel.
pStyle
stringA css-class that is applied to the elements in the Popup and that can be used to style popups using your custom CSS.
pReverseButtons
objectA boolean parameter to indicate that the OK and Cancel buttons must trade places (thus Cancel / OK)
pOnCloseScript
stringThe 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
stringThe 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
stringThe string to convert to a date time
pErrorMessage
stringThis by ref string will be set to an error message if applicable.
pTimeZone
PolarTimeZoneIf 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
stringThe number to convert
Returns
- double
A double.