public bool ActivateTrialLicense(out bool hasError, out int status, string firstName, string lastName, string eMail, string organization, Guid userId)
        {
            status = LexActivator.SetTrialActivationMetadata("FirstName", firstName);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                logger.Warn($"SetTrialActivationMetadata FirstName Code {status}");
                hasError = true;
                return(false);
            }
            status = LexActivator.SetTrialActivationMetadata("LastName", lastName);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                logger.Warn($"SetTrialActivationMetadata LastName Code {status}");
                hasError = true;
                return(false);
            }
            status = LexActivator.SetTrialActivationMetadata("eMail", eMail);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                logger.Warn($"SetTrialActivationMetadata eMail Code {status}");
                hasError = true;
                return(false);
            }

            status = LexActivator.SetTrialActivationMetadata("Organization", organization);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                logger.Warn($"SetTrialActivationMetadata Organization Code {status}");
                hasError = true;
                return(false);
            }

            status = LexActivator.SetTrialActivationMetadata("UserId", userId.ToString());
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                logger.Warn($"SetTrialActivationMetadata UserId Code {status}");
                hasError = true;
                return(false);
            }

            status = LexActivator.ActivateTrial();
            var statusEnum = (StatusCodesEnum)status;

            if (statusEnum == StatusCodesEnum.LA_OK)
            {
                hasError = false;
                Init();
                return(true);
            }
            else if (status == LexActivator.StatusCodes.LA_TRIAL_EXPIRED)
            {
                hasError = false;
                return(false);
            }
            else
            {
                hasError = false;
                return(false);
            }
        }
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var sra = LexActivator.ActivateTrial();

            e.Result = sra;
            return;
        }
示例#3
0
 private void activateTrialBtn_Click(object sender, EventArgs e)
 {
     try
     {
         LexActivator.SetTrialActivationMetadata("key2", "value2");
         int status = LexActivator.ActivateTrial();
         if (status != LexStatusCodes.LA_OK)
         {
             this.statusLabel.Text = "Error activating the trial: " + status.ToString();
             return;
         }
         else
         {
             this.statusLabel.Text = "Trial started Successful";
         }
     }
     catch (LexActivatorException ex)
     {
         this.statusLabel.Text = "Error code: " + ex.Code.ToString() + " Error message: " + ex.Message;
     }
 }
示例#4
0
        private void activateTrialBtn_Click(object sender, EventArgs e)
        {
            int status;

            status = LexActivator.SetTrialActivationMetadata("key2", "value2");
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                this.statusLabel.Text = "Error setting activation metadata: " + status.ToString();
                return;
            }
            status = LexActivator.ActivateTrial();
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                this.statusLabel.Text = "Error activating the trial: " + status.ToString();
                return;
            }
            else
            {
                this.statusLabel.Text = "Trial started Successful";
            }
        }
