Exemplo n.º 1
0
        }//loadFromFile

        private void setLicenseFromFile(String fName)
        { // Sets the license from the license file
            System.Text.ASCIIEncoding ansiEN = new System.Text.ASCIIEncoding();
            StreamReader streamReader        = new StreamReader(fName, ansiEN);
            string       lc = streamReader.ReadToEnd();

            m_objLicence             = new CryptoLicense(lc, cProperties.ProjectKey);
            m_objLicence.StorageMode = LicenseStorageMode.None;
            m_objLicence.Load();
            streamReader.Close();
        }//setLicenseFromFile
Exemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtProductLicense.Text))
            {
                MessageBox.Show("Please select an existing file.", msgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //
            // Validate the product license
            //
            CryptoLicense license = ProductLicense.Methods.CreateLicense();

            license.StorageMode     = LicenseStorageMode.ToFile;
            license.FileStoragePath = txtProductLicense.Text;

            // Load the license from file
            if (license.Load())
            {
                if (license.Status != LicenseStatus.Valid)
                {
                    MessageBox.Show("ConfigOS Foundry license validation failed.\nThe application will be closed.\n" + license.GetAllStatusExceptionsAsString() + "\nPlease select a correct license file and restart the application.", msgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    license.Dispose();
                    Process.GetCurrentProcess().Kill();
                }
                else
                {
                }
            }
            else
            {
                MessageBox.Show("ConfigOS Foundry license not found.\nThe application will be closed.", msgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                license.Dispose();
                Process.GetCurrentProcess().Kill();
            }
            //
            //
            // Copy the existing Foundrykey to the application folder
            try
            {
                File.Copy(txtProductLicense.Text, prouctLicensePath, true);
            }
            catch (Exception err)
            {
                MessageBox.Show("The ConfigOS Foundry license was not successfully copied to the ConfigOS Foundry application folder.\nThe application will be closed." + err.Message, msgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Process.GetCurrentProcess().Kill();
            }
            this.Close();
        }
Exemplo n.º 3
0
        private void A()
        {
            var A = new CryptoLicense
            {
                StorageMode = LicenseStorageMode.ToRegistry
            };

            A.ValidationKey = "AAAGgAGk/ESIIO4iJmXxVD/yH4xiLHGJIczm6SCvCAW157h/ew7tiYv/WJW0ug9nic4mf6y5GRywt0rBrFBL80Rb5otI+3AM79U669OUUIcdgP0tqaNSMUbAbLqXn6E/jispyo+R1LyUeKhNgk30iNJnto3C9LP6ASrQNA7jDWSQLWyrw94ztXc2vXSzzzpaRD0Jb3zWEqI9YY7QapnHMa/v0XI7pvK6aq46zgeZUP90yDbiHZjL7GU7R0qJOz8p3zI+6XPPKBohdfin9DcZ6QPJr9utB39wIJU6Mdx4i0acabWCGo1QeAmdUJ8Hvsc2EZ5Dpw0fFt2VfET4upf48aVpsx810oFJb4W70Y7+li5IO8Th9vcREF7OGaB1UasOppI5LCSEdgkv48r9PGldmkE58nAKjEBSp3MNVvhONMZrMPmozU/8YXttYEfmOxA7+5AaDLzJyJV5S38XC+4/0r7jOnezUggFGqjJ4gJIRXFHVMCcc8cRDQojYWzmKYloNF+2FlUDAAEAAQ==";
            if (!A.Load())
            {
                A.LicenseCode = "FgIkgTXjr2eZvNMBHgABbu29HnCHi267VJes6C+npz2IlKXxf3y6jv5STVfbfl6rU0s5pSByRT4ZclC9HYDwFg9TkLeIbowTpMNu+EFBVTILkovs7LfCIizYUZsfriR0sArMQCPzk5gP2dOdCK3Z+AyuovflkfissyJ+KAjDBYshohQ4yZdHIjPUhxA+TLc6mXv+GQTyrfFK/M1AFbJzj1km0UoeMhjRZ9SI2kh3bv5/QI8o18h9Fysa3aFRcVlGIi1ADHZGbcQK8XFzbicIyh1IVPoSRNtMzE3GeOQdzPL6YybM4+YQNIC+/yodUXbGUr9ldkMqTK7UoYtgTrTOgqJTOD/rPQrRQe4q5A40ZMSXtGu06tiZl+rfGzwlt9Aaalx8DGkV7Aixy2MGDNIxkVxIsVdmSP/BXLs9Qp8lPWpAGHG0nYZZr8iGNa9tpZ27lypQFrJdyrlYhL72vhcNlDSleR7Zn3AvyGJIvkKmzXwu/0f5bW/DAnhY7N49TmsR8LEjl7VHUallQ5ONI7iZ";
                A.Save();
            }

            if (!A.ShowEvaluationInfoDialog("Satış", "https://www.facebook.com/profile.php?id=100002547964778"))
            {
                Shutdown();
            }
            A.Dispose();
        }
Exemplo n.º 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            bool bLicOk = false;

            if (string.IsNullOrEmpty(textBoxLic.Text))
            {
                MessageBox.Show(ResStrings.str_Enter_a_License, ResStrings.strInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            CryptoLicense testLic = new CryptoLicense();

            testLic.ValidationKey = _validationKey;
            testLic.StorageMode   = LicenseStorageMode.ToRegistry;
            testLic.LicenseCode   = textBoxLic.Text;

            if (testLic.HasUserData)
            {
                Hashtable dataFields       = testLic.ParseUserData("#");
                string    licenseMachineId = dataFields["MachineID"] as string;
                string    machineId        = labelMachineID.Text;
                bLicOk = machineId.Equals(licenseMachineId);
            }

            if (bLicOk)
            {
                testLic.Save();
                lic.Load();
                UpdateLicence();
                MessageBox.Show(ResStrings.str_License_Info_Saved, ResStrings.strInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                textBoxLic.Text = string.Empty;
                MessageBox.Show(ResStrings.str_Not_a_valid_license_for_this_machine, ResStrings.strInfo, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            testLic.Dispose();
        }
Exemplo n.º 5
0
        public bool EvaluateLicense()
        {
            /*
             * This code demonstrates typically evaluation license scenario. The idea is as follows....
             * First you check if a full license is present (using CryptoLicense.Load method).
             * If .Load returns false, you switch to a hardcoded evaluation license code (using .LicenseCode property).
             * Then, you validate using .Status property.
             *
             * Even if user uninstalls, all the usage data associated which each license code remains in the
             * registry and if user reinstalls, the evaluation continues from where it left off.
             */
            var licenseValid = false;

            CryptoLicense license = CreateLicense();

            // The license will be loaded from/saved to the registry
            license.StorageMode = LicenseStorageMode.ToRegistry;

            // To avoid conflicts with other scenarios from this sample, the default load/save registry key is changed
            license.RegistryStoragePath = license.RegistryStoragePath + "EvalLicense";

            // The remove method can be useful during development and testing - it deletes a previously saved license.
            //license.Remove();

            // Another useful method during development and testing is .ResetEvaluationInfo()



            // Load the license from the registry
            bool loadDialog = !license.Load() || license.Status != LicenseStatus.Valid;

            if (loadDialog)
            {
                string dialogMessage = !license.Load()?"Licensing missing, enter the license key": license.Status != LicenseStatus.Valid?"Licensing expired, enter a new license key": "Licensing missing, enter the license key";
                // When app runs for first time, the load will fail, so specify an evaluation code....
                // This license code was generated from the Generator UI with a "Limit Usage Days To" setting of 30 days.
                LicenseForm licenseForm = new LicenseForm();
                licenseForm.labelMessage.Text = dialogMessage;
                if (licenseForm.ShowDialog() == DialogResult.OK)
                {
                    string licenseKey = licenseForm.textBoxLicense.Text;
                    license.LicenseCode = licenseKey;
                    // Save it so that it will get loaded the next time app runs


                    if (license.Status != LicenseStatus.Valid)
                    {
                        licenseValid = false;
                    }
                    else
                    {
                        license.Save();
                        licenseValid = true;
                    }
                }
                else
                {
                    Environment.Exit(0);
                }
            }

            if (license.Status != LicenseStatus.Valid)
            {
                licenseValid = false;
            }
            else
            {
                licenseValid = true;
            }



            return(licenseValid);

            // ShowEvaluationInfoDialog shows the dialog only if the license specifies evaluation limits
            if (license.ShowEvaluationInfoDialog("GrabCaster", "http://www.grabcaster.io") == false)
            {
                // license has expired, new license entered is also expired
                // or user choose the 'Exit Program' option
                licenseValid = false;

                // In your app, you may wish to exit app when eval license has expired
                Application.Exit();
            }
            else
            {
                // The current license is valid or the new license entered is valid
                // or the user choose the 'Continue Evaluation' option

                // If the user enters a new valid license code, it replaces the existing code
                // and is automatically saved to the currently specified
                // storage medium (registry in this sample) using the CryptoLicense.Save method.
                // The new license code is thus available the next time your software runs.

                // We still need to check whether the license is an evaluation license
                if (license.IsEvaluationLicense() == true)
                {
                    // reduce functionality in evaluation version if so desired
                    licenseValid = true;
                }
            }

            license.Dispose(); // Be sure to call Dispose during app exit or when done using the CryptoLicense object
            return(licenseValid);
        }
Exemplo n.º 6
0
        public bool CryptoLicensing(bool IsNewLic = false)
        {
            if (IsNewLic)
            {
                try
                {
                    int days = manifestWS.ValidateDays(Properties.Settings.Default.LineCode);
                    //Console.WriteLine("Days:"+days.ToString());
                    if (days > 0)
                    {
                        if (Properties.Settings.Default.OfflineCount != 0)
                        {
                            Properties.Settings.Default.OfflineCount = 0;
                            Properties.Settings.Default.Save();
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch
                {
                    Properties.Settings.Default.OfflineCount += 1;
                    Properties.Settings.Default.Save();

                    if (Properties.Settings.Default.OfflineCount < 5)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                try
                {
                    license = new CryptoLicense
                    {
                        ValidationKey = ValidationKey,
                        StorageMode   = LicenseStorageMode.ToRegistry
                    };

                    if (!license.Load())
                    {
                        return(false);
                    }

                    if (license.Status == LicenseStatus.Valid)
                    {
                        //if (license.HasUserData)
                        //{
                        //    string aaa = license.ParseUserData("#")["linecode"].ToString();
                        //    MessageBox.Show(aaa);
                        //}
                        //Read information from lock every time execute program
                        Properties.Settings.Default.LineCode = license.UserData.Split('#')[0].Split('=')[1].ToString();
                        Properties.Settings.Default.Company  = license.UserData.Split('#')[1].Split('=')[1].ToString();
                        //Properties.Settings.Default.Save();
                        return(true);
                    }
                    else
                    {
                        license.Remove();
                        return(false);
                    }
                }
                catch (Exception)
                {
                    return(false);

                    throw;
                }
                finally
                {
                    license.Dispose();
                }
            }
        }