Beispiel #1
0
        private void btnTestApiCreds_Click(object sender, EventArgs e)
        {
            Toopher.ToopherAPI api = new Toopher.ToopherAPI(tbApiKey.Text, tbApiSecret.Text, baseUrl: tbApiUrl.Text);
            AsyncLoggableJob   job = new AsyncLoggableJob(new TestApiJob(api));

            LogUI form = new LogUI(job);

            try {
                this.Enabled = false;
                form.ShowDialog();
            } finally {
                this.Enabled = true;
            }
        }
Beispiel #2
0
        private void btnAdminPairUnpairUser_Click(object sender, EventArgs e)
        {
            ToopherSettings settings = new ToopherSettings();

            Toopher.ToopherAPI api = new Toopher.ToopherAPI(settings.ToopherConsumerKey, settings.ToopherConsumerSecret, baseUrl: settings.ToopherBaseUrl);

            if (adminUserPaired)
            {
                try {
                    pnlAdminUserStatus.Enabled = false;
                    foreach (var pairing in adminUserPairings)
                    {
                        api.DeactivatePairing(pairing.id);
                    }
                } finally {
                    loadUserPairingStatus();
                }
            }
            else
            {
                PromptForm f = new PromptForm("Enter a Toopher Pairing Phrase");
                f.ShowDialog();
                string pairingPhrase = f.tbUserInput.Text.ToLower();

                LogUI logUI = new LogUI("Pairing with Toopher");
                logUI.Show();
                Action pairingTask = () => {
                    try {
                        Toopher.PairingStatus pairing = api.Pair(pairingPhrase, adminUserName);
                        while (pairing.pending && !pairing.enabled)
                        {
                            Thread.Sleep(200);
                            logUI.OnLog("checking pairing status...");
                            pairing = api.GetPairingStatus(pairing.id);
                        }
                        logUI.OnLog("Pairing Result: " + (pairing.enabled ? "Enabled" : "Denied"));
                    } finally {
                        logUI.OnDone();
                        loadUserPairingStatus();
                    }
                };
                new Task(pairingTask).Start();
            }
        }
Beispiel #3
0
        private void btnAdminPairUnpairUser_Click(object sender, EventArgs e)
        {
            ToopherSettings settings = new ToopherSettings ();
            Toopher.ToopherAPI api = new Toopher.ToopherAPI (settings.ToopherConsumerKey, settings.ToopherConsumerSecret, baseUrl: settings.ToopherBaseUrl);

            if(adminUserPaired) {
                try {
                    pnlAdminUserStatus.Enabled = false;
                    foreach(var pairing in adminUserPairings) {
                        api.DeactivatePairing (pairing.id);
                    }
                } finally {
                    loadUserPairingStatus ();
                }
            } else {
                PromptForm f = new PromptForm ("Enter a Toopher Pairing Phrase");
                f.ShowDialog ();
                string pairingPhrase = f.tbUserInput.Text.ToLower ();

                LogUI logUI = new LogUI ("Pairing with Toopher");
                logUI.Show ();
                Action pairingTask = () => {
                    try {
                        Toopher.PairingStatus pairing = api.Pair (pairingPhrase, adminUserName);
                        while(pairing.pending && !pairing.enabled) {
                            Thread.Sleep (200);
                            logUI.OnLog ("checking pairing status...");
                            pairing = api.GetPairingStatus (pairing.id);
                        }
                        logUI.OnLog ("Pairing Result: " + (pairing.enabled ? "Enabled" : "Denied"));
                    } finally {
                        logUI.OnDone ();
                        loadUserPairingStatus ();
                    }
                };
                new Task (pairingTask).Start ();

            }
        }
Beispiel #4
0
        private void btnTestApiCreds_Click(object sender, EventArgs e)
        {
            Toopher.ToopherAPI api = new Toopher.ToopherAPI (tbApiKey.Text, tbApiSecret.Text, baseUrl: tbApiUrl.Text);
            AsyncLoggableJob job = new AsyncLoggableJob (new TestApiJob (api));

            LogUI form = new LogUI (job);
            try {
                this.Enabled = false;
                form.ShowDialog ();
            } finally {
                this.Enabled = true;
            }
        }