Esempio n. 1
0
        public DbFileInfo GetFileInfo(Guid fileId)
        {
            DbFileInfo fileInfo = null;

            using (var connection = _connection)
            {
                connection.Open();

                var command = connection.CreateCommand();
                command.CommandText = "select fileName, key, iv from fileInfo where fileID = @guid";
                command.Parameters.AddWithValue("@guid", fileId);
                using (var reader = command.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        reader.Read();
                        fileInfo = new DbFileInfo
                        {
                            FileName = (string)reader["fileName"],
                            Key      = (byte[])reader["key"],
                            Iv       = (byte[])reader["iv"],
                            FileId   = fileId
                        };
                    }
                }
            }

            return(fileInfo);
        }
Esempio n. 2
0
        public void StoreFileDetails(DbFileInfo fileInfo)
        {
            using (var connection = _connection)
            {
                connection.Open();

                var command = connection.CreateCommand();
                command.CommandText = "insert into fileInfo values(@guid, @filename, @key, @iv)";
                command.Parameters.AddWithValue("@guid", fileInfo.FileId);
                command.Parameters.AddWithValue("@filename", fileInfo.FileName);
                command.Parameters.AddWithValue("@key", fileInfo.Key);
                command.Parameters.AddWithValue("@iv", fileInfo.Iv);
                command.ExecuteNonQuery();
            }
        }