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.");
            }
        }
Beispiel #2
0
 public async Task <Response> GetInstancesByLogAndUser(string accessToken, InstanceQueryValues QueryValues)
 {
     return(await HttpPost(accessToken, this.ApiControllerSet, ApiMethod.GetInstancesByLogAndUser, QueryValues));
 }