Example #1
0
 public async Task <Response> DependenciesGetCommandsThatDepends(string accessToken, DependenciesGetCommandsThatDependsQueryValues QueryValues)
 {
     return(await HttpPost(accessToken, this.ApiControllerSet, ApiMethod.DependenciesGetCommandsThatDepends, QueryValues));
 }
Example #2
0
        private async void GetInitialData()
        {
            try
            {
                UserDialogs.Instance.ShowLoading("Obteniendo lotes de los que depende...", 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
                    {
                        DependenciesGetLotsThatDependsQueryValues dependenciesGetLotsThatDependsQueryValues = new DependenciesGetLotsThatDependsQueryValues()
                        {
                            IdLog = this.CommandItem.InstanceItem.LogItem.IdLog,
                            IdLot = this.commanditem.IdLot
                        };
                        Response resultGetDependenciesLots = await ApiSrv.DependenciesGetLotsThatDepends(TokenGet.Key, dependenciesGetLotsThatDependsQueryValues);

                        if (!resultGetDependenciesLots.IsSuccess)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            DependenciesLots     = JsonConvert.DeserializeObject <List <DependenciesLot> >(Crypto.DecodeString(resultGetDependenciesLots.Data));
                            DependenciesLotItems = new ObservableCollection <DependenciesLotItem>();
                            foreach (DependenciesLot dependenciesLot in DependenciesLots)
                            {
                                DependenciesLotItems.Add(new DependenciesLotItem()
                                {
                                    IdLot       = dependenciesLot.IdLot,
                                    Code        = dependenciesLot.Code,
                                    NameLot     = dependenciesLot.NameLot,
                                    Type        = dependenciesLot.Type,
                                    NameType    = dependenciesLot.NameType,
                                    Status      = dependenciesLot.Status,
                                    AddedDate   = (dependenciesLot.AddedDate != null) ? (DateTime)dependenciesLot.AddedDate : new DateTime(),
                                    Number      = dependenciesLot.Number,
                                    Instance    = this.CommandItem.InstanceItem.NameInstance,
                                    StatusColor = GetStatusColor.ByIdStatus(dependenciesLot.IdStatus.Trim())
                                });
                            }
                        }
                        UserDialogs.Instance.HideLoading();
                        UserDialogs.Instance.ShowLoading("Obteniendo lotes que dependen de este...", MaskType.Black);
                        DependenciesGetDependentLotDetailQueryValues dependenciesGetDependentLotDetailQuery = new DependenciesGetDependentLotDetailQueryValues()
                        {
                            IdLog = this.CommandItem.InstanceItem.LogItem.IdLog,
                            IdLot = this.commanditem.IdLot
                        };
                        Response resultGetDependenciesLotsDetail = await ApiSrv.DependenciesGetDependentLotDetail(TokenGet.Key, dependenciesGetDependentLotDetailQuery);

                        if (!resultGetDependenciesLotsDetail.IsSuccess)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            DependenciesDetailLots     = JsonConvert.DeserializeObject <List <DependenciesLot> >(Crypto.DecodeString(resultGetDependenciesLotsDetail.Data));
                            DependenciesLotDetailItems = new ObservableCollection <DependenciesLotItem>();
                            foreach (DependenciesLot dependenciesLot in DependenciesDetailLots)
                            {
                                DependenciesLotDetailItems.Add(new DependenciesLotItem()
                                {
                                    IdLot       = dependenciesLot.IdLot,
                                    Code        = dependenciesLot.Code,
                                    NameLot     = dependenciesLot.NameLot,
                                    Type        = dependenciesLot.Type,
                                    NameType    = dependenciesLot.NameType,
                                    Status      = dependenciesLot.Status,
                                    AddedDate   = (dependenciesLot.AddedDate != null) ? (DateTime)dependenciesLot.AddedDate : new DateTime(),
                                    Number      = dependenciesLot.Number,
                                    Instance    = this.CommandItem.InstanceItem.NameInstance,
                                    StatusColor = GetStatusColor.ByIdStatus(dependenciesLot.IdStatus.Trim())
                                });
                            }
                        }
                        UserDialogs.Instance.HideLoading();
                        UserDialogs.Instance.ShowLoading("Obteniendo lotes-comandos de los que depende...", MaskType.Black);
                        DependenciesGetCommandsThatDependsQueryValues dependenciesGetCommandsThatDependsQueryValues = new DependenciesGetCommandsThatDependsQueryValues()
                        {
                            IdLog = this.CommandItem.InstanceItem.LogItem.IdLog,
                            IdLot = this.commanditem.IdLot
                        };
                        Response resultGetDependenciesCommands = await ApiSrv.DependenciesGetCommandsThatDepends(TokenGet.Key, dependenciesGetCommandsThatDependsQueryValues);

                        if (!resultGetDependenciesCommands.IsSuccess)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            DependenciesCommands     = JsonConvert.DeserializeObject <List <DependenciesCommand> >(Crypto.DecodeString(resultGetDependenciesCommands.Data));
                            DependenciesCommandItems = new ObservableCollection <DependenciesCommandItem>();
                            foreach (DependenciesCommand dependenciesCommand in DependenciesCommands)
                            {
                                DependenciesCommandItems.Add(new DependenciesCommandItem()
                                {
                                    IdCommand        = dependenciesCommand.IdCommand,
                                    Skip             = dependenciesCommand.Skip,
                                    Type             = dependenciesCommand.Type,
                                    IdLot            = dependenciesCommand.IdLot,
                                    Lot              = dependenciesCommand.Lot,
                                    Command          = dependenciesCommand.Command,
                                    LotOrder         = dependenciesCommand.LotOrder,
                                    NameType         = dependenciesCommand.NameType,
                                    Status           = dependenciesCommand.Status,
                                    AddedDate        = (dependenciesCommand.AddedDate != null) ? (DateTime)dependenciesCommand.AddedDate : new DateTime(),
                                    Number           = dependenciesCommand.Number,
                                    IdStatus         = dependenciesCommand.IdStatus,
                                    CriticalBusiness = dependenciesCommand.CriticalBusiness,
                                    StatusColor      = GetStatusColor.ByIdStatus(dependenciesCommand.IdStatus.Trim()),
                                    Instance         = this.CommandItem.InstanceItem.NameInstance
                                });
                            }
                        }
                        UserDialogs.Instance.HideLoading();
                        UserDialogs.Instance.ShowLoading("Obteniendo lotes-comandos que dependen de este...", MaskType.Black);
                        DependenciesGetDependentCommandDetailQueryValues dependenciesGetDependentCommandDetailQueryValues = new DependenciesGetDependentCommandDetailQueryValues()
                        {
                            IdLog = this.CommandItem.InstanceItem.LogItem.IdLog,
                            IdLot = this.commanditem.IdLot
                        };
                        Response resultGetDependenciesCommandsDetail = await ApiSrv.DependenciesGetDependentCommandDetail(TokenGet.Key, dependenciesGetDependentCommandDetailQueryValues);

                        if (!resultGetDependenciesCommandsDetail.IsSuccess)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            DependenciesDetailCommands     = JsonConvert.DeserializeObject <List <DependenciesCommandDetail> >(Crypto.DecodeString(resultGetDependenciesCommandsDetail.Data));
                            DependenciesCommandDetailItems = new ObservableCollection <DependenciesCommandDetailItem>();
                            foreach (DependenciesCommandDetail dependenciesCommandDetail in DependenciesDetailCommands)
                            {
                                DependenciesCommandDetailItems.Add(new DependenciesCommandDetailItem()
                                {
                                    IdCommand        = dependenciesCommandDetail.IdCommand,
                                    Skip             = dependenciesCommandDetail.Skip,
                                    Type             = dependenciesCommandDetail.Type,
                                    IdLot            = dependenciesCommandDetail.IdLot,
                                    Lot              = dependenciesCommandDetail.Lot,
                                    Command          = dependenciesCommandDetail.Command,
                                    NameType         = dependenciesCommandDetail.NameType,
                                    Number           = dependenciesCommandDetail.Number,
                                    IdStatus         = dependenciesCommandDetail.IdStatus,
                                    CriticalBusiness = dependenciesCommandDetail.CriticalBusiness,
                                    StatusColor      = GetStatusColor.ByIdStatus(dependenciesCommandDetail.IdStatus.Trim()),
                                    Instance         = this.CommandItem.InstanceItem.NameInstance
                                });
                            }
                        }
                        UserDialogs.Instance.HideLoading();
                        UserDialogs.Instance.ShowLoading("Obteniendo recursos de dependencias...", MaskType.Black);
                        DependenciesGetResourceQueryValues dependenciesGetResourceQueryValues = new DependenciesGetResourceQueryValues()
                        {
                            IdCommand = this.CommandItem.IdCommand
                        };
                        Response resultGetDependenciesResources = await ApiSrv.DependenciesGetResource(TokenGet.Key, dependenciesGetResourceQueryValues);

                        if (!resultGetDependenciesResources.IsSuccess)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            DependenciesResources     = JsonConvert.DeserializeObject <List <DependenciesResource> >(Crypto.DecodeString(resultGetDependenciesResources.Data));
                            DependenciesResourceItems = new ObservableCollection <DependenciesResourceItem>();
                            foreach (DependenciesResource dependenciesResource in DependenciesResources)
                            {
                                DependenciesResourceItems.Add(new DependenciesResourceItem()
                                {
                                    IdResource   = dependenciesResource.IdResource,
                                    ResourceName = dependenciesResource.ResourceName
                                });
                            }
                        }
                        UserDialogs.Instance.HideLoading();
                    }
                }
            }
            catch //(Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                Toast.ShowError(AlertMessages.Error);
            }
        }