Hit Counter For Client Application

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?
padillrrIT DirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
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
padillrrIT  DirectorAuthor Commented:
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
Sjef BosmanGroupware ConsultantCommented:
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

padillrrIT  DirectorAuthor Commented:
That looks like the information we're looking for, is there any way to extract that and put it on my application?
0
Sjef BosmanGroupware ConsultantCommented:
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
cezarFCommented:
this might help http:Q_21701916.html
0
padillrrIT  DirectorAuthor Commented:
Cezar that increments daily I need to increment every time somebody opens the db and reads a doc.......
0
cezarFCommented:
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
Sjef BosmanGroupware ConsultantCommented:
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
padillrrIT  DirectorAuthor Commented:
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
Sjef BosmanGroupware ConsultantCommented:
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
padillrrIT  DirectorAuthor Commented:
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
Sjef BosmanGroupware ConsultantCommented:
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
padillrrIT  DirectorAuthor Commented:
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
Sjef BosmanGroupware ConsultantCommented:
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
padillrrIT  DirectorAuthor Commented:
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
padillrrIT  DirectorAuthor Commented:
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
Sjef BosmanGroupware ConsultantCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
padillrrIT  DirectorAuthor Commented:
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
Sjef BosmanGroupware ConsultantCommented:
You have to completely close the database to trigger PostOpen on the next open, so both in Notes AND in the Designer!
0
padillrrIT  DirectorAuthor Commented:
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
Sjef BosmanGroupware ConsultantCommented:
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
padillrrIT  DirectorAuthor Commented:
cool thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.