Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 29th, 2005, 12:47 PM
Authorized User
 
Join Date: Aug 2004
Location: Montreal, Qu, Canada.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Timer issue in ASP

Hello!

I hope you can help me on this one.:) I would like to implement a timer that keeps running in background on my web hosting server.

For example, let's say that I would want a user to be deleted automatically from my Access Database if he/she does not login after a while without he/she having to login for this to happen, or me having to do it manually.

Are there any timer components, Activex, etc...?

A sample code of a timer function running in background on the server using VBScript would be appreciated.

Many Thanks..







Ramez
__________________
Ramez
Reply With Quote
  #2 (permalink)  
Old January 29th, 2005, 02:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Do you got server access? If not then you have to depend on clients request to awake your scripts. Another and more developer heavy way is to develop an administration module, that make you able to quickly identify which records should be deleted (based on your business logic) and let you do so with a click of a button.

 - mega
Moving to C# .NET
Reply With Quote
  #3 (permalink)  
Old January 29th, 2005, 07:40 PM
Authorized User
 
Join Date: Aug 2004
Location: Montreal, Qu, Canada.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for answering,

No, I only have access to the web forlders, but not the server itself. However, I got an IIS4.0 Server at home that I can use to practice on.

I really want to automate the systems so I do not have to go manually operate on each user record. I know that VBScrip itself is short of Timer commands. I've tried for fun the Aplication_OnStart() in the Global.asa knowing that it was not the way to go. As a matter of fact, it did not work. Beside that, I do not want to have performance hit by using the Global.asa file with a timer application running on it.

The Database access example that I gave, was just an example. Actually, I would like to have a minimum idea on how to implement a Timer refresh so I could refresh the Time displayed, or take any timed action, in general, to name a few.

If you have an idea on how to do this, I will practice your code or any hint you can provide me on my personal IIS4.0 Server.

Many thanks again,

Ramez


Ramez
Reply With Quote
  #4 (permalink)  
Old January 29th, 2005, 08:14 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You could write a VBScript and schedule that with the Windows Task scheduler. This is probably the easiest solution; VBScript is pretty similar to ASP (actually the other way around) so there is a fair chance you can use existing pages.

If you're using SQL Server you can also use the SQL Server agent to schedule database tasks, like clean-up stuff.

You can also write a Windows Service. This is easy in .NET, but not in VB 6.

All these methods require some sort of access to the server. If you cannot control the server at least a little bit, you're stuck with what mega suggested; have you clients trigger the functionality.

For example, on Session_OnStart you could run the clean up. On a bust site, you could clean up every 100 or 100 users....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #5 (permalink)  
Old January 29th, 2005, 09:12 PM
Authorized User
 
Join Date: Aug 2004
Location: Montreal, Qu, Canada.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for replying,

I thought already to reserve a client computer to call a page on the web site. But I wanted to look for something more general. It look s that there is not an easy and direct solution using VBScrip only for that task. Therefore, I'll go with a client, it will be the easiest and the fastest way to implement this thask for now.

Thanks a lot Imar, I appreciate your help.

Ramez

Ramez
Reply With Quote
  #6 (permalink)  
Old January 29th, 2005, 09:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

You'll probably be happy to know that the only different between NT 4.0 and NT 5.x(win2k and XP pro) is server.transfer and server.execute (and a lot behind the scenes).
I'm not sure what you want to do, but anything regarding timing in ASP (let JScript slip for a while) is mostly done by using VBScript "Timer"...
An example is this:
Code:
<%
  intStartT = Timer
  Server.Execute "SomePageIWantToMeasure.asp" ' whatever.....
  intStopKL = Timer
  intMesTime = (intStopKL -intStartT)
  Response.Write("""SomePageIWantToMeasure.asp""" was " & intMesTime & " seconds in execution.")
%>
 - mega
Moving to C# .NET
Reply With Quote
  #7 (permalink)  
Old January 30th, 2005, 01:16 PM
Authorized User
 
Join Date: Aug 2004
Location: Montreal, Qu, Canada.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:)Hi mega,

Nice from you and Imar to reply. I'm relatively new to ASP, and I'm really trying hard to learn it. I understand the code you've provided me with the Timer build-in function, but it does require a client to request a page.

If you don't mind, I will briefly explain to you why I do need an automated refresh.

I'm in the process of building an educational web site. What I would like to automate, is the process of filtering the users that are new on my web site from the others. The new will be shown on a window and the others in another one. Until now, I was able to write the program in VBScript for the windows and the filtering process. However, this is where I'm stuck, I have to do this manually. So if I receive a 1000 users one day, then I will have to miss a day of work in order to spend the whole day to separate the new users from the olders.

So, in order not to have to miss a working day, I've build a semi-manual control panel that allows me to hit a button and to process the filtering. However, I'm not always at my computer for many different reasons, nor I do have access all the time to one.

