Exemplo n.º 1
0
        public License GetDistributableLicense(string assemblyData)
        {
            LicenseClient client = new LicenseClient(_publicKeyXml);

            try
            {
                {
                    LicensePublisherResponse response = client.GetLicense(CultureInfo.CurrentCulture, Product, Version, _licenseEntry.LicenseKey, GetLicenseCategory(LicenseType.Distributable), LicenseEntry.Name, LicenseEntry.Company, LicenseEntry.Email, assemblyData);
                    client.Close();
                    if (!CheckLicense(response))
                    {
                        return(null);
                    }
                    else
                    {
                        return(response.License);
                    }
                }
            }
            catch (CommunicationException ex)
            {
                LastErrorMessage = ex.Message;
                client.Abort();
                return(null);
            }
        }
Exemplo n.º 2
0
        private static void GetLicense(LicenseCategory licenseCategory)
        {
            LicenseClient licenseClient = new LicenseClient(LicenseClient.PublicKeyXmlFromAssembly(Assembly.GetExecutingAssembly()));

            try
            {
                LicensePublisherResponse response = licenseClient.GetLicense(
                    Product,
                    Assembly.GetExecutingAssembly().GetName().Version,
                    s_licenseKeys[(int)licenseCategory],
                    licenseCategory.ToString(),
                    "Test User",
                    "Test Company",
                    "*****@*****.**",
                    MachineLicense.LocalMachineData);
                License license = response.License;
                if (license == null)
                {
                    Console.WriteLine("ERROR: " + response.ErrorMessage);
                }
                else
                {
                    File.WriteAllText(Assembly.GetExecutingAssembly().Location + ".lic", license.SignedString);
                    LicenseManager.Reset();
                }

                licenseClient.Close();
            }
            catch (CommunicationException exception)
            {
                Console.WriteLine("EXCEPTION: " + exception.Message);
                licenseClient.Abort();
            }
        }
Exemplo n.º 3
0
        private bool SetProductLicense(LicenseKey licenseKey, string userName, string company, string email, string designTimeLicenseCategory, string runtimeLicenseCategory)
        {
            Debug.Assert(!string.IsNullOrEmpty(runtimeLicenseCategory));

            License designTimeLicense = null;
            License runtimeLicense;

            LicenseClient client = new LicenseClient(_publicKeyXml);

            try
            {
                LicensePublisherResponse response;
                if (!string.IsNullOrEmpty(designTimeLicenseCategory))
                {
                    response = client.GetLicense(CultureInfo.CurrentCulture, Product, Version, licenseKey, designTimeLicenseCategory, userName, company, email, MachineLicense.LocalMachineData);
                    if (!CheckLicense(response))
                    {
                        client.Close();
                        return(false);
                    }
                    designTimeLicense = response.License;
                }
                response = client.GetLicense(CultureInfo.CurrentCulture, Product, Version, licenseKey, runtimeLicenseCategory, userName, company, email, MachineLicense.LocalMachineData);
                client.Close();
                if (!CheckLicense(response))
                {
                    return(false);
                }
                runtimeLicense = response.License;
            }
            catch (CommunicationException exception)
            {
                LastErrorMessage = exception.Message;
                client.Abort();
                return(false);
            }

            string designTimeLicenseString = designTimeLicense == null ? string.Empty : designTimeLicense.SignedString;
            string runtimeLicenseString    = runtimeLicense == null ? string.Empty : runtimeLicense.SignedString;

            SaveProductLicense(licenseKey, userName, company, email, designTimeLicenseString, runtimeLicenseString);
            return(true);
        }