[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Hit Counter For Client Application

Posted on 2006-04-18
23
Medium Priority
?
245 Views
Last Modified: 2013-12-18
Hola Experts,

I have researched the site and found a few good examples for a hit counter on DOCUMENTS, I'd like to keep track of when the db is opened for viewing, The DB opens to a frameset with 2 frames one frame contains a page with the menu the other frame a view, is there anyway I can put a counter on the menu that will increment everytime a person opens the db. This is a read only DB, users CANNOT make any changes to documents it is fed via an agent from another DB. The requirement is to have a "web" type counter displaying the number of times the db has been read. Can this be done?
0
Comment
Question by:padillrr
  • 11
  • 10
  • 2
23 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16478408
This requires more than you think... Do users log in into the server? If you have anonymous access things are more difficult: you'd have only IP-address to tell you the "user", and there can be more than one user with the same IP-address! Furthermore, there is no such thing as an "open" from a browser. The user just throws a URL to the server and the server responds. With clever means like Java you might be able to maintain some session, the Domino server might even have the info for you (if you enabled session-based login) but it's still not easy.

The best you can do is make a small page that is only displayed on the very first page that appears when the user opens the database. Just like the About this database page. In that page, the usual way is to have some image opened by a URL that is no image at all; e.g.
    <img height=0 width=0 border=0 src="http: // www.domain.com/db.nsf/countagent?openagent">
and you make sure the agent does a
    Print "[/icons/ecblank.gif]"
at the end.
0
 

Author Comment

by:padillrr
ID: 16478512
Users do Log on to the server and the application is strictly client based. So ther eis no way to track when the db is opened? even if we don't display the count on the page? I just need to keep a running tally of how often the app is used, we are trying to get rid of some applications and this would be our method of deterining if the applications are being used. So eventually I would use this on all our apps.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16478722
This is Notes client only?? Then you might be able to do it from the database's PostOpen event. See the Designer, under Other, Database Resources.

On the other hand, you don't need this at all. Check your server and look for a database called catalog.nsf. The view Database/By Title contains a document per database. Open a document and look at the last paragraph, Database Activity. Would that do it for you??
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:padillrr
ID: 16479003
That looks like the information we're looking for, is there any way to extract that and put it on my application?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16479836
You need it in your application? What do you need then?

The standard views in the Catalog do not contain all databases. If you want to do this without applying changes to the Catalog, you need the replica-id from the current database and use that as an index in the ($ReplicaID) view in the catalog. Otherwise, you have to add a (hidden) view with all database documents.

Check the fields in a database document, to find out which fields you need. Or open catalog.ntf in the Designer.
0
 
LVL 14

Expert Comment

by:cezarF
ID: 16484415
this might help http:Q_21701916.html
0
 

Author Comment

by:padillrr
ID: 16487564
Cezar that increments daily I need to increment every time somebody opens the db and reads a doc.......
0
 
LVL 14

Expert Comment

by:cezarF
ID: 16494092
that was just to give you an idea how to implement a counter. if you need to increment it when a document is read, create a procedure in a script library (that increments the counter) and call it on PostOpen event of all your forms.

this approach is prone to "save conflict documents". i would suggest an enhencement to it

1. retain the document that stores the count (call it countDoc)
2. create a dummy document everytime you want to increment the counter
3. count all the dummy documents and add the total to the count stored in the countDoc

daily maintenance:
1. count all the dummy documents and add the total to the count stored in the countDoc
2. update the count stored in the countDoc
3. delete all the dummy documents.

of course it is still best if you can get the info from the catalog.nsf as suggested by sjef_bosman as long as it is updated everytime you need the info.

hope this helps.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16495841
Just make sure the Catalog process is mentioned in notes.ini to run every night. Info will then be no more than 24 hours old.
0
 

Author Comment

by:padillrr
ID: 16500683
Hey Guys, I now have designer access to Catalog.nsf I see the form and field that the data is coming from, how would I incorporate that into my application?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16502844
Great! Now what do you need INSIDE your application? Wouldn't it be possible for your applicxation just to open Catalog.nsf and walk though all database documents? Or grab a particular database and deal with that? What do you want to record?
0
 

Author Comment

by:padillrr
ID: 16510538
I'd like to grab the Number of uses in previous 24 hours line and put it in the menu like a hit counter just the number would be fine
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16523176
If you want a hit counter for a database, maybe this is what you need:
    http://www-10.lotus.com/ldd/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/c12a2fd2142758b68525688d00708397?OpenDocument

It is not exactly a hit counter, but who cares, and who will know?
0
 

Author Comment

by:padillrr
ID: 16588169
can there not be a script put into the database script that would increment a counter once the database is opened? This is under other in the resoruces....
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16591070
Yes you can, using a profile document, with code in the PostOpen like this:

    Dim ns As New NotesSession
    Dim doc As NotesDocument
    Dim db As NotesDatabase
    Dim opens As Long    

    Set db= ns.CurrentDatabase
    Set doc= db.GetProfileDocument("DbCounter")
    opens= 1
    If doc.HasItem("Opens") Then
        opens= doc.Opens(0) + 1
    End If
    Call doc.Save(True, False)
0
 

Author Comment

by:padillrr
ID: 16596125
Can you help me ou twith the profile document, Iv'e never worked with one. This is what I've done so far:

I created a form unchecked Include in Menu

Added a field Opens

How do I access the data? and what makes it a profile doc?
0
 

Author Comment

by:padillrr
ID: 16596368
I am assuming you mean the PostOpen of the Database script, correct? I have added this formula to the field on another form called Hit Counter which I will use to display the number of hits:

@GetProfileField("DBCounter";
"opens")

This is a computed for display field. I am not getting any values, what am I missing here?
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 600 total points
ID: 16596574
You don't have to make a form for it, but if you want to, you can. The call to GetProfileField will create a profile document if one doesn't already exist with the name mentioned in the first parameter.

Strange you don't get a value. It might need an additional @Text() around it, for the value Opens is a number and not a string. Ah, now I see, me very bad! Classic mistake...

    Dim ns As New NotesSession
    Dim doc As NotesDocument
    Dim db As NotesDatabase
    Dim opens As Long    

    Set db= ns.CurrentDatabase
    Set doc= db.GetProfileDocument("DbCounter")
    opens= 1
    If doc.HasItem("Opens") Then
        opens= doc.Opens(0) + 1
    End If
    Call doc.ReplaceItemValue("Opens", opens)
    Call doc.Save(True, False)


0
 

Author Comment

by:padillrr
ID: 16596759
OK here's where I'm at:

1. Added script to postopen on resources->other->Database Resources ->Database Script

2. Created a Form with a field computed for display using the formula: (This is not a profile document)
@GetProfileField("DBCounter";
@Text("Opens"))

Would this then display the incrementing of the number of times the DB is open?
Even after I changed the script it is still not displaying any number.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16596890
You have to completely close the database to trigger PostOpen on the next open, so both in Notes AND in the Designer!
0
 

Author Comment

by:padillrr
ID: 16597345
That worked Perfectly! Thanks Sjef! I had to close notes and the designer but it looks great!!! any way I can add a few zeros to the beginging ofthe numbering?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16597700
Suppose so. In Formula language, look at @Text() in the Help db; in LotusScript you can use Format(value, "0000"). In Formula, I tend to use code like
    nt:= @Text(number);
    @If(@Length(nt)>=4; nt; @Right("000" + nt; 4)
0
 

Author Comment

by:padillrr
ID: 16597761
cool thanks!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question