Skip to content

Application Library

ThreadLocalStorage


Description

Stores and retrieves data local to current Thread.

Methods

Get(string)

Description

Return Type : Object

Static : Yes

Namespace : AppLib.ThreadLocalStorage

Parameters

Name Data Type Description
key string




Remove(string)

Description

Return Type : void

Static : Yes

Namespace : AppLib.ThreadLocalStorage

Parameters

Name Data Type Description
key string




Set(string, Object)

Description

Return Type : void

Static : Yes

Namespace : AppLib.ThreadLocalStorage

Parameters

Name Data Type Description
key string
obj Object




Session


Description

Provides information and tools related to current user's Session

Properties

Name Data Type Static Readonly Description
Storage Dictionary Yes No Stores and retrieves data related to a user Session. Data is erased when user session expires.
CurrentLanguage Domain.ApplicationLanguage Yes No Gets the Language details, used in the user's Application instance.
CurrentLocale Domain.ApplicationLanguage Yes No Gets the Locale details, used in the user's Application instance.

Methods

GetCurrentUserName()

Description

Returns the Username of the logged-in user.

Return Type : string

Static : Yes

Namespace : AppLib.Session

Syntax

if (AppLib.Session.GetCurrentUserName() == "Administrator") {
    return;
}



GetCurrentUser()

Description

Returns the logged-in Application User.

Return Type : Domain.ApplicationUser

Static : Yes

Namespace : AppLib.Session

Syntax

Domain.ApplicationUser user = AppLib.Session.GetCurrentUser();



Abandon()

Description

Removes all the objects stored in a Session.

Return Type : void

Static : Yes

Namespace : AppLib.Session

Syntax

AppLib.Session.Abandon();



ClearAuditTrailCache()

Description

Clears Audit Trail cached data and reloads its configuration.

Return Type : void

Static : Yes

Namespace : AppLib.Session

Syntax

AppLib.Session.ClearAuditTrailCache();



Security


Description

Provides information and functionality with regards to a user's Authentication, Permissions, Validations, Registrations, Encryptions, Descryptions etc.

Methods

SignOutUser()

Description

Signs out current User.

Return Type : void

Static : Yes

Namespace : AppLib.Security

Syntax

AppLib.Security.SignOutUser();
FormModels.SignInPage.Controller.Load.Execute();



SignInUser(string, string, bool)

Description

Signs in User if the login credentials are correct, else displays an error message informing user that he did not log in successfully.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
username string The Username of the user who tries to log in
password string The Password of the user who tries to log in
remember bool The value of the option 'Remember me'. True if user has selected the option 'Remember me' on the Sign-In page

Syntax

bool success = AppLib.Security.SignInUser(Model.UserNameTextBox, Model.PasswordTextBox, Model.RememberMeCB);
if !success {
    ShowMessage(LocalResources.SignInFailed, AppLib.MessageType.Error);
    return;
}



ValidateUser(string, string)

Description

Returns true, if the User credentials provided as inputs to the method are a valid match. Otherwise, returns false.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
username string The Username of the user
password string The Password of the user

Syntax

bool validMatch = AppLib.Security.ValidateUser(Model.UserNameTextBox, Model.PasswordTextBox);

if (!validMatch) 
{
    ShowMessage("The User credentials provided are invalid!", AppLib.MessageType.Error);
} 
else 
{
    ShowMessage("The User credentials provided are valid!");
}



GenerateEmailConfirmationToken(Domain.ApplicationUser)

Description

Returns a string which is used in order to send a confirmation e-mail upon user registration.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user Domain.ApplicationUser The Application User for whom the token is created

Syntax

Domain.ApplicationUser userToRegister;
string code = AppLib.Security.GenerateEmailConfirmationToken(userToRegister);



GeneratePasswordResetToken(Domain.ApplicationUser)

Description

Returns a string which is used in order to reset User’s password.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user Domain.ApplicationUser The Application User for whom the token is created

Syntax

Domain.ApplicationUser currentUser = AppLib.Session.GetCurrentUser();
string resetToken = AppLib.Security.GenerateEmailConfirmationToken(currentUser);



