Home Quick Start Extensibility Download Order

Visual Time Spent Visual Time Spent

Extensibility

Visual Time Spent API

Visual Time Spent provides an API that you can use to programmatically retrieve activity statistic collected by the Visual Time Spent monitoring module. To call Visual Time Spent API functions you need to reference "C:\Program Files (x86)\Visual Time Spent\vtsext.dll" assembly from your .NET 4 application.

Following functions from the VisualTimeSpentExt.Reports class are available:

// Returns activity summary grouped by solution/project/window and sorted by time spent.
static UserActivitySummary UserActivity(System.DateTime from, System.DateTime to)

To run your application that references vtsext.dll, copy to the application directory following files from "C:\Program Files (x86)\Visual Time Spent": sqlceca40.dll, sqlcecompact40.dll, sqlceer40EN.dll, sqlceme40.dll, sqlceqp40.dll, sqlcese40.dll, System.Data.SqlServerCe.dll, vtsext.dll.

UserActivity sample

You can download UserActivity sample C# application that demonstrates use of the Reports.UserActivity function. The sample application calculates report period from the first day of the current month to the current moment, calls the UserActivity function and prints all activity for solutions, projects and windows:
System.DateTime to = System.DateTime.Now;
System.DateTime from = new System.DateTime(to.Year, to.Month, 1);
VisualTimeSpentExt.UserActivitySummary summary = VisualTimeSpentExt.Reports.UserActivity(from, to);
Console.WriteLine("Time spent in Visual Studio for period {0} - {1}: {2}", from, to, summary.TimeSpent);
foreach (VisualTimeSpentExt.SolutionActivitySummary solution in summary.Solutions)
{
    string name = solution.Info != null ? solution.Info.Name : "[No solution]";
    string path = solution.Info != null ? solution.Info.Path : "";
    Console.WriteLine("  Solution {0}: {1} ({2})", name, solution.TimeSpent, path);
    foreach (VisualTimeSpentExt.ProjectActivitySummary project in solution.Projects)
    {
        string projectName = project.Info != null ? project.Info.Name : "[No project]";
        string projectPath = project.Info != null ? project.Info.Path : "";
        Console.WriteLine("    Project {0}: {1} ({2})", projectName, project.TimeSpent, projectPath);
        foreach (VisualTimeSpentExt.WindowActivitySummary window in project.Windows)
        {
            string title = window.Title != null ? window.Title : "[No window]";
            Console.WriteLine("      Window {0}: {1}", title, window.TimeSpent);
        }
    }
}
UserActivity sample report