Sync Outlook Appointments with Groove using VSTO

Both Outlook and Groove contain calendars so which one do you use? Each one has its own strengths but it would be cool to be able to sync your appointments. I have created a small sample using VSTO and the Groove SDK that will allow you to import and export appointments from Outlook to Groove. I started in my last post, Groove'n with VSTO, where I showed you how to connect to Groove using webservices.  Now I will continue with the sample application and add support for importing Calendar items.

First I created a Ribbon for the Appointment inspector that allows you to choose the account and workspace you want to pull the calendar from.

Most of this code for the above screens was in the last post so I wont' go over it again, although I did refactor it quite a bit as I went along. The next this is to click "Add from Groove" to select an appointment to import.

I created the calendar picker to let you select the day with appointments, in bold, and then the entry for that day.

Click Import to import the Groove appointment into outlook.

Here is the Groove appointment

Now imported into Outlook.

After you get a reference to the Groove workspace you can interate through the tools until you find the calendar tools.

 

         public static List<GrooveTools.Tool> Tools(GrooveSpaces.Space workspace)
        {
            GrooveTools.GrooveTools tools = new GrooveServices.GrooveTools.GrooveTools();
            tools.GrooveRequestHeaderValue = new GrooveServices.GrooveTools.GrooveRequestHeader();

            tools.GrooveRequestHeaderValue.GrooveIdentityURL = workspace.IdentityURL;
            tools.GrooveRequestHeaderValue.GrooveRequestKey = RequestKey;
            tools.Url = HostPortAddress + workspace.Tools;

            List<GrooveTools.Tool> toolsList = new List<GrooveServices.GrooveTools.Tool>();
            toolsList.AddRange(tools.Read());

            return toolsList;
        }
         public static List<GrooveCalendar.GrooveCalendar> Calendars(GrooveSpaces.Space workspace)
        {
            List<GrooveCalendar.GrooveCalendar> calendars = new List<GrooveCalendar.GrooveCalendar>();
            string calendarType = "urn:groove.net:platform.tools.Calendar";

            foreach (GrooveTools.Tool tool in Tools(workspace))
            {
                if (tool.Type == calendarType)
                {
                    GrooveCalendar.GrooveCalendar calendar = new GrooveServices.GrooveCalendar.GrooveCalendar();
                    calendar.GrooveRequestHeaderValue = new GrooveServices.GrooveCalendar.GrooveRequestHeader();

                    calendar.GrooveRequestHeaderValue.GrooveIdentityURL = workspace.IdentityURL;
                    calendar.GrooveRequestHeaderValue.GrooveRequestKey = RequestKey;
                    calendar.Url = HostPortAddress + tool.Data;

                    calendars.Add(calendar);
                }
            }

            return calendars;
        }

Now I just show the calendar picker and populate the outlook appointment. One thing I don't deal with yet in this sample is the fact that you could have mulitple calendar tools in a workspace. But it should be easy enough to just add another drop down to let the user pick the calendar.

            //Show the Calendar entries
            foreach (GrooveServices.GrooveCalendar.GrooveCalendar calendar in
                GrooveServices.GrooveHelper.Calendars(workspace))
            {
                GrooveCalendarPicker gcp = new GrooveCalendarPicker(calendar);
                gcp.ShowDialog();

                if (gcp.calendarEntriesListBox.SelectedIndex >= 0)
                {
                    GrooveServices.GrooveCalendar.CalendarEntry calEntry =
                        (GrooveServices.GrooveCalendar.CalendarEntry)gcp.calendarEntriesListBox.SelectedItem;

                    appointment.Subject = calEntry.Description;
                    appointment.Start = calEntry.Start;
                    appointment.End = calEntry.End;
                    appointment.Body = calEntry.Details;
                    appointment.AllDayEvent = calEntry.AllDay;
                }
            }

In the next post I hope to show you how to export your Outlook appointment to Groove.

Also Abbott who is the product manager for Groove pointed out that much of the helper code that I am writing in part of Groove Helpers. This is really cool, once I get down exploring the hard way I would like to go back and port my code to the Groove Helper.

If your at TechEd 2007 in Orlando next week, stop by the VSTO booth and talk to me about the code in detail.