示例#1
0
    protected async void RegisterCallBack()
    {
        spinner1.Active = true;
        if (!entry3.Text.Contains("/"))
        {
            MessageDialog mw = new MessageDialog(this,
                                                 DialogFlags.DestroyWithParent, MessageType.Warning,
                                                 ButtonsType.Close, "Invalid repository target." + entry3.Text);
            mw.Run();
            mw.Destroy();
            return;
        }
        Session session = await Session.CreateOauthSession();

        if (session == null)
        {
            return;
        }
        try {
            await session.SetCurrentUser();

            if (Session.server.isCancelled)
            {
                spinner1.Active = false;
                return;
            }
            spinner1.Active = false;
            MessageDialog md = new MessageDialog(this,
                                                 DialogFlags.DestroyWithParent, MessageType.Info,
                                                 ButtonsType.Close, "Succesfully authenticated as: " + session.current.Login);
            md.Run();
            md.Destroy();

            String[] repoInfo = entry3.Text.Split('/');

            MainWindow main = MainWindow.Create(new RepositoryManager(session, await session.client.Repository.Get(repoInfo [0], repoInfo [1])));

            main.Show();

            this.Destroy();
        } catch (AuthorizationException ex) {
            MessageDialog md = new MessageDialog(this,
                                                 DialogFlags.DestroyWithParent, MessageType.Warning,
                                                 ButtonsType.Close, "Login Failed: " + ex.Message);
            md.Run();
            md.Destroy();
            spinner1.Active = false;
        } catch (Exception ex) {
            ExceptionDialog md = ExceptionDialog.Create(ex.Message, ex.StackTrace);
            md.Run();
            md.Destroy();
            spinner1.Active = false;
        }
    }
示例#2
0
 private void saveSettings()
 {
     //TODO: don't store plaintext password, that or do't commit settings.ini
     try {
         SettingsWindow.manager.ChangeSetting("username", usernameField.Text);
         SettingsWindow.manager.ChangeSetting("password", passwordField.Text);
         if (isValidTime(timeField.Text))
         {
             manager.ChangeSetting("time", timeField.Text);
         }
         else
         {
             MessageDialog md = new MessageDialog(this.Handle);
             md.Text = "Time parameter not valid, using old setting";
             md.Show();
         }
         SettingsWindow.manager.ChangeSetting("lastCheckDate", calendar1.GetDate().ToString("yyyy-MM-dd"));
     }
     catch (Exception ex) {
         ExceptionDialog md = ExceptionDialog.Create(ex.Message, ex.StackTrace);
         md.Show();
     }
 }