Skip to content

Instantly share code, notes, and snippets.

Avatar
🖖
Merging without reviewing.

Gerade Geldenhuys GeradeDev

🖖
Merging without reviewing.
View GitHub Profile
View upload-blob-storage.cs
//Generate image
var memoryStream = GenerateBlogPostMetaCardWithDescription("{ " + metaCardDescription.PostMetaTagImageDescription + " }");
//Create the image in Blob Storage
CloudBlockBlob blob = blobContainer.GetBlockBlobReference($"{metaCardDescription.PostTitle}.png");
blob.Properties.ContentType = "image/png";
blob.UploadFromStream(memoryStream);
log.LogInformation($"Post image card generation for post {metaCardDescription.PostTitle} was successful. Image was uploaded to Blob Storage");
View generate-article-meta-card-image.cs
private static MemoryStream GenerateBlogPostMetaCardWithDescription(string description)
{
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
Bitmap newBitmap;
using (var bitmap = (Bitmap)LoadImageTemplate())//load the image file
{
View get-article-desc-github-api.cs
private static async Task<PostMetaTagImage> GetBlogPostCardDescription(ILogger log)
{
PostMetaTagImage cardDescription = new PostMetaTagImage();
try
{
string content = await MakeGitHubAPICall("https://api.github.com/repos/<website-repo>/commits");
List<CommitsData> commits = JsonConvert.DeserializeObject<List<CommitsData>>(content);
CommitsData latestCommit = commits.OrderByDescending(x => x.commit.author.date).FirstOrDefault();
View gen-order-invoice-function.cs
public static class OrderPlaceInvoiceGenerator
{
[FunctionName("OrderPlaceInvoiceGenerator")]
public static void Run([RabbitMQTrigger("medpark.orderservice/basket-service.basket_checked_out_invoice_gen", ConnectionStringSetting = "connectionStringSetting")] BasicDeliverEventArgs args,
ILogger log)
{
log.LogInformation($"Message received from RabbitMQ trigger: {message}");
}
}
View rabbitmq-trigger-ext-config-provider.cs
public class RabbitMqExtensionConfigProvider : IExtensionConfigProvider
{
private ILogger _logger;
public RabbitMqExtensionConfigProvider(ILogger logger)
{
_logger = logger;
}
public void Initialize(ExtensionConfigContext context)
View rabbitmq-binding-provider.cs
public class RabbitMqTriggerBindingProvider : ITriggerBindingProvider
{
private readonly ILogger _logger;
public RabbitMqTriggerBindingProvider(ILogger logger)
{
_logger = logger;
}
public Task<ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
View rabbitmq-trigger-binding.cs
public class RabbitMqTriggerBinding : ITriggerBinding
{
private readonly ILogger _logger;
public Type TriggerValueType => typeof(BasicDeliverEventArgs);
public IReadOnlyDictionary<string, Type> BindingDataContract => new Dictionary<string, Type>();
private readonly ParameterInfo _parameter;
View rabbitmq-trigger-listener.cs
public class RabbitMqTriggerListener : IListener
{
private readonly ITriggeredFunctionExecutor _executor;
private readonly RabbitMqTriggerAttribute _attribute;
IModel _model { get; }
IBasicPublishBatch _createBasicPublishBatch => CreateBasicPublishBatch();
private string _connectionString;
private string _hostName;
private string _queueName;
View rabbitmq-trigger-attribute.cs
[Binding]
[AttributeUsage(AttributeTargets.Parameter)]
public class RabbitMqTriggerAttribute : Attribute
{
public string HostName { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Port { get; set; }
public string Connection { get; set; }
View basket-controller-get.cs
[HttpGet("{customerid}")]
[Cached(Constants.Day_In_Seconds)]
public async Task<IActionResult> GetCustomerBasket(Guid customerid)
{
var basket = await _consulHttpClient.GetAsync<BasketDto>("basket-service", $"/basket/{customerid}");
return Ok(basket);
}
You can’t perform that action at this time.