Ejemplo n.º 1
0
        private void btnGetUsername_Click(object sender, RoutedEventArgs e)
        {
            ApiWaiting = new PleaseWait();
            ApiWaiting.Title = strings.AccountManager_TokenValidation;
            ApiWaiting.Owner = this;
            ApiWaiting.Show();
            string token = txtToken.Text;
            ThreadStart start = delegate()
            {
                XmlClient client = new XmlClient(_settings.UserLanguage, token);
                try
                {
                    string message;
                    List<string> result = client.GetUsernameByToken(out message);

                    /*for (int i = 1; i < 100; i++)
                    {
                        result = client.GetUsernameByToken(out message);
                        if (!String.IsNullOrEmpty(message))
                        {
                            Dispatcher.Invoke(DispatcherPriority.Background,
                                        new Action<string>(TokenError),
                                        message);
                            break;
                        }
                    }*/

                    if (result.Count > 0)
                        Dispatcher.Invoke(DispatcherPriority.Background,
                                        new Action<List<string>>(InitializeUsernameList),
                                        result);
                    else
                        Dispatcher.Invoke(DispatcherPriority.Background,
                                        new Action<string>(TokenError),
                                        message);
                }
                catch
                {
                    Dispatcher.Invoke(DispatcherPriority.Background,
                                    new Action<List<string>>(InitializeUsernameList),
                                    null);
                }
            };

            new System.Threading.Thread(start).Start();
        }
Ejemplo n.º 2
0
        private void LaunchInternetAccessManager_callback(bool visible, PleaseWait waiting, Exception updateException)
        {
            if (waiting != null)
                waiting.Close();

            ProgramSettings.Instance.NextInternetAccesUpdate = DateTime.Now.Add(_internetAccesUpdateInterval);
            ProgramSettings.Instance.Save();

            if (updateException != null)
            {
                LogEngine.Instance.Add(updateException, false);

                if (visible)
                    MessageBox.Show(updateException.Message, "CIV", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                if (_accountManagerForm != null)
                    _accountManagerForm.RefreshInternetAccess();

                if (ProgramSettings.Instance.Accounts.Count > 0)
                    RefreshAccount(false);
            }
        }
Ejemplo n.º 3
0
        private void miAppCheckUpdate_Click(object sender, RoutedEventArgs e)
        {
            AppUpdaterWaiting = new PleaseWait();
            AppUpdaterWaiting.Title = strings.Dashboard_CheckNewUpdate;
            AppUpdaterWaiting.Owner = this;
            AppUpdaterWaiting.Show();

            new LaunchAppUpdaterDelegate(LaunchAppUpdater).BeginInvoke(false, null, null);
        }
Ejemplo n.º 4
0
        private void LaunchInternetAccessManager(bool visible)
        {
            PleaseWait ApiWaiting = null;

            if (visible)
            {
                ApiWaiting = new PleaseWait();

                ApiWaiting.Title = CIV.strings.Dashboard_InternetAccessProgress;

                try
                {
                    // Si la fenêtre principale n'a jamais été affiché, une exception va être levée
                    ApiWaiting.Owner = this;
                }
                catch
                {
                    ApiWaiting.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
                    ApiWaiting.Topmost = true;
                }

                ApiWaiting.Show();
            }

            ThreadStart start = delegate()
            {
                try
                {
                    InternetAccessUpdater internetAccessManager = new InternetAccessUpdater();
                    internetAccessManager.IsNotCompatibleClient = CentralCenterNotCompatible;
                    internetAccessManager.Execute(null, null);

                    Dispatcher.Invoke(DispatcherPriority.Background,
                                       new Action<bool, PleaseWait, Exception>(LaunchInternetAccessManager_callback),
                                       visible, ApiWaiting, null);
                }
                catch (Exception updateException)
                {
                    Dispatcher.Invoke(DispatcherPriority.Background,
                                        new Action<bool, PleaseWait, Exception>(LaunchInternetAccessManager_callback),
                                        visible, ApiWaiting, updateException);
                }
            };

            new System.Threading.Thread(start).Start();
        }