コード例 #1
0
        private bool Exists_Internal(string tokenID)
        {
            string result = null;

            using (IDbConnection dbc = service.GetOpenConnection()) {
                using (IDbCommand dbcmd = dbc.CreateCommand()) {
                    dbcmd.CommandText = String.Format("SELECT tokenID FROM TokenData WHERE {0}='{1}'", SQLiteFields.Name.TOKEN_ID, tokenID);
                    using (IDataReader dbr = dbcmd.ExecuteReader()) {
                        while (dbr.Read())
                        {
                            result = dbr.GetString(0);
                        }
                    }
                }
            }
            return(result != null);
        }
コード例 #2
0
        // Accessors

        public void GetIDs(Action <string[], RequestStatus> OnGetIDs)
        {
            service.QueueTask(() => {
                List <string> result = null;

                using (IDbConnection dbc = service.GetOpenConnection()) {
                    using (IDbCommand dbcmd = dbc.CreateCommand()) {
                        dbcmd.CommandText = String.Format("SELECT {0} FROM QuestionData", SQLiteFields.Name.QUESTION_ID);

                        result = new List <string>();

                        using (IDataReader dbr = dbcmd.ExecuteReader()) {
                            while (dbr.Read())
                            {
                                int idx = dbr.GetOrdinal(SQLiteFields.Name.QUESTION_ID);
                                if (!dbr.IsDBNull(idx))
                                {
                                    result.Add(dbr.GetString(idx));
                                }
                            }
                        }
                    }
                }

                return(result as object);
            },
                              (resultObject) => {
                if (OnGetIDs != null)
                {
                    if (resultObject == null)                             // doesn't exist
                    {
                        OnGetIDs(null, RequestStatus.SQLITE_ERROR);
                    }
                    else
                    {
                        OnGetIDs((resultObject as List <string>).ToArray(), RequestStatus.SUCCESS);
                    }
                }
            });
        }