internal void RefreshLocalEntities(Action <int> setProgress) { var cloudTables = getAllKindNames(); //we get the keys and editdates foreach (var table in cloudTables) { var localCloudData = new CloudLocalStore <CloudEntity>(table.toKind()); var entities = localCloudData.GetUnsyncedLocalEntities( cloudTable: table.toKind(), localTable: getLocalTableName(table).toKind() ); if (entities.Count == 0) { continue; } var entityConverter = new EntityConverter(); var localStore = new CloudLocalStore <LocalEntity>(getLocalTableName(table).toKind()); var flatStore = new FieldValueStore(getTableFieldValueName(table)) { batchSize = 50 }; foreach (var entity in entities) { //we decrypt var localEntity = entityConverter.toLocalEntity(entity); var saved = localStore.Update(localEntity); if (saved == null) { //means we couldn't save, so we do what? //throw exception?? log(string.Format("Couldn't save record for ", table, entity.Id)); continue; } //and deidentify var deid = entityConverter.toDeidEntity(localEntity); var ged = DbSaveableEntity.fromJson <GeneralEntityDataset>( new KindItem(deid.DataBlob) ); //todo: modify so we sync from CloudLocalStore separately than when downloading //and save to localTables flatStore.Save(ged, localEntity, saved.recordId); } //call finalise flatStore.finalise(); } //check if we have these in the local tables //fetch and process records missing //or do a sql comparison }
public async Task <bool> addToProcessingQueue(KindName kindName, List <CloudEntity> cloudEntities) { var kindStore = new CloudLocalStore(kindName); foreach (var entity in cloudEntities) { kindStore.Update(entity); } return(true); }
private long getLastSyncedDateForKind(KindName kindName) { var db = new CloudLocalStore(kindName); var entity = db.GetLatestEntity(); if (entity == null || string.IsNullOrWhiteSpace(entity.Id)) { return(new DateTime(1900, 01, 01, 0, 0, 0, 1, DateTimeKind.Local).ToBinary()); } return(entity.EditDate); }