private void CheckLicense(string newPath)
        {
            var lv = new LicenceValidator(newPath);

            if (!lv.HasLicense)
            {
                MessageBox.Show("Лицензия не найдена. Укажите путь к папке с лицензией.");
                FolderBrowserDialog dr = new FolderBrowserDialog();
                var result             = dr.ShowDialog();
                if (result == DialogResult.OK)
                {
                    CheckLicense(dr.SelectedPath);
                }
                if (result == DialogResult.Cancel)
                {
                    Application.Exit();
                }
            }
            if (!lv.IsValid)
            {
                MessageBox.Show("Лицензия просрочена.Укажите путь к папке с лицензией.");
                FolderBrowserDialog dr = new FolderBrowserDialog();
                var result             = dr.ShowDialog();
                if (result == DialogResult.OK)
                {
                    CheckLicense(dr.SelectedPath);
                }
                if (result == DialogResult.Cancel)
                {
                    Application.Exit();
                }
            }
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var lv = new LicenceValidator();

            if (!lv.HasLicense)
            {
                MessageBox.Show("Лицензия не найдена. Купите её за 2 рубля где-нибудь.");
                Application.Exit();
            }
            if (!lv.IsValid)
            {
                MessageBox.Show("Лицензия просрочена. Купите её за 2 рубля где-нибудь.");
                Application.Exit();
            }
        }
Example #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var lv = new LicenceValidator();

            if (!lv.HasLicense)
            {
                MessageBox.Show("Лицензия не найдена. Приобретите лицензию у владельца ПО.");
                Application.Exit();
            }
            if (!lv.IsValid)
            {
                MessageBox.Show("Лицензия просрочена. Приобретите лицензию у владельца ПО.");
                Application.Exit();
            }
        }
Example #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var lv = new LicenceValidator();

            if (!lv.HasLicense)
            {
                MessageBox.Show("Лицензия не найдена. Приобретите ее у разработчика.");
                Application.Exit();
            }
            if (!lv.IsValid)
            {
                MessageBox.Show("Срок действия лицензии окончен. Приобретите ее у разработчика.");
                Application.Exit();
            }
        }
Example #5
0
        private void ValidateApplicationLicence()
        {
            int               trialDaysLeft     = 0;
            string            licencePath       = GetLicencePath();
            string            currentCulture    = deviceCulture;
            SystemInformation systemInformation = new SystemInformation();
            string            systemSignature   = systemInformation.GetSystemID();

            string licenceID = LicenceValidator.UpdateLastAccessDateTime(licencePath, currentCulture, systemSignature);

            int    errorCode          = 0;
            int    trialLicences      = 0;
            int    registeredLicences = 0;
            int    trialDays          = 0;
            double elapsedDays        = 0;
            bool   isValidLicence     = false;
            string message            = string.Empty;

            isValidLicence = LicenceValidator.IsValidLicence(licencePath, systemSignature, currentCulture, out errorCode, out trialLicences, out registeredLicences, out trialDays, out elapsedDays, out message);
            double remainingDays = double.Parse(trialDays.ToString()) - elapsedDays;

            if (errorCode > 0)
            {
                Session["IsValidLicence"] = "NO";
                redirectPage = string.Format("../Mfp/LicenseErrorpage.aspx?ErrorCode={0}", errorCode);
                return;
            }
            else if (errorCode == 0 && registeredLicences == 0 && remainingDays > 0) // Trial Period
            {
                Session["IsValidLicence"] = "YES";
                string clientIPAddress = Request.ServerVariables["REMOTE_ADDR"];

                if (!DataManagerDevice.ProviderDevice.ApplicationSettings.IsLicencesAvailable(trialLicences, Session.Timeout, Session.SessionID, clientIPAddress))
                {
                    redirectPage = string.Format("../Mfp/LicenseErrorpage.aspx?ErrorCode={0}", "501");
                    return;
                }
            }
            else if (registeredLicences > 0)
            {
                Session["IsValidLicence"] = "YES";
                ValidateDevice();
            }
        }
        public void GenerateLicencePackTest()
        {
            var licenceGenerator = new LicenceGenerator();
            var serialGenerator  = SerialGeneratorFactory.GetSerialGenerator();
            var licenceValidator = new LicenceValidator(serialGenerator);

            LicenceType licenceType = LicenceType.Full;
            var         licence     = new Licence
            {
                CustomerName = "Kookdc",
                Trial        = true,
                CreationDate = DateTime.Now,
                TrialDays    = 50,
                Type         = licenceType
            };
            var licencePackString = licenceGenerator.Generate(licence, serialGenerator.Generate());
            var returnedLicence   = licenceValidator.CheckLicence(licencePackString);

            Assert.AreEqual(returnedLicence.CustomerName, licence.CustomerName);
        }
