Is it possible to temporarily apply admin or last logged in user rights in order to close forms?


Author
Message
Cory Cookson
Cory Cookson
StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)
Group: Forum Members
Posts: 30, Visits: 416
yes it doesn't seem to affect the fact that the form has already been disabled.

Cory Cookson

Software Developer

Occupational Health Research

Cory Cookson
Cory Cookson
StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)
Group: Forum Members
Posts: 30, Visits: 416
yes I've tried it but it doesn't seem to reset the security on the forms so that they are no longer disabled.

Cory Cookson

Software Developer

Occupational Health Research

Cory Cookson
Cory Cookson
StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)
Group: Forum Members
Posts: 30, Visits: 416
bump

Cory Cookson

Software Developer

Occupational Health Research

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Cory.

Have you also tried Greg's advice, and worked on your Login form? Since we are fighting the normal behavior of the SessionLock, working on your Login form could give you some flexibility to take care of actions.

Dustin Taylor
Dustin Taylor
StrataFrame Team Member (664 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
Once you change the user you will have to call LockSession again to refresh the form states. You'll have to account for this in your AfterSessionLock logic, however, to prevent it from getting into an infinite loop.

That said, this isn't what I would recommend to handle the issue of unclosable locked forms. The session locking works the way it does for a reason, namely that users lower privileges should not be able to tamper with the work done by users of higher privileges (including discarding changes made by the administrator). That is why they have the different levels, to prevent one from having access to the other.  As such, if you want to avoid the situation where an administrator logs out, and then a standard users logs in and can't close some open forms, I would recommend enforcing the administrator to save and close their work before logging out, rather than upping the permissions of the standard user to allow them access to explicitly denied forms or functions.

Cory Cookson
Cory Cookson
StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)
Group: Forum Members
Posts: 30, Visits: 416
Thank you for the replies!  I really appreciate the support of the forum.

I am making sure that the first user has saved or reloaded all data that they are working on before they are logged out.

I've tried recalling LockSession in the afterSessionLock event and it just brings up the login form again.

I want to close the open forms without the second user even knowing they were open. 

There are however times that another person will login with equivelant rights and they should be able to see all of the screens that were left open by the first user.

As always any help is appreciated Smile

Cory Cookson

Software Developer

Occupational Health Research

Cory Cookson
Cory Cookson
StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)StrataFrame Novice (86 reputation)
Group: Forum Members
Posts: 30, Visits: 416
I believe that I've found a solution to the issue.  Code snippets as follows:

public static void HandleCurrentUserChanged(object sender, EventArgs e)

{

if (_UserID.Length > 0)

{

_UserChanged = (_UserID != SecurityBasics.CurrentUser.UserName.ToString());

}

_UserID = SecurityBasics.CurrentUser.UserName.ToString();

if(_UserChanged)

{

for (int i = 0; i <= Application.OpenForms.Count - 1; i++)

{

MicroFour.StrataFrame.UI.Windows.Forms.BaseForm bf = (MicroFour.StrataFrame.UI.Windows.Forms.BaseForm)Application.OpenForms[i];

if (bf.Name != "Form1")

bf.Close();

}

}

}

private static void HandleBeforeSessionLock(object sender, EventArgs e)

{

for (int i = 0; i <= Application.OpenForms.Count - 1; i++)

{

MicroFour.StrataFrame.UI.Windows.Forms.BaseForm bf = (MicroFour.StrataFrame.UI.Windows.Forms.BaseForm)Application.OpenForms[i];

if (bf.Name != "Form1")

{

if (bf.EditingState == MicroFour.StrataFrame.Business.BusinessEditingState.Editing)

{

if (MicroFour.StrataFrame.Messaging.MessageForm.ShowMessage("unsaved data detected",

"Do you want to save your changes to " + bf.Name, "", MicroFour.StrataFrame.Messaging.MessageFunction.YesNo, MicroFour.StrataFrame.Messaging.MessagingIcon.Question,

MicroFour.StrataFrame.Messaging.MessagingSounds.DefaultSound) == MicroFour.StrataFrame.Messaging.MessageFunctionType.Yes)

bf.Save();

else

bf.Undo();

}

}

}

}



Cory Cookson

Software Developer

Occupational Health Research

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Great, Cory! Cool
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search