ExchangeService.SyncFolderItems奇怪或误解? [英] ExchangeService.SyncFolderItems oddity or misunderstanding?

查看:225
本文介绍了ExchangeService.SyncFolderItems奇怪或误解?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好,我正在尝试使用SynckFolderItems跟踪几个文件夹中的更改,但是我没有达到理智的解决方案。我相信这一定是我的误解 - 但鉴于文件还没有完整,我对此失败的处理非常令人钦佩。 :)

我的第一个查询点与克服此SynckFolderItems调用中的512项限制有关。与该API集中的其他函数不同,没有数据的分页或偏移 - 只有"忽略列表"。 IEnumerable< ItemId>所以从这个我假设我应该多次打电话(哎呀!),每次发送一个不断增加的项目列表,忽略从我已经收到的项目建立? (双重!)如果那是错的 - 我真的很感激有人回到了直线上!

如果这是执行此操作的唯一方法,那么我有实现了这个并因此遇到了我的第二个问题 - 即,它不起作用。 :(具体来说,当我第一次对我的邮箱(收件箱中有4200多个项目)运行时(即synkState为空),每次调用都会得到一个新的512项 - 直到我到达结束(在第9个呼叫附近)。此时,它似乎循环回到开头并开始再次返回第一个项目 - 尽管这些项目在忽略列表中!˙最重要的是,MoreChangesAvailable仍为TRUE !如果我尝试拨打下一个电话,我从来没有收到服务器的回复...

下面是我正在做的可能(或可能不是)的修剪版本重现错误。您的收件箱中可能需要超过512条消息来测试它。它似乎在少于512项的文件夹上正常工作。(即MoreChangesAvailable == false)。如您所见,所有对SyncFolderItems的调用在一次传递中使用相同的stateKey - 新密钥被传递回调用者,然后调用者将其用作下一次传递的种子。

任何帮助都会非常感激ed!

注意


good afternoon,

i'm trying to keep track of changes in a few folders by using SynckFolderItems but am falling short of a sane solution.
i'm convinced that it must be a misunderstanding on my part - but given that the documentation is not yet complete, i am dealing with this failure quite admirably. :)

my first point of query has to do with overcoming the 512 item limit in this SynckFolderItems call.
unlike other functions in this API set, there is no paging or offsets of data - there is only an "ignore list" of IEnumerable<ItemId>. so from this i assume that i should make multiple calls (yuck!), each time sending in an ever increasing list of items to ignore built up from the items i have already received? (double-yuck!)
if that is wrong - i would really appreciate someone putting be back on the straight!

but if that is the only way to perform this operation, then i have implemented this and consequently encountered my second issue - namely, it doesn't work. :(
specifically, when i run this against my mailbox (4200-odd items in the inbox) for the first time (ie. synkState is empty), each call gets a new set of 512 Items - until i reach the end (around the 9th call). at this point, it seems to loop back to the beginning and starts returning the first items again - despite these items being in the ignore list!
to top it off, MoreChangesAvailable is still TRUE! and if i do try make the next call, i never get a response back from the server...

below is a trimmed-down version of what i am doing which may (or may not) reproduce the error. you will probably need more than 512 messages in your inbox to test this. it seems to work fine on folders with less that 512 items. (ie. MoreChangesAvailable == false). as you can see, all calls to SyncFolderItems in one pass use the same stateKey - the new key is passed back to the caller who would then use it as the seed for the next pass.

any help would be greatly appreciated!

take care


public static string TestInboxSynck(ExchangeService service, string synck_key)
{
   bool more_data = true;
   int fetch_count = 0;
   int email_count = 0;
   string new_key = string.Empty;
   List<ItemId> ignore_ids = new List<ItemId>();
   Dictionary<string, bool> processed_ids = new Dictionary<string, bool>();

   Folder inbox = Folder.Bind(service, WellKnownFolderName.Inbox);

   while(more_data)
   {
      Console.WriteLine("fetching SyncFolderItems (" + ++fetch_count + ") with (" + ignore_ids.Count + ") ignores");
      ChangeCollection<ItemChange> citems = service.SyncFolderItems(inbox.Id, BasePropertySet.FirstClassProperties, (ignore_ids.Count > 0 ? ignore_ids : null), 512, SyncFolderItemsScope.NormalItems, synck_key);

      foreach(ItemChange citem in citems)
      {
         if(processed_ids.ContainsKey(citem.ItemId.UniqueId))
            throw new ThisShouldNeverHappenException("duplicate key detected!");

         // other processing here



         ignore_ids.Add(citem.ItemId);
         processed_ids[citem.ItemId.UniqueId] = true;

         email_count += citems.Count;
         Console.WriteLine("total emails so far " + email_count.ToString());
         new_key = citems.SyncState;
         more_data = citems.MoreChangesAvailable;
      }
   }

   return new_key;
}

推荐答案

你好,

你应该更新你得到的cookie来自每轮的SyncFolder调用。请查看 http://www.infinitec.de/post/2009/06/07/Processing-items-in-an-Exchange-folder-using-EWS-Managed-API.aspx
<无线电通信亲切的问候,
Henning Krause
Hi,

you should update the cookie you get from the SyncFolder call on each round. Have a look at http://www.infinitec.de/post/2009/06/07/Processing-items-in-an-Exchange-folder-using-EWS-Managed-API.aspx.

Kind regards,
Henning Krause


这篇关于ExchangeService.SyncFolderItems奇怪或误解?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