Sankhya SDK

📊 ⚙️ Sankhya platform .NET SDK

Sankhya SDK

📊⚙️ Sankhya .NET SDK.

GitHub license Time tracker

Sankhya logo

CI/CD

Build status Last commit Tests Coverage Code Smells LoC
Build status GitHub last commit AppVeyor tests (branch) Coverage Code Smells Lines of Code

Code Quality

Codacy Badge Codacy Badge

codecov CodeFactor

Maintainability Test Coverage

Quality Gate Status Maintainability Rating

Technical Debt Duplicated Lines (%)

Reliability Rating Security Rating

Bugs Vulnerabilities


Installation

Github Releases

GitHub last release Github All Releases

Download the latest zip file from the Release page.

Nuget package manager

Package Version Downloads
Sankhya Sankhya NuGet Version Sankhya NuGet Downloads

Features

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.

Known Services

Wiki page about KSRW

Sankhya Wrapper

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.


Usage

Service registration (IoC / DI)

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

Constructor argument

public class MyClass {

    private readonly SankhyaContext _sankhyaContext;

    public MyClass(SankhyaContext sankyaContext) {
        _sankhyaContext = sankhyaContext ?? throw new ArgumentNullException(nameof(sankhyaContext));
    }
}

Retrieving manually

var sankhyaContext = ServiceLocator.Resolve<SankhyaContext>();

Know Services Wrapper

The KnowServicesRequestWrapper is a static class that can be used anywhere, since SankhyaContext is registered through ServiceLocator.

Session management

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);
}