简体   繁体   English

通过EWS更新日历事件后,Outlook中显示的时区不正确

[英]Incorrect time zone displayed in Outlook after updating a calendar event through EWS

I'm having an issue with time zones when updating an appointment. 更新约会时遇到时区问题。

Step 1, create a single event, works fine 第1步,创建一个活动,效果很好

First I create a single event, running from 10:00 to 11:00 local time (Amsterdam DST, so UTC+2). 首先,我创建一个事件,该事件在本地时间10:00到11:00之间运行(阿姆斯特丹DST,所以UTC + 2)。
My Exchange server 2010 (SP2) knows the "W. Europe Standard Time" timezone. 我的Exchange服务器2010(SP2)知道“欧洲标准时间”时区。
No issue there, here's the event in Outlook 2007: 那里没有问题,这是Outlook 2007中的事件:

在此处输入图片说明

This is the XML that creates the event: 这是创建事件的XML:

<soapenv:Envelope
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
  xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header>
  <typ:RequestServerVersion Version="Exchange2007_SP1"/>
  <typ:MailboxCulture>en-US</typ:MailboxCulture>
  <typ:TimeZoneContext>
     <typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
  </typ:TimeZoneContext>
</soapenv:Header>
<soapenv:Body>
   <mes:CreateItem SendMeetingInvitations="SendToNone">
      <mes:SavedItemFolderId>
         <typ:DistinguishedFolderId Id="calendar">
            <typ:Mailbox>
               <typ:EmailAddress>developer@timetellbv.nl</typ:EmailAddress>
            </typ:Mailbox>
         </typ:DistinguishedFolderId>
      </mes:SavedItemFolderId>
      <mes:Items>
         <typ:CalendarItem>
           <typ:Subject>New event 10:00-11:00</typ:Subject>
           <typ:Body BodyType="Text"></typ:Body>
           <typ:Categories>
             <typ:String>TimeTell</typ:String>
           </typ:Categories>
           <typ:ReminderIsSet>false</typ:ReminderIsSet>
           <typ:Start>2014-08-19T10:00:00.000+02:00</typ:Start>
           <typ:End>2014-08-19T11:00:00.000+02:00</typ:End>
           <typ:IsAllDayEvent>false</typ:IsAllDayEvent>
           <typ:LegacyFreeBusyStatus>Busy</typ:LegacyFreeBusyStatus>
           <typ:Location></typ:Location>
           <typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>
         </typ:CalendarItem>
      </mes:Items>
   </mes:CreateItem>
</soapenv:Body>
</soapenv:Envelope>

Note that I specify the MeetingTimeZone, and give Start/Finish an explicit time zone, so that Exchange Server knows how to convert it to UTC without having to rely on the server time zone (see Best Practices for Using Exchange Web Services for Calendaring Tasks ). 请注意,我指定了MeetingTimeZone,并为“开始/结束”指定了明确的时区,以便Exchange Server知道如何将其转换为UTC,而不必依赖服务器时区(请参阅使用Exchange Web服务执行日历任务的最佳做法 )。 。
I tried leaving out all time zone info when creating the event, but this immediately gives me the 'Reykjavik effect' of step 2. Anyway, step 1 works fine. 在创建事件时,我尝试忽略了所有时区信息,但这立即为我提供了步骤2的“雷克雅未克效果”。无论如何,步骤1可以正常工作。

Step 2, update the single event, fails: changes timezone as displayed in Outlook 步骤2,更新单个事件失败:更改时区,如Outlook中所示

Now I modify the event caption only; 现在,我仅修改事件标题; I need to specify all items again (my code has no idea what changed): 我需要再次指定所有项目(我的代码不知道更改了什么):

<soapenv:Envelope
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
  xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header>
  <typ:RequestServerVersion Version="Exchange2007_SP1"/>
  <typ:MailboxCulture>en-US</typ:MailboxCulture>
  <typ:TimeZoneContext>
     <typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
  </typ:TimeZoneContext>