Example #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var lv = new LicenceValidator();

            if (!lv.HasLicense)
            {
                MessageBox.Show("Лицензия не найдена! Попробуй указать путь к файлу лицензии и я добавлю его копию в директорию :)");

                string         path   = Directory.GetCurrentDirectory();
                OpenFileDialog ofd    = new OpenFileDialog();
                var            result = ofd.ShowDialog(this);
                if (result == DialogResult.OK)
                {
                    FileInfo f = new FileInfo(ofd.FileName);
                    if (Path.GetExtension(f.ToString()) != ".ar_licence")
                    {
                        MessageBox.Show("Вы добавили не лицензию!");
                        Application.Exit();
                        goto jump;
                    }
                    f.CopyTo(path + @"\licence.ar_licence", false);
jump:
                    lv = new LicenceValidator();
                    if (!lv.HasLicense)
                    {
                        MessageBox.Show("Лицензия не найдена!");
                        Application.Exit();
                    }
                }
                else
                {
                    Application.Exit();
                }

                if (!lv.IsValid)
                {
                    MessageBox.Show("Лицензия не найдена или просрочена!");
                    Application.Exit();
                }
            }
        }
Example #8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var licenceValid = new LicenceValidator();

            if (!licenceValid.HasLicense)
            {
                MessageBox.Show("Лицензия не найдена, приобретите её, чтобы продолжить работу.", "Внимание!");
                Application.Exit();
            }
            if (!licenceValid.IsValid)
            {
                MessageBox.Show("Лицензия просрочена, продлите её, чтобы продолжить работу.", "Внимание!");
                Application.Exit();
            }
            int days = 30;

            if (licenceValid.IsValid && licenceValid.ValidUntil <= DateTime.Now.AddDays(days))
            {
                var day = licenceValid.ValidUntil - DateTime.Now;
                days = day.Days;
                var s = days.ToString();
                MessageBox.Show("До истечения лицензии осталось: " + s + " дней!", "Внимание!");
            }
        }
Example #9
0
    private void ValidateApplicationLicence()
    {
        string            licenceID          = string.Empty;
        int               trialLicences      = 0;
        int               registeredLicences = 0;
        int               trialDays          = 0;
        double            elapsedDays        = 0;
        bool              isValidLicence     = false;
        bool              isServerLicenseed  = false;
        bool              isValidDataBase    = false;
        string            licencePath        = GetLicencePath();
        string            currentCulture     = Session["SelectedCulture"] as string;
        SystemInformation systemInformation  = new SystemInformation();
        string            systemSignature    = systemInformation.GetSystemID();
        string            message            = string.Empty;

        //isServerLicenseed = DataManager.Provider.Registration.isServerValidLicsence(systemSignature);

        //if (!isServerLicenseed)
        //{

        licenceID = LicenceValidator.UpdateLastAccessDateTime(licencePath, currentCulture, systemSignature);

        isValidLicence = LicenceValidator.IsValidLicence(licencePath, systemSignature, currentCulture, out errorCode, out trialLicences, out registeredLicences, out trialDays, out elapsedDays, out message);

        //isValidDataBase = LicenceValidator.isValidDataBase(licencePath,currentCulture);

        double remainingDays = double.Parse(trialDays.ToString()) - elapsedDays;

        Session["TrailDaysForBuild"] = trialDays.ToString();

        Session["DisplayfailoverMessage"] = null;

        //if (!isValidDataBase)
        //{
        //    errorCode = 3001;
        //    redirectPath = string.Format("~/Web/LicenceResponse.aspx?mc={0}", errorCode);
        //}
        if (errorCode > 0 && errorCode != 2001)
        {
            Session["IsValidLicence"] = "NO";
            Session["TrailDaysLeft"]  = null;
            Session["EXMessage"]      = message;
            redirectPath = string.Format("~/Web/LicenceResponse.aspx?mc={0}", errorCode);

            //Response.Redirect(redirectPath, false);
        }
        else if (errorCode == 2001)
        {
            Session["DisplayfailoverMessage"] = "YES";
        }

        else if (errorCode == 0 && registeredLicences == 0 && remainingDays > 0)
        {
            double remainingTrailDays = trialDays - elapsedDays;
            trialDaysLeft            = Convert.ToInt32(remainingTrailDays);
            Session["TrailDaysLeft"] = trialDaysLeft.ToString();

            //DisplayTrialMessage();

            Session["IsValidLicence"] = "YES";
        }
        else if (registeredLicences > 0)
        {
            Session["IsValidLicence"] = "YES";
            Session["TrailDaysLeft"]  = null;
        }
        // }
        else
        {
            Session["IsValidLicence"] = "YES";
            Session["TrailDaysLeft"]  = null;
        }
    }