Exemplo n.º 1
0
 public EventService(
     IEventWriteService eventWriteService,
     IOrganizationUserRepository organizationUserRepository,
     CurrentContext currentContext,
     GlobalSettings globalSettings)
 {
     _eventWriteService          = eventWriteService;
     _organizationUserRepository = organizationUserRepository;
     _currentContext             = currentContext;
     _globalSettings             = globalSettings;
 }
Exemplo n.º 2
0
        public Functions(IConfiguration config)
        {
            var storageConnectionString = config["AzureWebJobsStorage"];

            if (string.IsNullOrWhiteSpace(storageConnectionString))
            {
                return;
            }

            var repo = new Core.Repositories.TableStorage.EventRepository(storageConnectionString);

            _eventWriteService = new RepositoryEventWriteService(repo);
        }
Exemplo n.º 3
0
        static Functions()
        {
            var storageConnectionString = ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"];

            if (storageConnectionString == null || string.IsNullOrWhiteSpace(storageConnectionString.ConnectionString))
            {
                return;
            }

            var repo = new Core.Repositories.TableStorage.EventRepository(storageConnectionString.ConnectionString);

            _eventWriteService = new RepositoryEventWriteService(repo);
        }
Exemplo n.º 4
0
        public EventServiceTests()
        {
            _eventWriteService          = Substitute.For <IEventWriteService>();
            _organizationUserRepository = Substitute.For <IOrganizationUserRepository>();
            _currentContext             = new CurrentContext();
            _globalSettings             = new GlobalSettings();

            _sut = new EventService(
                _eventWriteService,
                _organizationUserRepository,
                _currentContext,
                _globalSettings
                );
        }
Exemplo n.º 5
0
 public EventService(
     IEventWriteService eventWriteService,
     IOrganizationUserRepository organizationUserRepository,
     IProviderUserRepository providerUserRepository,
     IApplicationCacheService applicationCacheService,
     ICurrentContext currentContext,
     GlobalSettings globalSettings)
 {
     _eventWriteService          = eventWriteService;
     _organizationUserRepository = organizationUserRepository;
     _providerUserRepository     = providerUserRepository;
     _applicationCacheService    = applicationCacheService;
     _currentContext             = currentContext;
     _globalSettings             = globalSettings;
 }
        private async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            var storageConnectionString = _configuration["azureStorageConnectionString"];

            if (string.IsNullOrWhiteSpace(storageConnectionString))
            {
                return;
            }

            var repo = new Core.Repositories.TableStorage.EventRepository(storageConnectionString);

            _eventWriteService = new RepositoryEventWriteService(repo);

            var storageAccount = CloudStorageAccount.Parse(storageConnectionString);
            var queueClient    = storageAccount.CreateCloudQueueClient();

            _queue = queueClient.GetQueueReference("event");

            while (!cancellationToken.IsCancellationRequested)
            {
                try
                {
                    var messages = await _queue.GetMessagesAsync(32, TimeSpan.FromMinutes(1),
                                                                 null, null, cancellationToken);

                    if (messages.Any())
                    {
                        foreach (var message in messages)
                        {
                            await ProcessQueueMessageAsync(message.AsString, cancellationToken);

                            await _queue.DeleteMessageAsync(message);
                        }
                    }
                    else
                    {
                        await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Exception occurred: " + e.Message);
                    await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
                }
            }

            _logger.LogWarning("Done processing.");
        }
Exemplo n.º 7
0
        private async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            var storageConnectionString = _configuration["azureStorageConnectionString"];

            if (string.IsNullOrWhiteSpace(storageConnectionString))
            {
                return;
            }

            var repo = new Core.Repositories.TableStorage.EventRepository(storageConnectionString);

            _eventWriteService = new RepositoryEventWriteService(repo);
            _queueClient       = new QueueClient(storageConnectionString, "event");

            while (!cancellationToken.IsCancellationRequested)
            {
                try
                {
                    var messages = await _queueClient.ReceiveMessagesAsync(32);

                    if (messages.Value?.Any() ?? false)
                    {
                        foreach (var message in messages.Value)
                        {
                            await ProcessQueueMessageAsync(message.DecodeMessageText(), cancellationToken);

                            await _queueClient.DeleteMessageAsync(message.MessageId, message.PopReceipt);
                        }
                    }
                    else
                    {
                        await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Exception occurred: " + e.Message);
                    await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
                }
            }

            _logger.LogWarning("Done processing.");
        }