</soapenv:Header>
<soapenv:Body>
<mes:UpdateItem ConflictResolution="AlwaysOverwrite" SendMeetingInvitationsOrCancellations="SendToNone">
   <mes:ItemChanges>
      <typ:ItemChange>
         <typ:ItemId Id="AQMkAZ[snip]hgAAAA==" ChangeKey="DwAAA[snip]yy5AX"/>
         <typ:Updates>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Subject"/>
               <typ:CalendarItem>
                 <typ:Subject>New event 10:00-11:00 (modified)</typ:Subject>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Sensitivity"/>
               <typ:CalendarItem>
                 <typ:Sensitivity>Normal</typ:Sensitivity>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Categories"/>
               <typ:CalendarItem>
                  <typ:Categories>
                     <typ:String>TimeTell</typ:String>
                  </typ:Categories>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Body"/>
               <typ:CalendarItem>
                 <typ:Body BodyType="Text"></typ:Body>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:Location"/>
               <typ:CalendarItem>
                 <typ:Location></typ:Location>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:ReminderIsSet"/>
               <typ:CalendarItem>
                 <typ:ReminderIsSet>false</typ:ReminderIsSet>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:IsAllDayEvent"/>
               <typ:CalendarItem>
                 <typ:IsAllDayEvent>false</typ:IsAllDayEvent>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:Start"/>
               <typ:CalendarItem>
                 <typ:Start>2014-08-19T10:00:00.000+02:00</typ:Start>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:End"/>
               <typ:CalendarItem>
                 <typ:End>2014-08-19T11:00:00.000+02:00</typ:End>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:LegacyFreeBusyStatus"/>
               <typ:CalendarItem>
                 <typ:LegacyFreeBusyStatus>Busy</typ:LegacyFreeBusyStatus>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellID" PropertyType="Integer"/>
               <typ:CalendarItem>
                  <typ:ExtendedProperty>
                     <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellID" PropertyType="Integer"/>
                     <typ:Value>10722</typ:Value>
                  </typ:ExtendedProperty>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncTime" PropertyType="SystemTime"/>
               <typ:CalendarItem>
                  <typ:ExtendedProperty>
                     <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncTime" PropertyType="SystemTime"/>
                     <typ:Value>2014-08-19T16:22:22.094+02:00</typ:Value>
                  </typ:ExtendedProperty>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncVer" PropertyType="Integer"/>
               <typ:CalendarItem>
                  <typ:ExtendedProperty>
                     <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncVer" PropertyType="Integer"/>
                     <typ:Value>80000</typ:Value>
                  </typ:ExtendedProperty>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncID" PropertyType="String"/>
               <typ:CalendarItem>
                  <typ:ExtendedProperty>
                     <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncID" PropertyType="String"/>
                     <typ:Value>0000000082ADE26393957649AD9C74BF97109BC2070084A6175871FF6A40850053554066620A000000000021000084A6175871FF6A40850053554066620A000232CB43830000</typ:Value>
                  </typ:ExtendedProperty>
               </typ:CalendarItem>
            </typ:SetItemField>
         </typ:Updates>
      </typ:ItemChange>
   </mes:ItemChanges>
 </mes:UpdateItem>
</soapenv:Body>
</soapenv:Envelope>

but now I get this: 但是现在我得到了:
The event shows properly in the calender overview 该事件在压光机概述中正确显示

在此处输入图片说明

but when I open it I suddenly get incorrect 'Reykjavik' times: 但是当我打开它时,我突然得到了不正确的“雷克雅未克”时间:

在此处输入图片说明

Note that the header of the UpdateItem call still has the 请注意,UpdateItem调用的标头仍然具有

<typ:TimeZoneContext>
   <typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
</typ:TimeZoneContext>

but there is no 但是没有

<typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>

in the call, as there was in the CreateItem call. 在呼叫中,就像在CreateItem呼叫中一样。

If I try to put it in like this I get an error "The specified object was not found in the store": 如果我尝试这样放入,则会收到错误消息“在商店中找不到指定的对象”:

<typ:SetItemField>
   <typ:FieldURI FieldURI="calendar:Start"/>
   <typ:CalendarItem>
     <typ:Start>2014-08-19T10:00:00.000+02:00</typ:Start>
     <typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>
   </typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
   <typ:FieldURI FieldURI="calendar:End"/>
   <typ:CalendarItem>
     <typ:End>2014-08-19T11:00:00.000+02:00</typ:End>
     <typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>
   </typ:CalendarItem>
</typ:SetItemField>

I have tried placing MeetingTimeZone at other locations in the file but keep getting syntax errors. 我曾尝试将MeetingTimeZone放置在文件中的其他位置,但一直收到语法错误。

Leaving the TimeZoneContext out of the header of the UpdateItem does not solve the issue (and from what I understand in TimeZoneContext documentation I should use it). 将TimeZoneContext留在UpdateItem的标题中并不能解决问题(根据我在TimeZoneContext文档中了解的内容,应该使用它)。

I need to use MeetingTimeZone for backward compatibility to Exchange Server 2007 SP1 (for later versions MeetingTimeZone is deprecated and we should use StartImeZone/EndTimeZone). 我需要使用MeetingTimeZone来实现与Exchange Server 2007 SP1的向后兼容性(不建议使用更高版本的MeetingTimeZone,我们应该使用StartImeZone / EndTimeZone)。

Question: How can I change the UpdateItem call to make sure my Outlook events keep having the correct time(zone)? 问题:如何更改UpdateItem调用以确保Outlook事件保持正确的时间(区域)?

Background information: 背景资料:

  • Exchange server version returns: Exchange服务器版本返回:

<ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="195" MinorBuildNumber="1" Version="Exchange2010_SP2"/>

I got it! 我知道了! Thanks to this EWS Calendar Recurrence Item Update - TimeZone problem post. 感谢此EWS日历重复项目更新-TimeZone问题

Indeed you cannot just insert a 实际上,您不能只插入一个

<typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>

line somewhere in the SOAP request, but you also have to specify MeetingTimeZone as a CalendarItem element that you want to change . 行在SOAP请求中的某处,但是您还必须将MeetingTimeZone指定为要更改的CalendarItem元素
So this additional item has to be inserted into the call: 因此,此附加项必须插入到调用中:

<typ:SetItemField>
   <typ:FieldURI FieldURI="calendar:MeetingTimeZone"/>
   <typ:CalendarItem>
      <typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time" />
   </typ:CalendarItem>               
</typ:SetItemField>

And make sure to put it at the right place, because the items have to be specified in the order as defined in the CalendarItem type 并确保将其放在正确的位置,因为必须按照CalendarItem类型中定义的顺序指定项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM