예제 #1
0
        public ResultMsg <SensorDataInfoDTO> GetDatasOfSensors()
        {
            int deviceid = 6633;
            DatasFuzzyQryPagingParas data = new DatasFuzzyQryPagingParas()
            {
                deviceId  = 6633,
                Method    = 2,
                TimeAgo   = 30,
                Sort      = "DESC",
                PageSize  = 1000,
                PageIndex = 1
            };

            ResultMsg <SensorDataInfoDTO> opResult = SDK.GetDatasOfSensors(data, this.Token);

            return(opResult);
        }
예제 #2
0
        /// <summary>
        /// 查询传感数据
        /// </summary>
        /// <returns></returns>
        public ResultMsg <SensorDataInfoDTO> GetDatasOfSensors(DatasFuzzyQryPagingParas query, string token = null)
        {
            var result = new ResultMsg <SensorDataInfoDTO>();

            #region --ToUse--
            //if (String.IsNullOrEmpty(txtToken))
            //if (!vry.IsSuccess())
            //{
            //    vry.CopyTo(result);
            //    return result;
            //}
            #endregion

            //1、先定义该API接口路径,可以从http://api.nlecloud.com/页面的得知
            String apiPath = String.Format("{0}/{1}", mApiHost, NLECloudAPIUrl.DatasOfSensorUrl);

            //2、根据该API接口 的请求参数中 得知需要创建个URI Parameters String类型参数,所以该参数直接跟在apiPath中
            apiPath  = apiPath.Replace("{deviceid}", query.deviceId.ToString());//将API地址中的{gatewayTag}替换成真实设备标识
            apiPath += string.Format("?{0}&{1}&{2}&{3}&{4}&{5}", "deviceId=" + query.deviceId, "Method=" + query.Method, "TimeAgo=" + query.TimeAgo, "Sort=" + query.Sort, "PageSize=" + query.PageSize, "PageIndex=" + query.PageIndex);
            //3、由于调用该API需要Token,所以我们定义了一个通用的对象HttpReqEntity,在AccessToken当成头部请求信息提交过去
            HttpReqEntity req = new HttpReqEntity();
            req.Method = HttpMethod.GET;
            req.Headers.Add("AccessToken", token);

            //4、定义该API接口返回的对象
            result = RequestAPIHelper.RequestServer <HttpReqEntity, SensorDataInfoDTO>(apiPath, req);

            if (result.IsSuccess() && result.ResultObj != null && result.ResultObj.DataPoints != null)
            {
                result.ResultObj.DataPoints.ForEach(p =>
                {
                    if (p.PointDTO != null)
                    {
                        foreach (var w in p.PointDTO)
                        {
                            ValueConvertToByteAry(w.Value);
                        }
                    }
                });
            }

            return(result);
        }