Exemplo n.º 1
0
        private bool LoadCheckLicense()
        {
            bool IsValid = false;

            Licensing.LicenseResponse resp = new Licensing.LicenseResponse();
            try
            {
                MyPropertyManager.OnLoad(); //call only once !!!

                string LocalTID = (string)MyPropertyManager.GetProperty("TID");
                try
                {
                    Microsoft.Win32.RegistryKey key;
                    key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("YTRLicense", true);
                    if (key == null)
                    {
                        key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("YTRLicense");
                    }
                    else
                    {
                        LocalTID = key.GetValue("tid") == null ? "" : key.GetValue("tid").ToString();
                    }
                    key.Close();
                }
                catch { }

                if (LocalTID.Length > 0)
                {
                    Task.Factory.StartNew(() => { Thread.Sleep(100); });
                    SetMessage("Checking license...", Color.Black);;
                    Http request = new Http();
                    resp = Licensing.CheckLicense(request, LocalTID);
                }
                else
                {
                    pLicense.Invoke((MethodInvoker) delegate { pLicense.Visible = true; });
                    SetMessage("Enter your License ID " + Environment.NewLine + "and Click 'Verify'", Color.Black);
                }

                IsValid = resp.IsValid;
                if (!IsValid)
                {
                    SetMessage(resp.Message, resp.color);
                    pLicense.Invoke((MethodInvoker) delegate { pLicense.Visible = true; });
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error SF100. Please contact support [email protected].");
                return(false);
            }
            return(IsValid);
        }
Exemplo n.º 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            /*bgw = new BackgroundWorker();
             * bgw.DoWork += submission;
             * bgw.RunWorkerAsync();
             */

            string TID = txtLicense.Text.Trim().Replace("'", "").Replace("?", "").Replace("&", "").Replace(":", "");

            if (TID.Length == 0)
            {
                SetMessage("License ID is empty.", Color.Red);
                txtLicense.Focus();
                return;
            }

            try
            {
                btnStartTrial.Enabled = btnSubmit.Enabled = false;
                SetMessage("Checking License...", Color.Red);
                Http request = new Http();
                Licensing.LicenseResponse resp = Licensing.CheckLicense(request, TID);
                if (resp.IsValid)
                {
                    //PREMIUM = true;
                    SetMessage("Starting YTR...", Color.Green);

                    validation  = true;
                    bgw         = new BackgroundWorker();
                    bgw.DoWork += load;
                    bgw.RunWorkerAsync();
                    return;
                }
                else
                {
                    SetMessage(resp.Message, resp.color);
                }
            }
            catch { }
            finally { btnStartTrial.Enabled = btnSubmit.Enabled = true; }
        }