示例#5
0
        static void Main(string[] args)
        {
            try
            {
                Init();
                LexActivator.SetLicenseCallback(LicenseCallback);
                int status = LexActivator.IsLicenseGenuine();
                if (LexStatusCodes.LA_OK == status)
                {
                    Console.WriteLine("License is genuinely activated!");
                    uint expiryDate = LexActivator.GetLicenseExpiryDate();
                    int  daysLeft   = (int)(expiryDate - DateTimeOffset.Now.ToUnixTimeSeconds()) / 86400;
                    Console.WriteLine("Days left:" + daysLeft);

                    // Checking for software release update
                    // LexActivator.CheckForReleaseUpdate("windows", "1.0.0", "stable", SoftwareReleaseUpdateCallback);
                }
                else if (LexStatusCodes.LA_EXPIRED == status)
                {
                    Console.WriteLine("License is genuinely activated but has expired!");
                }
                else if (LexStatusCodes.LA_GRACE_PERIOD_OVER == status)
                {
                    Console.WriteLine("License is genuinely activated but grace period is over!");
                }
                else if (LexStatusCodes.LA_SUSPENDED == status)
                {
                    Console.WriteLine("License is genuinely activated but has been suspended!");
                }
                else
                {
                    int trialStatus;
                    trialStatus = LexActivator.IsTrialGenuine();
                    if (LexStatusCodes.LA_OK == trialStatus)
                    {
                        uint trialExpiryDate = LexActivator.GetTrialExpiryDate();
                        int  daysLeft        = (int)(trialExpiryDate - DateTimeOffset.Now.ToUnixTimeSeconds()) / 86400;
                        Console.WriteLine("Trial days left: " + daysLeft);
                    }
                    else if (LexStatusCodes.LA_TRIAL_EXPIRED == trialStatus)
                    {
                        Console.WriteLine("Trial has expired!");

                        // Time to buy the product key and activate the app
                        Activate();
                    }
                    else
                    {
                        Console.WriteLine("Either trial has not started or has been tampered!");
                        // Activating the trial
                        trialStatus = LexActivator.ActivateTrial(); // Ideally on a button click inside a dialog
                        if (LexStatusCodes.LA_OK == trialStatus)
                        {
                            uint trialExpiryDate = LexActivator.GetTrialExpiryDate();
                            int  daysLeft        = (int)(trialExpiryDate - DateTimeOffset.Now.ToUnixTimeSeconds()) / 86400;
                            Console.WriteLine("Trial days left: " + daysLeft);
                        }
                        else
                        {
                            // Trial was tampered or has expired
                            Console.WriteLine("Trial activation failed: " + trialStatus);
                        }
                    }
                }
            }
            catch (LexActivatorException ex)
            {
                Console.WriteLine("Error code: " + ex.Code.ToString() + " Error message: " + ex.Message);
            }
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
示例#6
0
        private void ActivateTrialLicense(object obj)
        {
            IsBusy = true;

            int status;

            status = LexActivator.SetTrialActivationMetadata("FirstName", FirstName);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                logger.Warn($"SetTrialActivationMetadata FirstName Code {status}");
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                {
                    IsBusy = false;
                    SendErrorLogVisibility = Visibility.Visible;
                    Status = LocHelper.GetWord("Error setting activation data.");
                }));
                return;
            }
            status = LexActivator.SetTrialActivationMetadata("LastName", LastName);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                logger.Warn($"SetTrialActivationMetadata LastName Code {status}");
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                {
                    IsBusy = false;
                    SendErrorLogVisibility = Visibility.Visible;
                    Status = LocHelper.GetWord("Error setting activation data.");
                }));
                return;
            }
            status = LexActivator.SetTrialActivationMetadata("eMail", EMail);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                logger.Warn($"SetTrialActivationMetadata eMail Code {status}");
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                {
                    IsBusy = false;
                    SendErrorLogVisibility = Visibility.Visible;
                    Status = LocHelper.GetWord("Error setting activation data.");
                }));
                return;
            }
            status = LexActivator.SetTrialActivationMetadata("Organization", Organization);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                logger.Warn($"SetTrialActivationMetadata Organization Code {status}");
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                {
                    IsBusy = false;
                    SendErrorLogVisibility = Visibility.Visible;
                    Status = LocHelper.GetWord("Error setting activation data.");
                }));
                return;
            }
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
            {
                var activateTrial = LexActivator.ActivateTrial();
                var statusEnum    = (StatusCodesEnum)activateTrial;
                IsBusy            = false;
                if (statusEnum == StatusCodesEnum.LA_OK)
                {
                    Status = LocHelper.GetWord("You have successfully started your trial license. You can close this window and start using Celsus.");
                    CloseWindowVisibility = Visibility.Visible;
                }
                else if (status == LexActivator.StatusCodes.LA_TRIAL_EXPIRED)
                {
                    Status = LocHelper.GetWord("Product trial has expired.");
                    CloseWindowVisibility = Visibility.Visible;
                }
                else
                {
                    Status = LocHelper.GetWord($"Error occured. Error code {statusEnum.ToString()}");
                    CloseWindowVisibility = Visibility.Visible;
                }
            }));
            return;
        }