Connecting to Archer with Estrelica.Core
To interact with Archer via Estrelica.Core, you'll first need to validate your license, then provide the Core with connection details and credentials to connect to your Archer instance. This can be done by discrete calls to
public static Core ValidateLicense(Guid authenticationKey, Action<Exception> warningCallback, bool forceRefresh = false)
public Core CreateSession(string archerUrl, string archerInstance, string username, string password, string userDomain = null, string archerDbConnectionString = null)
with all of the relevant parameter values.
Alternately, if you've installed the Estrelica.Core.Configuration package, you can store your authentication key and Archer connection information in an appSettings.json file and let Estrelica.Core read it from there via the Estrelia.CoreConfig.Load() method:
public static Core Estrelica.CoreConfig.Load(Action<Exception> warningCallback, Action<string, LogLevel> logCallback = null, string appConfigFilename = null, string userSecretsId = null, bool forceRefresh = false, string configInstanceName = null)
In both cases, the Action<Exception> warningCallback parameter is required. This is how Estrelica.Core will let you know of any non-fatal issues arising during the license validation step, including notice of upcoming expiration. Since one use case for Estrelica.Core is to develop automated, unattended processes, it cannot display these warnings as pop-ups since there is presumably no active user involved to dismiss them. Therefore it is the responsibility of the developer to ensure that any exceptions returned via this callback are monitored and attended to. For example, it might make sense to log the message or email it to the manager in charge of the project.
If you prefer to handle all of the validation and authentication in code, just call ValidateLicense with the authentication key you received from CastleHill Software and a warningCallback method where you handle the warnings appropriately:
var core = Estrelica.Core.ValidateLicense("5E56F79E-E678-4BAF-8FCF-B50141FAD5C7", wm => Log(wm.Message));
This will verify that your license is in good standing and return an instance of the Estrelica.Core. The details of your license will be available in the core.LicenseText property, so you might want to log that information as well:
// Details of the license may be displayed or logged if desired Log(core.LicenseText);
At this point you can provide your Archer connection info and credentials in order to authenticate with Archer:
core.CreateSession("https://archer-server.company.com", "Archer-Production", "firstname.lastname@example.org", "Password123");
And then the core is ready for use in communicating with Archer.
Of course you wouldn't want to hard-code all of the values shown in the examples above. Instead you might want to store them in a configuration file or database somewhere. File-based configuration is very easy to use and manage with the Estrelica.Core.Configuration package.