public void Logout()
        {
            AuthenticationServiceClient client = new AuthenticationServiceClient();
            OperationContextScope       scope  = new OperationContextScope(client.InnerChannel);
            var prop = new HttpRequestMessageProperty();

            prop.Headers.Add(HttpRequestHeader.Cookie, ModelLocator.getInstance().SessionModel.SessionCookie);
            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = prop;

            try
            {
                client.Logout();
                mResponder.LogoutResult();
            }
            catch (FaultException <ONyRFaultException> ex)
            {
                mResponder.LogoutFault((ErrorCode)ex.Detail.ErrorCode);
            }
            catch (Exception)
            {
                mResponder.LogoutFault(ErrorCode.NonONyRError);
            }
            finally
            {
                if (client != null)
                {
                    client.Close();
                }
            }
        }
Пример #2
0
        public MainForm()
        {
            InitializeComponent();
            pnlHighlightedItemContainer = pnlOwnHighlightedItemContainer;

            ModelLocator.getInstance().SessionModel.UpdateEvent += new Model.UpdateHandler(SessionModel_UpdateEvent);
            ModelLocator.getInstance().SessionModel.Subscribe(this);

            new LoginUserNotifier("adhie", "passbaze").Handle();
        }
Пример #3
0
        public void ModifyPasswordResult()
        {
            MessageBox.Show("A jelszó módosítása sikeres!", "Információ", MessageBoxButtons.OK);

            if (ChangePasswordForm.hasInstance())
            {
                ChangePasswordForm.getCurrentInstance().Close();
            }
            ModelLocator.getInstance().SessionModel.NotifyOneOperationDone();
        }
Пример #4
0
        private UserServiceClient GetClient()
        {
            UserServiceClient     result = new UserServiceClient();
            OperationContextScope scope  = new OperationContextScope(result.InnerChannel);
            var prop = new HttpRequestMessageProperty();

            prop.Headers.Add(HttpRequestHeader.Cookie, ModelLocator.getInstance().SessionModel.SessionCookie);
            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = prop;

            return(result);
        }
Пример #5
0
        override protected void execute(LoginUserNotifier pLoginUserNotifier)
        {
            if (ModelLocator.getInstance().SessionModel.IsLoggedIn)
            {
                new AuthenticationServiceDeleage(
                    pLoginUserNotifier,
                    new AuthenticationServiceResponder()
                    ).Logout();
            }

            new AuthenticationServiceDeleage(
                pLoginUserNotifier,
                new AuthenticationServiceResponder()
                ).Login(pLoginUserNotifier.UserName, pLoginUserNotifier.Password);
        }
Пример #6
0
        public void RemoveUsersResult(object sender, RemoveUsersCompletedEventArgs e)
        {
            ONyR_client.model.vo.UserVO[] removedUsers = Convert(e.Result);
            ModelLocator locator = ModelLocator.getInstance();

            int[] ids = new int[removedUsers.Length];

            for (int i = 0; i < removedUsers.Length; ++i)
            {
                ids[i] = removedUsers[i].ID;
            }
            ModelLocator.getInstance().SessionModel.NotifyOneOperationDone();

            locator.UserModel.RemoveUsersByIDs(ids);
        }
Пример #7
0
        public void ModifyUsersResult(object sender, ModifyUsersCompletedEventArgs e)
        {
            ONyR_client.model.vo.UserVO[] newUsers = Convert(e.Result);
            SessionModel sessionModel = ModelLocator.getInstance().SessionModel;

            foreach (ONyR_client.model.vo.UserVO user in newUsers)
            {
                if (sessionModel.UserId == user.ID)
                {
                    sessionModel.SetCurrentUser(user);
                    break;
                }
            }
            ModelLocator.getInstance().SessionModel.NotifyOneOperationDone();
            ModelLocator.getInstance().UserModel.ModifyUsers(newUsers);
        }
        public static bool IsLoggedIn()
        {
            bool result = false;

            AuthenticationServiceClient client = new AuthenticationServiceClient();
            OperationContextScope       scope  = new OperationContextScope(client.InnerChannel);
            var prop = new HttpRequestMessageProperty();

            prop.Headers.Add(HttpRequestHeader.Cookie, ModelLocator.getInstance().SessionModel.SessionCookie);
            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = prop;

            result = client.IsLoggedIn();

            client.Close();

            return(result);
        }
Пример #9
0
        public void Refresh(ApplicationState value)
        {
            switch (value)
            {
            case ApplicationState.Loading:
                lblConnectionState.Text = "Betöltés...";
                miLogin.Enabled         = true;
                miLogout.Enabled        = false;
                tsmiOptions.Enabled     = false;
                tspbLoader.Visible      = true;
                break;

            case ApplicationState.Offline:
                lblConnectionState.Text = "Nincs kapcsolat.";
                miLogin.Enabled         = true;
                miLogout.Enabled        = false;
                tsmiOptions.Enabled     = false;
                tspbLoader.Visible      = false;
                break;

            case ApplicationState.Anonimous:
            case ApplicationState.Online:
                lblConnectionState.Text = value == ApplicationState.Online ? String.Format(
                    "Bejelentkezve mint: {0}.",
                    UserNameFormatter.Format(ModelLocator.getInstance().SessionModel.CurrentUser)
                    ) : "Bejelentkezve.";
                miLogin.Enabled     = false;
                miLogout.Enabled    = true;
                tsmiOptions.Enabled = value == ApplicationState.Online;
                tspbLoader.Visible  = false;

                if (lfLogin != null)
                {
                    lfLogin.Close();
                    lfLogin = null;
                }
                break;
            }
        }
