public async Task <FolderSyncCommandResult> FolderSync(string syncKey) { if (string.IsNullOrEmpty(syncKey)) { throw new ArgumentNullException(nameof(syncKey)); } FolderSyncCommand command = new FolderSyncCommand(new FolderSyncCommandParameter(syncKey), this.settings); ResponseResult <FolderSyncCommandResult> result = await command.Execute(); if (ActiveSyncErrorHelper.IsStatusProvisioningError(result.Data?.Status, result?.Error)) { await this.TryDoProvisioning(); result = await command.Execute(); } if (result.Error != null) { throw result.Error; } LogService.Log("ActiveSyncServer", "Folder sync success count: " + result.Data.AddedFolders.Count); return(result.Data); }
public async Task <SyncCommandResult> Sync(string syncKey, string folderId, ExchangeChangeSet changeset) { if (string.IsNullOrEmpty(syncKey)) { throw new ArgumentNullException(nameof(syncKey)); } if (string.IsNullOrEmpty(folderId)) { throw new ArgumentNullException(nameof(folderId)); } if (changeset == null) { throw new ArgumentNullException(nameof(changeset)); } LogService.Log("ActiveSyncServer", string.Format("Syncing key: {0} folder id: {1}", syncKey.TakeLast(5), folderId != null ? folderId.TakeLast(5) : "<none>")); SyncCommand command = new SyncCommand(new SyncCommandParameter(syncKey, folderId, changeset), this.settings); ResponseResult <SyncCommandResult> result = await command.Execute(); if (ActiveSyncErrorHelper.IsStatusProvisioningError(result.Data?.Status, result?.Error)) { await this.TryDoProvisioning(); result = await command.Execute(); } if (result.Error != null) { throw result.Error; } return(result.Data); }
protected override void ParseResponseCore(string commandName, XDocument document, WebRequestResponse response) { if (document == null) { // no changes, leave the object as is this.Status = "1"; return; } if (document.Element("Sync").Elements("Status").Any()) { this.Status = document.Element("Sync").Element("Status").Value; LogService.LogFormat("SyncCommandResult", "General status not OK : {0}", this.Status); // we detect and are able to react to provisioning error status code if (!ActiveSyncErrorHelper.IsStatusProvisioningError(this.Status, null)) { if (Debugger.IsAttached) { Debugger.Break(); } if (InvalidStatusFound != null) { InvalidStatusFound(this, new EventArgs <string>($"Status: {this.Status}")); } } return; } var collection = document.Element("Sync").Element("Collections").Element("Collection"); this.SyncKey = collection.Element("SyncKey").Value; this.Status = collection.Element("Status").Value; this.MoreAvailable = collection.Elements("MoreAvailable").Any(); this.ManageServerChanges(collection); this.ManageClientAcknowledgement(collection, response); LogService.LogFormat("SyncCommandResult", "status: {0} sync key: {1} more: {2}", this.Status, this.SyncKey.TakeLast(5), this.MoreAvailable.ToString()); }