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); } }
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; } }
public void assign() { List <Double> tempR = new List <Double>(); List <Double> tempP = new List <Double>(); tempR.Add(taxRates.First().first_cutoff); tempR.Add(taxRates.First().second_cutoff); tempR.Add(taxRates.First().third_cutoff); tempR.Add(taxRates.First().fourth_cutoff); tempP.Add(taxRates.First().first_rate); tempP.Add(taxRates.First().second_rate); tempP.Add(taxRates.First().third_rate); tempP.Add(taxRates.First().fourth_rate); var first = new DataModel(taxRates.First().countryName.ToString(), tempR.ToArray(), tempP.ToArray()); dms.Add(first); tempR.Add(taxRates.Last().first_cutoff); tempR.Add(taxRates.Last().second_cutoff); tempR.Add(taxRates.Last().third_cutoff); tempR.Add(taxRates.Last().fourth_cutoff); tempP.Add(taxRates.Last().first_rate); tempP.Add(taxRates.Last().second_rate); tempP.Add(taxRates.Last().third_rate); tempP.Add(taxRates.Last().fourth_rate); var last = new DataModel(taxRates.Last().countryName.ToString(), tempR.ToArray(), tempP.ToArray()); dms.Add(last); }
private async void myListView_Loaded(object sender, RoutedEventArgs e) { MobileServiceInvalidOperationException exception = null; try { NavigationContext.QueryString.TryGetValue("ID_USER_ASIC", out ID_USER_ASIC); items = await App.MobileService.GetTable <post>().Where(todoItem => todoItem.id == ID_USER_ASIC).ToCollectionAsync(); post listitem = myListView.ItemsSource as post; var firstFromGroup = items.First(); txtValid_id.Text = firstFromGroup.id; txtValid_title.Text = firstFromGroup.title; txtxValid_status.Text = firstFromGroup.status; try { OnMessageReceived(firstFromGroup.description); txtDisplayText = null; } catch {} } catch (MobileServiceInvalidOperationException ex) { exception = ex; } if (exception == null) { myListView.DataContext = items; } }
private async void EndMatchButton_Click(object sender, RoutedEventArgs e) { if (ConvertStringToInt(TeamOneScoreTextBlock.Text) != ConvertStringToInt(TeamTwoScoreTextBlock.Text)) { if (ConvertStringToInt(TeamOneScoreTextBlock.Text) > ConvertStringToInt(TeamTwoScoreTextBlock.Text)) { tournamentTeams = await tournamentTeamsTable.Where(p => p.TeamId == TeamOneIdTextBlock.Text && p.TournamentId == TournamentIdTextBlock.Text) .ToCollectionAsync(); TournamentTeam tournamentTeam = tournamentTeams.FirstOrDefault(); tournamentTeam.TeamWins = tournamentTeam.TeamWins + 1; await tournamentTeamsTable.UpdateAsync(tournamentTeam); } else if (ConvertStringToInt(TeamOneScoreTextBlock.Text) < ConvertStringToInt(TeamTwoScoreTextBlock.Text)) { tournamentTeams = await tournamentTeamsTable.Where(p => p.TeamId == TeamTwoIdTextBlock.Text && p.TournamentId == TournamentIdTextBlock.Text) .ToCollectionAsync(); TournamentTeam tournamentTeam = tournamentTeams.FirstOrDefault(); tournamentTeam.TeamWins = tournamentTeam.TeamWins + 1; await tournamentTeamsTable.UpdateAsync(tournamentTeam); } tournamentTeams = await tournamentTeamsTable.Where(p => p.TeamId == TeamOneIdTextBlock.Text && p.TournamentId == TournamentIdTextBlock.Text) .ToCollectionAsync(); TournamentTeam tournamentTeamOne = tournamentTeams.FirstOrDefault(); tournamentTeamOne.TeamPoints = tournamentTeamOne.TeamPoints + ConvertStringToInt(TeamOneScoreTextBlock.Text); await tournamentTeamsTable.UpdateAsync(tournamentTeamOne); tournamentTeams = await tournamentTeamsTable.Where(p => p.TeamId == TeamTwoIdTextBlock.Text && p.TournamentId == TournamentIdTextBlock.Text) .ToCollectionAsync(); TournamentTeam tournamentTeamTwo = tournamentTeams.FirstOrDefault(); tournamentTeamTwo.TeamPoints = tournamentTeamTwo.TeamPoints + ConvertStringToInt(TeamTwoScoreTextBlock.Text); await tournamentTeamsTable.UpdateAsync(tournamentTeamTwo); matches = await matchesTable.Where(p => p.Id == MatchIdTextBlock.Text).ToCollectionAsync(); Game match = matches.First(); match.Ended = true; await matchesTable.UpdateAsync(match); EndMatchButton.IsEnabled = false; } else { await new MessageDialog("Nie może być remisu").ShowAsync(); } }
private async Task UpdateTeamTwoScore(int score) { matches = await matchesTable.Where(p => p.Id == MatchIdTextBlock.Text).ToCollectionAsync(); Game match = matches.First(); match.TeamTwoScore = score; await matchesTable.UpdateAsync(match); }
private async void fremove(thing item) { jfitems = await ftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day && fthingItem.User == Username && fthingItem.Level == item.Level && fthingItem.Type == item.Type && fthingItem.Content == item.Content) .ToCollectionAsync(); if (jfitems.Count > 0) { await ftodoTable.DeleteAsync(jfitems.First()); } }
public async Task <StorageAccount> GetStorageAccountAsync(string storageAccountId) { MobileServiceCollection <MSStorageAccount, MSStorageAccount> accounts = await App.MobileService.GetTable <MSStorageAccount>() .Where(a => a.account_platform_id == storageAccountId).ToCollectionAsync(); if (accounts.Count >= 1) { return(StorageAccount.ConvertToStorageAccount(accounts.First())); } else { return(null); } }
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 passwordBox_KeyUp(object sender, KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { 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 Task Listen(bool withUI) { try { //Perform speech recognition SpeechRecognitionResult speechRecognitionResult = await RecognizeSpeech(); //Check the confidence level of the specch recognition attempt if (speechRecognitionResult.Confidence == SpeechRecognitionConfidence.Rejected) { await SpeakText("Ich habe leider nicht verstanden. Kannst Du bitte wiederholen?"); } else { if (speechRecognitionResult.Text == "Welche Orte gibt es in meiner Nähe?" || speechRecognitionResult.Text == "Welche Orte genau?" || speechRecognitionResult.Text == "Welche sind diese?" || speechRecognitionResult.Text == "Welche Orte?" || speechRecognitionResult.Text == "Welcher ist dieser?") { string locations = ""; foreach (var item in items) { if (item == items.First()) { locations = string.Concat(locations, item.Name); } else { locations = string.Concat(locations, " und ", item.Name); } } Debug.WriteLine(locations); await SpeakText(locations); } } } catch (Exception e) { Debug.WriteLine("Exception: " + e); } }
public async Task <PtcAccount> GetPtcAccountAsync(string accountId, string password = null) { Expression <Func <MSPtcAccount, bool> > lamda = (a => a.email == accountId); if (password != null) { lamda = (a => a.email == accountId && a.profile_password == password); } MobileServiceCollection <MSPtcAccount, MSPtcAccount> list = await App.MobileService.GetTable <MSPtcAccount>().Where(lamda).ToCollectionAsync(); if (list.Count >= 1) { PtcAccount account = PtcAccount.ConvertToPtcAccount(list.First()); this.myAccount = account; return(account); } else { return(null); } }
private async void subyestoday() { Zw = Zd = 0; yestodaypoints = await ytftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day - 1 && fthingItem.User == Username) .ToCollectionAsync(); if (yestodaypoints.Count == 0) { yitems = await todoTable .Where(thingItem => thingItem.Year == year && thingItem.Month == month && thingItem.Day == day - 1 && thingItem.User == Username && thingItem.Is == "未完成") .ToCollectionAsync(); if (yitems.Count != 0) { int g = 0; int t = 0; thing[] th = yitems.ToArray(); int i = 0; while (i < th.Length) { if (th[i].Type == "个人") { if (th[i].Level == "日常") { g += 24; } if (th[i].Level == "周期") { g += 30; } if (th[i].Level == "特殊") { g += 40; } if (th[i].Level == "生死攸关") { g += 50; } } if (th[i].Type == "团体") { if (th[i].Level == "日常") { t += 30; } if (th[i].Level == "周期") { t += 44; } if (th[i].Level == "特殊") { t += 60; } if (th[i].Level == "生死攸关") { t += 80; } } i++; } yestodaysubpoints y = new yestodaysubpoints() { Year = year, Month = month, Day = day - 1, User = Username, Sgp = g, Stp = t }; await ytftodoTable.InsertAsync(y); } yestodaypoints = await ytftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day - 1 && fthingItem.User == Username) .ToCollectionAsync(); if (yestodaypoints.Count != 0) { stpoint = yestodaypoints.First().Stp; sgpoint = yestodaypoints.First().Sgp; /* uitems = await ut * .Where(userItem => userItem.Username == Username) * .ToCollectionAsync(); * user u = uitems.First(); * u.tp = u.tp - stpoint; * u.gp = u.gp - sgpoint; * * await ut.UpdateAsync(u);*/ Zw -= sgpoint; Zd -= stpoint; } // subyestoday(); } else { stpoint = yestodaypoints.First().Stp; sgpoint = yestodaypoints.First().Sgp; /* uitems = await ut * .Where(userItem => userItem.Username == Username) * .ToCollectionAsync(); * user u = uitems.First(); * u.tp = u.tp - stpoint; * u.gp = u.gp - sgpoint; * * await ut.UpdateAsync(u);*/ Zw -= sgpoint; Zd -= stpoint; } }
private async void getpoints() { uitems = await ut .Where(userItem => userItem.Username == Username) .ToCollectionAsync(); u = uitems.First(); pgoint = u.gp; ptoint = u.tp; tp.Text = ptoint.ToString(); gp.Text = pgoint.ToString(); zw.Text = Zw.ToString(); zd.Text = Zd.ToString(); if (pgoint <= 10) { gn.Text = "平民"; piao.Visibility = Visibility.Visible; xin.Visibility = Visibility.Collapsed; qiang.Visibility = Visibility.Collapsed; wang.Visibility = Visibility.Collapsed; pang.Visibility = Visibility.Collapsed; } if (pgoint > 10 && pgoint <= 30) { gn.Text = "武士"; piao.Visibility = Visibility.Collapsed; xin.Visibility = Visibility.Visible; qiang.Visibility = Visibility.Collapsed; wang.Visibility = Visibility.Collapsed; pang.Visibility = Visibility.Collapsed; } if (pgoint > 30 && pgoint <= 80) { gn.Text = "剑客"; piao.Visibility = Visibility.Collapsed; xin.Visibility = Visibility.Collapsed; qiang.Visibility = Visibility.Visible; wang.Visibility = Visibility.Collapsed; pang.Visibility = Visibility.Collapsed; } if (pgoint > 80 && pgoint <= 120) { gn.Text = "大侠"; piao.Visibility = Visibility.Collapsed; xin.Visibility = Visibility.Collapsed; qiang.Visibility = Visibility.Collapsed; wang.Visibility = Visibility.Visible; pang.Visibility = Visibility.Collapsed; } if (pgoint > 120) { gn.Text = "武神"; piao.Visibility = Visibility.Collapsed; xin.Visibility = Visibility.Collapsed; qiang.Visibility = Visibility.Collapsed; wang.Visibility = Visibility.Collapsed; pang.Visibility = Visibility.Visible; } if (ptoint <= 10) { dw.Text = "士兵"; yanse.Text = "淡刚蓝,从士兵做起吧!"; } if (ptoint > 10 && ptoint <= 30) { dw.Text = "百人将"; back.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 100, 149, 237)); yanse.Text = "矢车菊的蓝色,领导你的百人队伍去战斗!"; } if (ptoint > 30 && ptoint <= 80) { dw.Text = "千人将"; back.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 65, 105, 225)); yanse.Text = "皇军蓝,掌握1000人的生死命运!"; } if (ptoint > 80 && ptoint <= 120) { dw.Text = "将军"; back.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 0, 0, 128)); yanse.Text = "海军蓝, 这就是将军眼中的景象!"; } if (ptoint > 120) { dw.Text = "帝王"; back.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 25, 25, 112)); yanse.Text = "午夜的蓝色, 江山如何坐稳,一声叹息一缕白发成!"; } }
private async void comboBoxidTecnico_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (comboBoxidTecnico.SelectedItem != null) { ProgressBarBefore(); try { usuarios = await UsuarioTable .Select(Usuario => Usuario) .Where(Usuario => Usuario.id == comboBoxidTecnico.SelectedValue.ToString()) .ToCollectionAsync(); ProgressBarAfter(); if (usuarios.Count() == 1) { var tecnico = usuarios.First(); textBlockNombre.Text = tecnico.Nombre; textBlock15Apaterno.Text = tecnico.APaterno; textBlock15Amaterno.Text = tecnico.AMaterno; textBlock15Telefono.Text = tecnico.telefono; textBlock15Correo.Text = tecnico.correo; textBlock15Direccion.Text = tecnico.direccion; } } catch (MobileServiceInvalidOperationException ex) { exception = ex; } if (exception != null) { await new MessageDialog(exception.Message, "Error!").ShowAsync(); } gridDetallesTecnico.Visibility = Visibility.Visible; } }
private async void checkBox_Checked(object sender, RoutedEventArgs e) { enableChangeStatus(); gridDetallesTecnico.Visibility = Visibility.Visible; //Cargar combobox id tecnico if(comboBoxIdDispositivo.SelectedItem != null) { try { ProgressBarBefore(); usuarios = await UsuarioTable .Select(Usuario => Usuario) .Where(Usuario => Usuario.Tipo == "Tecnico") .ToCollectionAsync(); comboBoxidTecnico.ItemsSource = usuarios; ProgressBarAfter(); comboBoxidTecnico.DisplayMemberPath = "id"; comboBoxidTecnico.SelectedValuePath = "id"; comboBoxidTecnico.SelectedIndex = 0; if(comboBoxEstado.SelectedIndex == 0) { //Selecciono atendido comboBoxCambiarEstado.SelectedIndex = 0; } else { //Selecciono no atendido comboBoxCambiarEstado.SelectedIndex = 1; } } catch (MobileServiceInvalidOperationException ex) { exception = ex; } if (exception != null) { await new MessageDialog(exception.Message, "Error al cargar a los Técnicos!").ShowAsync(); } } if(comboBoxidTecnico.SelectedItem != null) { ProgressBarBefore(); try { usuarios = await UsuarioTable .Select(Usuario => Usuario) .Where(Usuario => Usuario.id == comboBoxidTecnico.SelectedValue.ToString()) .ToCollectionAsync(); ProgressBarAfter(); if (usuarios.Count() == 1) { var tecnico = usuarios.First(); textBlockNombre.Text = tecnico.Nombre; textBlock15Apaterno.Text = tecnico.APaterno; textBlock15Amaterno.Text = tecnico.AMaterno; textBlock15Telefono.Text = tecnico.telefono; textBlock15Correo.Text = tecnico.correo; textBlock15Direccion.Text = tecnico.direccion; } }catch(MobileServiceInvalidOperationException ex) { exception = ex; } if(exception != null) { await new MessageDialog(exception.Message, "Error!").ShowAsync(); } gridDetallesTecnico.Visibility = Visibility.Visible; } }
public async Task<double> RefreshTelemetryItemValue(string sensor) { double value = -1; MobileServiceInvalidOperationException exception = null; try { // This code refreshes the entries in the list view by querying the telemetry2 table. telemetryItems = await telemetryTable .Where( (s => (s.Complete == false) && (s.Sensor == sensor)) ) .ToCollectionAsync(); } catch (MobileServiceInvalidOperationException e) { exception = e; } if (exception != null) { await new MessageDialog(exception.Message, "Error loading items").ShowAsync(); } else { //Sort in descending order = Most recent first .. Ww want the latest value of each sensor if (telemetryItems != null) { if (telemetryItems.Count() != 0) value = (double)telemetryItems.First().Value; } } return value; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { Restaurant = e.Parameter as Restaurant; if (Restaurant != null) { MobileServiceCollection <Restaurant, Restaurant> items = await App.MobileService.GetTable <Restaurant>().Where(r => r.Id == Restaurant.Id).ToCollectionAsync(); add.Content = "Save"; clear.Content = "Delete"; Restaurant = items.First(); name.Text = Restaurant.Name; address.Text = Restaurant.Address; contact.Text = Restaurant.ContactNo; cost.Text = Restaurant.Cost.ToString(); description.Document.SetText(TextSetOptions.None, Restaurant.Description); creditCard.IsChecked = Restaurant.CreditCard; wifi.IsChecked = Restaurant.Wifi; petFriendly.IsChecked = Restaurant.PetFriendly; outdoorSeating.IsChecked = Restaurant.OutdoorSeating; coverPhoto.Source = ByteArrayBitmapExtensions.AsBitmapImage(Restaurant.Image); foreach (StoreTime st in Restaurant.StoreTime) { switch (st.Day) { case DayOfWeek.Sunday: sun.IsChecked = true; sunOpenTime.Time = st.OpenTime; sunOpenTime.IsEnabled = true; sunCloseTime.IsEnabled = true; sunCloseTime.Time = st.CloseTime; break; case DayOfWeek.Monday: mon.IsChecked = true; monOpenTime.Time = st.OpenTime; monOpenTime.IsEnabled = true; monCloseTime.IsEnabled = true; monCloseTime.Time = st.CloseTime; break; case DayOfWeek.Tuesday: tue.IsChecked = true; tueOpenTime.Time = st.OpenTime; tueOpenTime.IsEnabled = true; tueCloseTime.IsEnabled = true; tueCloseTime.Time = st.CloseTime; break; case DayOfWeek.Wednesday: wed.IsChecked = true; wedOpenTime.Time = st.OpenTime; wedCloseTime.Time = st.CloseTime; wedOpenTime.IsEnabled = true; wedCloseTime.IsEnabled = true; break; case DayOfWeek.Thursday: thu.IsChecked = true; thuOpenTime.Time = st.OpenTime; thuOpenTime.IsEnabled = true; thuCloseTime.IsEnabled = true; thuCloseTime.Time = st.CloseTime; break; case DayOfWeek.Friday: fri.IsChecked = true; friOpenTime.Time = st.OpenTime; friOpenTime.IsEnabled = true; friCloseTime.IsEnabled = true; friCloseTime.Time = st.CloseTime; break; case DayOfWeek.Saturday: sat.IsChecked = true; satCloseTime.Time = st.CloseTime; satOpenTime.IsEnabled = true; satCloseTime.IsEnabled = true; satOpenTime.Time = st.OpenTime; break; } } foreach (Cuisine c in Restaurant.Cuisine) { Tags.SelectedItem = c.CuisineType; } foreach (Menu m in Restaurant.Menu) { menu.Add(new MenuImage { Image = ByteArrayBitmapExtensions.AsBitmapImage(m.MenuImage), Id = m.Id }); } menuImages.ItemsSource = menu; } else { Restaurant = new Restaurant(); } }