public void Init() { if (_generalStore != null) { return; } DBError error; var manager = DBDatastoreManager.Manager(DBAccountManager.SharedManager.LinkedAccount); if (string.IsNullOrEmpty(DatastoreId)) { _generalStore = manager.CreateDatastore(out error); Debug.WriteLine("Datastore created, take a note of this:", _generalStore.DatastoreId); _generalStore.SetRole("public", DBRole.Editor); } else { _generalStore = manager.OpenDatastore(DatastoreId, out error); } _generalStore.Sync(out error); // DeleteAll(); _generalStore.Sync(out error); _generalStore.AddObserver(_generalStore, () => { LoadData(); }); AutoUpdating = true; if (!_generalStore.Status.IsConnected) { LoadData(); } }
public void Init() { if (store != null) { return; } DBError error; store = DBDatastore.OpenDefaultStoreForAccount(DBAccountManager.SharedManager.LinkedAccount, out error); var sync = store.Sync(null); store.AddObserver(store, () => { LoadData(); }); AutoUpdating = true; store.BeginInvokeOnMainThread(() => { timer = NSTimer.CreateRepeatingScheduledTimer(1, () => { if (!AutoUpdating) { return; } store.Sync(null); }); }); }
//INICIALIZAMOS NUESTRO DATASTORE Y LE AGREGAMOS UN HADLE PARA IR VIENDO SI DESEAMOS EL ESTADO DE ESTA void InicializarDropboxDatastore(DBAccount account) { LogInfo("Inicializar DropboxDatastore"); if (DropboxDatastore == null || !DropboxDatastore.IsOpen || DropboxDatastore.Manager.IsShutDown) { //INICIALIAZAMOS DropboxDatastore DropboxDatastore = DBDatastore.OpenDefault(account ?? Account.LinkedAccount); DropboxDatastore.DatastoreChanged += HandleStoreChange; } //INVOCAMOS LA SINCRONIZACION DE DATASTORE DropboxDatastore.Sync(); }
public void DeleteAll() { var table = store.GetTable("monkeys"); DBError error; var results = table.Query(new NSDictionary(), out error); foreach (var result in results) { result.DeleteRecord(); } store.Sync(null); }
public void SetRace(string code) { if (!_raceDictionary.ContainsKey(code)) { return; } AutoUpdating = false; _race = _raceDictionary[code]; DBError error; if (_raceStore != null) { _raceStore.Close(); } var manager = DBDatastoreManager.Manager(DBAccountManager.SharedManager.LinkedAccount); _raceStore = manager.OpenDatastore(_race.DataStoreID, out error); _raceStore.Sync(out error); UpdateBoatInformation(); UpdateEventData(true); _raceStore.AddObserver(_raceStore, () => { UpdateEventData(false); // true will curtail the write each time }); AutoUpdating = true; }
void StartApp(DBAccount account = null) { AppDelegate.Current.DropboxStore.Init(account); DropboxDatastore = AppDelegate.Current.DropboxStore.store; Console.WriteLine("StartApp" + "..."); DropboxDatastore.Sync(); }
void ProccessResults(DBRecord[] results) { foreach (var result in results) { Shared.AddedLines.Add(result.ToLine()); } store.Sync(null); if (Shared.AddedLines.Count > 0) { store.BeginInvokeOnMainThread(() => { LinesUpdated(this, EventArgs.Empty); }); } }
public async Task SaveTodoItemAsync(TodoItem t) { await Task.Run(() => { var table = store.GetTable(tableName); var r = table.Get(t.ID); if (r == null) { table.Insert(t.ToDictionary()); } else { r.Update(t); } store.Sync(); return; }); }
public void Init(DBAccount account) { Console.WriteLine("Init"); if (store != null) { return; } store = DBDatastore.OpenDefault(account); store.Sync(); // store.AddObserver (store, () => { // Console.Write("AddObserver"); // // DBError error2; // store.Sync(out error2); // needed? // // var table = store.GetTable (tableName); // var results = table.Query (null, out error); // // Console.WriteLine(results.Length); // // ProccessResults (results); // }); // TIMER TO AUTOUPDATE AutoUpdating = true; #if __IOS__ store.BeginInvokeOnMainThread(() => { timer = NSTimer.CreateRepeatingScheduledTimer(2, () => { if (!AutoUpdating) { return; } //Console.WriteLine("AutoUpdating"); // SPAM DBError error3; store.Sync(out error3); }); }); #endif }
public void Init() { Console.Write("Init"); if (store != null) { return; } DBError error; store = DBDatastore.OpenDefaultStore(DBAccountManager.SharedManager.LinkedAccount, out error); DBError error1; var sync = store.Sync(out error1); store.AddObserver(store, () => { Console.Write("AddObserver"); DBError error2; store.Sync(out error2); // needed? var table = store.GetTable(tableName); var results = table.Query(null, out error); Console.WriteLine(results.Length); ProccessResults(results); }); // TIMER TO AUTOUPDATE AutoUpdating = true; store.BeginInvokeOnMainThread(() => { timer = NSTimer.CreateRepeatingScheduledTimer(2, () => { if (!AutoUpdating) { return; } //Console.WriteLine("AutoUpdating"); // SPAM DBError error3; store.Sync(out error3); }); }); }
public void Init (DBAccount account) { Console.WriteLine("Init"); if (store != null) return; store = DBDatastore.OpenDefault (account); store.Sync (); // store.AddObserver (store, () => { // Console.Write("AddObserver"); // // DBError error2; // store.Sync(out error2); // needed? // // var table = store.GetTable (tableName); // var results = table.Query (null, out error); // // Console.WriteLine(results.Length); // // ProccessResults (results); // }); // TIMER TO AUTOUPDATE AutoUpdating = true; #if __IOS__ store.BeginInvokeOnMainThread(()=>{ timer = NSTimer.CreateRepeatingScheduledTimer(2,()=>{ if(!AutoUpdating) return; //Console.WriteLine("AutoUpdating"); // SPAM DBError error3; store.Sync(out error3); }); }); #endif }
public void Init() { if (store != null) { return; } DBError error; store = DBDatastore.OpenDefaultStoreForAccount(DBAccountManager.SharedManager.LinkedAccount, out error); store.Sync(null); store.AddObserver(store, () => { LoadData(); }); }
void UpdateBoatInformation() { DBError error; bool updated = false; var path = DBPath.Root; foreach (DBFileInfo i in DBFilesystem.SharedFilesystem.ListFolder(path, out error)) { if (i.Path.Name.EndsWith(_race.Code + "-draw.json") && i.ModifiedTime > _race.BoatsUpdated) { Debug.WriteLine("need to update boats: " + i.Path.ToString()); string json = DBFilesystem.SharedFilesystem.OpenFile(i.Path, out error).ReadString(out error); try { var boats = JsonConvert.DeserializeObject <List <JsonEntry> >(json); if (boats != null && boats.Count > 0) { _boatDictionary = boats .Select(b => new BoatFactory() .SetNumber(b.StartNumber) .SetName(b.Name) .SetCategory(b.Category) .SetScratched(b.Scratched) .Create() ) .ToDictionary(b => b.Number, b => b); _race.BoatsUpdated = DateTime.Now; updated = true; } } catch (Exception ex) { updated = false; } } } var table = _raceStore.GetTable("boats"); if (updated) { DBRecord record; foreach (var kvp in _boatDictionary) { var bfields = kvp.Value.ToDictionary(); if (_boatRecords.TryGetValue(kvp.Key, out record)) { record.Update(bfields); } else { table.GetOrInsertRecord(kvp.Key.ToString(), bfields, false, out error); } } _raceStore.Sync(out error); _generalStore.Sync(out error); } var results = table.Query(null, out error); _boatRecords = results.ToDictionary(x => Int32.Parse(x.Fields["StartNumber"].ToString()), x => x); foreach (var result in results) { int start = Int32.Parse(result.Fields["StartNumber"].ToString()); IBoat boat; _boatDictionary.TryGetValue(start, out boat); if (boat == null) { boat = result.ToBoat(); _boatDictionary.Add(start, boat); } // todo - need to make sure that updates to the boat list are reflected here. } // race.BoatRecords = results.ToDictionary(x => new Tuple<int, string, string>(x.Fields[" }
void StartApp (DBAccount account = null) { AppDelegate.Current.DropboxStore.Init (account); DropboxDatastore = AppDelegate.Current.DropboxStore.store; Console.WriteLine("StartApp" + "..."); DropboxDatastore.Sync(); }