private async void VerificarVenta(bool obj) { if (obj) { Presupuesto.Cobrado += Cobrar; if (Total == Presupuesto.Cobrado) { Presupuesto.EstadoDeCobro = Constantes.EstadoDeCobro.Cobrado; } await ApiProcessor.PutApi(Presupuesto, $"Presupuesto/{Presupuesto.Id}"); Efectivo = false; Cobrar = 0; if (Presupuesto.EstadoDeCobro == EstadoDeCobro.Cobrado) { await Inicializar(); } Presupuesto = new PresupuestoDto(); MessageBox.Show("Operacion realizada!"); } else { Efectivo = false; } eventAggregator.GetEvent <PubSubEvent <bool> >().Unsubscribe(VerificarVenta); }
private async void Crear() { Operacion.Debe = Total; if (Operacion.Debe > 0 && Banco != null) { var cuentaCorriente = await ApiProcessor.GetApi <CuentaCorrienteDto>($"CuentaCorriente/Banco/{Banco.Id}"); Operacion.CuentaCorrienteId = cuentaCorriente.Id; Operacion.FechaVencimiento = Operacion.FechaEmision; Operacion.TipoOperacion = TipoOperacion.Tranferencia; Operacion.Haber = 0; Operacion.Referencia = 0; Operacion.ReferenciaPlus = ""; var transferencia = new TransferenciaDto(); transferencia.BancoId = Banco.Id; transferencia.Usado = Usado; transferencia.ImpuestoBancario = 0; transferencia.Concepto = Operacion.Concepto; transferencia.Entrada = true; transferencia.Fecha = (DateTime)Operacion.FechaEmision; transferencia.PagueseA = Operacion.DePara; transferencia.Numero = long.Parse(Operacion.CodigoCausal); transferencia.Monto = (decimal)Operacion.Debe; await ApiProcessor.PostApi(transferencia, "Transferencia/Insert"); await ApiProcessor.PostApi(Operacion, "Operacion/Insert"); var diccionario = new Dictionary <string, bool>(); diccionario.Add("TransferenciaEntrada", false); Operacion = new OperacionDto(); MessageBox.Show("La operacion a sido registrado con exito!"); } }
public async Task Inicializar() { regionManager.RequestNavigate("RegionTarea", "Tarea"); regionManager.RequestNavigate("RegionIngresoMaterial", "IngresoMaterial"); regionManager.RequestNavigate("RegionSalidaMaterial", "SalidaMaterial"); regionManager.RequestNavigate("RegionJornal", "Jornal"); eventAggregator.GetEvent <ObraAgreggator>().Publish(Obra); Propietarios = new ObservableCollection <EmpresaDto>(await ApiProcessor.GetApi <EmpresaDto[]>("Empresa/GetAll")); DescripcionTareas = new ObservableCollection <DescripcionTareaDto>(await ApiProcessor.GetApi <DescripcionTareaDto[]>($"DescripcionTarea/GetAll")); Materiales = new ObservableCollection <MaterialDto>(await ApiProcessor.GetApi <MaterialDto[]>("Material/GetInsumos")); Tareas = new ObservableCollection <TareaDto>(await ApiProcessor.GetApi <TareaDto[]>($"Tarea/GetByObra/{Obra.Id}")); Obras = new ObservableCollection <ObraDto>(await ApiProcessor.GetApi <ObraDto[]>("Obra/GetAll")); Obras.Remove(Obras.FirstOrDefault(x => x.Id == Obra.Id)); Encargados = new ObservableCollection <EmpleadoDto>(await ApiProcessor.GetApi <EmpleadoDto[]>("Empleado/GetAll")); MaterialesPorObra = new ObservableCollection <MaterialDto>(await ApiProcessor.GetApi <MaterialDto[]>($"IngresoMaterial/GetMaterialByObra/{Obra.Id}")); IngresoMateriales = new ObservableCollection <IngresoMaterialDto>(await ApiProcessor.GetApi <IngresoMaterialDto[]>($"IngresoMaterial/GetByObra/{Obra.Id}")); CalcularDuracion(); CalcularTiempo(); ImBuzy = false; if (Tareas.All(x => x.Estado == Constantes.EstadoTarea.Finalizada)) { Obra.EstadoObra = Constantes.EstadoObra.Finalizada; await ApiProcessor.PutApi(Obra, $"Obra/{Obra.Id}"); } }
public async Task <object> GetUserPostsAsync(PostsPlatform platform, string platformId) { var requestPlatform = platform.ToApiString(); var jsonAsStream = await ApiProcessor.GetAsync($"{_baseUrl}/{requestPlatform}/{platformId}"); object apiData; switch (platform) { case PostsPlatform.Instagram: apiData = await _jsonHelper.Deserialise <PostBase[]>(jsonAsStream); break; case PostsPlatform.TikTok: apiData = await _jsonHelper.Deserialise <PostBase[]>(jsonAsStream); break; case PostsPlatform.Twitter: apiData = await _jsonHelper.Deserialise <PostBase[]>(jsonAsStream); break; default: throw new NotSupportedException("Invalid platform type."); } return(apiData); }
async void OnPrevButtonClicked(object sender, EventArgs e) { //System.Diagnostics.Debug.WriteLine(">>>>>>IDSTARTC:" + idStartCache + " IDLASTC:" + idLastCache); // nu putem sa ajungem sub id 0 pt retetele din cache, deci trebuie sa verificam daca // idStartCache va mai fi >=0 daca scadem pasul if (idStartCache - pasId >= 0) { // scadem de unde incepem pentru a ne duce inapoi idStartCache -= pasId; ShowPageData(idStartCache, pasId); } else { string alert = await ApiProcessor.LoadTranslation("Finished!"); string message = await ApiProcessor.LoadTranslation("These are the first recipes."); string action = await ApiProcessor.LoadTranslation("Ok."); await DisplayAlert(alert, message, action); } }
private async void deleteStaff_Click(object sender, RoutedEventArgs e) { if (staffSelectDropDown.SelectedItem == null) { MessageBox.Show("Устгах ажилчнаа сонгоно уу?"); return; } try { StaffModel model = (StaffModel)staffSelectDropDown.SelectedItem; if (Confirm() == false) { return; } var t = await ApiProcessor.DeleteStaffByID(model.id); if (t != "success") { MessageBox.Show("Устгалт амжилтгүй"); } ResetForm(); staffs.Clear(); UpdateDataGridEvent?.Invoke(this, ""); } catch { MessageBox.Show("Сүлжээний алдаа. Сүлжээнд холбогдсон эсэхээ шалгана уу?"); } }
private async Task CrearNuevoAsistenciaApi() { if (Asistencia.Entrada < Asistencia.Salida || !Asistencia.Asistio) { if (Asistencia.Empleado != null) { if (!Asistencia.Asistio) { Asistencia.CausaId = Asistencia.Causa.Id; } Asistencia.EmpleadoId = Asistencia.Empleado.Id; Asistencia.JornalId = Jornal.Id; await ApiProcessor.PostApi(Asistencia, "AsistenciaDiaria/Insert"); await Inicializar(); Asistencia = null; Asistencia = new AsistenciaDiariaDto(); Asistio = false; } } else { MessageBox.Show("La hora de entrada debe ser menor a la de salida"); } }
protected async override Task EliminarElemento() { await ApiProcessor.DeleteApi($"JornalMaterial/{JornalMaterial.Id}"); StockHelper.AgregarStock(JornalMaterial.MaterialId, JornalMaterial.CantidadUsado); await Inicializar(); }
private async void AddStaffsToDatabase() { var form = Validate(); if (form.isValid == false) { MessageBox.Show("Форматаа зөв оруулна уу?"); return; } try { var t = await ApiProcessor.SaveStaff(form.model); if (t == "success") { await InsertToAttendanceSheet(form.model); } else { MessageBox.Show("Мэдээллийг хадгалахад алдаа гарлаа."); } } catch { MessageBox.Show("Сүлжээний алдаа. Сүлжээнд холбогдсон эсэхээ шалгана уу?"); } }
private void SaveStaffToDatabase() { var form = ValidateForm(); if (form.isValid == false) { MessageBox.Show("Өгөгдлөө зөв бөглөнө үү?"); return; } //string sql = "UPDATE staff SET branch_id = @branch_id, firstName = @firstName, lastName = @LastName, hasLunch = @hasLunch, fingerPrint = @fingerPrint WHERE id = @id"; //Dictionary<string, object> parameters = new Dictionary<string, object> //{ // { "@id", form.model.id }, // {"@branch_id", form.model.branch_id }, // {"@firstName", form.model.firstName }, // {"@lastName", form.model.lastName }, // {"@hasLunch", form.model.hasLunch }, // {"@fingerPrint", fpTemplate } //}; //SqliteDataAccess.SaveData(sql, parameters); try { var t = Task.Run(() => ApiProcessor.EditStaffByID(form.model)); t.Wait(); if (t.Equals("fail")) { MessageBox.Show("Сүлжээний алдаа. Сүлжээнд холбогдсон эсэхээ шалгана уу?"); } } catch { MessageBox.Show("Сүлжээний алдаа. Сүлжээнд холбогдсон эсэхээ шалгана уу?"); } }
private async Task InsertToAttendanceSheet(StaffModel theStaff) { try { string currentDate = getCurrentDate(); bool isNewDay = IsNewDay(currentDate); if (isNewDay == false) { var staffs = await ApiProcessor.LoadStaffs(); foreach (StaffModel staff in staffs) { if (theStaff.fingerPrint.SequenceEqual(staff.fingerPrint)) { theStaff.id = staff.id; break; } } var form = ValidateAttendanceModel(theStaff); var t = Task.Run(async() => await ApiProcessor.SaveToAttendanceSheet(form.model)); var res = t.Result; } } catch { MessageBox.Show("Сүлжээний алдаа. Сүлжээнд холбогдсон эсэхээ шалгана уу?"); } }
private async void OnIngsPgCompleted(object sender, EventArgs e) { var result = int.Parse(((Entry)sender).Text); // se pot afisa doar intre 1 si 16 ingrediente per pagina // deci daca este sub sau peste, ii vom schimba valoarea if (result < 1) { result = 1; } if (result > 16) { result = 16; } App.IngsPerPage = result; string alert = await ApiProcessor.LoadTranslation("Changed!"); string message = await ApiProcessor.LoadTranslation("From now on we'll show " + result + " ingredients per page."); string action = await ApiProcessor.LoadTranslation("Ok"); await DisplayAlert(alert, message, action); }
public override async Task Inicializar() { Obras = new ObservableCollection <ObraDto>(await ApiProcessor.GetApi <ObraDto[]>("Obra/GetAll")); Propietarios = new ObservableCollection <EmpresaDto>(await ApiProcessor.GetApi <EmpresaDto[]>("Empresa/GetAll")); Zonas = new ObservableCollection <ZonaDto>(await ApiProcessor.GetApi <ZonaDto[]>("Zona/GetAll")); Encargados = new ObservableCollection <EmpleadoDto>(await ApiProcessor.GetApi <EmpleadoDto[]>("Empleado/GetAll")); }
private async void Crear() { if (Operacion.Debe > 0 && Banco != null) { var cuentaCorriente = await ApiProcessor.GetApi <CuentaCorrienteDto>($"CuentaCorriente/Banco/{Banco.Id}"); Operacion.CuentaCorrienteId = cuentaCorriente.Id; Operacion.FechaVencimiento = Operacion.FechaEmision; Operacion.TipoOperacion = TipoOperacion.Deposito; Operacion.Haber = 0; Operacion.Referencia = 0; Operacion.ReferenciaPlus = ""; var deposito = new DepositoDto(); deposito.BancoId = Banco.Id; deposito.Usado = Usado; deposito.Entrada = true; deposito.Fecha = (DateTime)Operacion.FechaEmision; deposito.Concepto = Operacion.Concepto; deposito.DePara = Operacion.DePara; deposito.Numero = long.Parse(Operacion.CodigoCausal); deposito.Monto = (decimal)Operacion.Debe; await ApiProcessor.PostApi(deposito, "Deposito/Insert"); await ApiProcessor.PostApi(Operacion, "Operacion/Insert"); var diccionario = new Dictionary <string, bool>(); diccionario.Add("DepositoEntrada", false); Operacion = new OperacionDto(); MessageBox.Show("La operacion a sido registrado con exito!"); } }
// afiseaza toate ingredientele cu numele similar cu m_search async void ShowPageData(string m_search) { NextBtn.IsVisible = false; PrevBtn.IsVisible = false; //LoadingIng.Text = "Se cauta ingrediente..."; List <Ingrediente> eng_listaIngrediente = await ApiProcessor.LoadSearchIngredients(m_listaIngrediente, m_search); listViewIngrediente.ItemsSource = ApiProcessor.LoadTranslationIngrediente(eng_listaIngrediente); //LoadingIng.Text = ""; if (eng_listaIngrediente.Count == 0) { // afisam o alerta daca nu am gasit niciun ingredient string alert = await ApiProcessor.LoadTranslation("Oops!"); string message = await ApiProcessor.LoadTranslationLong("We couldn't find any ingredients. Try writing the entire name of the ingredient or using diacritics."); string action = await ApiProcessor.LoadTranslation("Ok."); await DisplayAlert(alert, message, action); } }
/// <summary> /// 分析Redis缓存中packetKey的数据包并处理 /// </summary> private void AnalyticMessage(ISocketSession session) { //StringLocker.Run("packetKey",) //{ string str = ""; //var packetList = redis.ListRange<string>("packetKey", 0, 10, DataType.Protobuf);//每次取10条数据 var packetList = redis.Smember <DataPacket>("packetKey", DataType.Protobuf); packetList.ForEach(async p => { //var packet = Formatter.Deserialize<DataPacket>(p);//反序列化 var responseMessage = await ApiProcessor.Process(p.Data); str = responseMessage == null ? "" : responseMessage.ToString(); }); session.Send(str); //StringLocker.Run("device", () => Task.Factory.StartNew(() => ApiProcessor.ProcessRedisCache())); //Thread.Sleep(50);//等待数据处理完毕后,在处理缓存 if (_processRedisTimer == null) { _processRedisTimer = new TimerX(obj => ApiProcessor.ProcessRedisCache(), null, 1000, 5000); } //Task.Factory.StartNew(() => ApiProcessor.ProcessRedisCache());//处理缓存 //} }
async void OnNextButtonClicked(object sender, EventArgs e) { // avem numai idMax ingrediente si va trebui sa adunam pasId pentru a trece // la urmatorul set, deci vom verifica daca locul de unde incepem este sub // id-ul maxim, adica daca mai putem afisa macar un ingredient // si in cazul in care nu mai putem afisa un set intreg de ingrediente // in functia de afisare va afisa doar ingredientele ramase // daca trecem peste idMax atunci vom afisa un mesaj de alerta care ne // spune ca nu mai exista ingrediente if (idStart + pasId < idMax) { idStart += pasId; ShowPageData(idStart, pasId); } else { string alert = await ApiProcessor.LoadTranslation("Finished!"); string message = await ApiProcessor.LoadTranslation("These are all the ingredients."); string action = await ApiProcessor.LoadTranslation("Ok."); await DisplayAlert(alert, message, action); } }
// afiseaza un set de ingrediente per pagina void ShowPageData(int m_idStart, int m_pasId) { NextBtn.IsVisible = true; PrevBtn.IsVisible = true; //DisplayAlert("VERIF22", "X_idStart=" + m_idStart + "X_idMax =" + idMax, "Ok."); List <Ingrediente> eng_listaIngrediente = ApiProcessor.LoadSomeIngredients(m_listaIngrediente, m_idStart, m_pasId, idMax); listViewIngrediente.ItemsSource = ApiProcessor.LoadTranslationIngrediente(eng_listaIngrediente); var converter = new ColorTypeConverter(); // daca nu mai putem merge in una dintre directii, culoarea butonului va deveni roz // daca mai putem merge, culoarea se va transforma in verde if (m_idStart <= 0) { PrevBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightCoral"); } else { PrevBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightGreen"); } if (m_idStart + m_pasId >= idMax) { NextBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightCoral"); } else { NextBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightGreen"); } }
public override async Task Inicializar() { regionManager.RequestNavigate("RegionTareaPlanificacion", "Tarea"); regionManager.RequestNavigate("Gantt", "Gantt"); eventAggregator.GetEvent <ObraAgreggator>().Publish(Obra); DescripcionTareas = new ObservableCollection <DescripcionTareaDto>(await ApiProcessor.GetApi <DescripcionTareaDto[]>($"DescripcionTarea/GetAll")); }
async void OnIngredientDeleteItemSelected(object sender, SelectedItemChangedEventArgs e) { Ingrediente ing; if (e.SelectedItem != null) { ing = e.SelectedItem as Ingrediente; // verificam daca utilizatorul doreste sa stearga ingredientul string alert = await ApiProcessor.LoadTranslation("Attention!"); string message = await ApiProcessor.LoadTranslation("Are you sure you want to erase " + ing.StrIngredient + " ?"); string action_yes = await ApiProcessor.LoadTranslation("Yes"); string action_no = await ApiProcessor.LoadTranslation("No"); var action = await DisplayAlert(alert, message, action_yes, action_no); if (action) { App.listaIngredienteFrigider.Remove(ing); idMax = App.listaIngredienteFrigider.Count; // resetam cache-ul retetelor RecipesPage.InitialiseRecipesCache(); // dupa ce stergem un ingredient vom da "refresh" la informatiile de pe pagina ShowPageData(idStart, pasId); } } }
public async Task StatsPSNPlunder([Remainder] string userName) { var jsonAsString = await ApiProcessor.GetUser( $"https://api.tracker.gg/api/v2/warzone/standard/profile/psn/{userName}"); var apiData = JsonConvert.DeserializeObject <ModerWarfareApiOutput>(jsonAsString); var name = apiData.Data.PlatformInfo.PlatformUserHandle; var pfp = apiData.Data.PlatformInfo.AvatarUrl; var levelImg = apiData.Data.Segment[0].Stats.Level.Metadata.IconUrl; var client = new ModernWarfareClient(); var allStats = await client.GetWarzoneStatsAsync(Platform.PSN, userName); var plunderStats = allStats.PlunderStats; var converter = new HtmlConverter(); var generationStrings = new StatsGenerationFiles(); string css = generationStrings.WarzoneCss(allStats.LifetimeStats.LevelProgression.DisplayValue); string html = String.Format(generationStrings.PlunderHtml(name, pfp, plunderStats.TimePlayed.DisplayValue, plunderStats.GamesPlayed.DisplayValue, levelImg.ToString(), allStats.LifetimeStats.Level.DisplayValue, allStats.LifetimeStats.LevelProgression.DisplayValue, plunderStats.KdRatio.DisplayValue, plunderStats.Kills.DisplayValue, plunderStats.WlRatio.DisplayValue, plunderStats.Wins.DisplayValue, plunderStats.Deaths.DisplayValue, plunderStats.AvarageLife.DisplayValue, plunderStats.Score.DisplayValue, plunderStats.ScorePerGame.DisplayValue, plunderStats.ScorePerMinute.DisplayValue, plunderStats.Downs.DisplayValue, plunderStats.Cash.DisplayValue, plunderStats.Contracts.DisplayValue)); int width = 520; var bytes = converter.FromHtmlString(css + html, width, CoreHtmlToImage.ImageFormat.Png); File.WriteAllBytes("Resources/PSNPlunderStats.png", bytes); await Context.Channel.SendFileAsync(new MemoryStream(bytes), "Resources/PSNPlunderStats.png"); }
private async void Filtrar() { if (FechaDesde < FechaHasta) { Cajas = new ObservableCollection <CajaDto>(await ApiProcessor.GetApi <CajaDto[]>($"Caja/GetDesde/{FechaDesde.ToString("MM-dd-yyyy")}/{FechaHasta.ToString("MM-dd-yyyy")}")); } }
private async void deleteBranch_Click(object sender, RoutedEventArgs e) { if (branchSelectDropdown.SelectedItem == null) { MessageBox.Show("Устгах тасгаа сонгоно уу?"); return; } try { BranchModel model = (BranchModel)branchSelectDropdown.SelectedItem; var t = await ApiProcessor.DeleteBranchByID(model.id); if (t != "success") { MessageBox.Show("Устгалт амжилтгүй."); } ResetForm(); branches.Clear(); UpdateDataGridEvent?.Invoke(this, ""); } catch { MessageBox.Show("Сүлжээний алдаа. Сүлжээнд холбогдсон эсэхээ шалгана уу?"); } }
public async Task RegisterBN([Remainder] string gameUsername) { if (gameUsername.Contains("#")) { gameUsername = gameUsername.Replace("#", "%23"); } else { var errorEmbed = new EmbedBuilder(); errorEmbed.WithTitle("Ouch! An error occurred."); errorEmbed.WithDescription("Invalid BattleNet username."); errorEmbed.WithColor(255, 0, 0); await Context.Channel.SendMessageAsync("", false, errorEmbed.Build()); return; } var jsonAsString = await ApiProcessor.GetUser($"https://api.tracker.gg/api/v2/warzone/standard/profile/battlenet/{gameUsername}"); var serverAccount = ServerAccounts.GetAccount(Context.Guild); var account = UserAccounts.GetAccount(Context.User); account.Platform = "battlenet"; account.GameUsername = gameUsername; UserAccounts.SaveAccounts(); var embed = new EmbedBuilder(); embed.WithDescription($"**Server Prefix:** `{serverAccount.Prefix}`"); embed.WithImageUrl("https://i.imgur.com/0hI99PO.png"); await Context.Channel.SendMessageAsync("", false, embed.Build()); }
public async Task Inicializar() { Obras = new ObservableCollection <ObraDto>(await ApiProcessor.GetApi <ObraDto[]>($"Obra/GetAll")); PointLabel = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation); Series = new SeriesCollection(); }
public async Task <Coupons> GetCouponsByBranchAsync(string id) { var jsonAsStream = await ApiProcessor.GetAsync($"{_baseUrl}/for/{id}"); var apiData = await _jsonHelper.Deserialise <Coupons>(jsonAsStream); return(apiData); }
public override async Task Inicializar() { Tareas = new ObservableCollection <TareaDto>(await ApiProcessor.GetApi <TareaDto[]>($"Tarea/GetByObra/{Obra.Id}")); if (Tareas.Count > 0) { eventAggregator.GetEvent <PubSubEvent <ObservableCollection <TareaDto> > >().Publish(Tareas); } }
public async Task <Search[]> SearchUserAsync(string term) { var jsonAsStream = await ApiProcessor.GetAsync($"{_baseUrl}/smart/{term}"); var apiData = await _jsonHelper.Deserialise <Search[]>(jsonAsStream); return(apiData); }
public async Task <Viral[]> GetViralsAsync() { var jsonAsStream = await ApiProcessor.GetAsync($"{_baseUrl}/"); var apiData = await _jsonHelper.Deserialise <Viral[]>(jsonAsStream); return(apiData); }
public async Task Inicializar() { Comprobantes = new ObservableCollection <ComprobanteCompraDto>(await ApiProcessor.GetApi <ComprobanteCompraDto[]>("ComprobanteCompra/GetAll")); if (Comprobantes.Count() == 0) { SinComprobantes = Visibility.Visible; } }