private void Login()
        {
            Task.Factory.StartNew(() =>
            {
                var client = new LoginServiceClient(new InstanceContext(new NoOpLoginCallback(ToastService)));

                try
                {
                    client.Subscribe();

                    if (!client.IsLoggedIn())
                    {
                        var remembered = client.GetRememberedUser();

                        if (!string.IsNullOrEmpty(remembered))
                        {
                            client.Relogin();
                        }
                    }
                }
                catch (Exception e)
                {
                    client.Abort();
                    Thread.Sleep(2000);
                    Login();
                }
            });
        }
        private bool IsLoggedIn()
        {
            LoginServiceClient client = new LoginServiceClient(new InstanceContext(new NoOpCallbacks()));

            try
            {
                bool result = client.IsLoggedIn();
                client.Close();
                return(result);
            }
            catch
            {
                client.Abort();
                return(false);
            }
        }
 public void Save()
 {
     try
     {
         if (_loginServiceClient != null)
         {
             _loginServiceClient.Close();
         }
     }
     catch (Exception e)
     {
         if (_loginServiceClient != null)
         {
             _loginServiceClient.Abort();
         }
     }
 }
        public void Load()
        {
            Task.Factory.StartNew(() =>
            {
                _loginServiceClient = new LoginServiceClient(new InstanceContext(this));

                try
                {
                    _loginServiceClient.Subscribe();

                    IsLoggedIn = _loginServiceClient.IsLoggedIn();
                    UserName   = _loginServiceClient.GetRememberedUser();
                }
                catch (Exception)
                {
                    _loginServiceClient.Abort();
                }
            });
        }
Example #5
0
        private void DeferredLoginTimerOnTick(object sender, EventArgs eventArgs)
        {
            _deferredLoginTimer.Stop();

            try
            {
                LoadingIndicator.Push();

                if (_client.State != CommunicationState.Opened)
                {
                    _client = new LoginServiceClient(new InstanceContext(this));
                }

                _client.Subscribe();
                _client.Login(_userName.Text, _password.Password, true);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                _client.Abort();
            }
        }
 public void open()
 {
     using (var client = new LoginServiceClient("WSHttpBinding_ILoginService"))
     {
         try
         {
             AuthenticationStatus request =
                 client.Authenticate(customerApiKey, serviceUserPassword, userApiKey, serviceUser, out message, out token);
             if (request == AuthenticationStatus.Ok)
             {
                 client.Close();
             }
             else
             {
                 client.Abort();  // Authentication failed, see message property for details.
             }
         }
         catch (Exception ex)
         {
             message = "Unexpected error occured while establishing the UltiPro authentication session.  " + ex.ToString();
         }
     }
 }
        public void Load()
        {
            Task.Factory.StartNew(() =>
            {
                _loginServiceClient = new LoginServiceClient(new InstanceContext(this));

                try
                {
                    _loginServiceClient.Subscribe();

                    IsLoggedIn = _loginServiceClient.IsLoggedIn();
                    UserName = _loginServiceClient.GetRememberedUser();
                }
                catch (Exception)
                {
                    _loginServiceClient.Abort();
                }
            });
        }
        private bool IsLoggedIn()
        {
            LoginServiceClient client = new LoginServiceClient(new InstanceContext(new NoOpCallbacks()));

            try
            {
                bool result = client.IsLoggedIn();
                client.Close();
                return result;
            }
            catch
            {
                client.Abort();
                return false;
            }
        }