How to get the statistics of a winform app usage - c#

Say I created a winform app and distributed to anonymous users, and I want to have a way to get the statistics of user opens the app, one way I can think of is opening a webpage (lightweight) on app startup then analyzing how many times the webpage is opened.
Any other ways to get the statistics?

The best way is to use the existing tools out there and implement them in your application for statistical usage and analytics for example as mentioned before: EQATEC.
you also have Preemptive analytics: http://www.preemptive.com/products/runtime-intelligence/overview
This is a most common used tool especially in the whole ALM lifecycle process and how applications and companies progress onwards with minimal effort story.
you also need to know exactly what kind of statistics are you monitoring here? number of times your app is run on a particular version of the software? particular screens being used within your app? memory/CPU usage? etc...
you also have trackerbird:
http://www.trackerbird.com/

There are many ways.
The initial idea of having your application "phone home" to count its usage isn't that bad, but it does not have to be an entire web page.
You could just post some data to a webservice.
If it can't connect to your web service, you could store the information locally and send it next time the app starts with a valid web connection.
If you do this asynchronously, it should be hardly noticeable when you start the app.

You can have your own tracking service, which you can consume every time when application starts. Alternative way you can use any third party application/service which provides this kind of functionality. Telerik eqatec analytics could be one of its kind.

Related

How would I create a long running process in C#?

This may seem very elementary, but I don't really have any experience in this realm - all my experience has been on the web side of things.
I need to create a process of some sort that will repeatedly query an API (around 5 times a second), get the results from the API (in JSON format), and then my process will do what it needs to do with the results (in my case, insert them into a SQL database). These details don't really matter to the scope of the question I have, I just want to give you an idea on what I'm trying to achieve in case someone wants to recommend a better way of doing it.
My first thought was to create a console app that basically never quits (unless I specifically tell it to). Is a console app the way to go for this? The idea is I'll have a VM set up which will host my solution, including this "process" I create. I'm not all too familiar with Windows Services, or Windows Tasks, but I probably need to write some custom code so therefore I imagine I can't use the Windows Task Scheduler, am I right?
Once options would be to create a Windows Service which is the OS-level implementation of a long running process. To do so in C# you may wish to read through some tutorials online, perhaps starting with the MSDN Walkthrough. You should also read about Windows Services in general and the differences between a service and a regular user process (mainly the fact that services have no UI and can't interact with the user directly, and some of the other security considerations).
Other options may be to leverage a framework such as WCF or similar.

Recurring background task in iOS

I would like to make an app that periodically, sporadically and automatically downloads some data from a list of user-defined sites, so it can then analyze and show historical graphs and other reports based on that data.
If I were to do this in Windows, I'd use the system Task Scheduler; if I were in Unix, I'd use cron; if I were in Android I'd use services. I would like to know how to do it in iOS.
As far as my research goes, this is not trivial in iOS, as there is no public interface for doing this. There are however, some workarounds to get this done:
Pull the historical data when the app awakens: Not possible, because I am not the provider of the data, and most of the data providers I will support don't store or offer access to historical data.
Download the data myself and have the clients pull it when awakening: Not desirable. Not only this requires additional costly infrastructure on my side (which would mean charging my users for what I intend to be a free app), but also some of the content providers require login credentials. I'd rather not ask for my users' login information to access information they can get themselves.
Save a timestamp from the last update and download data when the user puts the app in the foreground if the timestamp is expired: This doesn't serve my purposes, because data may (and is expected to) rapidly change in time. The entire purpose of this app is to automatically download this data periodically so all the historical data is available once the user opens the app again.
Use local notifications: It's pretty much the same as before. It requires user interaction to start the app, and the entire point of the app is to get this data even when the user is not using the device.
Use push notifications: Since these are just notifications that require user interaction to awaken the app, they can't be used for the same reason as local notifications. It seems you can process all pending push notifications once the app awakens, but I read you can't define custom fields for these notifications though.
Use background tasks: This technically seems the most promising of all options, but this is only available for very specific types of apps. I guess that a "Newsstand app" is the closest I can get, and it is actually meant to download data in the background. However, as it is named, it is meant for downloading "magazine or newspaper issues". Whether what I want to do can be classified as this is completely up to the app reviewer, and I'd rather not make an app that may get rejected on a technicality.
So, my question is: are there any other ways to do this that I am not aware of? Are there any apps that already do something similar?
Your assessment is correct. Your only 2 options are to host your own service that periodically downloads the data (your second bullet point) or use Newstand. For Newstand, it's possible that your app could fit the definition; it may just depend on how you characterize the app.
Your only choice in iOS really is to go with server-side infrastructure. Don't be afraid of charging the user; if the service you're providing is really useful, people will pay. I do get that it's a lot of extra work, etc, but it really is the only way.
Newsstand apps can only download data once a day, and they still require s server-side push notification to start the download, so you would have to put some infrastructure in place. More importantly, though, Apple is actually quite strict about being in the newsstand; I've been thru this a few times: you don't necessarily have to be a magazine/periodical, but your app should be primarily used for content distribution.
I think you have one further option, location based updates, but this depends on your users moving around regularly.
See e.g. http://blog.instapaper.com/post/24293729146 and http://blog.news.me/post/21643399885/introducing-paper-boy-automatically-download-your-news

running timer from global.asax vs quartz.net

