C# EWS管理的API同步缓存位置

C# EWS管理的API同步缓存位置,c#,exchangewebservices,ews-managed-api,C#,Exchangewebservices,Ews Managed Api,将Exchange Web服务(EWS)托管API用于或时,客户端缓存位于何处?它只是在记忆中吗?它在磁盘上吗?有没有办法找到或控制缓存的位置?我似乎在任何地方都找不到有关此的信息。通过将SyncFolderHierarchy和SyncFolderItems组合在一起,您可以高效地同步Exchange邮箱中所有文件夹(或其子集)的内容 文章中所示的流程是指示性的。调用SyncFolderItems返回一个changecolection,其中包含ItemChange或FolderChange类型的

将Exchange Web服务(EWS)托管API用于或时,客户端缓存位于何处?它只是在记忆中吗?它在磁盘上吗?有没有办法找到或控制缓存的位置?我似乎在任何地方都找不到有关此的信息。

通过将
SyncFolderHierarchy
SyncFolderItems
组合在一起,您可以高效地同步Exchange邮箱中所有文件夹(或其子集)的内容

文章中所示的流程是指示性的。调用
SyncFolderItems
返回一个
changecolection
,其中包含
ItemChange
FolderChange
类型的项。如果处理这些项目,则可以下拉文件夹中的其他信息,例如文件夹中每个项目的实际内容

处理完
ChangeCollection
后,应该将
SyncState
值存储在某个地方。下次调用
SyncFolderItems
时,传入该值,Exchange将返回下一批项目

由于(特别是第一次同步时)很可能有比
SyncFolderItems
在单个调用中返回的项目更多的项目,因此您应该检查以确定是否还有更多的事情要做

因此,所有这些都变成了这个循环:

// Track whether there are more items available for download on the server.
bool moreChangesAvailable = false;
do {
    // Get a list of all items in the Inbox by calling SyncFolderHierarchy repeatedly until no more changes are available.
    // The folderId parameter must be set to the root folder to synchronize,
    // and must be same folder ID as used in previous synchronization calls. 
    // The propertySet parameter is set to IdOnly to reduce calls to the Exchange database,
    // because any additional properties result in additional calls to the Exchange database. 
    // The ignoredItemIds parameter is set to null, so that no items are ignored.
    // The maxChangesReturned parameter is set to return a maximum of 10 items (512 is the maximum).
    // The syncScope parameter is set to Normal items, so that associated items will not be returned.
    // The syncState parameter is set to cSyncState, which should be null in the initial call, 
    // and should be set to the sync state returned by the 
    // previous SyncFolderItems call in subsequent calls.
    ChangeCollection<ItemChange> icc = service.SyncFolderItems(new FolderId(WellKnownFolderName.Inbox), PropertySet.IdOnly, null, 10, SyncFolderItemsScope.NormalItems, cSyncState);

    // If the count of changes is zero, there are no changes to synchronize.
    if (icc.Count <> 0) {
        // Otherwise, write all the changes included in the response to the console. 
        foreach (ItemChange ic in icc) {
            Console.WriteLine("ChangeType: " + ic.ChangeType.ToString());
            Console.WriteLine("ItemId: " + ic.ItemId);
        }
    }

    // Save the sync state for use in future SyncFolderContent requests.
    // The sync state is used by the server to determine what changes to report
    // to the client.
    string sSyncState = icc.SyncState;

   // Determine whether more changes are available on the server.
   moreChangesAvailable = icc.MoreChangesAvailable;
}
while (moreChangesAvailable);
//跟踪服务器上是否有更多可供下载的项目。
bool-moreChangesAvailable=false;
做{
//通过反复调用SyncFolderHierarchy获取收件箱中所有项目的列表,直到没有更多可用的更改。
//folderId参数必须设置为要同步的根文件夹,
//并且必须与以前的同步调用中使用的文件夹ID相同。
//propertySet参数设置为IdOnly以减少对Exchange数据库的调用,
//因为任何附加属性都会导致对Exchange数据库的附加调用。
//IgnoreditMids参数设置为null,因此不会忽略任何项。
//MaxChangesReturn参数设置为最多返回10项(512为最大值)。
//syncScope参数设置为普通项目,因此关联的项目将不会返回。
//syncState参数设置为cSyncState,在初始调用中应为null,
//并应设置为
//后续调用中的上一个SyncFolderItems调用。
ChangeCollection icc=service.SyncFolderItems(新FolderId(WellKnownFolderName.Inbox),PropertySet.IdOnly,null,10,SyncFolderItemsScope.NormalItems,cSyncState);
//如果更改计数为零,则没有要同步的更改。
如果(icc.0){
//否则,将响应中包含的所有更改写入控制台。
foreach(国际商会中的项目变更){
Console.WriteLine(“ChangeType:+ic.ChangeType.ToString());
Console.WriteLine(“ItemId:+ic.ItemId”);
}
}
//保存同步状态以供将来的SyncFolderContent请求使用。
//服务器使用同步状态确定要报告的更改
//给客户。
字符串sSyncState=icc.SyncState;
//确定服务器上是否有更多更改可用。
moreChangesAvailable=icc.moreChangesAvailable;
}
而(更易获得);
代码示例,因为我不能比他们说得更好

因此,没有客户端缓存这样的东西,除非您选择自己在客户端存储项目。如果您选择不存储它们,您只需继续循环,直到您感兴趣的内容开始。例如,上面的代码不下载任何内容,除了
ItemChange
记录和每个项目的ID(由
PropertySet.IdOnly
指示)


这。

您指的是什么“客户端缓存”?您提到的文章没有提到任何此类缓存,也没有提到
SyncFolderHierarchy
SyncFolderItems
的API文档。您可以使用有文档记录的方法和API将邮箱(其中的某些文件夹)的内容从Exchange同步到您希望将其存储到的任何系统。这就是我的问题:什么是客户端缓存?(文档中没有提到)服务器端数据同步到哪个客户端数据存储?API只允许您访问Exchange中的数据。它是同步的,无论你将它同步到什么。这篇文章描述了同步,因为这是它的常见用例(每次调用都会返回一个状态“cookie”,允许您从该点继续)。这篇文章也可能为您提供服务:。它从一个更高的层次描述了整个同步方法,并且(在我看来)有更好的例子。你是说客户端同步缓存只不过是ChangeCollection?回答得很好。由于API使用了“sync”一词,这意味着保持客户端和服务器端状态完全同步,因此我的心智模型不正确。但现在我明白了,这些Sync*调用实际上只是在最后一个SyncState时间戳之后返回增量,您是想使用这些增量来维护自己的“同步”副本,还是从这些增量中选择要读取的内容,这取决于您。对于正在阅读的其他人,请参阅聊天了解更多有用的详细信息: