Class Connector
This connection class provides the functionality for connecting to and logging into the LemonEdge system.
When any client application has logged into the system, either directly or through a web service, this also holds all the connection information for the client
Inheritance
Implements
Inherited Members
Namespace: LemonEdge.Client.Core.CommonUI
Assembly: API.dll
Syntax
public sealed class Connector : IDataUpdaterFactoryRegister
Properties
CurrentCache
Returns the current local cache for the client app
Declaration
public static IReadOnlyCache CurrentCache { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCache |
Factory
The current connection provider
Declaration
public static IDataUpdaterFactory Factory { get; }
Property Value
Type | Description |
---|---|
IDataUpdaterFactory |
FactoryTypes
A list of the connection types supported by the current providers added to this connection (via AddProvider(IDataUpdaterFactory))
Declaration
public static IEnumerable<ConnectionType> FactoryTypes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ConnectionType> |
Instance
The current static instance of this Connector, representing the current client connection to LemonEdge
Declaration
public static Connector Instance { get; }
Property Value
Type | Description |
---|---|
Connector |
IsUserFromRootAccount
Indicates if the current logged in user is part of the root account of the connected database.
Root accounts have greater access to what can be modified in the system
Declaration
public static bool IsUserFromRootAccount { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
LoggedInDatabaseAlias
The alias of the currently connected database
Declaration
public static string LoggedInDatabaseAlias { get; }
Property Value
Type | Description |
---|---|
System.String |
LoggedInSessionID
The globally unique id of the current logged in users session.
Depending on configuration, sessions can expire
Declaration
public static Guid LoggedInSessionID { get; }
Property Value
Type | Description |
---|---|
System.Guid |
LoggedInUser
The user information for the current logged in user
Declaration
public static UserInfo LoggedInUser { get; }
Property Value
Type | Description |
---|---|
UserInfo |
ServiceConnection
Returns the current connection string the current connection service is using
Declaration
public static string ServiceConnection { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
AddProvider(IDataUpdaterFactory)
Adds a connection provider for the client to be able to use in order to login, and interact with the system.
These providers are provided by LemonEdge, one for direct database connection and the other for connections via our web service
Declaration
public void AddProvider(IDataUpdaterFactory factory)
Parameters
Type | Name | Description |
---|---|---|
IDataUpdaterFactory | factory | The provider for a type of connection method |
Create()
If the system has logged in this will create and return an IEntityUpdaterUI for querying, retrieveing and modifying all entities in the system
Declaration
public static Task<IEntityUpdaterUI> Create()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IEntityUpdaterUI> | An IEntityUpdaterUI for querying, retrieveing and modifying all entities in the system |
ForceServiceURIUpdate()
Forces the system to reconnect to the current webservice and download the model again, used if the model is known to have changed
Declaration
public static Task ForceServiceURIUpdate()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
GetDatabaseAliases()
Returns all aliases the system can connect to if connecting through a web service
Declaration
public static Task<IEnumerable<string>> GetDatabaseAliases()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<System.String>> | A list of aliases that can be used when connecting referring to different databases behind the service |
IsLicensed()
Returns if the current logged in user has a valid license associated with this account
Declaration
public static Task<bool> IsLicensed()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
LoggedInUniqueConnection()
Returns the unique connection for the current login
Used for verifying local stored caches can be reused for the correct connections
Declaration
public static string LoggedInUniqueConnection()
Returns
Type | Description |
---|---|
System.String | The unique connection for the current login |
LoggedInUserFriendlyConnection(IReadOnlyCache)
Returns a long user friendly string of the current connection, including any currently active canvas, and invalid license info
For a direct database connection this includes database info
For a web service connection this includes the service address and database alias
Declaration
public static Task<string> LoggedInUserFriendlyConnection(IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCache | cache | The current local cache |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | A long user friendly string of the current connection, including any currently active canvas, and invalid license info |
LoggedInUserFriendlyConnection(IReadOnlyCache, Boolean)
Returns a user friendly string of the current connection, including any currently active canvas, and invalid license info
Declaration
public static Task<string> LoggedInUserFriendlyConnection(IReadOnlyCache cache, bool shortVersion)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCache | cache | The current local cache |
System.Boolean | shortVersion | Indicates if the string returned should be a short version for smaller restricted screens such as mobiles |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | A user friendly string of the current connection, including any currently active canvas, and invalid license info |
Login(String, String, String)
Logs into the LemonEdge system using the specified user and password
Declaration
public static Task<UserInfo> Login(string databaseAlias, string userName, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | databaseAlias | The databasealias to connect to. For a direct db connection this is the name of the database, for a web service this is one of the valid aliases the service allows |
System.String | userName | The username to login with |
System.String | password | The plain text password of the user to login with. The plain text is encrypted by this function before being sent anywhere. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<UserInfo> | The UserInfo for the logged in user if login was successful. An error is thrown otherwise. |
LoginWindows(String)
Logs into the LemonEdge system using the current windows domain name user
Declaration
public static Task<UserInfo> LoginWindows(string databaseAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | databaseAlias | The databasealias to connect to. For a direct db connection this is the name of the database, for a web service this is one of the valid aliases the service allows |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<UserInfo> | The UserInfo for the logged in user if login was successful. An error is thrown otherwise. |
OnUpdateServiceConnection(String)
Indicates the connector should use the specified connection url for connecting to a web service, or connection string for connecting to a database
This takes time to complete as the system verifies the webs service, and downloads the model of the webservice it is connecting to (as lemonedge services can have different models depending on the addins)
Declaration
public static Task OnUpdateServiceConnection(string connection)
Parameters
Type | Name | Description |
---|---|---|
System.String | connection | A valid url connection to a lemonedge web service, or database connection |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
ResetLicense()
Resets the cached flag indicating if this license is valid, forcing a new check next time IsLicensed() is called
Declaration
public static void ResetLicense()
SetLocalCache(Func<IReadOnlyCache>)
Sets the function used to return the local instance of the current cache for the client app from the CurrentCache call.
Declaration
public static void SetLocalCache(Func<IReadOnlyCache> getCache)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IReadOnlyCache> | getCache | A function that returns the current local cache for the client |
UseFactory(ConnectionType)
Tells the connector to use the specified type of connection
Declaration
public void UseFactory(ConnectionType type)
Parameters
Type | Name | Description |
---|---|---|
ConnectionType | type | The type of connection to use, either a direct database or web serice |
VerifyLicense(IAccountMaintenance, String)
Returns true if the current license for this account is valid
Declaration
public static Task<bool> VerifyLicense(IAccountMaintenance accountInfo, string license = null)
Parameters
Type | Name | Description |
---|---|---|
IAccountMaintenance | accountInfo | The current account |
System.String | license | An optional license to check. If this is null then the current license against the account (LicenseKey) is used |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True if the current license for this account is valid |