private async void GetInitialData() { try { UserDialogs.Instance.ShowLoading("Obteniendo comandos a controlar...", MaskType.Black); if (!await ApiIsOnline()) { UserDialogs.Instance.HideLoading(); Toast.ShowError(AlertMessages.Error); return; } else { if (!await GetTokenSuccess()) { UserDialogs.Instance.HideLoading(); Toast.ShowError(AlertMessages.Error); return; } else { ControlSchedulesExecutionQueryValues QueryValues = new ControlSchedulesExecutionQueryValues() { IdLog = this.LogItem.IdLog }; Response resultCommandsToControlGet = await ApiSrv.GetControlSchedulesExecution(TokenGet.Key, QueryValues); if (!resultCommandsToControlGet.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(AlertMessages.Error); return; } else { ControlSchedulesExecutions = JsonConvert.DeserializeObject <List <ControlSchedulesExecution> >(Crypto.DecodeString(resultCommandsToControlGet.Data)); CommandsToControlItems = new ObservableCollection <CommandsToControl>(); foreach (ControlSchedulesExecution controlSchedulesExecution in ControlSchedulesExecutions) { CommandsToControlItems.Add(new CommandsToControl() { IdStatus = controlSchedulesExecution.IdStatus, InstanceNumber = controlSchedulesExecution.InstanceNumber, Lot = controlSchedulesExecution.Lot, Command = controlSchedulesExecution.Command, StartDate = (controlSchedulesExecution.StartDate != null) ? (DateTime)controlSchedulesExecution.StartDate : new DateTime(), EndDate = (controlSchedulesExecution.EndDate != null) ? (DateTime)controlSchedulesExecution.EndDate : new DateTime(), TimeFrom = (controlSchedulesExecution.TimeFrom != null) ? (DateTime)controlSchedulesExecution.TimeFrom : new DateTime(), TimeUntil = (controlSchedulesExecution.TimeUntil != null) ? (DateTime)controlSchedulesExecution.TimeUntil : new DateTime(), OutOfSchedule = controlSchedulesExecution.OutOfSchedule, CriticalBusiness = controlSchedulesExecution.CriticalBusiness, StartDateString = (controlSchedulesExecution.StartDate != null) ? ((DateTime)controlSchedulesExecution.StartDate).ToString(DateTimeFormatString.LatinDate) : "", EndDateString = (controlSchedulesExecution.EndDate != null) ? ((DateTime)controlSchedulesExecution.EndDate).ToString(DateTimeFormatString.LatinDate) : "", TimeFromString = (controlSchedulesExecution.TimeFrom != null) ? ((DateTime)controlSchedulesExecution.TimeFrom).ToString(DateTimeFormatString.Time24Hour) : "", TimeUntilString = (controlSchedulesExecution.TimeUntil != null) ? ((DateTime)controlSchedulesExecution.TimeUntil).ToString(DateTimeFormatString.Time24Hour) : "", StatusColorEE = GetStatusColor.ByIdStatus(controlSchedulesExecution.IdStatus.Trim()), StatusColorEC = (controlSchedulesExecution.OutOfSchedule != null) ? StatusColor.Red : StatusColor.White, }); } UserDialogs.Instance.HideLoading(); if (CommandsToControlItems.Count == 0) { bool result = await Confirm.Show(string.Format("No hay comandos a controlar para la bitácora: {0}, desea cerrar la vista?", this.LogItem.NameLog)); if (result) { Application.Current.MainPage.Navigation.PopAsync(); } } } } } } catch (Exception ex) { UserDialogs.Instance.HideLoading(); Toast.ShowError(AlertMessages.Error); } }
public async Task <Response> GetControlSchedulesExecution(string accessToken, ControlSchedulesExecutionQueryValues QueryValues) { return(await HttpPost(accessToken, this.ApiControllerSet, ApiMethod.ControlSchedulesExecution, QueryValues)); }