Exemplo n.º 1
0
 public MyEventProcessor()
 {
     var connectionString = CloudConfigurationManager.GetSetting("reposConnectionString");
     _repos = new Repository(connectionString);
 }
Exemplo n.º 2
0
        private async Task RunAsync(CancellationToken cancellationToken)
        {
            var reposConnectionString = CloudConfigurationManager.GetSetting("reposConnectionString");

            var repos = new Repository(reposConnectionString);

            while (!cancellationToken.IsCancellationRequested)
            {
                var msg = await _client.ReceiveAsync(TimeSpan.FromSeconds(5));

                if(msg != null)
                {
                    var json = (string) msg.Properties["json"];

                    var result = JsonConvert.DeserializeObject<PurchaseResult>(json);

                    var record = new AuditRecord
                    {
                        Id = Guid.NewGuid(),
                        RequestId = result.Request.Id,
                        RequestTimestamp = result.Request.Timestamp,
                        ResultId = result.Id,
                        ResultTimestamp = result.Timestamp,
                        Success = result.Success,
                        FailureReason = result.Success ? "<none>" : result.FailureReason.Value.ToString(),
                        JsonTickets = JsonConvert.SerializeObject(result.Request.DesiredTickets)
                    };

                    await repos.AddAuditRecord(record);
                }
            }
        }
Exemplo n.º 3
0
 public MainHub()
 {
     var connectionString = ConfigurationManager.AppSettings["reposConnectionString"];
     _repos = new Repository(connectionString);
 }