public JObject PutItemDataBatch(JObject request) { IDbCommand command = _connection.CreateCommand(); command.CommandText = "BEGIN"; command.ExecuteNonQuery(); try { var batch = (JArray)request["batch"]; foreach (JToken item in batch) { var remoteSyncableItemInfo = SyncUtil.SyncableItemInfoFromJson(item["item"]); var itemData = new JObject { { "item", item["item"] } }; var remoteKnowledge = SessionDbHelper.LoadRemoteKnowledge(_connection); var localSyncableItemInfo = _store.LocateCurrentItemInfo(remoteSyncableItemInfo); var status = SyncUtil.CalculateSyncStatus(remoteSyncableItemInfo, localSyncableItemInfo, remoteKnowledge); SessionDbHelper.SaveItemData(_connection, remoteSyncableItemInfo, status, itemData); } command.CommandText = "COMMIT"; command.ExecuteNonQuery(); } catch (Exception) { command.CommandText = "ROLLBACK"; command.ExecuteNonQuery(); throw; } var json = new JObject(); return(json); }
public JObject ApplyChanges(JObject request) { SyncUtil.ApplyChangesAndUpdateKnowledge(_connection, _store, SessionDbHelper.LoadRemoteKnowledge(_connection)); return(new JObject()); }