Example #1
0
        public ClientDto RegisterClient(ITransactionScope transactionScope, ClientDto clientDto)
        {
            Client client = _clientRepository.GetClientsByFilterCriteria(transactionScope, new ClientFilterCriteria() {Name = clientDto.Name}).SingleOrDefault();
            ;
            if (client == null)
            {
                client = _clientRepository.Create();
            }

            client.Name = clientDto.Name;
            client.Hostname = clientDto.Hostname;
            client.Type = clientDto.Type;

            _clientRepository.Save(transactionScope, client);

            transactionScope.Flush();

            _clientRepository.Refresh(transactionScope, client);

            clientDto.Id = client.Id;

            return clientDto;
        }
Example #2
0
        public RunnedWorkflowDto GetWorkflowToExecute(ITransactionScope transactionScope)
        {
            var workflowToExecute = _workflowQueueRepository.GetNextQueuedWorkflowAndSetStarttime(transactionScope);

            if (workflowToExecute == null)
            {
                return null;
            }

            var runnedWorkflow = CreateRunnedWorkflow(transactionScope, workflowToExecute.DefinedWorkflow, workflowToExecute.Event);
            workflowToExecute.RunnedWorkflow = runnedWorkflow;

            _workflowQueueRepository.Save(transactionScope, workflowToExecute);

            transactionScope.Flush();

            _runnedWorkflowRepository.Refresh(transactionScope, runnedWorkflow);

            return TranslateToDto(runnedWorkflow);
        }
Example #3
0
        public EventDto GetEventsToProcess(ITransactionScope transactionScope)
        {
            var eventToProcess = _eventRepository.GetEvents(transactionScope, new EventFilterCriteria()
                {
                    IsProcessed = false
                }).OrderBy(e => e.TriggeredDate).FirstOrDefault();

            if (eventToProcess == null)
                return new EventDto(){Id = -1};

            eventToProcess.ProcessedDate = DateTime.UtcNow;

            _eventRepository.Save(transactionScope, eventToProcess);
            transactionScope.Flush();

            return new EventDto()
                    {
                        Id = eventToProcess.Id,
                        TriggeredDate = eventToProcess.TriggeredDate,
                        ProcessedDate = eventToProcess.ProcessedDate,
                        EventGroupType = eventToProcess.EventGroupType,
                        EventType = eventToProcess.EventType,
                        Data = eventToProcess.Data
                    };
        }