GetAllConnectedUsers()

Description

Returns all currenty connected users

Return Type : Collection

Static : Yes

Namespace : AppLib.Security

Syntax

Collection[Domain.ApplicationUser] connectedUsers = AppLib.Session.GetAllConnectedUsers();



ConfirmEmail(Domain.ApplicationUser, string)

Description

Returns true if user’s e-mail was confirmed successfully, false if not.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user Domain.ApplicationUser The Application User for whom the token is created
code string The token needed for user’s registration

Syntax

bool success = AppLib.Security.ConfirmEmail(user, code);



CurrentUserHasPermission(string)

Description

Returns true if user has the given Permission, false if not.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
permission string The name of the Permission

Syntax

bool success = AppLib.Security.CurrentUserHasPermission("ManageUsers");



PasswordIsValid(string)

Description

Returns true if the Password provided as input to the method is a valid match with the username of the logged in User. Else returns false.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
password string The Password to be validated

Syntax

bool isPasswordValid = AppLib.Security.PasswordIsValid(Model.PasswordTextBox);

if (!isPasswordValid) 
{
    ShowMessage("The provided Password is invalid!", AppLib.MessageType.Error);
} else 
{
    ShowMessage("The provided Password is valid!");
}



ChangePasswordOfUser(Domain.ApplicationUser, string, string)

Description

Changes the Password of the provided User, given the provided Current Password is correct.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user Domain.ApplicationUser The user who tries to change his password
currentPassword string User’s current password
newPassword string User’s new password

Syntax

string result = AppLib.Security.ChangePasswordOfUser(AppLib.Session.GetCurrentUser(), Model.txtCurrent, Model.txtNew);



ResetPasswordOfUser(Domain.ApplicationUser, string)

Description

Resets the Password of the provided User, to the value of the provided New Password.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user Domain.ApplicationUser The user subject to password reset
newPassword string The new password

Syntax

var success = AppLib.Security.ResetPasswordOfUser(Model.UserWhosePasswordToReset, Model.NewPassword);



SignOutUserFromAllSessions(Domain.ApplicationUser)

Description

Forces sign out of a user from all connected clients

Return Type : void

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user Domain.ApplicationUser The user subject to sign out

Syntax

var success = AppLib.Security.SignOutUserFromAllSessions(Model.UserToSignOut);



ResetPasswordOfUserAsAdmin(Domain.ApplicationUser, string)

Description

Allows Admins to reset the Password of the provided User, to the value of the provided New Password. This only works if 'Allow Admins to set user passwords' setting is turned on.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user Domain.ApplicationUser The user subject to password reset
newPassword string The new password

Syntax

var success = AppLib.Security.ResetPasswordOfUserAsAdmin(Model.UserWhosePasswordToReset, Model.NewPassword);



GetAdminCanSetPasswordSetting()

Description

Returns true if 'Allow Admins to set user passwords' setting is turned on, false if turned off.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Syntax

var adminCanSetPasswords = AppLib.Security.GetAdminCanSetPasswordSetting();



ResetPasswordOfUser(Domain.ApplicationUser, string, string)

Description

Resets a user password using a reset password token.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user Domain.ApplicationUser The user subject to password reset
code string The password token
newPassword string New password

Syntax

var success = AppLib.Security.ResetPasswordOfUser(Domain.ApplicationUser.GetByKey("admin"), "myToken", "admin1234!");



RegisterUser(Domain.ApplicationUser, string)

Description

Creates an Application User for this user by registering him in the application. If user is registered successfully null is returned, otherwise the error description.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
name Domain.ApplicationUser The user who will be registered
password string User’s password

Syntax

string error =  AppLib.Security.RegisterUser(userToRegister, Model.PasswordTextBox);



RegisterOSUser(Domain.ApplicationUser)

Description

Creates an Application User for this user by registering him in the application as an OS Authenticated user. If user is registered successfully null is returned, otherwise the error description. CAUTION: Use this method ONLY with Applications that are using 'OS Authentication'!

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
OSUser Domain.ApplicationUser The user to be be registered with Operating System (OS) Authentication

Syntax

