本文介绍了如何在活动连接Outlook日历上将活动写入特定日历?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在探索Live Connect SDK。



我可以创建日历和阅读事件,甚至使用 Microsoft创建新的事件。 图书馆



创建日历后,说 [编程日历] 写一个事件。



但是,我的所有尝试都没有将事件链接到新创建的日历,即 [编程日历] code>。



所以我正在阅读SDK文档,并找到以下内容:

M y代码创建是:

 私有异步任务editEvent()
{
if(!connected)
{
try
{
var authClient = new LiveAuthClient();
LiveLoginResult result = await authClient.LoginAsync(new string [] {wl.signin,wl.calendars,wl.calendars_update});
//\"wl.skydrive,wl.skydrive_update,
if(result.Status == LiveConnectSessionStatus.Connected)
{
var eventToPost = new Dictionary< string,object> ();
eventToPost.Add(name,my new event);

eventToPost.Add(calendar_id,calendar.136c10ca65544801.99c35f9a9fb341a3af35daa82f4569f8);

eventToPost.Add(description,这应该是第二个日历);
eventToPost.Add(start_time,2014-09-10T01:30:00-08:00);
eventToPost.Add(end_time,2014-09-12T03:00:00-08:00);
eventToPost.Add(location,business placeeeeeee);
eventToPost.Add(is_all_day_event,false);
eventToPost.Add(可用性,繁忙);
eventToPost.Add(visibility,public);

this.session = result.Session;
connected = true;
this.connectClient = new LiveConnectClient(result.Session);
var meResult = await connectClient.PostAsync(me / events,eventToPost);

meData = meResult.Result;

}
}
catch(LiveAuthException ex)
{
infoTextBlock.Text + = ex.Data +.autexception ..+ ex。信息;
//显示错误消息。
}
catch(LiveConnectException ex)
{
infoTextBlock.Text + = ex.Data +.conExcception ..+ ex.Message;
//显示错误消息。
}
}

}

