public Boolean ConnectDatabase_PastAnswers() { try { Report.Enter(); this._pastAnswers = new PersistTable <String, String>(Environment.SpecialFolder.CommonApplicationData, "PastAnswers"); if (null != this._pastAnswers) { this._autoDisposables.TryAdd(this._captchaDatabase, DateTime.Now); return(true); } } catch (InvalidOperationException) { } catch (PathTooLongException) { } catch (DirectoryNotFoundException) { } catch (FileNotFoundException) { } finally { Report.Exit(); } return(false); }
public Boolean ConnectDatabase_Websites() { try { Report.Enter(); this._webSites = new PersistTable <String, WebSite>(Environment.SpecialFolder.CommonApplicationData, "Websites"); if (null != this._webSites) { this._autoDisposables.TryAdd(this._webSites, DateTime.Now); } } catch (InvalidOperationException) { return(false); } catch (PathTooLongException) { return(false); } catch (DirectoryNotFoundException) { return(false); } catch (FileNotFoundException) { return(false); } finally { Report.Exit(); } return(null != this._webSites); }
private void DisplayAccounts() { using ( var account = new PersistTable<String, String>( Environment.SpecialFolder.LocalApplicationData, "Accounts" ) ) { this.accountsToolStripMenuItem.DropDownItems.Clear(); foreach ( var pair in account ) { var item = this.accountsToolStripMenuItem.DropDownItems.Add( pair.Key ); item.Click += ( o, args ) => { this.Login( pair.Key, pair.Value ); }; } } this.accountsToolStripMenuItem.GetCurrentParent().Refresh(); }
private void loginToolStripMenuItem_Click( Object sender, EventArgs e ) { var accounts = new PersistTable<String, String>( Environment.SpecialFolder.LocalApplicationData, "Accounts" ); if ( !accounts.Any() ) { accounts.Dispose(); this.AskForNewKey(); } accounts.Dispose(); this.DisplayAccounts(); }
public Boolean ConnectDatabase_Websites() { try { Report.Enter(); this._webSites = new PersistTable<String, WebSite>( Environment.SpecialFolder.CommonApplicationData, "Websites" ); if ( null != this._webSites ) { this._autoDisposables.TryAdd( this._webSites, DateTime.Now ); } } catch ( InvalidOperationException ) { return false; } catch ( PathTooLongException ) { return false; } catch ( DirectoryNotFoundException ) { return false; } catch ( FileNotFoundException ) { return false; } finally { Report.Exit(); } return null != this._webSites; }
public Boolean ConnectDatabase_PastAnswers() { try { Report.Enter(); this._pastAnswers = new PersistTable<String, String>( Environment.SpecialFolder.CommonApplicationData, "PastAnswers" ); if ( null != this._pastAnswers ) { this._autoDisposables.TryAdd( this._captchaDatabase, DateTime.Now ); return true; } } catch ( InvalidOperationException ) { } catch ( PathTooLongException ) { } catch ( DirectoryNotFoundException ) { } catch ( FileNotFoundException ) { } finally { Report.Exit(); } return false; }
private void AskForNewKey() { String apikey; String secret = null; var form = new AskForInput( "What is the account APIKey?" ); switch ( form.ShowDialog( this ) ) { case DialogResult.OK: apikey = form.Response; break; case DialogResult.Cancel: return; default: throw new ArgumentOutOfRangeException(); } form = new AskForInput( "What is the account secret?" ); switch ( form.ShowDialog( this ) ) { case DialogResult.None: break; case DialogResult.OK: secret = form.Response; break; case DialogResult.Cancel: return; default: throw new ArgumentOutOfRangeException(); } if ( String.IsNullOrWhiteSpace( apikey ) || String.IsNullOrWhiteSpace( secret ) ) { return; } using ( var accounts = new PersistTable<String, String>( Environment.SpecialFolder.LocalApplicationData, "Accounts" ) ) { accounts[ apikey ] = secret; accounts.Flush(); } }