Results 1 to 10 of 10

Thread: Count People that they currently use my application ?

  1. #1

    Thread Starter
    Lively Member JadaDev's Avatar
    Join Date
    Apr 2018
    Posts
    82

    Exclamation Count People that they currently use my application ?

    Hello everyone well i was really interested in this question long time ago but didn't want to bother anyone with it but now i feel it's the correct time to ask.

    Anyways as title says i want to count how many people are currently using my application and also how many people have it ( first opened ) ( something like total downloads but only when they open it ) and total opens.

    So i was wondering how this could even happen ? I'm not sure ...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Count People that they currently use my application ?

    You would need your application to contact a server when it starts up and when it exits. Exactly how you do that is up to you. A web service seems the most likely option.

    Assuming a Windows Forms app, here's the sort of thing I would do in that case:
    vb.net Code:
    1. Imports Microsoft.VisualBasic.ApplicationServices
    2.  
    3. Namespace My
    4.     ' The following events are available for MyApplication:
    5.     ' Startup: Raised when the application starts, before the startup form is created.
    6.     ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    7.     ' UnhandledException: Raised if the application encounters an unhandled exception.
    8.     ' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
    9.     ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    10.     Partial Friend Class MyApplication
    11.  
    12.         Private Sub MyApplication_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup
    13.             'Contact server to add new session here.
    14.  
    15.             If My.Settings.IsFirstRun Then
    16.                 'Contact server to add new download here.
    17.  
    18.                 My.Settings.IsFirstRun = False
    19.             End If
    20.         End Sub
    21.  
    22.         Private Sub MyApplication_Shutdown(sender As Object, e As EventArgs) Handles Me.Shutdown
    23.             'Contact server to remove ended session here.
    24.         End Sub
    25.  
    26.     End Class
    27. End Namespace

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Count People that they currently use my application ?

    @jmcilhinney

    How can My.Settings.IsFirstRun be anything other than indeterminate on first run of the application? You can't distribute an application with intact My.Settimgs values

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Count People that they currently use my application ?

    Quote Originally Posted by .paul. View Post
    You can't distribute an application with intact My.Settimgs values
    Of course you can. They are stored in the config file. Application-scoped settings are stored solely in the main config file and are read-only while User-scoped settings have their default value stored in the main config file and their current value stored in the user config file. Whatever value you set for IsFirstRun on the Settings page of the project properties is the value that will be stored in the main config file.

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Count People that they currently use my application ?

    Quote Originally Posted by jmcilhinney View Post
    Of course you can. They are stored in the config file. Application-scoped settings are stored solely in the main config file and are read-only while User-scoped settings have their default value stored in the main config file and their current value stored in the user config file. Whatever value you set for IsFirstRun on the Settings page of the project properties is the value that will be stored in the main config file.
    That requires distributing the config file with the executable. I don't think you should've omitted that information...

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Count People that they currently use my application ?

    Quote Originally Posted by .paul. View Post
    I don't think you should've omitted that information...
    I don't think I should have to explain the basics of programming every time I post. Deploying an executable's dependencies with that executable is not something I feel the need to explain every time I post something about application settings.

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Count People that they currently use my application ?

    I'd use a php script to record activity information, then to run your online php script...

    Code:
    Dim request As HttpWebRequest = DirectCast(HttpWebRequest.Create(New Uri("http://www.yoursite.com/records.php?app=yourAppName")), HttpWebRequest)
    request.Method = WebRequestMethods.Http.Get
    Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    ' process response here
    response.Close()

  8. #8
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,757

    Re: Count People that they currently use my application ?

    Writing the new user on app start is certainly necessary, but writing the user exit when the app shuts down is probably not good enough. If your app terminates abnormally (from the task manager for example), you would never write the user exit.

    To be thorough, you would need to run a script on the server from cron for linux server or the Microsoft equivalent (task scheduler?). The script would run on a timer and it would check to see if users are to old, and if so, then they would be deleted. Your app would then constantly be trying to add the user to the data table using INSERT IGNORE for a MySQL server or INSERT INTO...WHERE NOT EXISTS for SQL. You would also want the app to post at a rate much faster the the cron job runs for it to be effective.
    Last edited by kebo; Jun 24th, 2018 at 07:59 AM.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  9. #9
    Lively Member
    Join Date
    Feb 2012
    Posts
    72

    Re: Count People that they currently use my application ?

    I'm not sure if I've picked this up correctly but you could could just store values in a database.
    as jmcilhinney said, check to see if application is FirstRun, if it is, then get "Downloads" value from DB and +1 to it, while the application is running add a +1 to the value of "RunningApp" in the DB and on close -1 from the value. that should give you numbers of running apps and downloaded apps

    I'm not entirely sure if this would be the most efficient but it should work, please correct me if i am incorrect.

    Luke

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Count People that they currently use my application ?

    Quote Originally Posted by Weeluke View Post
    I'm not sure if I've picked this up correctly but you could could just store values in a database.
    as jmcilhinney said, check to see if application is FirstRun, if it is, then get "Downloads" value from DB and +1 to it, while the application is running add a +1 to the value of "RunningApp" in the DB and on close -1 from the value. that should give you numbers of running apps and downloaded apps

    I'm not entirely sure if this would be the most efficient but it should work, please correct me if i am incorrect.

    Luke
    That's certainly what you would do but the thing is that you need a central database to store that information, so how does the client connect. The answers provided so far have really been about what happens at the client end, rather than at the server.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width