Domain.WindowsUser windowsUser; 
string error =  AppLib.Security.RegisterOSUser(windowsUser);



GoogleAccountIsLinked(DomainModel.ApplicationUser)

Description

Returns true, if the user's Google Account has been successfully linked with the Application.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user DomainModel.ApplicationUser The User being checked for a linked Google Account

Syntax

bool success = AppLib.Security.GoogleAccountIsLinked(user);



FacebookAccountIsLinked(DomainModel.ApplicationUser)

Description

Returns true, if the user's Facebook Account has been successfully linked with the Application.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user DomainModel.ApplicationUser The User being checked for a linked Facebook Account

Syntax

bool success = AppLib.Security.FacebookAccountIsLinked(user);



AESEncrypt(string, string)

Description

Encrypt an arbitrary string using the provided key it uses AES Algorithm.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
input string An arbitrary string
key string Encryption key. It should be 128bit, 192bit or 256-bit length.

Syntax

string encryptedText = AppLib.Security.AESEncrypt("test", "B374A26A71490437AA024E4FADD5B497");



AESDecrypt(string, string)

Description

Decrypt an arbitrary string using the provided key it uses AES Algorithm.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
input string An arbitrary string
key string Encryption key. It should be 128bit, 192bit or 256-bit length.

Syntax

string decryptedText = AppLib.Security.AESDecrypt("Gnn5xHQmP6rUNL6umP16lQ==", "B374A26A71490437AA024E4FADD5B497");



AESDecrypt(string, string, bool)

Description

Decrypt an arbitrary string using the provided key it uses AES Algorithm, skip key validation if needed.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
input string An arbitrary string
key string Encryption key. It should be 128bit, 192bit or 256-bit length.
validateKey bool Flag for testing key's validity

Syntax

string decryptedText = AppLib.Security.AESDecrypt("Gnn5xHQmP6rUNL6umP16lQ==", "B374A26A71490437AA024E4FADD5B497",  false);



AESDecrypt(string, string, bool, bool)

Description

Decrypt an arbitrary string using the provided key it uses AES Algorithm, skip key validation if needed and don't handle input as it is at base64 format.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
input string An arbitrary string
key string Encryption key. It should be 128bit, 192bit or 256-bit length.
validateKey bool Flag for testing key's validity
inputIsBASE64 bool Flag for handling input as it is at base64 format

Syntax

string decryptedText = AppLib.Security.AESDecrypt("Gnn5xHQmP6rUNL6umP16lQ==", "B374A26A71490437AA024E4FADD5B497",  false, true);



AESDecrypt(Array[byte], string, bool, bool)

Description

Decrypt an array of bytes using the provided key it uses AES Algorithm, skip key validation if needed and don't handle input as it is at base64 format.

Return Type : string

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
input Array An array of bytes
key string Encryption key. It should be 128bit, 192bit or 256-bit length.
validateKey bool Flag for testing key's validity
inputIsBASE64 bool Flag for handling input as it is at base64 format

Syntax

Array[byte] encryptedText = CommonLib.Utilities.UTF8ToByteArray("Gnn5xHQmP6rUNL6umP16lQ==");
string decryptedText = AppLib.Security.AESDecrypt(encryptedText, "B374A26A71490437AA024E4FADD5B497",  false, true);



IsAuthenticatedByOS()

Description

Returns true if the Current User is Authenticated using OS Authentication.

Return Type : bool

Static : Yes

Namespace : AppLib.Security

Syntax

bool isWindowsAuthenticated = Applib.Security.IsAuthenticatedByOS( );



InvalidateUserSecurityData(Domain.ApplicationUser)

Description

Invalidates (resets) the Security Data of an Application User

Return Type : void

Static : Yes

Namespace : AppLib.Security

Parameters

Name Data Type Description
user Domain.ApplicationUser The Application User whose Security Data is to be invalidated (reset)

Syntax

if(forceLogout){
    AppLib.Security.InvalidateUserSecurityData(user);
    return;
}



Globalization


Description

Provides Date and Time information, on an international scale, regardless of the chosen Language and/or Locale.

Methods

GetDayName(int)

Description

