private async void RefreshDataObjectsSync() { var dataObjects = await _syncServer.DataObjects.Get(new DataObjectRichQueryRequest() { ProjectId = ProjectId, CollectionId = CollectionId, Folder = FolderName }); DataObjectsSync.Clear(); foreach (var dataObject in dataObjects) { DataObjectsSync.Add(dataObject); } }
private async void Connect() { //Login _syncServer = new SyncServer(this.InstanceName, this.ApiKey); var login = await _syncServer.Start(); this.IsConnected = login.WasSuccessful; //Add subscriptions. if ((await _syncServer.RealTimeSync.GetSubscriptions()).Any(s => s.Type == "Project" && s.Id == this.ProjectId) == false) { await _syncServer.RealTimeSync.SubscribeProject(ProjectId); } //React on subscriptions using reactive extensions //Subscribe to new data notifications _syncServer.NewDataObservable.SubscribeOnDispatcher().Subscribe(n => { App.Current.Dispatcher.Invoke(() => DataObjectsSync.Add(n.Data)); }); _syncServer.DeleteDataObservable.SubscribeOnDispatcher().Subscribe(n => { App.Current.Dispatcher.Invoke(() => { RefreshDataObjectsSync(); }); }); //Create Http connection object _syncanoClient = new Syncano.Net.SyncanoClient(this.InstanceName, this.ApiKey); //Load existing objects RefreshDataObjectsHttp(); RefreshDataObjectsSync(); }