Ejemplo n.º 1
0
        public static IClientLicense GetLicense(int product_id, string product_version, bool AllowSubscription, bool AllowTrial, bool AlwaysCheck, int option_id)
        {
            if (!AllowSubscription)
            {
                // string alias_path = "c:\\windows\\system32\\Trial" + product_id.ToString() + ".xml";
                string alias_path = Env.GlobalConfigDataPath + "/_program_data.xml";

                try
                {
                    if (System.IO.File.Exists(LicenseLocation))
                    {
                        var seat = new ClientLicense(LicenseLocation, product_id, encryptionKeyId, clientKey, serverKey, product_version);
                        var loadr = seat.LoadFile();

                        // make sure the option is valid
                        if (option_id > 0 && option_id != seat.ProdOptionID)
                        {
                            // it's not
                            System.IO.File.Move(LicenseLocation, LicenseLocation + ".option" + seat.ProdOptionID.ToString());
                            throw new InvalidLicenseException();
                        }

                        var run_count = Env.GetConfigVar("run_count", 0, true);
                        if (seat.IsValid())
                        {
                            Env.SetConfigVar("run_count", run_count + 1);
                            return seat;
                        }
                        else
                            throw new InvalidLicenseException();
                    }
                    else
                    {
                        throw new InvalidLicenseException();
                    }

                }
                catch
                {
                    if (!System.IO.File.Exists(TrialLicenseLocation))
                    {
                        var trial = new TrialLicense(LicenseLocation, TrialLicenseLocation, product_id, encryptionKeyId, clientKey, serverKey, alias_path);
                        var got_new_trial = AllowTrial ? trial.CreateFreshTrial() : trial.CreateExpiredTrial();
                        trial.LoadFile();
                        return trial;
                    }
                    else
                    {
                        var trial = new TrialLicense(LicenseLocation, TrialLicenseLocation, product_id, encryptionKeyId, clientKey, serverKey, alias_path);
                        trial.LoadFile();
                        return trial;
                    }
                }
            }
            else
            {
                // check for subscription license
                throw new NotImplementedException();
            }
        }
 public ProtectionPlusIntroFormFull(TrialLicense trialLicense)
 {
     InitializeComponent();
     TrialLicense = trialLicense;
 }
 public ProtectionPlusIntroForm(TrialLicense license)
 {
     InitializeComponent();
     _license = license;
 }