private void loadUserPairingStatus() { if (this.InvokeRequired) { this.Invoke((Action) delegate { loadUserPairingStatus(); }); } else { adminUserName = tbAdminUsername.Text.ToLower(); ToopherSettings settings = new ToopherSettings(); Toopher.ToopherAPI api = new Toopher.ToopherAPI(settings.ToopherConsumerKey, settings.ToopherConsumerSecret, baseUrl: settings.ToopherBaseUrl); adminUserIsKnown = false; adminUserPaired = false; adminUserEnabled = false; try { IDictionary <string, object> userData = api.SearchForUser(adminUserName); adminUserPairings = api.GetUserPairings(adminUserName); adminUserPaired = adminUserPairings.Any((p) => p.enabled && !(p["deactivated"].ToString().ToLower() == "true")); if (userData.ContainsKey("disable_toopher_auth")) { adminUserEnabled = userData["disable_toopher_auth"].ToString().ToLower() != "true"; } else { adminUserEnabled = true; } adminUserIsKnown = true; } catch (Toopher.RequestError err) { adminUserIsKnown = false; if (err.Message == "No users with name = " + adminUserName) { // effectively the same as a UserUnknownError - ignore } else { pnlAdminUserStatus.Visible = false; MetroFramework.MetroMessageBox.Show(this, "Error retrieving user data: " + err.Message); } } pnlAdminUserStatus.Visible = true; pnlAdminUserStatus.Enabled = true; updatePairedStatusGuiElements(); } }
public void Run() { Running = true; try { Log("Testing API Connectivity"); IDictionary <string, object> d = api.SearchForUser("vqnvq743q3ghahdfas3fvaaaw3"); testPassed(); } catch (Toopher.RequestError e) { if (e.Message == "No users with name = vqnvq743q3ghahdfas3fvaaaw3") { testPassed(); } else { Log("Connectivity Test Failed."); Log("Error Type : " + e.GetType().Name); Log("Error Message: " + e.Message); } } finally { Running = false; Done(); } }
private void loadUserPairingStatus() { if(this.InvokeRequired) { this.Invoke ((Action)delegate { loadUserPairingStatus (); }); } else { adminUserName = tbAdminUsername.Text.ToLower (); ToopherSettings settings = new ToopherSettings (); Toopher.ToopherAPI api = new Toopher.ToopherAPI (settings.ToopherConsumerKey, settings.ToopherConsumerSecret, baseUrl: settings.ToopherBaseUrl); adminUserIsKnown = false; adminUserPaired = false; adminUserEnabled = false; try { IDictionary<string, object> userData = api.SearchForUser (adminUserName); adminUserPairings = api.GetUserPairings (adminUserName); adminUserPaired = adminUserPairings.Any ((p) => p.enabled && !(p["deactivated"].ToString ().ToLower () == "true")); if(userData.ContainsKey ("disable_toopher_auth")) { adminUserEnabled = userData["disable_toopher_auth"].ToString ().ToLower () != "true"; } else { adminUserEnabled = true; } adminUserIsKnown = true; } catch(Toopher.RequestError err) { adminUserIsKnown = false; if(err.Message == "No users with name = " + adminUserName) { // effectively the same as a UserUnknownError - ignore } else { pnlAdminUserStatus.Visible = false; MetroFramework.MetroMessageBox.Show (this, "Error retrieving user data: " + err.Message); } } pnlAdminUserStatus.Visible = true; pnlAdminUserStatus.Enabled = true; updatePairedStatusGuiElements (); } }