Ejemplo n.º 1
0
        public Task Execute(IJobExecutionContext context)
        {
            DateTimeOffset     toTime   = DateTimeOffset.UtcNow;
            DateTimeOffset     fromTime = _repositoryHdd.LastTime();
            IList <AgentModel> agents   = _repositoryAgent.GetAll();


            foreach (var agent in agents)
            {
                if (agent.Status == true)
                {
                    AllHddMetricsApiResponse allHddMetrics = _client.GetAllHddMetrics(new GetAllHddMetricsApiRequest
                    {
                        FromTime = fromTime,
                        ToTime   = toTime,
                        Addres   = agent.Ipaddress
                    });

                    if (allHddMetrics != null)
                    {
                        foreach (var metric in allHddMetrics.Metrics)
                        {
                            _repositoryHdd.Create(new HddMetricModel
                            {
                                IdAgent = agent.Id,
                                Time    = metric.Time,
                                Value   = metric.Value
                            });
                        }
                    }
                }
            }

            return(Task.CompletedTask);
        }