public static UpdateResult GetCamlUpdateResult(this XElement xmlNode) { UpdateResult result = new UpdateResult(); XNamespace defaultns = xmlNode.GetDefaultNamespace(); //XNamespace rowsetns = xmlNode.GetNamespaceOfPrefix("z"); XNamespace rowsetns = "#RowsetSchema"; string ResultID = xmlNode.Attribute("ID").Value; string[] IdAndCommand = ResultID.Split(",".ToCharArray()); result.UpdateItemID = Int32.Parse(IdAndCommand[0]); result.Command = IdAndCommand[1]; result.ErrorCode = xmlNode.Element(defaultns + "ErrorCode").Value; XElement errorMessageElement = xmlNode.Elements(defaultns + "ErrorText").FirstOrDefault(); result.ErrorMessage = (errorMessageElement == null) ? null : errorMessageElement.Value; XElement listItemElement = xmlNode.Elements(rowsetns + "row").FirstOrDefault(); result.ItemData = listItemElement == null ? null : listItemElement.GetCamlListItem(); return result; //UpdateResult x; // }
private SyncConflict CreateSyncError(UpdateResult r, DataRow clientRow) { Microsoft.Synchronization.SyncStage syncStage = Microsoft.Synchronization.SyncStage.UploadingChanges; switch (r.Command) { case "New": syncStage = Microsoft.Synchronization.SyncStage.ApplyingInserts; break; case "Update": syncStage = Microsoft.Synchronization.SyncStage.ApplyingUpdates; break; case "Delete": syncStage = Microsoft.Synchronization.SyncStage.ApplyingDeletes; break; } SyncConflict conflict; if (r.ErrorCode == UpdateResult.VersionConflict) { if (r.Command == "Update") conflict = new SyncConflict(ConflictType.ClientUpdateServerUpdate, syncStage); else if (r.Command == "Delete") conflict = new SyncConflict(ConflictType.ClientDeleteServerUpdate, syncStage); else conflict = new SyncConflict(ConflictType.Unknown, syncStage); if (r.ItemData != null) { Exception e; DataRow serverRow = clientRow.Table.NewRow(); MapListItemToDataRow(r.ItemData, serverRow, out e); if (e == null) { conflict.ServerChange = serverRow.Table.Clone(); conflict.ServerChange.TableName = this.TableName; conflict.ServerChange.Rows.Add(serverRow); } } } else if (r.ErrorCode == UpdateResult.ItemDeleted) { conflict = new SyncConflict(ConflictType.ClientUpdateServerDelete, syncStage); } else { conflict = new SyncConflict(ConflictType.ErrorsOccurred, syncStage); } if (conflict.ClientChange == null) { conflict.ClientChange = clientRow.Table.Clone(); conflict.ClientChange.TableName = clientRow.Table.TableName; } conflict.ClientChange.ImportRow(clientRow); conflict.ErrorMessage = r.ErrorMessage; return conflict; }