Наследование: LicenseManagerBase
Пример #1
0
        /// <summary>
        /// Load your Netseal Licenses
        /// </summary>
        private void LoadLocalLicenses()
        {
            LoadLocalLicensesV2();
            return;

            this.ltvLicenses.Items.Clear();

            Logger.LogInformation("Loading local license(s)");

            var licenseReader = new LicenseReader();
            if (!Directory.Exists(licenseReader.LocalPath))
            {
                Logger.LogWarning("No license(s) found");
                return;
            }

            var files = Directory.GetFiles(licenseReader.LocalPath).Where((x) =>
            {
                var fileName = Path.GetFileNameWithoutExtension(x);
                return fileName.Length == 32;
            });

            var counter = 0;

            foreach (var file in files)
            {
                try
                {
                    var fileName = Path.GetFileNameWithoutExtension(file);
                    var dbTuple = IdsDataBase.IDsDataBase[fileName];
                    var id = dbTuple.Item1; //Netseal ID
                    var programName = dbTuple.Item2; //Netseal program name

                    if (!string.IsNullOrEmpty(id))
                    {
                        var licenseFile = licenseReader.ReadLicenseFrom(file, id);
                        //Store the license
                        Licenses.Add(licenseFile);

                        programName = !string.IsNullOrEmpty(programName) ? programName : this.txtUnknownProgramName.Text;

                        ltvLicenses.Items.Add(id).SubItems.AddRange(new string[]
                        {
                            programName,
                            licenseFile.GUID,
                            licenseFile.Remember.ToString(),
                            licenseFile.Username,
                            licenseFile.Sha1Password,
                        });
                        counter++;
                    }
                }
                catch
                {
                    continue;
                }
            }
            Logger.LogInformation("Loaded " + counter + " license(s)");
        }
Пример #2
0
        private void LoadLocalLicensesV2()
        {
            this.ltvLicenses.Items.Clear();

            Logger.LogInformation("Loading local license(s)");

            var licenseReader = new LicenseReader();
            if (!Directory.Exists(licenseReader.LocalPath))
            {
                Logger.LogWarning("No license(s) found");
                return;
            }

            var regex = new Regex(@"^login_([A-F0-9]{8})\.bin$");

            var files = Directory.GetFiles(licenseReader.LocalPath).Where((x) =>
            {
                return regex.IsMatch(Path.GetFileName(x));
            }).ToArray<string>();

            if (Directory.Exists(licenseReader.LocalPathV2))
            {
                var files2 = Directory.GetFiles(licenseReader.LocalPathV2).Where((x) =>
                {
                    return regex.IsMatch(Path.GetFileName(x));
                }).ToArray<string>();

                Array.Resize(ref files, files.Length + files2.Length);
                Array.Copy(files2, 0, files, files.Length - 1, files2.Length);
            }

            var counter = 0;

            foreach (var file in files)
            {
                try
                {
                    var fileName = Path.GetFileName(file);
                    var id = regex.Match(fileName).Groups[1].Value;
                    var programName = IdsDataBase.IDsDataBaseV2[id];

                    if (!string.IsNullOrEmpty(id))
                    {
                        var licenseFile = licenseReader.ReadLocalLicenseV2(id);
                        //Store the license
                        Licenses.Add(licenseFile);

                        programName = !string.IsNullOrEmpty(programName) ? programName : this.txtUnknownProgramName.Text;

                        ltvLicenses.Items.Add(id).SubItems.AddRange(new string[]
                        {
                            programName,
                            licenseFile.GUID,
                            licenseFile.Remember.ToString(),
                            licenseFile.Username,
                            licenseFile.Sha1Password,
                        });
                        counter++;
                    }
                }
                catch
                {
                    continue;
                }
            }
            Logger.LogInformation("Loaded " + counter + " license(s)");
        }