public async Task <int> GetLastIdUser() { await Initialize(); var User = await userTable.ToListAsync(); return(int.Parse(User.Last().Id)); }
public static List <DefaultTrainingProgram> getDefaultTrainingPrograms() { IMobileServiceTable <DefaultTrainingProgram> defaultTrainingProgramsTable = MobileService.GetTable <DefaultTrainingProgram>(); defaultTrainingProgramsTable.ToListAsync().Wait(); defaultTrainingPrograms = defaultTrainingProgramsTable.ToListAsync().Result; defaultTrainingPrograms = defaultTrainingPrograms.FindAll(prog => prog.Id.Equals("008c9cd1-bb1f-4058-a633-a7ad383bafe1") || prog.Id.Equals("0480b175-b37d-4da3-b6e9-44b6ca2586ad") || prog.Id.Equals("049133ab-2753-41cc-9080-79a31fe47c84") || prog.Id.Equals("099f0d69-a823-4956-b12f-d6e747050c04") || prog.Id.Equals("179bb769-a8c1-40f3-92cd-c82fe29da2ad") || prog.Id.Equals("19a5196e-2eb5-412b-be32-c3310895161f")); UserWorkoutStatisticsTable.ToListAsync().Wait(); UserWorkoutStatistics = UserWorkoutStatisticsTable.ToListAsync().Result; return(defaultTrainingPrograms); }
private async Task InitializeCrashListAsync() { Debug.Log("Downloading crash data from Azure..."); for (int i = 0; i < numberOfAttempts; i++) { try { Debug.Log("Connecting... attempt " + (i + 1)); crashesFromServer = await crashesTable.ToListAsync(); Debug.Log("Done downloading."); return; } catch (System.Exception e) { Debug.Log("Error connecting: " + e.Message); } if (i == numberOfAttempts - 1) { Debug.Log("Connection failed. Check logs, try again later."); } else { await Task.Delay(500); } } }
/// <summary> /// Get the list of characters from an embedded JSON file, including their child entities. /// </summary> /// <returns>Array of Character objects</returns> /**private async Task<Character[]> ReadCharactersFromFile() * { * var assembly = typeof(CharacterService).GetTypeInfo().Assembly; * Stream stream = assembly.GetManifestResourceStream(Constants.CharactersFilename); * string text; * * using (var reader = new System.IO.StreamReader(stream)) * { * text = await reader.ReadToEndAsync(); * } * * var characters = JsonConvert.DeserializeObject<Character[]>(text); * return characters; * }*/ private async Task <List <Character> > ReadCharactersFromServer() { IMobileServiceTable <Character> CharacterTable = App.Client.GetTable <Character>(); var characters = await CharacterTable.ToListAsync(); return(characters); }
private async Task UpdateAdmina(string email) { await klijentTabela.ToListAsync().ContinueWith(adminTask => { List <Klijent> klijenti = adminTask.Result; foreach (Klijent k in klijenti) { if (k.email.Equals(email)) { k.administrator = true; klijentTabela.UpdateAsync(k); } } }, TaskScheduler.FromCurrentSynchronizationContext()); }
private async Task InitList() { if (drugname.Equals("")) { var items = await AdressesTable.ToListAsync(); this.annots = new List <AnnotationForMap>(); foreach (var item in items) { annots.Add(new AnnotationForMap() { Title = item.Adress, Coordinate = new CLLocationCoordinate2D(item.Xvalue, item.Yvalue), available = true }); } } else { var paramDictionary = new Dictionary <string, string>(); paramDictionary.Add("DrugName", drugname); var items = await MobileService.InvokeApiAsync <List <Adresses> >("JoinForAdresses", System.Net.Http.HttpMethod.Get, paramDictionary); this.annots = new List <AnnotationForMap>(); foreach (var item in items) { annots.Add(new AnnotationForMap() { Title = item.Adress, Coordinate = new CLLocationCoordinate2D(item.Xvalue, item.Yvalue), available = item.Available }); } } }
private async Task BindListview(MobileServiceClient client) { IMobileServiceTable <Character> CharacterTable = client.GetTable <Character>(); var characters = await CharacterTable.ToListAsync(); var movies = characters.SelectMany(x => from item in x.Appearances select new { Id = item.Id, MovieName = item.Title } ).Distinct().ToList(); List <MovieList> list = new List <MovieList>(); foreach (var m in movies) { var c = characters.Where(x => x.Appearances.Select(p => p.Id).Contains(m.Id)).ToList(); if (c != null) { var mg = new MovieList(); foreach (var item in c) { mg.Characters.Add(item); } mg.MovieName = m.MovieName; list.Add(mg); } } ListOfMovies = list; uiListviewMovies.ItemsSource = ListOfMovies; uiListviewMovies.IsGroupingEnabled = true; }
/// <summary> /// Loads the changeable application settings (accent color and background image) /// from Windows Azure Mobile Service /// </summary> private async void LoadSettingsAsync() { List <Setting> settings = null; try { settings = await settingsTable.ToListAsync(); } catch (MobileServiceInvalidOperationException ex) { HandleError(ex); } catch (HttpRequestException ex1) { // If the sample hasn't been configured properly and the mobile service url and key isn't set in App.xaml.cs // then HttpRequestException will be thrown. ShowError(ex1.Message); } if (settings == null || settings.Count == 0) { // no settings - default color. AccentColor = "#63a9eb"; return; } AccentColor = settings.Single(s => s.Key == "accentColor").Value; BackgroundImage = settings.Single(s => s.Key == "backgroundImage").Value; }
private async void LoadSkills() { var skillList = await skillTable.ToListAsync(); skillListView.ItemsSource = skillList; LoadUserSkills(); }
public async Task <ObservableCollection <EventInvites> > Get() { var results = await mobileServiceTable.ToListAsync(); items = new ObservableCollection <EventInvites>(results.ToList()); return(items); }
private async void ucitajProjekte() { IMobileServiceTable <Projekti> projectsTable = MobileService.GetTable <Projekti>(); var projects = await projectsTable.ToListAsync(); for (int i = 0; i < projects.Count; i++) { if (projects.ElementAt(i).obrisan == false) { List <Korisnik> listaKolaboratora = new List <Korisnik>(); String[] idKolaboratora = new String[0]; if (projects.ElementAt(i).kolaboratori_id != null) { projects.ElementAt(i).kolaboratori_id.Split(','); for (int j = 0; j < idKolaboratora.Count(); j++) { Korisnik kor = BatNet.Korisnici.Find(k => k.ID.Equals(idKolaboratora[j])); if (kor != null) { listaKolaboratora.Add(kor); } } Korisnik autor = BatNet.Korisnici.Find(k => k.ID.Equals(projects.ElementAt(i).autor_id)); BatNet.Projekti.Add(new Projekat(projects.ElementAt(i).id, projects.ElementAt(i).naslov, autor, listaKolaboratora)); autor.Projekti.Add(BatNet.Projekti.Last()); foreach (Korisnik k in listaKolaboratora) { k.Projekti.Add(BatNet.Projekti.Last()); } } } } }
private async Task GetCategoryData() { // Display the progress wheel when getting data ProgressRing LoginProgress = new ProgressRing(); LoginProgress.HorizontalAlignment = HorizontalAlignment.Center; LoginProgress.VerticalAlignment = VerticalAlignment.Center; ContentRoot.Children.Add(LoginProgress); LoginProgress.IsActive = true; // Get the list of category names from the database to display in the choice box List <string> CategoryNames = new List <string>(); IMobileServiceTable <Category> CategoryTable = App.alltheairgeadClient.GetTable <Category>(); Categories = await CategoryTable.ToListAsync(); // Add each to a list of names to set as the item source for the box foreach (Category i in Categories) { CategoryNames.Add(i.id); } CategoryBox.ItemsSource = CategoryNames; // Disable the progress wheel LoginProgress.IsActive = false; ContentRoot.Children.Remove(LoginProgress); }
private async void Button_Click(object sender, RoutedEventArgs e) { dataList.Clear(); AvgTemp = 0; ttlCoins = 0; var client = new MobileServiceClient("https://iotwater.azurewebsites.net"); IMobileServiceTable <logs> itemTable = client.GetTable <logs>(); List <logs> items = await itemTable.ToListAsync(); List <logs> dt = new List <logs>(); foreach (logs it in items) { DataTest d = new DataTest(); d.Coins = it.coins.ToString() + " Coins"; d.Temp = "Temp: " + it.temperature;; d.Time = "Time: " + it.createdat.Remove(16); ttlCoins = ttlCoins + int.Parse(it.coins.ToString()); totalCoins = (ttlCoins + int.Parse(it.coins.ToString())).ToString() + " Coins"; AvgTemp = AvgTemp + it.temperature; dataList.Add(d); } avgTemp = AvgTemp / dataList.Count + " C"; coinsBlock.Text = ttlCoins.ToString(); tempBlock.Text = avgTemp; totalCoinBlock.Text = (ttlCoins).ToString(); listView.ItemsSource = dataList; dataList.CollectionChanged += DataList_CollectionChanged; }
private async void dodajKontakte() { IMobileServiceTable <Korisnici> usersTable = MobileService.GetTable <Korisnici>(); var users = await usersTable.ToListAsync(); for (int i = 0; i < users.Count; i++) { if (users.ElementAt(i).obrisan == false) { List <Korisnik> listaKontakata = new List <Korisnik>(); String[] idKontakata = new String[0]; if (users.ElementAt(i).kontakti_id != null) { idKontakata = users.ElementAt(i).kontakti_id.Split(','); for (int j = 0; j < idKontakata.Count(); j++) { Korisnik kor = BatNet.Korisnici.Find(k => k.ID.Equals(idKontakata[j])); if (kor != null) { listaKontakata.Add(kor); } } Korisnik kori = BatNet.Korisnici.Find(x => x.ID.Equals(users.ElementAt(i).id)); kori.Kontakti = listaKontakata; } } } }
public async void dodavanjeKorisnika(object parametar) { if ((Korisnik.Opcija12Mjeseci || Korisnik.Opcija1Mjesec || Korisnik.Opcija6Mjeseci) && Korisnik.Errors.Errors.Count == 0) { try { KorisnikTabela obj = dajObjekat(Korisnik); List <KorisnikTabela> lista = await userTableObj.ToListAsync(); if (lista.Count() == 0) { obj.priv = "Admin"; obj.admin = true; } await userTableObj.InsertAsync(obj); Messenger.prikaziPoruku("Korisnik je uspjesno registrovan!"); Parent.NavigationService.GoBack(); } catch (Exception ex) { Messenger.prikaziPoruku("Izuzetak:" + ex.Message); } } else { Messenger.prikaziPoruku("Niste popunili sva polja ili odabrali potrebne opcije."); } }
protected override async void OnAppearing() { Userlar = await UserTable.ToListAsync(); isim.Text = Userlar[Userf.whichUser].Name; base.OnAppearing(); }
public static IList <Task> GetTasks() { var asyncTask = table.ToListAsync(); asyncTask.Wait(); return(asyncTask.Result); }
//gets and returns a list of schools from DB public async Task <List <School> > getSchools() { IMobileServiceTable <School> schoolTable = MobileService.GetTable <School>(); List <School> schoolsFromDB = await schoolTable.ToListAsync(); return(schoolsFromDB); }
// Updates the entries of the list view by requerying the Azure database table. The query // returns all valid results for a user (by authenticated ID). For additional details about // configuring the database read script, see the readme file provided with this sample. private async void RefreshVoiceNotesAsync() { //Verify network connectivity is available before attempting authentication if (!NetworkInterface.GetIsNetworkAvailable()) { MessageBox.Show("Network connection unavailable. Please close app, verify your network connection, and try again."); return; } bool retrieved = true; //Attempt to retrieve the latest Azure database table information, updating //the UI if results are retrieved. List <VoiceNote> result = new List <VoiceNote>(); try { result = await noteTable.ToListAsync(); } catch (MobileServiceInvalidOperationException) { retrieved = false; } if (retrieved) { notes = new ObservableCollection <VoiceNote>(result); NoteList.ItemsSource = notes; } else { MessageBox.Show("Error retrieving data. Retry login."); } }
public async Task <ICollection <T> > ReadAllItemsAsync() { var t = await _table.ToListAsync(); Debug.WriteLine("got the data"); return(t); }
//public void StartInsertDataTask(TableItem item) //{ // if (insert.Status != TaskStatus.Running) // { // //data.S // if (insert.Status == TaskStatus.RanToCompletion) // insert = new Task(InsertData(item)); // data.Start(); // } // insert.Wait(); //} public async void GetData() { bool error = false; string str = ""; //mainTable = App.MobileService.GetTable<TableItem>(); //items = await mainTable.ToCollectionAsync(); try { items = await mainTable.ToListAsync(); //items = await mainTable.ToCollectionAsync(); } catch (Exception e) { //Debug.WriteLine("Klaida updatinant" + e.ToString()); error = true; str = e.ToString(); items = null; } if (error) { Debug.WriteLine("Klaida gaunant duomenis"); } //await map.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => //{ // map.Message("Klaida gaunant duomenis" + str); //}); }
public async Task <string> GetLastIdPlace() { await Initialize(); var User = await placesTable.ToListAsync(); return(int.Parse(User.Last().Id + 1).ToString()); }
private async Task DajBrojVozaca() { await vozacTabela.ToListAsync().ContinueWith(vozacTask => { List <Vozac> vozaci = vozacTask.Result; labelaBrojVozaca.Text = vozaci.Count().ToString(); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public async Task <List <Cases> > GetCases() { await Initialize(); List <Cases> cases = await casesTable.ToListAsync(); return(cases); }
public async Task Refresh() { List <DoggyTodo> items = await todoTable.ToListAsync(); todoList.ItemsSource = items; todoList.EndRefresh(); }
//get list async call works. public static async Task <List <Note> > GetList() { List <Note> list = new List <Note>(); list = await NoteTableObj.ToListAsync(); return(list); }
private async Task DajBrojKlijenata() { await klijentTabela.ToListAsync().ContinueWith(klijentTask => { List <Klijent> klijenti = klijentTask.Result; labelaBrojKlijenata.Text = klijenti.Count().ToString(); }, TaskScheduler.FromCurrentSynchronizationContext()); }
internal async Task InitialLoad() { if (!_initialized) { _usersTable = App.MobileService.GetTable<User>(); _initialized = true; _usersList = await _usersTable.ToListAsync(); } }
/// <summary> /// Get the list of characters /// </summary> /// <returns>ObservableCollection of Character objects</returns> public async Task <ObservableCollection <Character> > GetCharactersAsync() { string mobileServiceClientUrl = "http://xamarinalliancebackend.azurewebsites.net"; MobileServiceClient Client = new MobileServiceClient(mobileServiceClientUrl); IMobileServiceTable <Character> CharacterTable = Client.GetTable <Character>(); var characters = await CharacterTable.ToListAsync(); return(new ObservableCollection <Character>(characters)); }
public async Task <IEnumerable <Member> > GetItemsAsync(bool forceRefresh = false) { if (forceRefresh && CrossConnectivity.Current.IsConnected) { items = await MemberTable.ToListAsync(); } return(items); }
internal async Task InitialLoad() { if (!_initialized) { _messageTable = App.MobileService.GetTable<Message>(); _initialized = true; _messagesList = await _messageTable.ToListAsync(); } }
internal async Task InitialLoad() { if (!_initialized) { _connectionsTable = App.MobileService.GetTable<Connection>(); _initialized = true; _connectionsList = await _connectionsTable.ToListAsync(); } }
private async Task LoadData() { //await _connection.CreateTableAsync<Visitor>(); var visitors = await _visitorTable.ToListAsync(); _visitors = new ObservableCollection <Visitor>(visitors); VisitorList.ItemsSource = _visitors; }