EWS UpdateItem 中的 ChangeKey 有何用途?

发布于 2024-07-06 00:56:38 字数 384 浏览 4 评论 0原文

我正在尝试使用 Exchange Web 服务来更新日历项目。 我正在创建一个 ItemChangeType,然后创建一个 ItemIdType。 我有一个用于 ItemIdType.Id 的唯一 ID,但没有任何内容可用于 ChangeKey。 当我忽略它时,我得到一个 ErrorChangeKeyRequiredForWriteOperations。 但是当我尝试将一些东西放在那里时,我得到一个 ErrorInvalidChangeKey 。

我可以用什么来让它工作?

我还试图确定用于 ItemChangeType.Item 的 BaseItemIdType 的最佳实现是什么。 到目前为止,我正在使用 ItemIdType,我猜这是正确的,但我还没有找到任何关于此的特别有用的文档。

I'm trying to use Exchange Web Services to update a calendar item. I'm creating an ItemChangeType, and then an ItemIdType. I have a unique ID to use for ItemIdType.Id, but I have nothing to use for the ChangeKey. When I leave it out, I get an ErrorChangeKeyRequiredForWriteOperations. But when i try to just put something in there, I get an ErrorInvalidChangeKey.

What can I use for this to get it to work?

I'm also trying to determine what is the best implementation of BaseItemIdType to use for ItemChangeType.Item. So far, I'm using ItemIdType, and I'm guessing that's correct, but I haven't been able to find any particularly helpful documentation on this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

放低过去 2024-07-13 00:56:38

我建议您使用 Exchange 托管 API(而不是 Exchange Web 服务)来处理 Exchange。 使用起来要容易得多。 您可以在下面找到更多详细信息:

https://msdn .microsoft.com/en-gb/library/dd877012(v=exchg.150).aspx

I recommend you to use the Exchange Managed API, instead of Exchange Web Services, for working with Exchange. It is much easier to use. You can find more details below:

https://msdn.microsoft.com/en-gb/library/dd877012(v=exchg.150).aspx

不语却知心 2024-07-13 00:56:38

如果你只知道ID,你可以轻松获得ChangeKey,例如文件夹:

  private FolderIdType GetFullFolderID(string folderID)
  {
     GetFolderType request = new GetFolderType();
     request.FolderIds = new BaseFolderIdType[1];

     FolderIdType id = new FolderIdType();
     id.Id = folderID;
     request.FolderIds[0] = id;

     request.FolderShape = new FolderResponseShapeType();
     request.FolderShape.BaseShape = DefaultShapeNamesType.IdOnly;

     GetFolderResponseType response = _binding.GetFolder(request);

     FailOnError(response);

     FolderInfoResponseMessageType firmt = (FolderInfoResponseMessageType)response.ResponseMessages.Items[0];
     FolderType ft = (FolderType)firmt.Folders[0];
     id.ChangeKey = ft.FolderId.ChangeKey;

     return id;
  }

If you know ID only, you can get ChangeKey easily, for example for folder:

  private FolderIdType GetFullFolderID(string folderID)
  {
     GetFolderType request = new GetFolderType();
     request.FolderIds = new BaseFolderIdType[1];

     FolderIdType id = new FolderIdType();
     id.Id = folderID;
     request.FolderIds[0] = id;

     request.FolderShape = new FolderResponseShapeType();
     request.FolderShape.BaseShape = DefaultShapeNamesType.IdOnly;

     GetFolderResponseType response = _binding.GetFolder(request);

     FailOnError(response);

     FolderInfoResponseMessageType firmt = (FolderInfoResponseMessageType)response.ResponseMessages.Items[0];
     FolderType ft = (FolderType)firmt.Folders[0];
     id.ChangeKey = ft.FolderId.ChangeKey;

     return id;
  }
擦肩而过的背影 2024-07-13 00:56:38

更明确地说明 Hauge 的答案:ChangeKey 存储在 Exchange 中并标识项目的当前状态。 对该项目的任何更改都会创建一个新的 ChangeKey。

这使得 Exchange 能够“知道”您的更新正在应用到与您查看该项目时相同的项目状态 - 自您检查以来它没有更改。

一些代码可在:
http://msdn.microsoft.com/en-us/library/aa563020.aspx

To be a bit more explicit on Hauge's answer: the ChangeKey is stored in Exchange and identifies the current state of the item. Any change to that item creates a new ChangeKey.

This allows Exchange to "know" that your update is being applied to the same item state as when you looked at the item - it hasn't changed since you checked it.

Some code available at:
http://msdn.microsoft.com/en-us/library/aa563020.aspx

成熟稳重的好男人 2024-07-13 00:56:38

如果您拥有 ItemIdType.Id 属性,您还应该可以访问 Changekey,它也是 ItemIdType 的属性:

ItemIdType.ChangeKey

与 Id 属性一样,它是一个字符串,因此您可以在抓取时抓取它身份证号。

问候
杰斯帕·豪格

If you have the ItemIdType.Id property you should also have access to the Changekey, it's also a property of ItemIdType:

ItemIdType.ChangeKey

Like the Id property it's a string, so you can grab it when you grab the Id.

Regards
Jesper Hauge

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文