使用VSTO把Groove和Outlook的约会进行同步(转)

本文介绍如何使用VSTO和Groove SDK实现Outlook与Groove之间的日程同步功能。通过创建一个示例应用程序,展示了如何从Outlook导入和导出日程到Groove,并提供了一个用于选择日程的界面。
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.

image%7B0%7D.png

image%7B0%7D%5B2%5D.png

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.

image%7B0%7D%5B4%5D.png

Click Import to import the Groove appointment into outlook.

Here is the Groove appointment

image%7B0%7D%5B6%5D.png

Now imported into Outlook.

image%7B0%7D%5B8%5D.png

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.

转载于:https://www.cnblogs.com/redmoon/archive/2007/07/20/825275.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值