private async Task RefreshOrderList() { MobileServiceInvalidOperationException exception = null; try { orders = await ordersTable .OrderByDescending(x => x.Id) .ToCollectionAsync(); customers = await customersTable.CreateQuery().ToCollectionAsync(); ListItems.ItemsSource = orders; TextCustomer.ItemsSource = customers; } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } }
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 .Where(todoItem => todoItem.Complete == false) .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 static Task <Face> GetLatestFace() { faces = await faceTable .OrderByDescending(faceTable => faceTable.UpdatedAt).ToCollectionAsync(); return(faces[0]); }
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.OrderByDescending(items2=>items2.Score) .ToCollectionAsync(); for (int i = 0; i <= items.Count-1; i++) { items[i].Id = i + 1; } } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } else { listPoints.ItemsSource = items; } }
private async void RefreshAsync() { MobileServiceInvalidOperationException exception = null; try { // This code refreshes the entries in the list view by querying the TodoItems table. items = await todoTable.ToCollectionAsync(); myList = new List <string>(); foreach (ToDoItem item in items) { myList.Add(item.Text); } } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { } else { list.ItemsSource = myList; } }
public void MobileServiceCollectionCanCopyToAndNotNotifies() { // Get the Books table MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceCollection <Book> collection = new MobileServiceCollection <Book>(query); List <string> properties = new List <string>(); List <string> expectedProperties = new List <string>() { }; List <NotifyCollectionChangedAction> actions = new List <NotifyCollectionChangedAction>(); List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>() { }; Book book = new Book(); collection.Add(book); Book[] books = new Book[1]; ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); collection.CopyTo(books, 0); Assert.AreEqual(1, collection.Count); Assert.AreEqual(1, books.Count()); Assert.AreEqual(collection[0], books[0]); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }
public async Task <bool> RefreshSessionItems(dxevent _chosenSession) { MobileServiceInvalidOperationException exception = null; try { // This code refreshes the entries in the list view by querying the session table. items = await sessionTable .Where(sessionItem => sessionItem.eventid == _chosenSession.id) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { //await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); return(false); } else { return(true); } }
public void MobileServiceCollectionCanClearAndNotifies() { // Get the Books table MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceCollection <Book> collection = new MobileServiceCollection <Book>(query); List <string> properties = new List <string>(); List <string> expectedProperties = new List <string>() { "Count", "Item[]" }; List <NotifyCollectionChangedAction> actions = new List <NotifyCollectionChangedAction>(); List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>() { NotifyCollectionChangedAction.Reset }; Book book = new Book(); collection.Add(book); ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); collection.Clear(); Assert.AreEqual(0, collection.Count); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }
public async Task MobileServiceCollectionHasMoreItemsShouldBeFalseAfterRetrievingDataWhenNoPaging() { // Get the Books table MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>(); MobileServiceCollection <Book> collection = new MobileServiceCollection <Book>(query); CancellationTokenSource tokenSource = new CancellationTokenSource(); List <string> properties = new List <string>(); List <string> expectedProperties = new List <string>() { "HasMoreItems", "Count", "Item[]", "Count", "Item[]", "TotalCount" }; List <NotifyCollectionChangedAction> actions = new List <NotifyCollectionChangedAction>(); List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>() { NotifyCollectionChangedAction.Add, NotifyCollectionChangedAction.Add }; ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); int result = await collection.LoadMoreItemsAsync(tokenSource.Token); Assert.IsFalse(collection.HasMoreItems); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }
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; } }
private async Task RefreshTodoItems() { //App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount); 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) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } else { ListItems.ItemsSource = items; this.ButtonSave.IsEnabled = true; } }
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 .Where(TodoItem => TodoItem.Complete == false) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } //else //{ // ListItems.ItemsSource = items; // this.btnRefresh.IsEnabled = true; //} }
private async void GetData() { username = USERNAME.Text; password = PASSWORD.Password; if(username.Equals("") || password.Equals("")){ MessageBox.Show("Username or Password cannot be empty","Error",MessageBoxButton.OK); } else{ try { credentials = await credentialTable. Where(userCredentials => userCredentials.username == username && userCredentials.password == password). ToCollectionAsync(); } catch(MobileServiceInvalidOperationException e) { MessageBox.Show(e.Message,"Database Error",MessageBoxButton.OK); } int count = credentials.Count(); if (count == 1) { NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } } }
private async void radioButtonEliminar_Checked(object sender, RoutedEventArgs e) { disableTexBox(); comboBoxIdTecnicoEditar.IsEnabled = true; buttonEliminar.Visibility = Visibility.Visible; textBlockTitleNewEdit.Text = "Eliminar TĆ©cnico"; comboBoxIdTecnicoEditar.DisplayMemberPath = "id"; comboBoxIdTecnicoEditar.SelectedValuePath = "id"; try { ProgressBarBefore(); usuarios = await UsuariosTable .Select(Tecnicos => Tecnicos) .Where(Tecnicos => Tecnicos.Tipo == "Tecnico") .ToCollectionAsync(); comboBoxIdTecnicoEditar.ItemsSource = usuarios; ProgressBarAfter(); if (usuarios.Count >= 1) { comboBoxIdTecnicoEditar.SelectedIndex = 0; } } catch (MobileServiceInvalidOperationException ex) { exception = ex; } if (exception != null) { await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync(); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { int f = 0; StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile sampleFile = await folder.CreateFileAsync("Sample.txt", CreationCollisionOption.OpenIfExists); try { string testlol = await Windows.Storage.FileIO.ReadTextAsync(sampleFile); ids = JsonConvert.DeserializeObject <List <string> >(testlol); items = await Table.ToCollectionAsync(); } catch (Exception ex) { f = 1; } finally { if (f == 1) { MessageDialog m = new MessageDialog("Oops... There was some Problem Handling your Request"); await m.ShowAsync(); } else { Voice.ItemsSource = items; } } }
private async void RefreshAsync() { 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 SitesTable.ToCollectionAsync(); myList = new List<string>(); foreach (ToDoItem item in items) { myList.Add(item.Text); } } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { } else { list.ItemsSource = myList; } }
// Referesh List Method 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 user = await todoTable .Where(TodoItem => TodoItem.Complete == false) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } else { var dialog = new MessageDialog("Successfully Updated"); await dialog.ShowAsync(); } }
private async Task RefreshTodoItems() { MobileServiceInvalidOperationException exception = null; try { // This code refreshes the entries in the list view items = await todoTable .Where(todoItem => todoItem.Complete == false) .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; } }
async private void DeleteCourseForm_Tapped(object sender, TappedRoutedEventArgs e) { //populated delete course form information for easy deletion. MobileServiceInvalidOperationException exception1 = null; try { if (deleteSelectedName.SelectedValue != null) { classList = await completedCourses .Where(CoursesComplete => CoursesComplete.courseName == deleteSelectedName.SelectedItem.ToString() && CoursesComplete.courseRemoved == false) .ToCollectionAsync(); deleteId.Text = classList[0].Id; deleteCourseName.Text = classList[0].courseName; deleteCourseNumber.Text = classList[0].courseNumber; deleteCreditsReceived.Text = classList[0].courseCredits; deleteGrade.Text = classList[0].gradeReceived; deleteQuarter.Text = classList[0].quarterComplete; deleteInstructor.Text = classList[0].instructorName; } else { await new MessageDialog("Course Name not selected").ShowAsync(); } } catch (MobileServiceInvalidOperationException e2) { exception1 = e2; } }
public async static Task <Person> GetLatestPerson() { persons = await personTable .OrderByDescending(personTable => personTable.UpdatedAt).ToCollectionAsync(); return(persons[0]); }
private async void addyestoday() { Zw = Zd = 0; ys = await ya.Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day - 1 && fthingItem.User == Username) .ToCollectionAsync(); if (ys.Count == 0) { todayaddpoints t = new todayaddpoints(); t.Isadd = false; t.Year = year; t.Month = month; t.Day = day - 1; t.User = Username; t.Nowgp = 0; t.Nowtp = 0; await ya.InsertAsync(t); } if (ys.Count != 0) { /* uitems = await ut * .Where(userItem => userItem.Username == Username) * .ToCollectionAsync(); * user u = uitems.First(); * u.tp = u.tp + ys.First().Nowtp; * u.gp = u.gp + ys.First().Nowgp; * * * await ut.UpdateAsync(u);*/ Zw += ys.First().Nowgp; Zd += ys.First().Nowtp; } }
private async void tr() { String time = Time.Text; char[] s = new char[1]; s[0] = '/'; String[] t = time.Split(s); //Time.Text = t[0] + t[1] + t[2]; year = int.Parse(t[0]); month = int.Parse(t[1]); day = int.Parse(t[2]); try { items = await todoTable .Where(thingItem => thingItem.Year == year && thingItem.Month == month && thingItem.Day == day && thingItem.User == Username) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { MessageBox.Show(e.Message, "Error loading items", MessageBoxButton.OK); } ListItems.ItemsSource = items; }
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 .OrderBy(todoItem => todoItem.Text) .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 <TodoItem> RefreshTodoItemAsync(string key) { 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 .Where(l => l.Id == key) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading item").ShowAsync(); } return(items.ToList <TodoItem>().FirstOrDefault()); }
private async void Project_Tapped(object sender, TappedRoutedEventArgs e) { List <String> param = new List <String>(); string text = ((sender as StackPanel).FindName("projectId") as TextBlock).Text; param.Add(text); bids = await bidTable .Where(Bid => Bid.ProjectId == text) .Where(Bid => Bid.Bidder == "*****@*****.**") //Bidder should come from global.cs .ToCollectionAsync(); List <Bid> bidList = new List <Bid>(); bidList = bids.ToList(); if (bidList.Count == 0) // The user has not bid for this project before { Debug.Write("Add Bid"); param.Add("Add"); } else // The user wants to update the bid for this project { Debug.Write("Update Bid"); param.Add("Update"); } Debug.Write("Text: " + text); Frame.Navigate(typeof(Bidding), param); }
// gegevens uit database halen 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 .Where(todoItem => todoItem.Complete == false) .ToCollectionAsync(); //gegevens database in observeble collection plaatsn foreach (TodoItem item in items) { //item.Add(item);//items tovoegen } } 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; } }
async private void LoadEditRecipe_Clicked(object sender, RoutedEventArgs e) { MobileServiceInvalidOperationException exception1 = null; try { if (editRecipeName.SelectedValue != null) { singleRecipe = await recipesList .Where(RecipesList => RecipesList.recipeName == editRecipeName.SelectedItem.ToString()) .ToCollectionAsync(); editHiddenID.Text = singleRecipe[0].Id; editHiddenRecipeName.Text = singleRecipe[0].recipeName; editRecipeShareable.IsChecked = singleRecipe[0].isChecked; editingredient1.Text = singleRecipe[0].ingredient1; editingredient2.Text = singleRecipe[0].ingredient2; editingredient3.Text = singleRecipe[0].ingredient3; editingredient4.Text = singleRecipe[0].ingredient4; editingredient5.Text = singleRecipe[0].ingredient5; editingredient6.Text = singleRecipe[0].ingredient6; editingredient7.Text = singleRecipe[0].ingredient7; } else { await new MessageDialog("Recipe Name not selected.").ShowAsync(); } } catch (MobileServiceInvalidOperationException e1) { exception1 = e1; } }
async private void EditRecipe_Clicked(object sender, RoutedEventArgs e) { AddRecipeGrid.Visibility = Visibility.Collapsed; EditRecipeGrid.Visibility = Visibility.Visible; ViewRecipeGridHeader.Visibility = Visibility.Collapsed; ClearUpdate(); MobileServiceInvalidOperationException exception = null; try { singleRecipe = await recipesList .Where(RecipesList => RecipesList.userID == MainPage.SessionUser.sessionUsername) .OrderBy(RecipesList => RecipesList.recipeName) .ToCollectionAsync(); if (singleRecipe.Count == 0) { await new MessageDialog("No Recipes Available to Update").ShowAsync(); } else { editRecipeName.Items.Clear(); for (int i = 0; i < singleRecipe.Count; i++) { editRecipeName.Items.Add(singleRecipe[i].recipeName); } } } catch (MobileServiceInvalidOperationException ex) { exception = ex; } }
public MainScreenMessage(bool isNew, TrainingItem trainingItem, MobileServiceCollection<TrainingItem, TrainingItem> items, IMobileServiceTable<TrainingItem> trainingItemsTable) { _isNewTraining = isNew; _trainingItem = trainingItem; _items = items; _trainingItemsTable = trainingItemsTable; }
private async void RefreshTodoItems() { // TODO: Mark this method as "async" and uncomment the following block of code. MobileServiceInvalidOperationException exception = null; try { // TODO #1: uncomment the following statment // that defines a simple query for all items. items = await todoTable.ToCollectionAsync(); // // TODO #2: More advanced query that filters out completed items. // items = await todoTable // .Where(todoItem => todoItem.Complete == false) // .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; } // Comment-out or delete the following lines of code. //this.ButtonSave.IsEnabled = true; //ListItems.ItemsSource = items; }
async void MainPage_Loaded(object sender, RoutedEventArgs e) { Start.channel.PushNotificationReceived += channel_PushNotificationReceived; test = new ObservableCollection<ChatPubList>(); items = await Table.OrderByDescending(ChatPublic => ChatPublic.__CreatedAt).ToCollectionAsync(); var networkProfiles = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles(); var adapter = networkProfiles.First<Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter string networkAdapterId = adapter.NetworkAdapterId.ToString(); foreach (ChatPublic k in items) { ChatPubList a = new ChatPubList(); a.date = k.__CreatedAt.Date.ToString(); a.time = k.__CreatedAt.TimeOfDay.ToString(); a.time=a.time.Remove(5); a.date=a.date.Remove(10); a.Name = k.Name; a.Message = k.Message; if (a.Name == networkAdapterId) { a.col = "#FF9B0E00"; } else { a.col = "#FF5D340C"; } test.Add(a); } lol.ItemsSource = test; test.CollectionChanged += test_CollectionChanged; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { this.navigationHelper.OnNavigatedTo(e); string title = (string)e.Parameter; MobileServiceInvalidOperationException exception = null; try { CommentsItems = await CommentsTable. Where(Comments => Comments.to == title). ToCollectionAsync(); } catch (MobileServiceInvalidOperationException ex) { exception = ex; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } else { int length = CommentsItems.Count(); for (int count = 0; count < length; count++) { ListItems.Items.Add(CommentsItems[count].title); } } Ring.IsActive = false; }
private async void nowpoints() { nfitems = await ftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day && fthingItem.User == Username) .ToCollectionAsync(); int g = 0; int t = 0; fthing[] n = nfitems.ToArray(); DateTime d = DateTime.Now; int i = 0; while (i < n.Length) { if (n[i].Type == "äøŖäŗŗ") { if (n[i].Level == "ę„åøø") { g += 5; } if (n[i].Level == "åØę") { g += 8; } if (n[i].Level == "ē¹ę®") { g += 16; } if (n[i].Level == "ēę»ęøå ³") { g += 30; } g -= n[i].Fhour; } if (n[i].Type == "å¢ä½") { if (n[i].Level == "ę„åøø") { t += 5; } if (n[i].Level == "åØę") { t += 8; } if (n[i].Level == "ē¹ę®") { t += 16; } if (n[i].Level == "ēę»ęøå ³") { t += 30; } t -= n[i].Fhour; } i++; } ntpoint = t; ngpoint = g; }
private async void SearchButton2_Click(object sender, RoutedEventArgs e) { StoreListView2.Visibility = Visibility.Collapsed; SearchButton2.Visibility = Visibility.Collapsed; LoadingBar2.Visibility = Visibility.Visible; LoadingBar.IsIndeterminate = true; try { items2 = await Table2.Where(Collections => Collections.Name.Contains(Box2.Text)).ToCollectionAsync(); StoreListView2.ItemsSource = items2; Box2.Visibility = Visibility.Visible; StoreListView2.Visibility = Visibility.Visible; SearchButton2.Visibility = Visibility.Visible; LoadingBar2.Visibility = Visibility.Collapsed; //write code to navigate to detail page of collection } catch (Exception) { MessageDialog msgbox = new MessageDialog("Something is not right at this time"); await msgbox.ShowAsync(); LoadingBar2.Visibility = Visibility.Collapsed; } }
private async void submit() { submityes = await suby .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day - 1 && fthingItem.User == Username) .ToCollectionAsync(); todayaddpoints tt = submityes.First(); if (tt.Isadd == false) { todayaddpoints t = submityes.First(); t.Isadd = true; await tftodoTable.UpdateAsync(t); pgoint += Zw; ptoint += Zd; tp.Text = ptoint.ToString(); gp.Text = pgoint.ToString(); uitems = await ut .Where(userItem => userItem.Username == Username) .ToCollectionAsync(); user u = uitems.First(); u.gp = pgoint; u.tp = ptoint; await ut.UpdateAsync(u); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { rec = new StoreListing(); LoadingBar.Visibility = Visibility.Visible; LoadingBar.IsIndeterminate = true; rec = e.Parameter as StoreListing; Title.Text = rec.Title; Cover.Source = rec.Image; FullCost.Text = "Tour " + rec.Price; string[] ids = rec.MyId.Split(','); try { foreach (string nid in ids) { if (nid != "") { recM = new StoreListing(); items = await Table.Where(Scrap => Scrap.Id == nid).ToCollectionAsync(); recM.Id = items[0].Id; recM.Title = items[0].Title; recM.MyId = items[0].Point_List; recM.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(this.BaseUri, "Assets/augmented-reality-for-blog.jpg")); // image fromasset store sl.Add(recM); } } StoreListView.DataContext = sl; } catch (Exception) { } }
private async void Button_Click(object sender, RoutedEventArgs e) { LoadingBar.Visibility = Visibility.Visible; LoadingBar.IsActive = true; try { items2 = await Table2.Where(User => User.username == testlol).ToCollectionAsync(); User a = items2[0]; if (!(Funds.Text.All(char.IsDigit))) { LoadingBar.Visibility = Visibility.Collapsed; MessageDialog msgbox = new MessageDialog("Enter correct amount"); await msgbox.ShowAsync(); return; } a.wallet += int.Parse(Funds.Text); await Table2.UpdateAsync(a); MessageDialog msgbox1 = new MessageDialog("Money Added!!"); LoadingBar.Visibility = Visibility.Collapsed; await msgbox1.ShowAsync(); Frame.Navigate(typeof(MainPage)); } catch (Exception) { LoadingBar.Visibility = Visibility.Collapsed; MessageDialog msgbox = new MessageDialog("Can't add money"); await msgbox.ShowAsync(); } }
private async void LoadChartContents(DateTime date) { MobileServiceInvalidOperationException exception = null; string idDeshidratadora; object selectedItem = comboBox.SelectedValue.ToString(); idDeshidratadora = selectedItem.ToString(); try { ProgressBarBefore(); temperaturas = await TempDeshTable .Where(Tempe => Tempe.Fecha == date.ToString("yyyy-MM-dd") && Tempe.idDeshidratadora == idDeshidratadora) .ToCollectionAsync(); if (temperaturas.Count >= 1) { foreach (var c in temperaturas) { string[] hora = c.Hora.Split(' '); c.Hora = hora[1]; } CategoryAxis categoryAxis = new CategoryAxis() { Orientation = AxisOrientation.X, Location = AxisLocation.Bottom, AxisLabelStyle = App.Current.Resources["VerticalAxisStyle"] as Style }; (LineSeries.Series[0] as LineSeries).IndependentAxis = categoryAxis; (LineSeries.Series[0] as LineSeries).ItemsSource = temperaturas; LineSeries.Visibility = Visibility.Visible; ProgressBarAfter(); } else { LineSeries.Visibility = Visibility.Collapsed; MessageDialog mensaje = new MessageDialog("No existe registro para esta fecha.", "No existe registro"); await mensaje.ShowAsync(); ProgressBarAfter(); } } catch (MobileServiceInvalidOperationException ex) { exception = ex; } if (exception != null) { await new MessageDialog(exception.Message, "Error!").ShowAsync(); } // (LineSeries.Series[0] as LineSeries).ItemsSource = financialStuffList; }
private async void ReadItemsTable() { try { itemsCollection = await itemsTable.ToCollectionAsync(); Content.ItemsSource = itemsCollection; } catch (InvalidOperationException) { } }
// returns an ordered list of location that matches the search query public static IEnumerable<Event> GetMatchingEvents(MobileServiceCollection<Event, Event> eventlist, string query) { return eventlist .Where(c => c.Title.IndexOf(query, StringComparison.CurrentCultureIgnoreCase) > -1 || c.Location.IndexOf(query, StringComparison.CurrentCultureIgnoreCase) > -1 || c.Category.IndexOf(query, StringComparison.CurrentCultureIgnoreCase) > -1) .OrderByDescending(c => c.Title.StartsWith(query, StringComparison.CurrentCultureIgnoreCase)) .ThenByDescending(c => c.Location.StartsWith(query, StringComparison.CurrentCultureIgnoreCase)) .ThenByDescending(c => c.Category.StartsWith(query, StringComparison.CurrentCultureIgnoreCase)); }
private async void RefreshTodoItems() { try { items = await todoTable .Where(todoItem => todoItem.Complete == false).ToCollectionAsync(); ListItems.ItemsSource = items; } catch (HttpRequestException) { ShowError(); } }
public async Task<PodcastEpisode> GetTimeAsync(int shownum) { try { //retrieve postcast based off show number podcasts = await podcastTable.Where(p=>p.ShowNumber == shownum).ToCollectionAsync(); return podcasts.Count > 0 ? podcasts[0] : null; } catch (Exception ex) { } return new PodcastEpisode { ShowNumber = shownum, CurrentTime = 0 }; }
private async void RefreshTodoItems() { try { items = await todoTable .Where(todoItem => todoItem.Complete == false) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { MessageBox.Show(e.Message, "Error loading items", MessageBoxButton.OK); } //ListItems.ItemsSource = items; }
private async void RefreshTodoItems() { // This code refreshes the entries in the list view be querying the TodoItems table. // The query excludes completed TodoItems try { items = await Common.GetIncompleteItems() .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { MessageBox.Show(e.Message, "Error loading items", MessageBoxButton.OK); } ListItems.ItemsSource = items; }
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 _trainingItemsTable.ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } else { fetchedTrainingsList.ItemsSource = _items; } }
async void MainPage_Loaded(object sender, RoutedEventArgs e) { //PushNotificationChannel channel; //channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); //try //{ // await App.Mugd_appClient.GetPush().RegisterNativeAsync(channel.Uri); // //await App.Mugd_appClient.InvokeApiAsync("notifyAllUsers", // // new JObject(new JProperty("toast", "Sample Toast"))); //} //catch (Exception exception) //{ // HandleRegisterException(exception); //} Start.channel.PushNotificationReceived += channel_PushNotificationReceived; test = new ObservableCollection<ChatPubList>(); items = await Table.OrderByDescending(ChatPublic => ChatPublic.CreatedAt).ToCollectionAsync(); var networkProfiles = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles(); var adapter = networkProfiles.First<Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter string networkAdapterId = adapter.NetworkAdapterId.ToString(); foreach (ChatPublic k in items) { ChatPubList a = new ChatPubList(); a.date = k.CreatedAt.Date.ToString(); a.time = k.CreatedAt.TimeOfDay.ToString(); a.time = a.time.Remove(5); a.date = a.date.Remove(10); a.Name = k.Name; a.Message = k.Message; if (a.Name == networkAdapterId) { a.col = "#FF9B0E00"; } else { a.col = "#FF5D340C"; } test.Add(a); } lol.ItemsSource = test; test.CollectionChanged += test_CollectionChanged; }
private async void button_Click(object sender, RoutedEventArgs e) { try { ProgressBarBefore(); usuarios = await UsuarioTable .Select(Usuarios => Usuarios) .Where(Usuarios => Usuarios.id == textBoxUser.Text && Usuarios.contrasena == passwordBox.Password.ToString()) .ToCollectionAsync(); ProgressBarAfter(); if(usuarios.Count >= 1) { var rsUsuario = usuarios.First(); if(rsUsuario.Tipo == "Tecnico") { Frame.Navigate(typeof(Administrador), "Tecnico"); } else { Frame.Navigate(typeof(Administrador), "Administrador"); } } else { MessageDialog mensaje = new MessageDialog("Usuario o contraseƱa incorrectos.", "Credenciales invalidas"); await mensaje.ShowAsync(); } } catch (MobileServiceInvalidOperationException ex) { exception = ex; } if (exception != null) { await new MessageDialog(exception.Message, "Error!").ShowAsync(); } }
private async void button_Click(object sender, RoutedEventArgs e) { String userName = userNameText.Text; String password = passwordBox.Password; try { guests = await guestTable.Where(guests => guests.name == userName && guests.password == password).ToCollectionAsync(); } catch (MobileServiceInvalidOperationException ex) { await new MessageDialog(ex.Message, "Could not connect to server.").ShowAsync(); System.Diagnostics.Debug.WriteLine("This is user name and password :"******"username"] = userName; this.Frame.Navigate(typeof(Home), null); var channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); string deviceId = GetDeviceId(); string uri = channel.Uri; System.Diagnostics.Debug.WriteLine("uri is :" + uri); try { await App.azure_rendezvous_mobile_service_3Client.GetPush().RegisterNativeAsync(channel.Uri); await App.azure_rendezvous_mobile_service_3Client.InvokeApiAsync("modifychanneluri", new JObject(new JProperty("channeluri", uri), new JProperty("username", userName))); } catch (MobileServiceInvalidOperationException ex) { System.Diagnostics.Debug.WriteLine("exception is :" + ex.Message); } } else { MessageDialog msgBox = new MessageDialog("Invalid username or password"); await msgBox.ShowAsync(); } }
private async void RefreshTodoItems() { // This code refreshes the entries in the list view be querying the TodoItems table. // The query excludes completed TodoItems try { items = await todoTable .Where(todoItem => todoItem.Complete == false) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { MessageBox.Show(e.Message, "Error loading items", MessageBoxButton.OK); } ListItems.ItemsSource = items; this.ButtonSave.IsEnabled = true; }
// Refresh the item list each time we navigate to this page private async void RefreshEventList(string query) { eventTable = App.MobileService.GetTable<Event>(); if (query == null) { try { events = await eventTable.ToCollectionAsync(); } catch (Exception ex) { Debug.WriteLine(ex.StackTrace.ToString()); ErrorText.Text = "Connectivity error, please try again"; ErrorText.Visibility = Visibility.Visible; } finally { ProgressRing.IsActive = false; SearchBox.Visibility = Visibility.Visible; } eventListGridView.ItemsSource = events; if(events.Count == 0) { ErrorText.Text = "No Events Found"; ErrorText.Visibility = Visibility.Visible; } } else { var MatchEvents = EventController.GetMatchingEvents(events, query).ToList<Event>(); if(MatchEvents.Count > 0) { ErrorText.Visibility = Visibility.Collapsed; eventListGridView.ItemsSource = MatchEvents; } else { eventListGridView.ItemsSource = null; ErrorText.Text = "No Events Found"; ErrorText.Visibility = Visibility.Visible; } } }
public async Task MobileServiceCollectionMultipleLoadItemsAsyncShouldThrow() { // Get the Books table MobileServiceTableQueryMock<Book> query = new MobileServiceTableQueryMock<Book>(); MobileServiceCollection<Book, Book> collection = new MobileServiceCollection<Book, Book>(query); CancellationTokenSource tokenSource = new CancellationTokenSource(); Exception ex = null; try { await TaskEx.WhenAll(collection.LoadMoreItemsAsync(tokenSource.Token), collection.LoadMoreItemsAsync(tokenSource.Token)); } catch (InvalidOperationException e) { ex = e; } Assert.IsNotNull(ex); }
private async Task RefreshTodoItems() { MobileServiceInvalidOperationException exception = null; try { // Query that returns all items. 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; } }
private async void searchbtnclicked(object sender, RoutedEventArgs e) { String location = ((ComboBoxItem)locationcomboBox.SelectedItem).Content.ToString(); String category = ((ComboBoxItem)categorycomboBox.SelectedItem).Content.ToString(); var parameters = new Dictionary<String, String> { {"Location",location}, { "Category",category} }; // parameters.Add("Location",location); // parameters.Add("Category",category); try { restaurants = await restaurantTable.WithParameters(parameters).ToCollectionAsync(); } catch (MobileServiceInvalidOperationException ex) { await new MessageDialog(ex.Message, "Could not connect to server.").ShowAsync(); } Boolean containsvalue = restaurants.Any<Restaurant>(); if (!containsvalue) { await new MessageDialog("No restaurants matching!").ShowAsync(); } ListItems.ItemsSource = restaurants; // Restaurant res1 = restaurants.First<Restaurant>(); // Restaurant res2 = restaurants.Last<Restaurant>(); // System.Diagnostics.Debug.WriteLine("first element returned:" + res1.Name); // System.Diagnostics.Debug.WriteLine("last element returned:" + res2.Name); }
private async Task RefreshPersons() { MobileServiceInvalidOperationException exception = null; try { persons = await personsTable.ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading").ShowAsync(); } else { PersonsCollection = new ObservableCollection<Person>(persons); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { int f = 0; StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile sampleFile = await folder.CreateFileAsync("Sample.txt", CreationCollisionOption.OpenIfExists); try { string testlol = await Windows.Storage.FileIO.ReadTextAsync(sampleFile); ids = JsonConvert.DeserializeObject<List<string>>(testlol); items = await Table.ToCollectionAsync(); } catch(Exception ex) { f = 1; } finally { if (f == 1) { MessageDialog m = new MessageDialog("Oops... There was some Problem Handling your Request"); await m.ShowAsync(); } else { Voice.ItemsSource = items; } } }
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 unitLogTable.OrderByDescending(unitLog => unitLog.ReportedTime) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } else { ListItems.ItemsSource = items; } }
private async Task RefreshTodoItems() { MobileServiceInvalidOperationException exception = null; try { _items = await _groceriesTable .Where(x => x.OwnerUserId == _user.UserId) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } else { ListItems.ItemsSource = _items; ButtonSave.IsEnabled = true; } }
public void MobileServiceCollectionCanClearAndNotifies() { // Get the Books table MobileServiceTableQueryMock<Book> query = new MobileServiceTableQueryMock<Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceCollection<Book, Book> collection = new MobileServiceCollection<Book, Book>(query); List<string> properties = new List<string>(); List<string> expectedProperties = new List<string>() { "Count", "Item[]" }; List<NotifyCollectionChangedAction> actions = new List<NotifyCollectionChangedAction>(); List<NotifyCollectionChangedAction> expectedActions = new List<NotifyCollectionChangedAction>() { NotifyCollectionChangedAction.Reset }; Book book = new Book(); collection.Add(book); ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); collection.Clear(); Assert.AreEqual(0, collection.Count); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }