private async Task ProcessMessagesAsync(Message message, CancellationToken token) { Console.WriteLine($"Received message: SequenceNumber:{message.SystemProperties.SequenceNumber}"); // Complete the message so that it is not received again. // This can be done only if the queue Client is created in ReceiveMode.PeekLock mode (which is the default). if (message.ContentType == "string") { Console.WriteLine($"Received message: body:{Encoding.UTF8.GetString(message.Body)}"); } else if (message.ContentType.ToLower() == "filemodel") { FileModel fileMode = Common.ByteArrayToObject <FileModel>(message.Body); TableStorage tableStorage = new TableStorage(); FileModelTable fileModelTable = new FileModelTable() { FileName = fileMode.FileName, FileSize = fileMode.FileSize, ImagePath = fileMode.ImagePath, ProjectId = fileMode.ProjectId, SectionId = fileMode.SectionId, ThumbPath = fileMode.ThumbPath }; tableStorage.SaveTableStorage(fileModelTable); } await queueClient.CompleteAsync(message.SystemProperties.LockToken); }
public void SaveTableStorage(FileModelTable fileModel) { CloudStorageAccount storageAccount = Common.CreateStorageAccountFromConnectionString(); // Create the table client. CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); // Retrieve a reference to the table. CloudTable table = tableClient.GetTableReference("File"); // Create the table if it doesn't exist. table.CreateIfNotExists(); TableOperation tableOperation = TableOperation.Insert(fileModel); table.Execute(tableOperation); }