Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Security: Auto log out: Inactivity Period
PostPosted: Mon Feb 20, 2017 12:22 pm 

Joined: Thu Dec 13, 2012 2:07 pm
Posts: 10

Offline
Can the auto logout inactivity period be changed at runtime?


 Profile  
 
 Post subject: Re: Security: Auto log out: Inactivity Period
PostPosted: Wed Feb 22, 2017 3:58 am 

Joined: Wed Mar 09, 2016 3:53 am
Posts: 5

Offline
As fas as I know its not possible. But here's a small example how you can do your own log out function with your own tag for seconds before auto logout.
It uses the mouse position, and that works even if you dont have a mouse attached.

private static System.Windows.Forms.Timer _timer;
private int _mouseX = -1;
private int _mouseY = -1;
private int _mouseMoved;

private void TimerTick(Object sender, EventArgs e)
{
var x = System.Windows.Forms.Control.MousePosition.X;
var y = System.Windows.Forms.Control.MousePosition.Y;

if( ( Math.Abs(_mouseX-x) > 5 ) || ( Math.Abs(_mouseY-y) > 5 ) )
{
_mouseMoved=0;
}
else
{
_mouseMoved++;

var inactivityTimeout = Globals.Tags.System_InactivityTimeBeforeLogout.Value * 60;

if((inactivityTimeout>0) && (_mouseMoved > inactivityTimeout))
{
Globals.Security.Logout();
}
}
_mouseX = x;
_mouseY = y;
}

void Scriptmodule_Created(System.Object sender, System.EventArgs e)
{
// Set up timer that monitors if the mouse has moved
_timer = new System.Windows.Forms.Timer {Interval = 1000};
_timer.Tick += TimerTick;
_timer.Enabled = true;
}

Good luck :)


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: