Beispiel #1
0
        public ClientDto Register(ClientDto clientDto)
        {
            var restResponse = JarvisRestClient.Execute<ResultDto<ClientDto>>(new RegisterClientRequest() {ClientDto = clientDto}, "POST");

            JarvisRestClient.CheckForException(restResponse.ResponseStatus);
            return restResponse.Result;
        }
Beispiel #2
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;
        }
Beispiel #3
0
        public virtual void Init(IKernel container)
        {
            Thread.Sleep(10000);

            if (State >= State.Initialized)
            {
                throw new Exception("Client already initialized");
            }

            Container = container;

            AddAddInConfigHandling();
            LoadLocalClientInformation();

            if (EnableAddins)
            {
                LoadAddins();
            }

            CheckIfServerIsOnlineAndWait();

            if (!isAlreadyRegistered())
            {
                ClientDto = _clientService.Register(ClientDto);
                _log.InfoFormat("Client {0} ({1}) with Id {2} registered", _clientDto.Name, _clientDto.Hostname, _clientDto.Id);
                _configuration.ClientId = ClientDto.Id;
                SaveSettings();
            }
            ClientDto.Hostname = GetLocalHostname();

            Logon();

            State = State.Initialized;
        }
Beispiel #4
0
 public void Logon(ITransactionScope transactionScope, ClientDto clientDto)
 {
     SetIsOnlineState(transactionScope, clientDto, true);
 }
Beispiel #5
0
 public void Logoff(ITransactionScope transactionScope, ClientDto clientDto)
 {
     SetIsOnlineState(transactionScope, clientDto, false);
 }
Beispiel #6
0
        private void SetIsOnlineState(ITransactionScope transactionScope, ClientDto clientDto, bool isOnline)
        {
            var client = _clientRepository.GetById(transactionScope, clientDto.Id);

            if (client == null)
            {
                throw new Exception("client not registered");
            }

            client.IsOnline = isOnline;
            clientDto.Hostname = clientDto.Hostname;
            _clientRepository.Save(transactionScope, client);
        }
Beispiel #7
0
 public void Logon(ClientDto clientDto)
 {
     var restResponse = JarvisRestClient.Execute<ResultDto>(new LoginClientRequest() { ClientDto = clientDto }, "PUT");
     JarvisRestClient.CheckForException(restResponse.ResponseStatus);
 }