📊⚙️ Sankhya .NET SDK.
Build status | Last commit | Tests | Coverage | Code Smells | LoC |
---|---|---|---|---|---|
Download the latest zip file from the Release page.
Package | Version | Downloads |
---|---|---|
Sankhya |
This SDK implements many of Sankhya's web services. Some of them are called Know Services. If the service you are looking for is not set in the SDK, you can implement the service request/response on your own (and use it on your code or submit a pull request to this repository).
There are also some Request Wrappers that allow you to make some requests in an easy way.
The last mile operations are done on this wrappers. All HTTP request/responses, login/logout, serialization, download/upload operations are defined on this class.
Avoid usage of this class directly from you implementation. Only call methods of this class if you are extending the usage of the SDK or even implementing a new feature for the SDK, otherwise, prefer using one of the request wrappers, or the Sankhya Context class.
This SDK is based on CrispyWaffle toolkit, so you can use it's Service Locator feature to register it.
Assuming you are using Crispy Waffle, you can register the Sankhya wrapper in the Bootstrapper.cs file this way:
var connectionSankhya = new Connection(); //Fill in your details
ServiceLocator.Register(() => new SankhyaContext(connectionSankhya), LifeStyle.Singleton);
Later, when you need to access the Sankhya Context in you code, you can just pass it as constructor's argument or retrieve it from Service Locator
public class MyClass {
private readonly SankhyaContext _sankhyaContext;
public MyClass(SankhyaContext sankyaContext) {
_sankhyaContext = sankhyaContext ?? throw new ArgumentNullException(nameof(sankhyaContext));
}
}
var sankhyaContext = ServiceLocator.Resolve<SankhyaContext>();
The KnowServicesRequestWrapper
is a static class that can be used anywhere, since SankhyaContext is registered through ServiceLocator.
You can use this to get all active sessions in Sankhya and kill one by one:
var sessions = KnowServicesRequestWrapper.GetSessions();
foreach (var session in sessions) {
KnowServicesRequestWrapper.KillSession(session.Id);
}