public Task LoadData()
        {
            var task = Task.Factory.StartNew(() => {
                var table     = store.GetTable("monkeys");
                DBError error = new DBError();
                var results   = table.Query(null, out error);

                if (results.Length == 0)
                {
                    populateMonkeys();
                    return;
                }
                ProccessResults(results);
            });

            return(task);
        }
        // urgent - this will never be called if we're offline - we do need to be able to read from the offline version
        public void LoadData()
        {
            new NSObject().BeginInvokeOnMainThread(() => {
                if (!AutoUpdating)
                {
                    return;
                }
                AutoUpdating = false;
                var table    = _generalStore.GetTable("races");
                DBError error;
                var results = table.Query(null, out error);

                ProcessResults(results);

                AutoUpdating = true;
            });
        }
Exemple #3
0
        public async Task SaveTodoItemAsync(TodoItem t)
        {
            DBError error;

            var table = store.GetTable(tableName);
            var r     = table.GetRecord(t.ID, out error);

            if (r == null)
            {
                table.Insert(t.ToDictionary());
            }
            else
            {
                r.Update(t);
            }

            await store.SyncAsync();
        }
Exemple #4
0
        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 Update(Task t)
        {
            DBError error;

            var table = store.GetTable(tableName);
            var r     = table.GetRecord(t.id, out error);

            if (r == null)
            {
                table.Insert(t.ToDictionary());
            }
            else
            {
                r.Update(t);
            }

            store.SyncAsync(null);
        }
        public Task LoadData()
        {
            var task = Task.Factory.StartNew(() => {
                var table     = store.GetTable("lines");
                DBError error = new DBError();

                var results = table.Query(null, out error);
                if (results.Length != 0)
                {
                    ProccessResults(results);
                }
                else
                {
                    store.BeginInvokeOnMainThread(() => {
                        ClearLines(this, EventArgs.Empty);
                    });
                }
            });

            return(task);
        }
        public void Dump()
        {
            new NSObject().BeginInvokeOnMainThread(() => {
                if (!AutoUpdating)
                {
                    return;
                }
                AutoUpdating = false;
                var table    = _raceStore.GetTable("sequenceitems");
                DBError error;
                // todo - will probably want to filter out only the items from the race we're currently interested in
                var results = table.Query(null, out error);

                var records = results
                              .ToDictionary(
                    x => new Tuple <string, string, int>(x.Fields["Name"].ToString(), x.Fields["Token"].ToString(), ((NSNumber)x.Fields["StartNumber"]).IntValue),
                    x => x);
                var dict = records.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToItem(kvp.Key.Item3 <= 0 ? new BoatFactory().SetNumber(kvp.Key.Item3).Create() : _boatDictionary[kvp.Key.Item3]));

                WriteDropboxFile(records.Select(r => new Tuple <string, string>(r.Key.Item1, r.Key.Item2)).Distinct(), dict);

                AutoUpdating = true;
            });
        }
Exemple #8
0
        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);
                });
            });
        }