Connecting to Archer with Estrelica.Core
To interact with Archer via Estrelica.Core, you'll first need to validate your license, then provide Estrelica.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)
and
public Core CreateSession(string archerUrl, string archerInstance, string username, string password, string userDomain = null, string archerDbConnectionString = null)
with all of the relevant parameter values.
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 the validation and authentication steps 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 class. 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", "apiuser@company.com", "Password123");
And then the "core" reference is ready for use in communicating with Archer.
External configuration
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.
If you've installed the Estrelica.Core.Configuration package (also available from the CastleHill Software nuget server) 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)
This approach also provides additional security by allowing you to store any or all of your settings in local "user secrets" files, ensuring that no sensitive information like individual developer credentials will be leaked via source control.
See the Managing Configuration article for more details.