Пример #1
0
        private void CreateNewUser()
        {
            User savedUser = null;

            IsRegisterFailed = false;
            ErrorMessage     = string.Empty;
            using (IWorkContextScope scope = _workEnvironment.GetWorkContextScope())
            {
                savedUser = _userService.GetUser(UserName);

                if (savedUser == null)
                {
                    savedUser = _userService.Register(_user);
                    _sessionManager.Add(savedUser);
                }
                else
                {
                    IsRegisterFailed = true;
                    ErrorMessage     = _userService.ErrorString;
                }
            }
            if (!IsRegisterFailed)
            {
                GoBack(savedUser);
            }
        }
Пример #2
0
        private async Task OnClientConnected(INetworkClient client)
        {
            await m_SessionManager.Add(client);

            client.OnSendComplete = OnSendComplete;
            client.OnDataReceived = async(id, data) => await m_SessionManager.OnDataReceived(id, data);
        }
Пример #3
0
 public Task <ISession> ConnectAsync(string ip, int port, string phoneNumber = null)
 {
     return(bootstrap.ConnectAsync(new IPEndPoint(IPAddress.Parse(ip), port)).ContinueWith(task =>
     {
         ISession session = new Session {
             Channel = task.Result, PhoneNumber = phoneNumber
         };
         sessionManager.Add(session);
         return session;
     }, TaskContinuationOptions.OnlyOnRanToCompletion));
 }
Пример #4
0
        public IUserSnap GetUser(string securitytoken, LoginType type)
        {
            IUserSnap snap = _session_manager.Get(securitytoken);

            if (snap == null)
            {
                _usersnap_loader.SetResource(WebConfiguration.Instance.WebUpdateUserAddress);
                snap = _usersnap_loader.Load(securitytoken, type);
                if (snap == null)
                {
                    return(snap);
                }
                _session_manager.Add(snap);
            }
            return(snap);
        }
        UserDto IUserService.Connect(string login, string motDePasse)
        {
            if (null != motDePasse &&
                !"".Equals(motDePasse) &&
                null != login &&
                !"".Equals(login) &&
                motDePasse.Equals(authenticateData.GetPassword(login)))
            {
                Authenticate authenticate = authenticateData.GetByLogin(login);
                User         user         = userData.GetByAuthenticationId(authenticate.authenticateId.id);

                string token = sessionManager.Add(user.id.id);

                return(userDtoAdapter.ModelToDto(user, authenticate, token));
            }
            ;

            return(null);
        }