Exemple #1
0
        private void Get_Click(object sender, RoutedEventArgs e)
        {
            string assemblyData;

            try
            {
                assemblyData = AssemblyLicense.GetAssemblyData(AssemblyPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            if (assemblyData == LicenseConsoleData.Singleton.AssemblyData)
            {
                MessageBox.Show(Strings.FormatDistributableLicenseForSelfComponent(assemblyData));
                return;
            }

            if (LicenseMethod == LicenseMethod.WebService)
            {
                License license = GetDistributableLicense(assemblyData);
                if (license == null)
                {
                    MessageBox.Show(Data.LastErrorMessage);
                }
                else
                {
                    License = license.SignedString;
                }
            }
            else
            {
                EmailLicenseRequestWindow.Show(this, AssemblyPath, assemblyData);
            }
        }
Exemple #2
0
        internal static int GetAndSaveLicense(string assemblyPath, string outputPath, out string message)
        {
            AssemblyName callerAssembly;

            try
            {
                callerAssembly = AssemblyName.GetAssemblyName(assemblyPath);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(1);
            }

            License license = Data.GetDistributableLicense(AssemblyLicense.GetAssemblyData(assemblyPath));

            if (license == null)
            {
                message = Data.LastErrorMessage;
                return(2);
            }

            try
            {
                string filePath = Path.Combine(outputPath, LicenseFileName);
                File.WriteAllText(filePath, license.SignedString);
                message = Strings.FormatDistributableLicenseSaved(LicenseFileName, outputPath);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(3);
            }

            return(0);
        }