Normal Topic Perform action if user hasn't logged in for a whil (Read 1230 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Perform action if user hasn't logged in for a whil
Apr 4th, 2011 at 6:43pm
Print Post Print Post  
I've got something percolating in my noggin but I'm not sure if it's possible, and if it is I'm not sure how to begin.

I'd like to somehow program one of my databases to pop up a notice for the user when he logs in, on the condition that he hasn't logged in for a specific length of time.  Let's say a week.

So the scenario is:  Sammy logs in on a daily basis, does some stuff, normal day after normal day.  Then Sammy goes on vacation for a week.  When he gets back he logs into the application and opens the form.  Programming does it's thing and says to itself, "Hey, Sammy hasn't been here for a week!" and up pops the notification, which Sammy has to acknowledge (and hopefully read) before he can continue.  The programming sees that he's acknowledged the notice and resets itself looking for another missed week (or more).

And advice on how I could accomplish this?  Thanks!
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Perform action if user hasn't logged in for a
Reply #1 - Apr 4th, 2011 at 7:17pm
Print Post Print Post  
Hello Scott,

You can use the On Application Open event for this and store the user's last login date in a GlobalValue. Below is an Example of how to do this. The user will get a message if they have not logged in for over 7 days.

Code
Select All
Var vUser as String
Var vLastLogin as Date
Var vToday as Date

vUser = @UserID
vLastLogin = @ToDate(@GlobalValue(vUser + "LastLogin"))
vToday = @ServerDate()
If vToday > (vLastLogin + 7) Then
{
	Writeln("You have not logged in for " + @Str(@ToNumber(vToday - vLastLogin)) + " Days")
}
GlobalValue(vUser + "LastLogin",vToday) 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Perform action if user hasn't logged in for a
Reply #2 - Apr 4th, 2011 at 8:02pm
Print Post Print Post  
Thanks Ray!  I'll give it a try.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Perform action if user hasn't logged in for a
Reply #3 - Apr 5th, 2011 at 2:13pm
Print Post Print Post  
OK, I incorporated the programming into On Application Open, but set the time limit to vLastLogin + 1, so it should fire off tomorrow.  A few questions in the meantime:

* How can this work, when vUser and "LastLogin" are text strings? vLastLogin = @ToDate(@GlobalValue(vUser + "LastLogin"))


* A new scenario:  Sammy has been on vacation, which I have been unaware of since such things are the province or personnel and payroll and not MIS.  However, I am the admin of the database he uses.  Sammy is supposed to return to work today, at which time he will get the important message the above programming is designed to give him.  However, he has not returned to work today (maybe he's sick), so the message never was seen and the action he's supposed to accomplish has not occurred.  This is something that I, as admin, need to know.  How should I tweak the programming so that if Sammy hasn't logged in on day 8 a message is sent to me when I log in?

Thanks for your help Ray.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Perform action if user hasn't logged in for a
Reply #4 - Apr 5th, 2011 at 2:43pm
Print Post Print Post  
The first time I logged into the application after incorporating the programming I got the message "You have not logged in for 734232 Days", so it looks like I need to initialize vLastLogin for all users before distributing the revised App.   I belive I just need to do this using a mass update that creates the Global Value.  But what should I set it as?

BTW, why "734232"?  Does that number have special significance?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Perform action if user hasn't logged in for a
Reply #5 - Apr 5th, 2011 at 2:47pm
Print Post Print Post  
Quote:
How can this work, when vUser and "LastLogin" are text strings? vLastLogin = @ToDate(@GlobalValue(vUser + "LastLogin"))


Let's say vUser is Sammy that will resolve to

Code
Select All
vLastLogin = @ToDate(@GlobalValue("Sammy" + "LastLogin")) 


which becomes
Code
Select All
vLastLogin = @ToDate(@GlobalValue("SammyLastLogin")) 


So Sesame returns the value from the GlobalValue named "SammyLastLogin

Quote:

* A new scenario:  Sammy has been on vacation, which I have been unaware of since such things are the province or personnel and payroll and not MIS.  However, I am the admin of the database he uses.  Sammy is supposed to return to work today, at which time he will get the important message the above programming is designed to give him.  However, he has not returned to work today (maybe he's sick), so the message never was seen and the action he's supposed to accomplish has not occurred.  This is something that I, as admin, need to know.  How should I tweak the programming so that if Sammy hasn't logged in on day 8 a message is sent to me when I log in?  


That becomes a bit more complicated. Do you want the message if any user has not logged in over 7 days or only certain ones? If it's all users, You can use @ItterateGlobalValues() along with @SearchStringArray() to get the names of all the GlobalValues that end with the string "LastLogin". Once you have the list of GlobalValue names you can loop through using @AccessStringArray(), @CountStringArray() and @GlobalValue() to grab the value from each GlobalValue. Then compare that value with today's date and display a message if needed.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Perform action if user hasn't logged in for a
Reply #6 - Apr 5th, 2011 at 3:23pm
Print Post Print Post  
Quote:
That becomes a bit more complicated. Do you want the message if any user has not logged in over 7 days or only certain ones?

Let's keep it simple for now and say just one user.  I imagine in such a case all I would have to do is, when I log in, have the application programming look at the global value that was set when Sammy last logged in and, if it's 8 days, send me a popup.  So, maybe something like this:
Code
Select All
If (@Group = "Admin" and (@GlobalValue(SammyLastLogin) > @ToNumber((@date - 7)) ) )
Then
{
	Writeln("Sammy has not logged in for " + @Str(@ToNumber(@date - @GlobalValue(SammyLastLogin)) + " Days")
} 


Am I close?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Perform action if user hasn't logged in for a
Reply #7 - Apr 5th, 2011 at 3:35pm
Print Post Print Post  
Infinity wrote on Apr 5th, 2011 at 2:43pm:
The first time I logged into the application after incorporating the programming I got the message "You have not logged in for 734232 Days", so it looks like I need to initialize vLastLogin for all users before distributing the revised App.   I belive I just need to do this using a mass update that creates the Global Value.  But what should I set it as?

BTW, why "734232"?  Does that number have special significance?


Hello Scott,

Initialize them to today's date. 734232 I believe is the number of days from 00/00/0000 to today.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Perform action if user hasn't logged in for a
Reply #8 - Apr 5th, 2011 at 3:40pm
Print Post Print Post  
Infinity wrote on Apr 5th, 2011 at 3:23pm:
Let's keep it simple for now and say just one user.  I imagine in such a case all I would have to do is, when I log in, have the application programming look at the global value that was set when Sammy last logged in and, if it's 8 days, send me a popup.  So, maybe something like this:
Code
Select All
If (@Group = "Admin" and (@GlobalValue(SammyLastLogin) > @ToNumber((@date - 7)) ) )
Then
{
	Writeln("Sammy has not logged in for " + @Str(@ToNumber(@date - @GlobalValue(SammyLastLogin)) + " Days")
} 


Am I close?


You are close except SammyLastLogin needs to be in quotes as it is a string, and just from looking at it I think
Code
Select All
If (@Group = "Admin" and (@GlobalValue(SammyLastLogin) > @ToNumber(@date - 7) ) ) 


should be
Code
Select All
If (@Group = "Admin" and (@Date > (@ToDate(@GlobalValue("SammyLastLogin")) + 7) ) ) 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged