Ejemplo n.º 1
0
 public IDisposable RegisterBlockRepository(BlockRepository repository)
 {
     var listener = new EventLoopMessageListener<IncomingMessage>((m) =>
     {
         if(m.Node != null)
         {
             if(m.Message.Payload is HeadersPayload)
             {
                 foreach(var header in ((HeadersPayload)m.Message.Payload).Headers)
                 {
                     repository.WriteBlockHeader(header);
                 }
             }
             if(m.Message.Payload is BlockPayload)
             {
                 repository.WriteBlock(((BlockPayload)m.Message.Payload).Object);
             }
         }
     });
     return new CompositeDisposable(AllMessages.AddMessageListener(listener), OwnResource(listener));
 }
Ejemplo n.º 2
0
 public BlockController()
 {
     this.repo = new BlockRepository();
 }
        public IHttpActionResult MenuBlock()
        {
            try
            {
                MenuRepository menuRepo = new MenuRepository();
                BlockRepository blockRepo = new BlockRepository();

                SectionCollectionViewModel model = new SectionCollectionViewModel();

                foreach (KeyValuePair<int, string> section in Constants.SECTION)
                {
                    model.menu.Add(section.Value, menuRepo.GetByPosition(section.Key));
                }

                foreach (KeyValuePair<int, string> section in Constants.BLOCK_SECTION)
                {
                    model.block.Add(section.Value, blockRepo.GetByPosition(section.Key));
                }

                return Ok(model);
            }
            catch (Exception ex)
            {
                return BadRequest(ex.Message);
            }
        }
Ejemplo n.º 4
0
        public TasklingClient(IConfigurationReader configurationReader,
            ITaskRepository taskRepository = null,
            ITasklingConfiguration configuration = null,
            ITaskExecutionRepository taskExecutionRepository = null,
            IExecutionTokenRepository executionTokenRepository = null,
            ICommonTokenRepository commonTokenRepository = null,
            IEventsRepository eventsRepository = null,
            ICriticalSectionRepository criticalSectionRepository = null,
            IBlockFactory blockFactory = null,
            IBlockRepository blockRepository = null,
            IRangeBlockRepository rangeBlockRepository = null,
            IListBlockRepository listBlockRepository = null,
            IObjectBlockRepository objectBlockRepository = null,
            ICleanUpService cleanUpService = null,
            ICleanUpRepository cleanUpRepository = null)
        {
            if (taskRepository == null)
                taskRepository = new TaskRepository();

            if (configuration == null)
                _configuration = new TasklingConfiguration(configurationReader);

            if (commonTokenRepository == null)
                commonTokenRepository = new CommonTokenRepository();

            if (executionTokenRepository == null)
                executionTokenRepository = new ExecutionTokenRepository(commonTokenRepository);

            if (eventsRepository == null)
                eventsRepository = new EventsRepository();

            if (taskExecutionRepository != null)
                _taskExecutionRepository = taskExecutionRepository;
            else
                _taskExecutionRepository = new TaskExecutionRepository(taskRepository, executionTokenRepository, eventsRepository);

            if (criticalSectionRepository != null)
                _criticalSectionRepository = criticalSectionRepository;
            else
                _criticalSectionRepository = new CriticalSectionRepository(taskRepository, commonTokenRepository);

            if (blockRepository == null)
                blockRepository = new BlockRepository(taskRepository);

            if (rangeBlockRepository != null)
                _rangeBlockRepository = rangeBlockRepository;
            else
                _rangeBlockRepository = new RangeBlockRepository(taskRepository);

            if (listBlockRepository != null)
                _listBlockRepository = listBlockRepository;
            else
                _listBlockRepository = new ListBlockRepository(taskRepository);

            if (objectBlockRepository != null)
                _objectBlockRepository = objectBlockRepository;
            else
                _objectBlockRepository = new ObjectBlockRepository(taskRepository);

            if (blockFactory != null)
                _blockFactory = blockFactory;
            else
                _blockFactory = new BlockFactory(blockRepository, _rangeBlockRepository, _listBlockRepository, _objectBlockRepository, _taskExecutionRepository);

            if (cleanUpRepository == null)
                cleanUpRepository = new CleanUpRepository(taskRepository);

            if (cleanUpService != null)
                _cleanUpService = cleanUpService;
            else
                _cleanUpService = new CleanUpService(_configuration, cleanUpRepository);
        }
 public AccountService(BlockRepository blockRepository, IUserService userService)
 {
     _blockRepository = blockRepository;
     _userService     = userService;
 }