Exemplo n.º 1
0
        public string GetChartData(string station)
        {
            StationModelDash dash = new StationModelDash();
            var clientDados       = new RestClient(string.Format("https://localhost:44397/api/StateSensors/{0}/{1}", "station:005_station", station));

            clientDados.Timeout = -1;
            var requestDados = new RestRequest(Method.GET);

            requestDados.AddHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Im1hcmN1cyIsInJvbGUiOiJtYXN0ZXJ1c2VyIiwibmJmIjoxNjIwODcwMDc4LCJleHAiOjE2MjA4NzcyNzgsImlhdCI6MTYyMDg3MDA3OH0.r0QiM1FtO3nwwCKqClPox-72laDsyDTLSFZCWj6P-O4");
            IRestResponse <List <StationModel> > responseDados = clientDados.Execute <List <StationModel> >(requestDados);

            dash.Station     = "station:003";
            dash.SationModel = responseDados.Data;

            var chartData = new object[dash.SationModel.Count + 1];

            chartData[0] = new object[] {
                "Minutes",
                "station:003"
            };
            List <RetornoTeste> list = new List <RetornoTeste>();
            int j = 0;

            foreach (var i in responseDados.Data)
            {
                j++;
                RetornoTeste teste = new RetornoTeste();
                teste.minutes = j;
                teste.value   = Convert.ToInt32(i.attrValue);
                list.Add(teste);
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(list));
        }
Exemplo n.º 2
0
        public string GetStation(string station)
        {
            StationModelDash dash = new StationModelDash();
            var clientDados       = new RestClient(string.Format("https://localhost:44397/api/StateSensors/{0}/{1}", "station:005_station", station));

            clientDados.Timeout = -1;
            var requestDados = new RestRequest(Method.GET);

            requestDados.AddHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Im1hcmN1cyIsInJvbGUiOiJtYXN0ZXJ1c2VyIiwibmJmIjoxNjIwODcwMDc4LCJleHAiOjE2MjA4NzcyNzgsImlhdCI6MTYyMDg3MDA3OH0.r0QiM1FtO3nwwCKqClPox-72laDsyDTLSFZCWj6P-O4");
            IRestResponse <List <StationModel> > responseDados = clientDados.Execute <List <StationModel> >(requestDados);

            dash.Station     = "station:003";
            dash.SationModel = responseDados.Data;
            return(Newtonsoft.Json.JsonConvert.SerializeObject(dash));
        }