private async Task RefreshTodoItems() { MobileServiceInvalidOperationException exception = null; try { // This code refreshes the entries in the list view by querying the TodoItems table. // The query excludes completed TodoItems. items = await todoTable .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } else { ListItems.ItemsSource = items; this.ButtonSave.IsEnabled = true; } }
public async Task <ObservableCollection <SocietyPlayer> > GetSocietyPlayers() { await Initialize(); return(await tableSocietyPlayer .ToCollectionAsync()); }
public async Task <ObservableCollection <ProviderDetails> > GetAll() { await SyncAsync(true); ObservableCollection <ProviderDetails> theCollection = new ObservableCollection <ProviderDetails>(); theCollection = await azureSyncTable.ToCollectionAsync(); return(theCollection); }
private async Task SyncAsync() { string errorString = null; try { await client.SyncContext.PushAsync(); await sightTable.PushFileChangesAsync(); await sightFileTable.PushFileChangesAsync(); await tripTable.PullAsync("tripItems", tripTable.CreateQuery()); foreach (var trip in await tripTable.ToCollectionAsync()) { await sightTable.PullAsync("attractionItems", sightTable.CreateQuery().Where(s => s.TripId == trip.Id)); } foreach (var sight in await sightTable.ToCollectionAsync()) { await sightFileTable.PullAsync("attractionFileItems", sightFileTable.CreateQuery().Where(sf => sf.SightId == sight.Id)); } } catch (MobileServicePushFailedException ex) { errorString = "Push failed because of sync errors. You may be offline.\nMessage: " + ex.Message + "\nPushResult.Status: " + ex.PushResult.Status; } catch (Exception ex) { errorString = "Pull failed: " + ex.Message + "\n\nIf you are still in an offline scenario, " + "you can try your Pull again when connected with your Mobile Service."; } if (errorString != null) { await ShowError(errorString); } }
private async Task RefreshTodoItems() { MobileServiceInvalidOperationException exception = null; try { // This code refreshes the entries in the list view by querying the TodoItems table. // The query excludes completed TodoItems. data = await weatherTable .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading data").ShowAsync(); } }
public async Task <ObservableCollection <DatapointContainer> > GetDatapointContainersAsync(bool syncItems = false) { try { #if OFFLINE_SYNC_ENABLED if (syncItems) { await this.SyncAsync(); } #endif ICollection <ContainerDataPoint> items = await containerDataPointTable //.Where(pcdp => pcdp.ArchivedAt == null) .ToCollectionAsync(); var allDataPoints = items; // select all the case names var containerElements = allDataPoints.Where(pcdp => pcdp.DataPointName == DataPointDefinitions.CASE_NAME.DataPointName); List <DatapointContainer> containers = new List <DatapointContainer>(); foreach (var pce in containerElements) { DatapointContainer container = new DatapointContainer(); container.ContainerDataPoints = allDataPoints.Where((pcdp => pcdp.ParentId == pce.Id || pcdp == pce)).ToList(); containers.Add(container); } return(new ObservableCollection <DatapointContainer>(containers)); } catch (MobileServiceInvalidOperationException msioe) { Debug.WriteLine(@"Invalid sync operation: {0}", msioe.Message); } catch (Exception e) { Debug.WriteLine(@"Sync error: {0}", e.Message); } return(null); }
public async Task <List <TodoItem> > RefreshTodoItemsAsync() { MobileServiceInvalidOperationException exception = null; MobileServiceCollection <TodoItem, TodoItem> items = null; try { // This code refreshes the entries in the list view by querying the TodoItems table. // The query excludes completed TodoItems items = await todoTable.ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } return(items.ToList()); }
/*********************************************************************/ /* Sync the data */ /*********************************************************************/ public async Task SyncAsync(bool pullData = false) { /* Local token is being used to make calls for "personal" data */ /* Try to sync the local store with the remote database */ try { await _client.SyncContext.PushAsync(); if (pullData) { /* Pull down student related tables */ await _assignmentTable.PullAsync("allAssignments", _assignmentTable.Where(assignment => assignment.StudentId == CurrentUser)); await _courseTable.PullAsync("allCourses", _courseTable.Where(course => course.StudentId == CurrentUser)); await _studentTable.PullAsync("currentStudent", _studentTable.Where(student => student.Id == CurrentUser)); await _attendanceTable.PullAsync("AllAttendanceViolations", _attendanceTable.Where(attendance => attendance.StudentId == CurrentUser)); await _offenseTable.PullAsync("AllStudentCourtOffenses", _offenseTable.Where(offense => offense.StudentId == CurrentUser)); await _eventSignupTable.PullAsync("SignedUpevents", _eventSignupTable.Where(eventSignup => eventSignup.StudentId == CurrentUser)); await _studentEventTable.PullAsync("allStudentEvents", _studentEventTable.Where(studentEvent => studentEvent.StudentId == CurrentUser)); await _offenseCategoryTable.PullAsync("AllStudentCourtOffenseCategories", _offenseCategoryTable.Where(offense => offense.StudentId == CurrentUser)); await _professorTable.PullAsync("allProfessorTimes", _professorTable.Where(professor => professor.StudentId == CurrentUser)); PullOptions data = new PullOptions { MaxPageSize = 150 }; await _fourWindsTable.PullAsync("allFourWindsItems", _fourWindsTable.CreateQuery(), data); await _varsityTable.PullAsync("allVarsityItems", _varsityTable.CreateQuery()); await _grabAndGoTable.PullAsync("allGrabAndGoItems", _grabAndGoTable.CreateQuery()); await _eventsTable.PullAsync("allEvents", _eventsTable.CreateQuery()); var list = await _studentEventTable.ToCollectionAsync(); Debug.WriteLine($"\n\n\nStudent events: {list.Count}"); } } catch (Exception ex) { Debug.WriteLine($"{ex.Message} in SyncAsync"); Debug.WriteLine("Please check your Internet connection!"); } }