The project is designed to take into account sessions, and control licenses in the software At startup, the data is read from the encrypted archive and checked according to the requirements.
the library was created with the support of https://github.com/Infarh
Install-SessionLicenseControl -Version 1.0.0
Install-Package SessionLicenseControl.WPF -Version 1.0.0 For WPF
var lic = new LicenseGenerator(Secret, hdd, expirationDate, Ouner, check_sessions);
lic.CreateLicenseFile(LicenseFilePath);
where:
Secret
- secret string to encrypt datahdd
- HDD id of PC where file will useexpirationDate
- Date when license will expireOuner
- for whom the license is createdcheck_sessions
- enable session control in licensesLicenseFilePath
- path, where license file will saved
You can use "LicenseCreator" to create a license through the console
Or use WPF application
To work with a license file:
var controller = new SessionLicenseController(LicenseFilePath, Secret, StartNewSession, "Admin");
If the license has expired or the data has been compromised - you will receive an error at this stage
To view license information:
controller.License.ToString(); //or controller.License.GetLicenseInformation()
view sessions data
foreach (var (date_time, sessions) in controller.SessionController.GetSessionData())
{
$"Day: {date_time:dd.MM.yyyy}".ConsoleYellow();
foreach (var session in sessions)
{
session.ConsoleRed();
}
}
how to check for console:
var flag = true;
string row = null;
while (flag)
try
{
var controller = row is null ? new SessionLicenseController(SessionsFilePath, Secret, true, "Admin") : new SessionLicenseController(row, Secret, SessionsFilePath, true, "Admin");
flag = false;
"License information:".ConsoleYellow();
controller.License.ToString().ConsoleRed();
}
catch (Exception)
{
Console.WriteLine("License is bad, Enter license code or add file");
row = Console.ReadLine();
}
how to check for WPF:
LicenseChecker.CheckLicense("license.lic", "testwpf", true, "admin");
if there is an error in the WPF license, the interface will be blocked by the license line input window