private async Task <bool> GetTokenSuccess() { bool result = false; Response resultToken = await ApiSrv.GetToken(); if (resultToken.IsSuccess) { TokenGet = JsonConvert.DeserializeObject <Token>(Crypto.DecodeString(resultToken.Data)); result = true; } return(result); }
private async void GetLogs() { try { UserDialogs.Instance.ShowLoading("Obteniendo bitácoras...", MaskType.Black); Response resultApiIsAvailable = await ApiSrv.ApiIsAvailable(); if (!resultApiIsAvailable.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultApiIsAvailable.Message); return; } Response resultToken = await ApiSrv.GetToken(); if (!resultToken.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultToken.Message); return; } else { Token token = JsonConvert.DeserializeObject <Token>(Crypto.DecodeString(resultToken.Data)); Response resultGetLogs = await ApiSrv.GetLogs(token.Key); if (!resultGetLogs.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultGetLogs.Message); return; } else { Logs = JsonConvert.DeserializeObject <List <Log> >(Crypto.DecodeString(resultGetLogs.Data)); LogItems = new ObservableCollection <LogItem>(); foreach (Log log in Logs) { LogItems.Add(new LogItem() { IsExecution = this.IsExecution, IdLog = (Int32)log.IdLog, NameLog = log.NameLog.Trim(), IsEventual = (bool)log.IsEventual, NotIsEventual = !(bool)log.IsEventual, BarItemColor = ((bool)log.IsEventual) ? BarItemColor.HighLight : BarItemColor.Base, IdEnvironment = (Int16)log.IdEnvironment, NameEnvironment = log.NameEnvironment.Trim(), ExecutionDateTime = (log.ExecutionDateTime != null) ? (DateTime)log.ExecutionDateTime : new DateTime(), EndingDateTime = (log.EndingDateTime != null) ? (DateTime)log.EndingDateTime : new DateTime(), ExecutionDateTimeString = (log.ExecutionDateTime != null) ? ((DateTime)log.ExecutionDateTime).ToString(DateTimeFormatString.LatinDate24Hours) : "", EndingDateTimeString = (log.EndingDateTime != null) ? ((DateTime)log.EndingDateTime).ToString(DateTimeFormatString.LatinDate24Hours) : "", TotalCommands = (Int32)log.TotalCommands, ErrorCommands = (Int32)log.ErrorCommands, IsChecked = false, IsEnabled = true, IdUser = PbUser.IdUser, Operator = string.Format("{0} ({1}, {2})", PbUser.IdUser, PbUser.FisrtName.Trim(), PbUser.LastName.Trim()), NotificationIcon = IconSet.Notification }); } if (LogItems.Count == 0) { this.FullViewIsVisible = false; this.CompactViewIsVisible = false; this.IsVisibleEmptyView = true; } else { this.FullViewIsVisible = true; this.CompactViewIsVisible = false; this.IsVisibleEmptyView = false; } } } UserDialogs.Instance.HideLoading(); } catch //(Exception ex) { UserDialogs.Instance.HideLoading(); Toast.ShowError("Ocurrió un error."); //return; } }
private async void GetInitialData() { try { UserDialogs.Instance.ShowLoading("Obteniendo datos del monitor de procesos...", MaskType.Black); Response resultApiIsAvailable = await ApiSrv.ApiIsAvailable(); if (!resultApiIsAvailable.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultApiIsAvailable.Message); return; } Response resultToken = await ApiSrv.GetToken(); if (!resultToken.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultToken.Message); return; } else { Token token = JsonConvert.DeserializeObject <Token>(Crypto.DecodeString(resultToken.Data)); MonitorDataQueryValues query = new MonitorDataQueryValues() { CurrentDate = DateTime.Now, IsRecurrent = 0 }; Response resultGetMonitorData = await ApiSrv.MonitorGetData(token.Key, query); if (!resultGetMonitorData.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultGetMonitorData.Message); return; } else { MonitorData = JsonConvert.DeserializeObject <List <Monitor> >(Crypto.DecodeString(resultGetMonitorData.Data)); ProcessItems = new ObservableCollection <ProcessItem>(); foreach (Monitor item in MonitorData) { ProcessItems.Add(new ProcessItem() { IdCalendar = item.IdCalendar, PID = item.PID, IdLot = (item.IdLot != null) ? (Int32)item.IdLot : 0, NameLot = item.NameLot, IdCommand = (item.IdCommand != null) ? (Int32)item.IdCommand : 0, NameCommand = item.NameCommand, IdEnvironment = (item.IdEnvironment) != null ? (short)item.IdEnvironment : new short(), NameEnvironment = item.NameEnvironment, IPAddress = item.IPAddress, IdService = (item.IdService != null) ? (short)item.IdService : new short(), NameService = item.NameService, IsServicePD = (item.IsServicePD != null) ? (bool)item.IsServicePD : false, StartHour = (item.StartHour != null) ? (TimeSpan)item.StartHour : new TimeSpan(), IdStatus = (item.IdStatus != null) ? (string)item.IdStatus : "", Ommited = (item.Ommited != null) ? (string)item.Ommited : "", ExecutionStart = (item.ExecutionStart != null) ? (DateTime)item.ExecutionStart : new DateTime(), ExecutionEnd = (item.ExecutionEnd != null) ? (DateTime)item.ExecutionEnd : new DateTime(), ReExecution = (item.ReExecution != null) ? (bool)item.ReExecution : false, RecurrenceTime = (item.RecurrenceTime != null) ? (TimeSpan)item.RecurrenceTime : new TimeSpan(), EndHour = (item.EndHour != null) ? (TimeSpan)item.EndHour : new TimeSpan(), Order = (item.Order) != null ? (short)item.Order : new short(), StartHourString = (item.StartHour != null) ? ((TimeSpan)item.StartHour).ToString() : "", ExecutionStartString = (item.ExecutionStart != null) ? ((DateTime)item.ExecutionStart).ToString(DateTimeFormatString.LatinDate24Hours) : "", ExecutionEndString = (item.ExecutionEnd != null) ? ((DateTime)item.ExecutionEnd).ToString(DateTimeFormatString.LatinDate24Hours) : "", RecurrenceTimeString = (item.RecurrenceTime != null) ? ((TimeSpan)item.RecurrenceTime).ToString() : "", EndHourString = (item.EndHour != null) ? ((TimeSpan)item.EndHour).ToString() : "", IsChecked = false, IsEnabled = true, Status = GetExecutionStatus.ByIdStatus((item.IdStatus != null) ? (string)item.IdStatus.Trim() : "") }); } //if (LogItems.Count == 0) //{ // this.FullViewIsVisible = false; // this.CompactViewIsVisible = false; // this.IsVisibleEmptyView = true; //} //else //{ // this.FullViewIsVisible = true; // this.CompactViewIsVisible = false; // this.IsVisibleEmptyView = false; //} } } UserDialogs.Instance.HideLoading(); } catch //(Exception ex) { UserDialogs.Instance.HideLoading(); Toast.ShowError("Ocurrió un error."); } }
private async void GetCommandsByInstance(int IdInstance) { try { UserDialogs.Instance.ShowLoading("Obteniendo lote/comandos...", MaskType.Black); Response resultApiIsAvailable = await ApiSrv.ApiIsAvailable(); if (!resultApiIsAvailable.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultApiIsAvailable.Message); return; } Response resultToken = await ApiSrv.GetToken(); if (!resultToken.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultToken.Message); return; } else { Token token = JsonConvert.DeserializeObject <Token>(Crypto.DecodeString(resultToken.Data)); CommandQueryValues commandQueryValues = new CommandQueryValues() { IdInstance = this.InstanceItem.IdInstance }; Response resultGetCommandsByInstance = await ApiSrv.GetCommandsByInstance(token.Key, commandQueryValues); if (!resultGetCommandsByInstance.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultGetCommandsByInstance.Message); return; } else { Commands = JsonConvert.DeserializeObject <List <Cmd> >(Crypto.DecodeString(resultGetCommandsByInstance.Data)); CommandItems = new ObservableCollection <CommandItem>(); foreach (Cmd command in Commands) { TimeSpan execTime = TimeSpan.FromMinutes(command.ExecutionTime); CommandItems.Add(new CommandItem() { IsExecution = this.IsExecution, IdLot = command.IdLot, NameLot = command.NameLot.Trim(), IdCommand = command.IdCommand, NameCommand = command.NameCommand.Trim(), Order = command.Order, IdStatus = command.IdStatus, Duration = string.Format("{0:00} hora(s) {1:00} minuto(s)", (int)execTime.TotalHours, execTime.Minutes), ExecutionStart = (command.ExecutionDateTime != null) ? ((DateTime)command.ExecutionDateTime).ToString(DateTimeFormatString.LatinDate24Hours) : "", ExecutionEnd = (command.EndDateTime != null) ? ((DateTime)command.EndDateTime).ToString(DateTimeFormatString.LatinDate24Hours) : "", IsChecked = false, IsEnabled = true, StatusColor = GetStatusColor.ByIdStatus(command.IdStatus.Trim()), InstanceItem = this.InstanceItem, BarItemColor = (this.InstanceItem.LogItem.IsEventual) ? BarItemColor.HighLight : BarItemColor.Base }); } if (CommandItems.Count == 0) { this.FullViewIsVisible = false; this.CompactViewIsVisible = false; this.IsVisibleEmptyView = true; } else { this.FullViewIsVisible = true; this.CompactViewIsVisible = false; this.IsVisibleEmptyView = false; } } } UserDialogs.Instance.HideLoading(); } catch //(Exception ex) { UserDialogs.Instance.HideLoading(); Toast.ShowError("Ocurrió un error."); } }
private async void GetInstancesByLogAndUser(int IdLog, string IdUser, bool IsEventual) { try { UserDialogs.Instance.ShowLoading("Obteniendo instancias...", MaskType.Black); Response resultApiIsAvailable = await ApiSrv.ApiIsAvailable(); if (!resultApiIsAvailable.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultApiIsAvailable.Message); return; } Response resultToken = await ApiSrv.GetToken(); if (!resultToken.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultToken.Message); return; } else { Token token = JsonConvert.DeserializeObject <Token>(Crypto.DecodeString(resultToken.Data)); InstanceQueryValues instanceQueryValues = new InstanceQueryValues() { IdLog = IdLog, IdUser = IdUser, IsEventual = IsEventual }; Response resultGetInstancesByLogAndUser = await ApiSrv.GetInstancesByLogAndUser(token.Key, instanceQueryValues); if (!resultGetInstancesByLogAndUser.IsSuccess) { UserDialogs.Instance.HideLoading(); Toast.ShowError(resultGetInstancesByLogAndUser.Message); return; } else { Instances = JsonConvert.DeserializeObject <List <Instance> >(Crypto.DecodeString(resultGetInstancesByLogAndUser.Data)); InstanceItems = new ObservableCollection <InstanceItem>(); foreach (Instance instance in Instances) { InstanceItems.Add(new InstanceItem() { IsExecution = this.IsExecution, IdInstance = instance.IdInstance, InstanceNumber = instance.InstanceNumber, NameInstance = instance.NameInstance.Trim(), IdStatusInstance = instance.IdStatusInstance, IdStatusLastCommand = instance.IdStatusLastCommand, TotalCommands = instance.TotalCommands, PendingCommands = instance.PendingCommands, OkCommands = instance.OkCommands, ErrorCommands = instance.ErrorCommands, OmittedCommands = instance.OmittedCommands, IsChecked = false, IsEnabled = true, NotificationIcon = IconSet.Notification, StatusInstanceColor = GetStatusColor.ByIdStatus(instance.IdStatusInstance.Trim()), StatusLastProcessColor = GetStatusColor.ByIdStatus(instance.IdStatusLastCommand.Trim()), LogItem = this.LogItem, BarItemColor = (this.logitem.IsEventual) ? BarItemColor.HighLight : BarItemColor.Base }); } if (InstanceItems.Count == 0) { this.FullViewIsVisible = false; this.CompactViewIsVisible = false; this.IsVisibleEmptyView = true; } else { this.FullViewIsVisible = true; this.CompactViewIsVisible = false; this.IsVisibleEmptyView = false; } } } UserDialogs.Instance.HideLoading(); } catch //(Exception ex) { UserDialogs.Instance.HideLoading(); Toast.ShowError("Ocurrió un error."); } }