Esempio n. 1
0
        private string GetDataField(string fieldName)
        {
            Hashtable data = license.ParseUserData("#");
            string    rc   = data[fieldName].ToString();

            return(rc);
        }
        private void ParseLicenseInfosForThanks()
        {
            System.Collections.Hashtable dataFields = cryptoLicense.ParseUserData("#");
            this.LicenseThanks_HardwareID   = cryptoLicense.GetLocalMachineCodeAsString();
            this.LicenseThanks_Organisation = dataFields["Organisation"] as string;
            this.LicenseThanks_Name         = dataFields["Name"] as string;
            this.LicenseThanks_Mail         = dataFields["Mail"] as string;
            if (dataFields["Liteversion"] as string == "True")
            {
                this.LicenseThanks_Version = "Lite";
            }
            else
            {
                this.LicenseThanks_Version = "Basic";
            }

            this.LicenseThanks_FeatureMailOn     = cryptoLicense.IsFeaturePresentEx(1);
            this.LicenseThanks_FeatureMapOn      = cryptoLicense.IsFeaturePresentEx(2);
            this.LicenseThanks_FeatureAlarmappOn = cryptoLicense.IsFeaturePresentEx(3);

            this.LicenseThanks_DateExpires = cryptoLicense.DateExpires.ToString();
            if (!cryptoLicense.HasDateExpires)
            {
                this.LicenseThanks_DateExpires = "Unbegrenzt";
            }
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        void UpdateLicence()
        {
            //ThreadPool.QueueUserWorkItem(new WaitCallback(treatMachineID), null);
            TreatMachineId();

            labelLicenceStatus.Text = lic.Status.ToString();
            switch (lic.Status)
            {
            case LicenseStatus.DateRollbackDetected:
            case LicenseStatus.Expired:
            case LicenseStatus.EvaluationExpired:
                labelLicenceStatus.ForeColor = Color.Red;
                buttonCont.Enabled           = false;
                break;

            case LicenseStatus.Valid:
                if (lic.IsEvaluationLicense())
                {
                    labelLicenceStatus.Text      = ResStrings.str_Evaluation_Period;
                    labelLicenceStatus.ForeColor = Color.DarkOrange;


                    if (lic.RemainingExecutions < 100)
                    {
                        labelRun.Visible       = true;
                        labelRun.Text          = string.Format(ResStrings.str_runs_remaining, lic.RemainingExecutions, lic.MaxExecutions);
                        progressBarRun.Visible = true;
                        progressBarRun.Maximum = lic.MaxExecutions;
                        progressBarRun.Value   = lic.RemainingExecutions;
                    }

                    labelDays.Visible = true;
                    labelDays.Text    = string.Format(ResStrings.str_days_remaining, lic.RemainingUsageDays, lic.MaxUsageDays);

                    progressBarDays.Visible = true;
                    progressBarDays.Maximum = lic.MaxUsageDays;
                    progressBarDays.Value   = lic.RemainingUsageDays;

                    buttonCont.Enabled = true;
                    buttonCont.Text    = ResStrings.str_Continue_Evaluation;
                }
                else
                {
                    labelLicenceStatus.ForeColor = Color.Green;
                    buttonCont.Enabled           = true;
                    buttonCont.Text = ResStrings.str_Continue;
                }
                break;
            }

            if (lic.HasUserData)
            {
                string userName = null;
                string company  = null;
                try
                {
                    Hashtable dataFields = lic.ParseUserData("#");
                    company  = dataFields["Company"] as string;
                    userName = dataFields["Name"] as string;
                }
                catch
                {
                }
                labelCompany.Text = company;
                labelUser.Text    = userName;
            }


            if (lic.HasDateExpires)
            {
                TimeSpan remain = lic.DateExpires.Subtract(DateTime.Now);
                labelExpirationDate.Text = lic.DateExpires.ToShortDateString();
                labelDaysLeft.Text       = remain.Days.ToString(CultureInfo.InvariantCulture);

                if (remain.Days < 15)
                {
                    labelExpirationDate.ForeColor = Color.DarkOrange;
                    labelDaysLeft.ForeColor       = Color.DarkOrange;
                }
                if (remain.Days < 5)
                {
                    labelExpirationDate.ForeColor = Color.Red;
                    labelDaysLeft.ForeColor       = Color.Red;
                }
            }
        }