async Task SynchronizeResponsesAsync(string questionId) { if (!CrossConnectivity.Current.IsConnected) { return; } try { await responseTable.PullAsync("syncResponses" + questionId, responseTable.Where(r => r.SurveyQuestionId == questionId)); } catch (MobileServicePushFailedException ex) { if (ex.PushResult != null) { foreach (var result in ex.PushResult.Errors) { await ResolveError(result); } } } catch (Exception ex) { // TODO: handle error Debug.WriteLine("Got exception: {0}", ex.Message); } }
public async Task <ObservableCollection <TodoItem> > GetTodoItemsAsync(bool syncItems = false) { try { if (syncItems) { await this.SyncAsync(); } IEnumerable <TodoItem> items = await _todoTable .Where(todoItem => !todoItem.Done) .ToEnumerableAsync(); return(new ObservableCollection <TodoItem>(items)); } catch (MobileServiceInvalidOperationException msioe) { Debug.WriteLine(@"Invalid sync operation: {0}", msioe.Message); IEnumerable <TodoItem> items = await _todoTable .Where(todoItem => !todoItem.Done) .ToEnumerableAsync(); return(new ObservableCollection <TodoItem>(items)); } catch (Exception e) { Debug.WriteLine(@"Sync error: {0}", e.Message); IEnumerable <TodoItem> items = await _todoTable .Where(todoItem => !todoItem.Done) .ToEnumerableAsync(); return(new ObservableCollection <TodoItem>(items)); } }
public async Task <IEnumerable <Scores> > GetScores(GameType gameType) { await Initialize(); await SyncScores(); return(await table.Where(a => a.GameType == (int)gameType).OrderByDescending(s => s.Score).ToEnumerableAsync()); }
public async Task <string> LoadCategories() { await Initialize(); await SyncBookings(); string answer = "false"; //System.Diagnostics.Debug.WriteLine((await App.MobileService.GetTable<User>().LookupAsync(1) as User).firstName); //User item = await coffeeTable.LookupAsync("6cc1aca348714a26af9c1d9d1757d0c2"); try { List <Shop_Two> item = await shopz .Where(todoItem => todoItem.ProductName != null) .ToListAsync(); CategoriesPage.ListViewItems2.Clear(); foreach (var x in item) { Shop_Two one = new Shop_Two(x.ProductName); Shop.ListViewItems2.Add(one); answer = "true"; } return(answer); } catch (Exception er) { await DisplayAlert("Alert", "da error: " + er, "Ok"); return(answer); } }
private async void 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 .Where(todoItem => todoItem.Complete == false) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { MessageBox.Show(exception.Message, "Error loading items"); } else { ListItems.ItemsSource = items; } }
// For normal users, get only their entered Cases public async Task <IEnumerable <CaseInfo> > GetEventCases(string eventName, string volName) { //Initialize await Initialize(); return(await caseInfoTable.Where(e => (e.EventName == eventName) && (e.VolunteerName == volName)).ToEnumerableAsync());; }
public async Task <List <Volunteering> > GetDetailAsync(string name) { try { #if OFFLINE_SYNC_ENABLED if (syncItems) { await this.SyncAsync(); } #endif List <Volunteering> items = await volunteeringTable .Where(couItem => couItem.Name.Trim().ToLower() == name.ToLower().Trim()) .ToListAsync(); return(items); } 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 <Trip> > LoadTripsWithAttractionsAsync() { try { await InitializeAsync(); var trips = await tripTable.ToListAsync(); foreach (var trip in trips) { trip.Sights = new List <Sight>(await sightTable.Where(a => a.TripId == trip.Id).ToCollectionAsync()); } return(trips); } catch (Exception ex) { var errorString = "Load failed: " + ex.Message + "\n\nIf you are still in an offline scenario, " + "you can try your Pull again when connected with your Mobile Service."; await ShowError(errorString); throw; } }
public async Task <ObservableCollection <UserAccount> > GetUserBasedOnRoleAsync(bool syncItems = false, string searchRole = "Members") { try { #if OFFLINE_SYNC_ENABLED if (syncItems) { await this.SyncAsync(); } #endif IEnumerable <UserAccount> items; if (string.IsNullOrEmpty(searchRole)) { items = await userAccount .Where(userAccount => !userAccount.Deleted) .ToEnumerableAsync(); } else { items = await userAccount .Where(userAccount => !userAccount.Deleted && userAccount.Role == searchRole) .ToEnumerableAsync(); } return(new ObservableCollection <UserAccount>(items)); } catch (MobileServiceInvalidOperationException msioe) { Debug.WriteLine("Invalid sync operation: {0}", new[] { msioe.Message }); } catch (Exception e) { Debug.WriteLine("Sync error: {0}", new[] { e.Message }); } return(null); }
public async Task <ObservableCollection <Course> > GetEmailClassAsync(string email) { try { #if OFFLINE_SYNC_ENABLED if (syncItems) { await this.SyncAsync(); } #endif IEnumerable <Course> items = await courseTable .Where(couItem => couItem.Email == email) .ToEnumerableAsync(); return(new ObservableCollection <Course>(items)); } 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 <Job2> > GetDetailAsync(string post, string name) { try { #if OFFLINE_SYNC_ENABLED if (syncItems) { await this.SyncAsync(); } #endif List <Job2> items = await job2Table .Where(couItem => couItem.Postcode == post && couItem.Name == name) .ToListAsync(); return(items); } 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 <ObservableCollection <Mentor> > GetPeersAsync(string skill) { try { #if OFFLINE_SYNC_ENABLED if (syncItems) { await this.SyncAsync(); } #endif IEnumerable <Mentor> items = await mentorTable .Where(mentorItem => mentorItem.Skill == skill) .ToEnumerableAsync(); return(new ObservableCollection <Mentor>(items)); } 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 CompleteJobAsync(Job job) { job.Status = Job.CompleteStatus; await jobTable.UpdateAsync(job); var inprogress = await jobTable .Where(j => j.Status == Job.InProgressStatus) .Take(1) .ToListAsync(); if (inprogress.Count == 0) { var nextJob = (await jobTable .Where(j => j.Status == Job.PendingStatus) .Take(1) .ToListAsync() ).FirstOrDefault(); if (nextJob != null) { nextJob.Status = Job.InProgressStatus; await jobTable.UpdateAsync(nextJob); } } }
public async Task <Platillos> ObtenerPlatillo(string id) { await Initialize(); await SyncPlatillos(); return((await tablaPlatillos.Where(a => a.Id == id).Take(1).ToEnumerableAsync()).FirstOrDefault()); }
/***************************************************************** * METHOD TO CHECK IF A PPSN IS ALREADY IN DATABASE ****************************************************************/ public async Task <bool> CheckPPSN(string PPSN) { await Intialize(); await SyncPersons(); bool answer = false; //System.Diagnostics.Debug.WriteLine((await App.MobileService.GetTable<User>().LookupAsync(1) as User).firstName); //User item = await coffeeTable.LookupAsync("6cc1aca348714a26af9c1d9d1757d0c2"); List <Person> item = await personTable .Where(todoItem => todoItem.PPSN == PPSN) .ToListAsync(); // DisplayAlert("ITEM CONTENT",item.ToString(),"Cancel"); foreach (var x in item) { string daName = x.PPSN; if (item.Count() > 0) { answer = true; break; } else { answer = false; break; } } return(answer); }
//Get Messages public async Task <ObservableCollection <TodoItem> > GetTodoItemsAsync(bool syncItems = false) { try { #if OFFLINE_SYNC_ENABLED if (syncItems) { await this.SyncAsync(); } #endif IEnumerable <TodoItem> items = await todoTable .Where(todoItem => !todoItem.Done && todoItem.Over > DateTime.Now) .ToEnumerableAsync(); return(new ObservableCollection <TodoItem>(items)); } catch (MobileServiceInvalidOperationException msioe) { Debug.WriteLine("Invalid sync operation: {0}", new[] { msioe.Message }); } catch (Exception e) { Debug.WriteLine("Sync error: {0}", new[] { e.Message }); } return(null); }
public async Task <SurveyResponse> GetResponseForSurveyAsync(string questionId, string name) { await InitializeAsync(); return((await responseTable.Where(r => r.SurveyQuestionId == questionId && r.Name == name) .ToEnumerableAsync()).FirstOrDefault()); }
//This method can be improved, need to think of a better way public async Task <Boolean> CheckAndSave(List <CalendarAttendance> attendances) //This is to prevent checking users again in the same date { try { bool verify = true; foreach (CalendarAttendance i in attendances) { IEnumerable <CalendarAttendance> check; check = await calendarAttendance.Where (calendarAttendance => calendarAttendance.DateTime == i.DateTime && calendarAttendance.UserAccountID == i.UserAccountID).ToEnumerableAsync(); if (check.Count() != 0) //Means that it has been saved before. Return to tell them to check { verify = false; return(verify); } } foreach (CalendarAttendance a in attendances) { await SaveTaskAsync(a); } return(verify); } catch (Exception e) { if (e.InnerException != null) { Debug.WriteLine("Inner Exception: " + e.InnerException); } Debug.WriteLine("Error: " + e); return(false); } }
/// <summary> /// Syncs Preset Experiences with mobile api /// </summary> /// <returns>System.Theading.Task.Tasks</returns> public async Task <SyncState> SyncPresetExperiences() { string emptyGuid = Guid.Empty.ToString(); SyncState state = SyncState.Offline; if (CrossConnectivity.Current.IsConnected) { try { //TODO: Verify requirement of where await experienceTable.PullAsync(Guid.NewGuid().ToString(), experienceTable.Where(w => w.ProfileId == emptyGuid)); state = SyncState.Complete; } catch (MobileServicePushFailedException exc) { await SimpleConflictResolution(exc); state = SyncState.CompleteWithConflicts; } catch (Exception ex) { var message = ex.Message; state = SyncState.Error; } } return(state); }
public async Task <ObservableCollection <TodoItem> > getChatfromAzure(string Quesryid, string Retailerid) { IEnumerable <TodoItem> items = await todoTable .Where(x => x.QueryID == Quesryid && x.RetailerID == Retailerid) .ToEnumerableAsync(); return(new ObservableCollection <TodoItem>(items)); }
public async Task <List <ExpenseReport> > GetAllExpenseReportsForUserAsync(string id) { await SyncAsync(); //Assume each person has less than 50 reports to display return(await expenseReportTable.Where(r => r.ReportOwner == id).Take(50).ToListAsync()); }
public async Task <bool> CheckIfExists(FoodEnteredTable food) { await SyncAsync(true); var check = await azureSyncTable.Where(x => x.FoodID == food.FoodID).ToListAsync(); return(check.Any()); }
public async Task <bool> CheckIfExists(GoalTable goal) { await SyncAsync(true); var check = await azureSyncTable.Where(x => x.Id == goal.Id).ToListAsync(); return(check.Any()); }
public async Task <bool> CheckIfExists(Req location) { await SyncAsync(true); var locations = await azureSyncTable.Where(x => x.Id == location.Id).ToListAsync(); return(locations.Any()); }
public async Task <bool> CheckIfExists(Location location) { await SyncAsync(true); var locations = await azureSyncTable.Where(x => x.LocalizedName == location.LocalizedName || x.Key == location.Key).ToListAsync(); return(locations.Any()); }
public async Task <IEnumerable <Acquaintance> > GetItems() { return(await Execute <IEnumerable <Acquaintance> >(async() => { await SyncItemsAsync().ConfigureAwait(false); return await _AcquaintanceTable.Where(x => x.DataPartitionId == _DataPartitionId).OrderBy(x => x.LastName).ToEnumerableAsync().ConfigureAwait(false); }, new List <Acquaintance>()).ConfigureAwait(false)); }
public async Task <bool> CheckIfExists(MeetupsTable meetUp) { await SyncAsync(true); var check = await azureSyncTable.Where(x => x.Id == meetUp.Id).ToListAsync(); return(check.Any()); }
public async Task <bool> CheckIfExists(Users UserReq, string currentUser) { await SyncAsync(currentUser, true); var requests = await azureSyncTable.Where(x => x.ReqTo == UserReq.ReqTo && x.ReqFrom == currentUser).ToListAsync(); return(requests.Any()); }
public async Task <bool> CheckIfExists(ProviderDetails provider) { await SyncAsync(true); var providers = await azureSyncTable.Where(x => x.Name == provider.Name || x.Address == provider.Address).ToListAsync(); return(providers.Any()); }
public async Task <DataStoreSyncResult <T> > GetItemsAsync <T>(bool syncItems = false, bool includeNavigationProperties = false) where T : class, ISyncEntity { try { var result = new DataStoreSyncResult <T>(); if (syncItems) { result.Code = await SyncAsync(); } IEnumerable <T> items = null; if (typeof(T).Equals(typeof(Tag))) { items = (IEnumerable <T>)(await _tagTable.ToEnumerableAsync()); } else if (typeof(T).Equals(typeof(Contact))) { items = (IEnumerable <T>)(await _contactTable.ToEnumerableAsync()); } else if (typeof(T).Equals(typeof(Transaction))) { if (includeNavigationProperties) { var transactions = await _transactionTable.ToListAsync(); var contactKeys = transactions.GroupBy(p => p.ContactId).Select(p => p.Key); var contacts = await _contactTable.Where(p => contactKeys.Contains(p.Id)).ToEnumerableAsync(); foreach (var transaction in transactions) { transaction.Contact = contacts.Single(p => p.Id == transaction.ContactId); } items = (IEnumerable <T>)transactions; } else { items = (IEnumerable <T>)(await _transactionTable.ToEnumerableAsync()); } } if (result.Code == DataStoreSyncCode.None) { result.Code = DataStoreSyncCode.Success; } result.Items = new ObservableCollection <T>(items); return(result); } catch (MobileServiceInvalidOperationException msioe) { Debug.WriteLine($"Invalid sync operation: {msioe.Message}"); } catch (Exception ex) { Debug.WriteLine($"Sync Error: {ex.Message}"); } return(null); }