Exemplo n.º 1
0
        public async static Task Run([QueueTrigger("watermarkqueue")] WatermarkQueueDto myQueueItem)
        {
            try
            {
                StorageConnection.ConnectionString = "****";
                var blobStorage  = new BlobStorageBaseRepository();
                var tableStorage = new TableStorageBaseRepository <UserPicture>();
                foreach (var item in myQueueItem.Pictures)
                {
                    var stream = await blobStorage.DownloadAsync(item, ContainerType.picture);

                    var response = await AddWatermark(myQueueItem.Text, stream);

                    await blobStorage.UploadAsync(response, item, ContainerType.watermarkpicture);
                }
                var userPicture = await tableStorage.GetAsync(myQueueItem.City, myQueueItem.UserId).ConfigureAwait(false);

                if (userPicture.WatermarkRawPaths != null)
                {
                    var watermark = JsonConvert.DeserializeObject <List <string> >(userPicture.WatermarkRawPaths);
                    myQueueItem.Pictures.AddRange(watermark);
                }
                userPicture.WatermarkRawPaths = JsonConvert.SerializeObject(myQueueItem.Pictures);
                await tableStorage.AddAsync(userPicture);

                var client  = new HttpClient();
                var request = await client.GetAsync("https://localhost:44308/api/Pictures/CompletedNotification/" + myQueueItem.ConnectionId);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
Exemplo n.º 2
0
        public async Task <JsonResult> AddWatermark(WatermarkQueueDto dto)
        {
            if (dto.Pictures.Count == 0)
            {
                return(Json(new { message = "Döküman seçimi yapılmadı!", success = false }));
            }
            else
            {
                var serielizeObject = JsonConvert.SerializeObject(dto);
                var base64          = Convert.ToBase64String(Encoding.UTF8.GetBytes(serielizeObject));
                await _queueStorageSevice.SendMessageAsync(base64);

                return(Json(new { message = "Yazı ekleme işlemi başarılı", success = true }));
            }
        }