public void Initialize() { if (!AwfulWebRequest.CanAuthenticate) { using (var dao = new AwfulProfileDAO()) { var profile = dao.GetProfileByUsername(StaticParameters.TEST_USERNAME); if (profile != null) { AwfulWebRequest.SetCookieJar(profile.GetTokensAsCookies()); } } } }
public void Initialize() { if (this.pmService == null) { this.pmService = AwfulServiceManager.PrivateMessageService; } if (!AwfulWebRequest.CanAuthenticate) { using (var dao = new AwfulProfileDAO()) { var profile = dao.GetProfileByUsername(StaticParameters.TEST_USERNAME); if (profile != null) { AwfulWebRequest.SetCookieJar(profile.GetTokensAsCookies()); } } } }
public void Started() { var dao = new AwfulProfileDAO(); var testProfile = dao.GetProfileByUsername(StaticParameters.TEST_USERNAME); if (testProfile != null) { AwfulWebRequest.SetCookieJar(testProfile.GetTokensAsCookies()); if (!AwfulWebRequest.CanAuthenticate) { AwfulAuthenticateByBrowser.LoginSuccessful += (o, a) => { dao.SaveAuthenticationCookiesToProfile(testProfile, a.Cookies); dao.Dispose(); }; } } TestContext = AwfulDataContext.CreateDataContext(TEST_FILENAME); }
public void UpdateUserBookmarksAsync(AwfulProfile user, bool refresh, Action<AwfulProfile> result) { // check database first var bookmarks = new List<AwfulThreadBookmark>(); if (!refresh) { user = this.GetProfileByUsername(user.Username); bookmarks.AddRange(user.ThreadBookmarks); } if (bookmarks.IsNullOrEmpty()) { // fetch from web AwfulForumPage cp = new AwfulControlPanel().GetBookmarks(); cp.RefreshAsync(cpRefreshed => { using (var dao = new AwfulProfileDAO()) { var profile = dao.SaveBookmarksToProfile(user, cpRefreshed.Threads); if (profile == null) { // if we're here, then there's a database issue, but the show must go on using (var dao2 = new AwfulProfileDAO()) { user = dao2.GetProfileByUsername(user.Username); user.AddRangeToBookmarks(cpRefreshed.Threads); result(user); } } else { result(profile); } } }); } else { result(user); } }