Exemple #1
0
        public async static Task Run([QueueTrigger("watermarkqueue")] PictureWatermarkQueue myQueueItem, ILogger log)
        {
            ConnectionStrings.AzureStorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=udemyrealstorageaccount;AccountKey=rzzWG1uOtG1SCvsC1xOz63N9iavDE2IJnbofGMHAAl/wW7oLbKwpWRlhWgiAJBq/CcdGIob1A123cmVVjuC0eg==;EndpointSuffix=core.windows.net";
            IBlobStorage blobStorage = new BlobStorage();
            INoSqlStorage <UserPicture> noSqlStorage = new TableStorage <UserPicture>();

            foreach (var item in myQueueItem.Pictures)
            {
                using var stream = await blobStorage.DownloadAsync(item, EContainerName.pictures);

                using var memoryStream = AddWaterMark(myQueueItem.WatermarkText, stream);

                await blobStorage.UploadAsync(memoryStream, item, EContainerName.watermarkpictures);

                log.LogInformation($"{item} resmine watermark eklenmiştir.");
            }

            var userpicture = await noSqlStorage.Get(myQueueItem.UserId, myQueueItem.City);

            if (userpicture.WatermarkRawPaths != null)
            {
                myQueueItem.Pictures.AddRange(userpicture.WatermarkPaths);
            }

            userpicture.WatermarkPaths = myQueueItem.Pictures;

            await noSqlStorage.Add(userpicture);

            HttpClient httpClient = new HttpClient();

            var response = await httpClient.GetAsync("https://localhost:44332/api/Notifications/CompleteWatermarkProcess/" + myQueueItem.ConnectionId);

            log.LogInformation($"Client({myQueueItem.ConnectionId}) bilgilendirilmiştir");
        }
        public async Task <IActionResult> AddWatermark(PictureWatermarkQueue pictureWatermarkQueue)

        {
            var jsonString = JsonConvert.SerializeObject(pictureWatermarkQueue);

            string jsonStringBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonString));

            AzQueue azQueue = new AzQueue("watermarkqueue");

            await azQueue.SendMessageAsync(jsonStringBase64);

            return(Ok());
        }