Exemplo n.º 1
0
        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.");
            }
        }
Exemplo n.º 2
0
 public async Task <Response> MonitorGetData(string accessToken, MonitorDataQueryValues QueryValues)
 {
     return(await HttpPost(accessToken, this.ApiControllerSet, ApiMethod.PlannerMonitorsGetData, QueryValues));
 }