Archive

Author Archive

VB.net Add Calendar Entry Google API

April 11, 2012 Leave a comment

Adding a new calendar event to Google Calendar via the API is easier than I thought. Only a few lines of code to get a new calendar event setup and added. I did not do this with the “quick add” method, but that one looks even easier.

At the top:

Imports Google.GData.Calendar
Imports Google.GData.Extensions
Imports Google.GData.Client

I have this bit -o- code in a sub, called from a button click on my test app:

Dim newEvent As New EventEntry
Dim newatom As AtomEntry

Dim serv As New Google.GData.Calendar.CalendarService("GCal")
serv.setUserCredentials("you@email.com", "yourGPWD")
newEvent.Title.Text = "New Event Title"
newEvent.Content.Content = "This is the event description"
Dim newTime As New [When]()
newTime.StartTime = Convert.ToDateTime(DTSTB.text) 'getting date/time from textbox for testing
newTime.EndTime = DateAdd(DateInterval.Hour, 1, Convert.ToDateTime(TextBox3.Text)) 'add 1 hour for end
newEvent.Times.Add(newTime)

Dim uri As New Uri("https://www.google.com/calendar/feeds/default/private/full")
newatom = serv.Insert(uri, newEvent)

The “newatom” object as an Atomentry contains all of the details of the newly created event. I have to dig some more to find a good method for determining if the event was created correctly or not. Right now I’m looking at the URI for the event, making the assumption that if I get a URI back, the event was created properly.

Advertisements

Google Calendar API in VB.net (VS 2008) – Display Calendar Events

April 6, 2012 2 comments

I poked around the web for some samples on integrating Google Calendar into a VB.net app but didn’t find much more than bits n pieces. So I’ve started writing my own.
To start, all I wanted to do was extract calendar events for a given date range. I then take the title, startTime, endTime and ‘description’ and plop em into a listbox.

The first thing to do is make sure you have the Google API installed.

Then in your Studio project, add three references:

  • Google Data API Calendar
  • Google Data API Core
  • Google Data API Extensions

Now at the top of your code:

Imports Google.GData.Calendar
Imports Google.GData.Extensions
Imports Google.GData.Client

Now you can begin building the connection to Google. I have this setup in a sub right now but you could put it in the Form_load event:
Dim srvce As New Google.GData.Calendar.CalendarService("GCal")
Dim query As New FeedQuery
Dim entr As EventEntry
query.Uri = New Uri("http://www.google.com/calendar/feeds/YOURGOOGLE CAL ACCOUNT/private/full")
query.StartDate = "4/5/2012 8:00"      'optional but recommended so you don't get every single event, ever
query.EndDate = "4/5/2012 22:00"      'optional
query.ExtraParameters = "orderby=starttime&sortorder=ascending"   'optional but nice to have the events in order by date/time

Make sure you use your Google Calendar account’s email and password:

srvce.setUserCredentials("YOUR EMAIL","YOUR GOOGLE Cal PWD")
dim calfeed as atomfeed
calfeed = srvce.Query(query)
for each entr in calfeed.Entries

'  entr.Title.Text  has the title of the calendar event
' entr.Times.item(0).StartTime has the starting time of the event
'  entr.times.item(0).EndTime has the ending time of the event
' entr.Content.Content.ToString has the long description of the event
next

That’s all there really is to it. As I get a sample written for creating a new Event on a Calendar, I will post it. What I am currently doing is populating a gridview control that shows 8am to 10pm in one hour blocks. This will be used for scheduling Project Rooms. In the gridview, if you double click an open time slot, you are prompted if you would like to make a reservation.

Categories: VB.net Tags: , , ,

VMware View Usage Dashboard

October 4, 2011 1 comment

I’ve had the new version of my app running for a few months. This has given me quite a bit of raw data, but no really nice method for perusing it (aside from just raw SQL on the DB).

So I took some time yesterday to write a sort of dashboard based on the data I’ve collected and based on questions I get from the “higher-ups.”

This is version number 1. The dashboard is web-based using a combination of whatever I felt like writing at the time, some .NET, some classic ASP, javascript and AJAX. All of the graphs/charts on the page are from Google charts.

The top of the page shows current usage in each of my three pools. The gauge is scaled for the number of machines in the pool: pool 1 has 20 machines, pools 2 and 3 each have 100. The CPU utilization is averaged across all users as the percent reported by Windows itself (like you would see in Task Manager).

Next to those is a term cloud that shows the top 10 currently running apps in the pools. As a cloud it means that the more instances there are of a given app, the larger the font in respect to the other apps listed.

The Start and Stop buttons control the AJAX that refreshes the gauges and term cloud on a specific interval.

Under that is a graph that shows logins and average CPU for the month of September. This one is just looking at one specific pool right now (Pool 2 from the gauges). And below that are two pie charts that show top apps for the month by frequency and time-in-use.

I think I will continue to tweak this based on what I’d like to see along with any other requests I get from ‘higher up.’

Comments appreciated

Desktop Usage Stats

June 15, 2011 Leave a comment

I’ve completely re-written my application to gather more data on usage. Now I have access to real-time data on which apps users are running along with CPU utilization. Kind of interesting to see the numbers emerging from the data.

As an example, top apps are Internet Explorer, Word, Firefox then trailing quite a bit behind Excel (Access was 6th, Visual Studio was 9th). One of the surprising things that came up is idle time. Seeing scrnsave.scr show up in the list of applications started me looking at how often the machines are sitting ‘idle’ as evidenced by scrnsave.scr showing up in the application list. A quick bit of ts-sql showed that for about 11% of the logged-in time, scrnsave.scr was active. I need to let the new version run a bit longer to get a better idea what the average CPU utilization is.