Пример #10
0
        public void AddUsers(UserVO[] pUser)
        {
            UserServiceClient client = GetClient();

            try
            {
                ModelLocator.getInstance().SessionModel.NotifyOneOperationBegin();
                client.AddUsersCompleted += new EventHandler <AddUsersCompletedEventArgs>(mResponder.AddUsersResult);
                client.AddUsersAsync(ConvertToServer(pUser));
            }
            catch (FaultException <ONyRFaultException> ex)
            {
                mResponder.AddUsersFault((ErrorCode)ex.Detail.ErrorCode);
            }
            catch (Exception)
            {
                mResponder.AddUsersFault(ErrorCode.NonONyRError);
            }
            finally
            {
                client.Close();
            }
        }
Пример #11
0
        public void LoadUsers(UserFilter pFilter, int pID = -1, int[] pIDs = null)
        {
            UserServiceClient client = GetClient();

            try
            {
                ModelLocator.getInstance().SessionModel.NotifyOneOperationBegin();
                client.LoadUsersCompleted += new EventHandler <LoadUsersCompletedEventArgs>(mResponder.LoadUsersResult);
                client.LoadUsersAsync(pFilter, pID, pIDs);
            }
            catch (FaultException <ONyRFaultException> ex)
            {
                mResponder.LoadUsersFault((ErrorCode)ex.Detail.ErrorCode);
            }
            catch (Exception)
            {
                mResponder.LoadUsersFault(ErrorCode.NonONyRError);
            }
            finally
            {
                client.Close();
            }
        }
Пример #12
0
        public void ModifyPassword(string pOldPassword, string pNewPassword)
        {
            UserServiceClient client = GetClient();

            try
            {
                ModelLocator.getInstance().SessionModel.NotifyOneOperationBegin();
                client.ModifyPassword(pOldPassword, pNewPassword);
                mResponder.ModifyPasswordResult();
            }
            catch (FaultException <ONyRFaultException> ex)
            {
                mResponder.ModifyPasswordFault((ErrorCode)ex.Detail.ErrorCode);
            }
            catch (Exception)
            {
                mResponder.ModifyPasswordFault(ErrorCode.NonONyRError);
            }
            finally
            {
                client.Close();
            }
        }
Пример #13
0
        public void ModifyUsers(UserVO[] pOriginalUser, UserVO[] pNewUser, bool isForced = false)
        {
            UserServiceClient client = GetClient();

            try
            {
                ModelLocator.getInstance().SessionModel.NotifyOneOperationBegin();
                client.ModifyUsersCompleted += new EventHandler <ModifyUsersCompletedEventArgs>(mResponder.ModifyUsersResult);
                client.ModifyUsersAsync(ConvertToServer(pOriginalUser), ConvertToServer(pNewUser), isForced);
            }
            catch (FaultException <ONyRFaultException> ex)
            {
                mResponder.ModifyUsersFault((ErrorCode)ex.Detail.ErrorCode);
            }
            catch (Exception)
            {
                mResponder.ModifyUsersFault(ErrorCode.NonONyRError);
            }
            finally
            {
                client.Close();
            }
        }
Пример #14
0
 private void tsmiOptions_Click(object sender, EventArgs e)
 {
     new UserEditorForm(ModelLocator.getInstance().SessionModel.CurrentUser).ShowDialog();
 }
Пример #15
0
 public void LoginFault(ErrorCode pCode)
 {
     ModelLocator.getInstance().SessionModel.Logout();
     ApplicationFaultManager.Fault(pCode, Initiator);
 }
Пример #16
0
 public void LogoutResult()
 {
     ModelLocator.getInstance().SessionModel.Logout();
 }
Пример #17
0
 public void LoginResult(string cookie)
 {
     ModelLocator.getInstance().SessionModel.SetSessionCookie(cookie);
 }
Пример #18
0
 public void ModifyUsersFault(ErrorCode pCode)
 {
     ModelLocator.getInstance().SessionModel.NotifyOneOperationDone();
     ApplicationFaultManager.Fault(pCode, Initiator);
 }
Пример #19
0
 public void AddUsersResult(object sender, AddUsersCompletedEventArgs e)
 {
     ModelLocator.getInstance().SessionModel.NotifyOneOperationDone();
     ONyR_client.model.vo.UserVO[] addedUsers = Convert(e.Result);
     ModelLocator.getInstance().UserModel.AddUsers(addedUsers);
 }