和我的代码更新为:

 私有异步任务editEvent()
{
if(!connected)
{
try
{
var authClient = new LiveAuthClient();
LiveLoginResult result = await authClient.LoginAsync(new string [] {wl.signin,wl.calendars,wl.calendars_update});

if(result.Status == LiveConnectSessionStatus.Connected)
{
var eventToPost = new Dictionary< string,object>();
eventToPost.Add(name,program c# - 2nd trial);

eventToPost.Add(calendar_id,calendar.136c10ca65544801.99c35f9a9fb341a3af35daa82f4569f8);

eventToPost.Add(description,这应该是第二个日历);
eventToPost.Add(start_time,2014-09-10T01:30:00-08:00);
eventToPost.Add(end_time,2014-09-12T03:00:00-08:00);
eventToPost.Add(location,business placeeeeeee);
eventToPost.Add(is_all_day_event,false);
eventToPost.Add(可用性,繁忙);
eventToPost.Add(visibility,public);

this.session = result.Session;

connected = true;
this.connectClient = new LiveConnectClient(result.Session);

var meResult = await connectClient.PutAsync(event.136c10ca6a355671.5f21a7994c7e40fd800bc48dcc07300b.991d1912ec6b4523a0f08839992aa2bb,eventToPost);

meData = meResult.Result;
}
}
catch(LiveAuthException ex)
{
//显示错误消息。
}
catch(LiveConnectException ex)
{
//显示错误消息。
infoTextBlock.Text + = ex.Data +...+ ex.Message;
}
}
}

它工作正常,除了它将永远不会更改日历ID属性,它将使用默认的日历ID。



所以研究文档在


I'm exploring the Live Connect SDK.

I can create calendar and read events, and even create new events using the Microsoft.Live library.

After I created a calendar say [Programming calendar] I wanted to write an event to it.

However all my attempts have failed to link the event to the newly created calendar i.e. [Programming calendar].

So I was reading the SDK documentations and found the following:

My code for creation was:

private async Task editEvent()
{
    if (!connected)
    {
 try
                {
                    var authClient = new LiveAuthClient();
                    LiveLoginResult result = await authClient.LoginAsync(new string[] { "wl.signin", "wl.calendars", "wl.calendars_update" });
                    //"wl.skydrive, wl.skydrive_update",
                    if (result.Status == LiveConnectSessionStatus.Connected)
                    {
                        var eventToPost = new Dictionary<string, object>();
                     eventToPost.Add("name", "my new event");

                     eventToPost.Add("calendar_id", "calendar.136c10ca65544801.99c35f9a9fb341a3af35daa82f4569f8");

                     eventToPost.Add("description", "this should be 2nd calendar");
                     eventToPost.Add("start_time", "2014-09-10T01:30:00-08:00");
                     eventToPost.Add("end_time", "2014-09-12T03:00:00-08:00");
                     eventToPost.Add("location", "business placeeeeeee");
                     eventToPost.Add("is_all_day_event", false);
                     eventToPost.Add("availability", "busy");
                     eventToPost.Add("visibility", "public");

                        this.session = result.Session;
                        connected = true;
                        this.connectClient = new LiveConnectClient(result.Session);
                        var meResult = await connectClient.PostAsync("me/events", eventToPost);

                        meData = meResult.Result;

                    }
                }
                catch (LiveAuthException ex)
                {
                    infoTextBlock.Text += ex.Data + " .autexception.." + ex.Message;
                    // Display an error message.
                }
                catch (LiveConnectException ex)
                {
                    infoTextBlock.Text += ex.Data + " .conExcception.." + ex.Message;
                    // Display an error message.
                }
}

}

and my code for update was:

private async Task editEvent()
{
    if (!connected)
    {
        try
        {
            var authClient = new LiveAuthClient();
            LiveLoginResult result = await authClient.LoginAsync(new string[] { "wl.signin", "wl.calendars", "wl.calendars_update" });

            if (result.Status == LiveConnectSessionStatus.Connected)
            {
                var eventToPost = new Dictionary<string, object>();
                eventToPost.Add("name", "program my c# - 2nd trial");

                eventToPost.Add("calendar_id", "calendar.136c10ca65544801.99c35f9a9fb341a3af35daa82f4569f8");

                eventToPost.Add("description", "this should be 2nd calendar");
                eventToPost.Add("start_time", "2014-09-10T01:30:00-08:00");
                eventToPost.Add("end_time", "2014-09-12T03:00:00-08:00");
                eventToPost.Add("location", "business placeeeeeee");
                eventToPost.Add("is_all_day_event", false);
                eventToPost.Add("availability", "busy");
                eventToPost.Add("visibility", "public");

                this.session = result.Session;

                connected = true;
                this.connectClient = new LiveConnectClient(result.Session);

                var meResult = await connectClient.PutAsync("event.136c10ca6a355671.5f21a7994c7e40fd800bc48dcc07300b.991d1912ec6b4523a0f08839992aa2bb", eventToPost);

                meData = meResult.Result;
            }
        }
        catch (LiveAuthException ex)
        {
            // Display an error message.
        }
        catch (LiveConnectException ex)
        {
            // Display an error message.
            infoTextBlock.Text += ex.Data + " ..." + ex.Message;
        }
    }
}

It works fine except that it will never change the calendar ID property and it will use the default calendar ID.

So researching the documentations on the REST reference I found the following fact !!

so there is a discrepancy in the documentations bec. the table says the calendar_id is readonlyand they claims that you can write to any calendar using the correct scope " Use wl.calendars_update to create Event objects on any of the user's calendars "

One more things I confirmed that in my newly created calendar [Programming calendar] the permission property I am the owner !

So what am I missing here?

解决方案

Ok I discovered where i was wrong:

//this line is useless since the property is readOnly

eventToPost.Add("calendar_id", "calendar.136c10ca65544801.99c35f9a9fb341a3af35daa82f4569f8");

//this is the wrong line [ wrong path]

var meResult = await connectClient.PostAsync("me/events", eventToPost);

//this is the correct way [proper path use]i.e. replace "me" by "CALENDAR_ID"

var meResult = await connectClient.PostAsync("calendar.136c10ca65544801.99c35f9a9fb341a3af35daa82f4569f8/events", eventToPost);

referrence for this solution :http://social.msdn.microsoft.com/Forums/windowsapps/en-US/15207829-4999-46d9-a835-e350526f3aa

这篇关于如何在活动连接Outlook日历上将活动写入特定日历?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:16