All-DAy事件,时区和更新

时间:2014-05-05 16:31:50

标签: c# timezone exchangewebservices

        ItemId id=null;
        string s = "";
        const string dts = " dd.MM.yyyy HH:mm ";
        if(true) {
            TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
            ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2010, tz);
            ews.AutodiscoverUrl("Alexander@contoso.com");
            Appointment app = new Appointment(ews);
            app.IsAllDayEvent = true;
            app.StartTimeZone = tz;
            app.EndTimeZone = tz;
            app.Start = DateTime.Now;
            app.End = DateTime.Now;
            app.Save(SendInvitationsMode.SendToNone);
            id = app.Id;
            Console.WriteLine(app.Start.ToString(dts));
        }
        if(true) {
            TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
            ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2010, tz);
            ews.AutodiscoverUrl("Alexander@contoso.com");
            Appointment app = Appointment.Bind(ews,id);
            Console.WriteLine(app.Start.ToString(dts));

            app.IsAllDayEvent = true;
            app.StartTimeZone = tz;
            app.EndTimeZone = tz;
            app.Start = DateTime.Now;
            app.End = DateTime.Now;
            app.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
            Console.WriteLine(app.Start.ToString(dts));
        }
        if (true)
        {
            TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
            ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2010, tz);
            ews.AutodiscoverUrl("Alexander@contoso.com");
            Appointment app = Appointment.Bind(ews, id);
            Console.WriteLine(app.Start.ToString(dts));
        }

控制台输出是:

 05.05.2014 18:17 
 05.05.2014 00:00 
 05.05.2014 18:17 
 05.05.2014 02:00

所以创造一个新的全天活动就像一个魅力(这比我今天早上的好)。

但是为什么最后一行02:00,以及我如何重写我的程序以将00:00 CEST存储为全天约会开始日期?

1 个答案:

答案 0 :(得分:0)

我不是开发人员,但我们(Java)开发人员正在研究这个问题。您似乎必须从原始约会中获得所有时区 s ,否则您将遇到此问题...下面的参考/其他堆栈溢出问题,编号5得到它,那是找到的最后一个:(

  1. You are at the same stage as the person asking this one
  2. One step closer, the actual time is correct, but the meeting displays the wrong time zone.
  3. This similar question without answer
  4. Answered for these versions but I can't see what it means: Exchange Server 2007 Service Pack 1 (SP1) / Exchange Server 2010
  5. This one actually got it to work right.引用this answer on the Microsoft fora
  6. 如果这有助于某人,也许其他人也可以最终关闭:)