private async Task <string> GetValueInternalAsync(string context, string key)
        {
            ValidateInput(key);
            SqlPassContext config = DeserializeContext(context);

            string queryTemplate = "SELECT value FROM {0} WHERE name = ?";
            Dictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "name", key },
            };

            string value = (string) await OpenConnectionAndExecute(config, queryTemplate, parameters, async (command) =>
            {
                using (OdbcDataReader reader = command.ExecuteReader())
                {
                    if (await reader.ReadAsync())
                    {
                        return(reader["value"].ToString());
                    }
                    else
                    {
                        throw new SecureStoreException(
                            SecureStoreException.Type.SecretNotFound,
                            Resource.ResourceManager.GetString(nameof(Resource.SecretNotFound), CultureInfo.InvariantCulture));
                    }
                }
            });

            return(config.IsEncrypted.Value ? CryptoHelper.Decrypt(value) : value);
        }
예제 #2
0
        public async Task <List <string> > GetCustomers()
        {
            var customers = new List <string>();

            await using (OdbcConnection conn = new OdbcConnection())
            {
                conn.ConnectionString = @"Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=database_location\database;";
                await conn.OpenAsync();

                string         query  = "select [FolderName] from [customers] order by [FolderName]";
                OdbcCommand    cmd    = new OdbcCommand(query, conn);
                OdbcDataReader reader = await cmd.ExecuteReaderAsync() as OdbcDataReader;

                while (await reader.ReadAsync())
                {
                    string customer = reader[0].ToString();
                    customers.Add(customer);
                }
                conn.Close();
            }
            return(customers);
        }
예제 #3
0
 public async Task <bool> ReadAsync()
 {
     return(await _reader.ReadAsync());
 }