public async void ActualizarNewSms(Esms esms) { var result = await esms.Enviar(); Mensaje = string.Empty; if (result.ErrorCode == "null") { esms.image = SMSImageInfo.ic_check_ok_18pt_3x.ToString(); await _Global.CurrentAccount.MakeTransaction_Manualcharge(esms.monto, "sms a " + esms.NumeroTelefono); } else { esms.image = SMSImageInfo.ic_error_outline_red_18pt_3x.ToString(); } var grupo = ItemsGrouped.First(x => x.First().NumeroTelefono == esms.NumeroTelefono); grupo.Remove(esms); _Global.GrupoSMS.ListaSMS.Remove(esms); esms.isSend = true; _Global.GrupoSMS.ListaSMS.Add(esms); grupo.Add(esms); esms.Ingresar(); ActualizarLista(); }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); ItemsGrouped.Clear(); var items = await DataStoreNew.GetItemsAsync <Invoice>(); foreach (var item in items) { Items.Add(item); } foreach (var group in items.GroupBy(x => x.SellerName)) { ItemsGrouped.Add(group); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async void EnviarExecute(object parameter) { var date = DateTime.Now; var fecha = date.Month + "/" + date.Day + "/" + date.Year; var hora = DateTime.Now.ToString("hh:mm tt").Replace(".", "").ToUpper(); var id = 1; try { id = _Global.GrupoSMS.sms.Id; } catch { } var newSms = new Esms { Id = id + 1, Fecha = fecha, Hora = hora, // IsNew = false, isSend = false, Firma = "", NumeroTelefono = _Global.GrupoSMS.numero, NombreContacto = _Global.GrupoSMS.nombreContacto, monto = monto, Mensaje = Mensaje, i_account = _Global.CurrentAccount.i_account, Phone1 = _Global.CurrentAccount.phone1, Token = "AFAfytf56AR56AY67T76g67guysdf67", ItemHeight = ItemHeight }; newsms = newSms; if (newSms.monto > _Global.CurrentAccount.balance) { CurrentPage.DisplayAlert("TeleYuma", "No tiene sufuciente balance para mandar este mensaje", "ok"); return; } _Global.GrupoSMS.ListaSMS.Add(newSms); ActualizarNewSms(newSms); try { ItemsGrouped.First(x => x.First().NumeroTelefono == newsms.NumeroTelefono).Add(newsms); } catch { ActualizarLista(); } ListView.ScrollTo(newSms, ScrollToPosition.MakeVisible, false); Mensaje = string.Empty; }
public void EliminarExecute(object parameter) { //var result = await CurrentPage.DisplayAlert("TeleYuma", "Está seguro que desea eliminar la conversación", "Eliminar", "Cancelar"); //if (result) //{ popupOpcionesVisible = false; ItemsGrouped.First(x => x.First().NumeroTelefono == LongPressSelected.NumeroTelefono).Remove(LongPressSelected); LongPressSelected.Delete(); _Global.GrupoSMS.ListaSMS.Remove(LongPressSelected); ActualizarLista(); //} }
async Task RefreshData() { IsBusy = true; try { Items.Clear(); ItemsGrouped.Clear(); var employee = await Repo.GetEmployeeAsync(App.DefaultEmployeeAlias); //TODO: Temp Hack. Fix this when login page is ready App.EmployeeId = employee.Id; DependencyService.Get <CurrentIdentityService>().SetNewIdentity(employee.Alias, employee.Id, employee.Manager, employee.Name, false); var items = await Repo.GetOutstandingChargesForEmployeeAsync(employee.Id); Items.ReplaceRange(items); var sorted = from item in Items orderby item.ExpenseDate descending group item by item.ExpenseDate.ToString("MMMM") into itemGroup select new Grouping <string, Charge>(itemGroup.Key, itemGroup); ItemsGrouped.ReplaceRange(sorted); OnPropertyChanged("TotalAmount"); } catch (Exception ex) { Debug.WriteLine(ex); MessagingCenter.Send(new MessagingCenterAlert { Title = "Error", Message = "Unable to load items.", Cancel = "OK" }, "message"); } finally { IsBusy = false; } }
private async Task RefreshData() { IsBusy = true; var data = await _client.GetTable <TodoItem>().ToListAsync(); foreach (var item in data) { Items.Add(item); } var sorted = from item in Items orderby item.Text group item by item.Text[0].ToString() into itemGroup select new Grouping <string, TodoItem>(itemGroup.Key, itemGroup); foreach (var item in sorted) { ItemsGrouped.Add(item); } IsBusy = false; }
public async Task getCategoryData() { if (CategoryPosts.Count != 0) { return; } string htmlPage = ""; try { using (var client = new HttpClient()) { htmlPage = await client.GetStringAsync("http://id.wikihow.com/Istimewa:Categorylisting").ConfigureAwait(false); } htmlDocument.LoadHtml(htmlPage); var innerText = htmlDocument.DocumentNode .Descendants("div") .Where(o => o.GetAttributeValue("class", "") == "section_text").FirstOrDefault(); htmlDocument.LoadHtml(innerText.OuterHtml); var divs = htmlDocument.DocumentNode .Descendants("div") .Where(o => o.GetAttributeValue("class", "") == "thumbnail").ToList(); foreach (var div in divs) { Post newPosts = new Post(); string imageUrl = ""; string title = ""; string url = ""; imageUrl = Regex.Match(div.OuterHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value; url = Regex.Match(div.OuterHtml, "<a.+?href=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value; var match = Regex.Match(div.OuterHtml, @"(<p.*?>.*?</p>)", RegexOptions.Singleline); title = Regex.Replace(match.Groups[1].Value, @"\s*<.*?>\s*", ""); title = WebUtility.HtmlDecode(title); newPosts.Title = title; newPosts.ImageUrl = imageUrl; newPosts.PostUrl = "http://id.wikihow.com" + url; CategoryPosts.Add(newPosts); } var sorted = from item in CategoryPosts orderby item.Title group item by item.Title[0].ToString() into itemGroup select new Grouping <string, Post>(itemGroup.Key, itemGroup); var itemsGrouped = new ObservableRangeCollection <Grouping <string, Post> >(sorted); ItemsGrouped.ReplaceRange(itemsGrouped); } catch (Exception) { } }