public string GetUsernameFromAccount(int accountId) { AccountUsername username = new AccountUsername(); try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT username FROM accounts " + "JOIN users ON accounts.user_id = users.user_id " + "WHERE account_id = @account_id", conn); cmd.Parameters.AddWithValue("@account_id", accountId); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows && reader.Read()) { username.Username = Convert.ToString(reader["username"]); } } } catch (SqlException) { Console.WriteLine("There was a problem with the database connection."); } return(username.Username); }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs var username = AccountUsername.Get(context); var password = AppPassword.Get(context); var passwordString = new System.Net.NetworkCredential(string.Empty, password).Password; //Prepare default header var authHeaderString = username + ":" + passwordString; // This is the format used in the HTTP request header. var base64EncodedCredentials = Base64Encode(authHeaderString); // Create client and assign default request header var defaultHttpClient = new HttpClient(); defaultHttpClient.DefaultRequestHeaders .Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", base64EncodedCredentials); var client = new FluentClient("https://api.bitbucket.org/2.0/", defaultHttpClient); // Send to child activities _objectContainer.Add(client); return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } // Outputs }); }