示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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();
        }
示例#4
0
        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();
        }
示例#5
0
        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;
        }
示例#6
0
        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;
        }
示例#7
0
        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();
            }
        }