Returns the name of the day of the week specified. Sunday is 0.

Return Type : string

Static : Yes

Namespace : AppLib.Globalization

Parameters

Name Data Type Description
dayNumber int The number of the day of the week. Sunday is 0.

Syntax

string nameOfDay = Applib.Security.GetDayName(0);



GetMonthName(int)

Description

Returns the name of the month of the year specified. January is 0.

Return Type : string

Static : Yes

Namespace : AppLib.Globalization

Parameters

Name Data Type Description
monthNumber int The number of the month of the year. January is 0.

Syntax

string nameOfMonth = Applib.Globalization.GetMonthName(0);



Application


Description

Exports information and functionality regarding the running Application, such as Version, Coniguration, Error, defined Classes etc.

Properties

Name Data Type Static Readonly Description
Id int Yes No Deprecated attribute
Name string Yes No The Name of the running Application
MajorVersion int Yes No Application's Major revision number
MinorVersion int Yes No Application's Minor revision number
PatchVersion int Yes No Application's Patch revision number
SemanticVersion string Yes No Application's full Semantic version. ie: 1.0.3

Methods

GetTypes()

Description

Returns a collection of RuntimeType instances for every class defined in app's Domain.

Return Type : Collection

Static : Yes

Namespace : AppLib.Application

Syntax

Collection[RuntimeType] types = AppLib.Application.GetTypes();



GetConfigurationKey(string)

Description

Returns the value of an Application Setting, as defined in Configuration model.

Return Type : string

Static : Yes

Namespace : AppLib.Application

Parameters

Name Data Type Description
key string Application Setting Key

Syntax

var appVersion = AppLib.Application.GetConfigurationKey("Version");



GetLastError()

Description

Gets Last Error thrown by the Application.

Return Type : AppLib.Error

Static : Yes

Namespace : AppLib.Application

Syntax

string errorMessage = AppLib.Application.GetLastError().Message;



ApplicationCache


Description

Exports methods that get, set and remove items from the Application Cache.

Methods

Get(string)

Description

This function returns the object that is setted to the application cache with the specified key. If no object found returns null.

Return Type : Object

Static : Yes

Namespace : AppLib.ApplicationCache

Parameters

Name Data Type Description
key string The key to search for the object

Syntax

Domain.MyClass myObject = Applib.ApplicationCache.Get(key);



Remove(string)

Description

This function removes the entry with the specified key from the application cache.

Return Type : void

Static : Yes

Namespace : AppLib.ApplicationCache

Parameters

Name Data Type Description
key string The key of the element to remove

Syntax

Applib.ApplicationCache.Remove(key);



Set(string, Object)

Description

This function sets the specified key and value to the application cache.

Return Type : void

Static : Yes

Namespace : AppLib.ApplicationCache

Parameters

Name Data Type Description
key string The key of the element to add
value Object The value of the element to add

Syntax

Domain.MyClass object;
Applib.ApplicationCache.Set("myKey",object);



AddIfNotExists(string, Object)

Description

This function adds a new value to the application cache with the specific key if the key isn't already defined, and it returns true; otherwise, it not set it and returns false.

Return Type : bool

Static : Yes

Namespace : AppLib.ApplicationCache

Parameters

Name Data Type Description
key string The key of the element to add
value Object The value of the element to add

Syntax

Domain.MyClass object;
var isSucceed = Applib.ApplicationCache.AddIfNotExists("myKey", object);



Error


Description

Error or Exception thrown by the Application

Properties

Name Data Type Static Readonly Description
Message string No No Description of the error or exception
StackTrace string No No Trace of the executed methods that led to the error occurence

Methods

GetFriendlyMessage()

Description

Returns the last error in a user friendly format.

Return Type : string

Static : No

Namespace : AppLib.Error

Syntax

string friendlyErrorMessage = AppLib.Application.GetLastError().GetFriendlyMessage();



MessageType


Description

Enumeration holding all the available Message Types.

Properties

Name Data Type Static Readonly Description
Success string No No Message presenting a successful outcome
Error string No No Message presenting an error that has occured
Warning string No No Message presenting a warning
Info string No No Informational message
Back to top