Guest User

Untitled

a guest
Sep 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. bool CanLogin(string user, string pass)
  2. {
  3. int i = 0;
  4.  
  5. while (true) // try has a return
  6. {
  7. if (!Online())
  8. {
  9. textBox3.Text = "No internet.";
  10. return false;
  11. }
  12. else
  13. {
  14. textBox3.Text = "Please add leagues, enter username and password and click "Begin web scraping".";
  15. }
  16.  
  17. try
  18. {
  19. String username = user;
  20. String password = pass;
  21.  
  22. String consumerKey = EVERNOTE_CONSUMER_KEY;
  23. String consumerSecret = EVERNOTE_CONSUMER_SECRET;
  24.  
  25. String evernoteHost = EVERNOTE_HOST;
  26. String edamBaseUrl = "http://" + evernoteHost;
  27.  
  28. Uri userStoreUrl = new Uri(edamBaseUrl + "/edam/user");
  29. TTransport userStoreTransport = new THttpClient(userStoreUrl);
  30. TProtocol userStoreProtocol = new TBinaryProtocol(userStoreTransport);
  31. UserStore.Client userStore = new UserStore.Client(userStoreProtocol);
  32.  
  33. bool versionOK =
  34. userStore.checkVersion(CLIENT_NAME,
  35. Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MAJOR,
  36. Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MINOR);
  37.  
  38. if (!versionOK)
  39. {
  40. throw new Exception(ERROR_VERSION);
  41. }
  42.  
  43. AuthenticationResult authResult = null;
  44. try
  45. {
  46. //authResult = userStore.authenticate(username, password,consumerKey, consumerSecret);
  47. }
  48. catch
  49. {
  50. return false;
  51. }
  52.  
  53. return true;
  54. }
  55. catch(Exception e)
  56. {
  57. if (e.Message == ERROR_VERSION)
  58. throw;
  59. }
  60.  
  61. if (i++ > 20)
  62. throw new Exception("Failed to connect to evernote. This application can not be started.");
  63. }
  64. }
Add Comment
Please, Sign In to add comment