That's the reason why I would like to fully automate the system, unstead of me having to push on a button, or to wait for a user to enter my web site in order to trigger the process.

I also have other applications on the web site to fully automate it.

Any way, you and Imar are surely more experienced programmers than I.

For this, I would like to ask you for an advice. I heard that PHP is a better and more complete program than VBScript. If you know about PHP, is it true that I could find most what I need in PHP than with ASP in order to implement timed automation processes in my programs.

Again, many thanks for your help and advices.

Sheers,


Ramez
Reply With Quote
  #8 (permalink)  
Old January 30th, 2005, 03:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

With the arrival of ASP.NET, ASP 3.0 is the latest and final update to ASP. Because of that PHP will probably evolve to a greater magnitude than classic ASP ever is. Having said that you can do anything in ASP that you can do in PHP, it’s just more difficult.

You write that “The new will be shown on a window and the others in another one.” Does this not mean that a user have to visit you site before your list changes? My point is this: If a user visits then you already got a trigger.

I’m not sure I fully understand what you are trying to accomplish. These list do their contain usernames from logged in visitors or is it just the number of visitors? In any case you can easily determine if a user is new or not (especially if log in is required). Write a cookie to the client the first time he/she visits your site and then check the existents of that cookie in your default page. Then you know… The pit falls of this is that you can’t be sure who the client is. Let say A visits your site and then leaves the computer (if it’s a public computer) and B uses the same machine to visit your site afterwards, then B will figure as an old visitor in your application. If it’s required to log in at your site on the other hand, then you can have a Boolean value in your database indicating weather a user is new or old.


 - mega
Moving to C# .NET
Reply With Quote
  #9 (permalink)  
Old January 30th, 2005, 06:42 PM
Authorized User
 
Join Date: Aug 2004
Location: Montreal, Qu, Canada.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:)Hi Mega,

Thanks for replying. Actually the users are already registered in the database. In order to make the thing clear, I'll explain a real situation.

As I told you, I'm designing an educational web site where futur students will have to register in order to inscribe for a course.

Now, a registered user when he/she inscribes in one of my virtual classroom, will need to pay for that course. I use PayPal for this.

When a payment notice will be received from PayPal, then I'll have to go on the database and manually check a checkbox in order to activate the course of a student, the next time he/she logs in.

As for now, I must go on my mailbox, retreive the PayPal notices one by one, and activate the course by checking the database for each email address belonging to a registered user who has inscribed itself/herself.

I would like the system to go automatically look in my mailbox, retreive all new PayPal payment notices, and parse them in order to retreive the email address of the user who has made his/her payment and activate the course.

I cannot find a simple way with ASP on how to do that. But I'll find something in between, eventually; and I will follow also your and Imar recommandations. This will surely give me much more knowledge than what I have up to now.

By the way, you mentionned ASP.NET; do you recommand to shift to ASP.NET. I heard that it was completely different than regular ASP.

So many programming languages out there, to confuse people that have no starting knowledge over which one to choose from, once and for all, and for a long time.

Thanks again for your help and recommandations.

:)Sheers

Ramez
Reply With Quote
  #10 (permalink)  
Old January 31st, 2005, 09:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Unfortunately web programming is one of the fastest moving technologies out there. But that doesn't mean that you can choose a language that will be supported in feature technologies. VBScript is not one of them. There is still plenty use for VBScript, but it’s not used in .NET and not by any other company but Microsoft, witch in turns make VBScript obsolete as a web programming language. Your knowledge of VBScript is not of no use because programming languages is so alike (in particular scripting languages like PHP and JavaScript/Jscript).

Back to your problem: Do your ISP have a mail component like AspPOP3http://mavweb.net/asppop3.asp? You can use AspPOP3 to retrieve your emails from a folder on the server – using your script you can set the value in your database (you have to change your PayPal account email address). If you get a thousand hits everyday it seems to me you got a fine trigger. In your global.asa you could use session on end and some business logic that fire your script once a day.
http://www.powerasp.com/content/hint...ule-global.asp
If this is not accurate enough then you can set up your own computer to activate a .vbs file on the server witch contain your script.

 - mega
Moving to C# .NET
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer ( ASP.net) C# aliusmankhan ASP.NET 2.0 Professional 6 July 21st, 2008 11:21 AM
Timer control in asp.net raj2max ASP.NET 1.0 and 1.1 Basics 3 July 18th, 2007 02:13 AM
Timer in ASP.net 1.1 wunnavabk ASP.NET 1.0 and 1.1 Professional 1 May 25th, 2007 02:36 AM
Implement Timer in asp.net Malabika Das ASP.NET 1.0 and 1.1 Professional 2 November 3rd, 2005 12:29 AM



All times are GMT -4. The time now is 07:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.