This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Install the CircleCI CLI tool. | |
# https://github.com/circleci-public/circleci-cli | |
set -o errexit | |
set -o nounset | |
echo Installing CircleCI CLI | |
RELEASE_URL="https://api.github.com/repos/CircleCI-Public/circleci-cli/releases/latest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task Recognize(Stream imageStream) | |
{ | |
var faceClient = new FaceClient(new ApiKeyServiceClientCredentials(FaceSubscriptionKey)) | |
{ | |
Endpoint = "https://westus.api.cognitive.microsoft.com" | |
}; | |
try | |
{ | |
Console.WriteLine(DateTime.Now + ": Attempting to recognize faces..."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IEnumerable<Tweet>> GetTweets(CancellationToken ct = default) | |
{ | |
return await _context.Tweets | |
.ToListAsync(ct) | |
.ConfigureAwait(false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task InsertTweetWithoutLogScope(string username, string message, CancellationToken ct = default) | |
{ | |
_context.Tweets.Add(new Tweet | |
{ | |
Username = username, | |
Message = message | |
}); | |
await _context.SaveChangesAsync(ct); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IEnumerable<Tweet>> GetTweetsWithQueryTags(CancellationToken ct = default) | |
{ | |
return await _context.Tweets | |
.TagWith("GetTweets") | |
.ToListAsync(ct) | |
.ConfigureAwait(false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (_logger.BeginScope(new Dictionary<string, object> { { "EFQueries", "GetTweets" } })) | |
{ | |
var tweets = await _twitterService.GetTweets(ct); | |
} | |
// Same query as before. | |
public async Task<IEnumerable<Tweet>> GetTweets(CancellationToken ct = default) | |
{ | |
return await _context.Tweets | |
.ToListAsync(ct) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Task InsertTweetStoreProc(string username, string message, CancellationToken ct = default) | |
{ | |
using (_logger.BeginScope(new Dictionary<string, object> { { "EFQueries", "InsertTweetStoreProc" } })) | |
{ | |
_ = _context.Tweets | |
.FromSqlRaw( | |
"InsertTweet @Username, @Message", | |
new SqlParameter("Username", username), | |
new SqlParameter("Message", message)) | |
// A hack to make STORE PROC work when they don't return anything. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task InsertTweet(string username, string message, CancellationToken ct = default) | |
{ | |
using (_logger.BeginScope(new Dictionary<string, object> { { "EFQueries", "InsertTweet" } })) | |
{ | |
_context.Tweets.Add(new Tweet | |
{ | |
Username = username, | |
Message = message, | |
CreatedUtc = DateTime.UtcNow | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IEnumerable<Tweet>> GetTweetsWithExtraLogs(CancellationToken ct = default) | |
{ | |
using (_logger.BeginScope(new Dictionary<string, object> { { "EFQueries", "GetTweetsLog" } })) | |
{ | |
return await _context.Tweets | |
.TagWith("GetTweets + LogContext") | |
.ToListAsync(ct) | |
.ConfigureAwait(false); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task InsertTweetStoreProc(string username, string message, CancellationToken ct = default) | |
{ | |
using (_logger.BeginScope(new Dictionary<string, object> { { "EFQueries", "InsertTweetStoreProc" } })) | |
{ | |
_ = await _context.Database | |
.ExecuteSqlRawAsync( | |
"InsertTweet @Username, @Message", | |
new SqlParameter("Username", username), | |
new SqlParameter("Message", message)); | |
} |
OlderNewer