Categories: Usage Stats, View, Vmware

VMware View usage statistics re-visited

June 1, 2011 Leave a comment

well, that didn’t take long. I’ve re-written my program that collects usage statistics on my view pools (any physical machines too.)  First thing I did was to generalize the program a little and set it up for command-line options. I can over-ride the default database and catalog settings on the command line if I wish (it currently uses a DSN-less connection to MSSQL server).

I setup a command line switch for data collection level. I can then set level equal to 1,2 or 3. At 1, the program will only record login, logout and View Broker URL, View Client IP and Client OS type. Level 2 is level 1 and the list of applications the user opened. Level 3 is level 2 along with average CPU utilization as a percent and eventually average memory used.

The View information comes out of the Volatile Environment reg key. This will be used to differentiate users connecting from on- or off-site. The CPU comes from System.Diagnostics.PerformanceCounters. CPU is accumulated every 3 seconds and then at logout or shutdown the CPU accumulator is divided by logged-in time/3. I’m not sure on how frequently to sample CPU at this point. I will probably set it up as another command-line switch to change frequency so I can do some testing to see what the best sample rate is. The minimum is 1 second per msdn, but that seems excessive. Average logged-in time for my users is 55 minutes which would be 3,300 samples. One of the things I don’t want to have happen is that my app skews any of the data collected, at least not skew it too badly.

so, as it stands I can run the program from an AD GPO and use command-line switches to control the functionality. It would look something like:  datacol.exe -ds=mySQLserver -ic=mylabs -L=3

The exe is 24k for the release build and on my win7 test pool seems to start somewhere around 20meg of ram used. Over time this creeps up to about 30meg but then drops back down to 27.

I also have the program set to minimize to the system tray, ignore mouse clicks and not allow the user to terminate it. Almost seems like it’s getting to the point where it might make more sense to re-write as a service instead.

Comments/suggestions appreciated.

Categories: View, Vmware

VMware View Usage statistics

May 31, 2011 2 comments

My boss kept asking me for usage stats for our View installation. I looked at Stratusphere UX, which looks to be a great product, but at  $15,600 for 400 licenses, is out of our budget at this time. What to do, what to do?  Write my own, of course!

While I’m not saying that my homegrown app will come close to the functionality of Stratusphere, it does a decent job of tracking usage and see what apps are used and for how long. One other tidbit that comes up from the data is a list of applications that users leave open when they logoff or disconnect.

It is written in visual studio 2008 .net and uses Process.GetProcesses to enumerate any process that has a title set. This is stored in an array and a timer then checks every so often to see if the process is still running. If not, the stop time is recorded in the array. Once the user logsout, the app then calls some stored procs on a database server to dump all of the data.

The data has the machine name, userid of the person, date/time stamp for login, date/time stamp for logout, then in a different table it has all of the applications that the user ran along with date/time stamp for start and stop of the app.

With this data I can then use excel to analyze what’s going on, how long users are staying connected (55 mins on average) which applications they are running and for how long (IE, then excel then word are the most used). Then based on login/logout DTS I can plot usage by day and time. So in the graph you can see that usage ramps up just after 8 am and then winds down again just afer 8 pm. Not the best program I’ve ever written but it sure has been handy to show the higher-ups some graphs and pictures to help justify View. Having the data for application usage helps too in that we can better leverage licensing (I know that SPSS was only used 20 times during the data gathering period and can track it back to specific users) NOTE: this was run on one small pool, hence the max concurrent of just over 100 users

While not a direct relacement for something like Stratusphere, I think that others can use in-house developed apps to get much of the same data in their own environments.

Up next: I will be re-writing the app to include connection broker URL, client IP and OS to help differentiate locally connected users and those connecting through a security gateway from off-site

Categories: View, Vmware

VMware View 4.5 real-time usage statistics pt2

January 5, 2011 Leave a comment

I have redone my trigger for pool-based usage stats. In looking through the event log table I found that there was not always an AGENT_DISCONNECTED record for all user logoff events. I don’t know if it is dependent upon whether the user logs off or just disconnects or what, but it seems like there are always BROKER_DESKTOP_REQUEST and AGENT_ENDED both of which contain the pool in a field called DESKTOPID.

So now I am basing my logic on those two types. If I get BROKER_DESKTOP_REQUESTED, I then get the count from the table based on that pool, then increment it. Same goes for the AGENT_ENDED event, I get the count from a table (which is pre-populated with pool names of course) and then decrement the count. Works great so far, but my users are not back in full swing yet so we’ll see how things go when there’s some real load on the View infrastructure.

So, to recap it looks like a View client login/logout shows up in the event table as follows:

  1. BROKER_USERLOGGEDIN
  2. BROKER_DESKTOP_REQUEST
  3. BROKER_MACHINE_ALLOCATED
  4. AGENT_PENDING
  5. AGENT_CONNECTED
  6. BROKER_VC_ENABLED
  7. BROKER_USERLOGGEDOUT
  8. AGENT_ENDED
  9. AGENT_SHUTDOWN

This is on a floating pool with View Composer set to refresh the machine at logoff. I guess now only time will tell how well this works. The database server shouldn’t have a problem with the extra bit of load from the trigger.. I’m sure I’ll find out soon enough if it doesn’t work. Everyone knows where my office is 😉

Categories: View, Vmware