コード例 #1
0
        private async Task CompleteAsync(TagTransactionEntity tx)
        {
            //await start.CompleteAsync();

            tx.Stored = DateTime.UtcNow;

            await this.TagTransactionTable.Update(tx);

            var message = new StoreTagMessage(tx.Channel, tx.Id);

            await this.TagQueue.EnqueueMessageAsync(message);
        }
コード例 #2
0
        public static async Task StoreTag([QueueTrigger(StorageName.TagTransactionQueue)] StoreTagMessage message, string channel, string transactionId, int dequeueCount, TextWriter log)
        {
            using (var scope = _provider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                try
                {
                    var command = scope.ServiceProvider.GetService <StoreTagCommand>();

                    await command.ExecuteAsync(channel, transactionId);
                }
                catch (StoreTagJobException e)
                {
                    try
                    {
                        if (!e.OnlyLog)
                        {
                            ITagTransactionTable txTable = scope.ServiceProvider.GetService <ITagTransactionTable>();

                            await txTable.AddTagTransactionErrorMessageAsync(channel, transactionId, e.Message);
                        }

                        await log.WriteLineAsync(e.Message);
                    }
                    catch (Exception exception)
                    {
                        await log.WriteLineAsync($"Failed to store message for {channel}/{transactionId}. Original message: {e.Message}. Exception: {exception.ToString()}");
                    }
                }


                //var connection = new Connection(TableStorageConnectionString /*_environment.TableStorageConnectionString*/);

                //var tagTxTable = connection.TransactionTable();

                //var tagTx = await tagTxTable.GetTagTransactionAsync(channel, transactionId);

                //if (tagTx == null)
                //{
                //    await log.WriteLineAsync($"Could not find transaction id: {transactionId} in channel: {channel}");
                //    return;
                //}

                //try
                //{
                //    var update = new UpdateStorageCommand(connection, tagTx);
                //    await update.ExecuteAsync();

                //    if (update.DidWork)
                //    {
                //        await connection.QueueIndexMessageAsync(new IndexChannelMessage(channel));
                //    }
                //}
                //catch (StoreTagJobException e)
                //{
                //    try
                //    {
                //        await tagTxTable.AddTagTransactionErrorMessageAsync(tagTx, e.Message);
                //    }
                //    catch (Exception exception)
                //    {
                //        await log.WriteLineAsync($"Failed to store message for {channel}/{transactionId}. Original message: {e.Message}. Exception: {exception.ToString()}");
                //    }
                //}
            }
        }