Пример #1
0
 private void dispatcherTimer_Tick(object sender, EventArgs e)
 {
     OkTime = true;
     DispatcherTimer.Stop();
     if (ShowWinLicense)
     {
         var winLicense = new WinLicense();
         OkDbChange = true;
         winLicense.Show();
         Close();
     }
     if (OkLogin)
     {
         var winLogin = new WinLogin();
         OkDbChange = true;
         winLogin.Show();
         Close();
     }
     if (OkShutdownApp)
     {
         OkDbChange = true;
         Application.Current.Shutdown();
     }
 }
Пример #2
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DispatcherTimer.Tick    += dispatcherTimer_Tick;
            DispatcherTimer.Interval = new TimeSpan(0, 0, 0, 10);
            DispatcherTimer.Start();
            try
            {
                new MunicipalArchiveDbConfiguration().Configurate();
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا", "خطا در ارتباط اولیه با پایگاه داده" + "\n" + exception);
                Process.GetCurrentProcess().Kill();
            }
            //await Task.Run(() => new MunicipalArchiveDbChanges().Configurate());
            var licenseData = new List <tblLicense>();

            try
            {
                licenseData = DLicense.GetData();
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا", "خطا در ارتباط  با پایگاه داده" + "\n" + exception);
                Process.GetCurrentProcess().Kill();
            }

            var serialNumber = await Task.Run(() => SerialNumber.GetHardwareSerial());

            var salt = new SaltyPasswordHashing
            {
                MaxHashSize = 40,
                SaltSize    = 0
            };
            string applicense = null;

            foreach (var variable in licenseData)
            {
                if (!await Task.Run(() => salt.VerifyHash(serialNumber, variable.AppLicense)))
                {
                    applicense = variable.AppLicense;
                }
            }

            if (applicense == null)
            {
                var checkTime = await Task.Run(CheckWinTimeUpdate);

                var checkTrial = await Task.Run(Check3DayTrial);

                if ((await DVersion.GetData())[0].AppVersion == null)
                {
                    var dVersion = new DVersion
                    {
                        DAppVersion = "1.0.0"
                    };
                    await Task.Run(() => dVersion.Edit());
                }

                if (!checkTime || !checkTrial)
                {
                    if (OkTime && OkShutdownApp)
                    {
                        OkDbChange = true;
                        Application.Current.Shutdown();
                    }
                    if (OkTime && !OkShutdownApp)
                    {
                        var winLicense = new WinLicense();
                        OkDbChange = true;
                        winLicense.Show();
                        Close();
                    }
                    else
                    {
                        ShowWinLicense = true;
                    }
                    return;
                }

                if (OkTime)
                {
                    var winLogin = new WinLogin();
                    OkDbChange = true;
                    winLogin.Show();
                    Close();
                }
                else
                {
                    OkLogin = true;
                }
            }
            else
            {
                if (OkTime)
                {
                    var winLogin = new WinLogin();
                    OkDbChange = true;
                    winLogin.Show();
                    Close();
                }
                else
                {
                    OkLogin = true;
                }
            }
        }