I am developing a asp.net site that needs hit a few social media sites daily for blanket friend/follower data. I have chosen arvixe business class as my hosting. In the future if we grow, I'd love to get onto a dedicated server and run a windows service, however since that is not in the cards at this point I need another reliable way of running scheduled tasks. I am familiar with running a thread timer from the app_code(global.aspx). However the app pool recycling will cause some problems with the timer. I have never used task scheduling like quartz but have read a lot about it on stackoverflow. I was looking for some advise as to how to approach my goal. One big problem I have using either method is that I will need the crawler threads to sleep for up to an hour regularly due to api call limits. My first thoughts were to use the db to save the starting and ending of a job. When the app pool recycles I would clear out any parts not completed and only start parts that do not have a record of running on that day. What do the experts here think? any good links to sample architecture of this type of scheduling?
It doesn't really matter what method you use, whether you roll your own or use Quartz. You are at the mercy of ASP.NET/IIS because that's where you want to host it.
Do you have a spare computer laying around that can just run a scheduled task and upload data to a hosted database? To be honest, it's possibly safer (depending on your use case) to just do it that way then try to run a scheduler in ASP.NET.
Somewhat along the lines of Bryan's post;
Find a spare computer.
Instead of allowing DB access have it call up a web service on your site. This service call should be the initiator of the process you are trying to do. Don't try to put params into it, just something like "StartProcess()" should work fine.
As far as going to sleep and resuming later take a look at Workflow Foundation. There are some nice built in features to persist state.
Don't expose your DB to the outside world, instead expose that page or web service and wraps some security around that. WCF has some nice built in security features for that.
The best part is when you decide to move off, you can keep your web service and have it called from a Windows Service in the same manner.
As long as you use a persistent job store (like a database) and you write and schedule your jobs so that they can handle things like being killed half way through, having IIS recycle your process is not that big a deal.
The bigger issue is that IIS shuts your site down if it doesn't have traffic. If you can keep your site up, then just make sure you set the misfire policy appropriately and that your jobs store any state data needed to pick up where they left off, you should be able to pull it off.
If you are language-agnostic and don't mind writing your "job-activation-script" in your favourite, Linux-supported language...
One solution that has worked very well for me is:
Getting relatively cheap, stable Linux hosting(from reputable
companies),
Creating a WCF service on your .Net hosted platform that will contain the logic you want to run regularly (RESTfully or SOAP or XMLRPC... whichever suits you),
Handling the calls through your Linux hosted cron jobs, written in your language of choice(I use PHP).
Working very well, like I said. No VPS expense,configurable and externally activated. I have one central place where my jobs are activated, with 99 to 100% uptime(never had any failures).

WCF service health monitoring

I just implemented a WCF service and I am currently looking at service monitoring options. Our server team that currently hosts only java services wants us to have instances running all the time, so it can gather data in that instance during its lifetime and they said they will use one of our operations with webmon to get statistical information. But we are using per call and I dont think that will work under this architecture.
I am wondering if there is a way to get the statistics of how an operation in the service did in certain amount of time and provide an another operation for webmon to use that gives an integer value about its performace in certain time period, webmon, then decides weather to alert the admin or not.
I was considering parsing of log files to get statistics but that might be an expensive operation if done every 15 mins.
If not what are my options for detailed automatic health monitoring of wcf applications?
My company very recently agreed to open-source (under the GPL License) the tool that we use internally to monitor our live web services and for producing availability and response time reports. It's called ServiceMon and it may meet your needs.
It runs on Windows as a standalone application and works by following a simple script of operations that dictate the services to be monitored. For example, to check a web page contains a particular value, in a similar manner to webmon, you'd use this line:
http-get "http://www.google.com" must-contain "I'm Feeling Lucky"
The frequency at which it executes the script operations can be easily configured as can the order which it processes them.
In addition to monitoring web pages and web services we use ServiceMon to track availability statistics of each service and to produce response time statistics.
ServiceMon is written using a plugin architecture so you can use .NET to add new types of monitoring operations. So, for example, if your web service uses funky authentication you can fairly easily plug this in to the utility.
Full documentation and download instructions here
I hope you find it useful and I'd love to hear your thoughts
Disclaimer: I developed ServiceMon so I may be a little bit biased :)

Determining programmatically whether an ASP.NET/C# Website is down

I am having an ASP.NET/C# Web application hosted in IIS6. My requirement is to send a mail whenever the Website is down without using any third party tool. How can I accomplish this job programmatically (of course using C#)? Thanks in advance!!!!!
You will need a PC that is as independent as possible form the WebServer. Ideally on the other side of the world.
Then run a little program with a Timer and check every X minutes. Do a simple grab with WebClient. If it fails, send the mail.
For improved reliability, run more instances of the monitoring program at different locations.
Define "down". There are many reasons why a website might not be accessible or only partially working. Ultimately, it's really what the end user is seeing that's most important. A tool that is running outside of the website's network infrastructure that periodically queries the website's key pages and checks important factors such as the HTTP status code, the response time, the size of the page and even possibly checks that important chunks of HTML are present would achieve this.
Attempting to determine why the site is not responsing is an even more complex task that would involve checking for the presence of the IIS application pool, etc.
This is not a trivial tool to create so I would recommend using an off-the shelf solution if possible.

Categories