예제 #1
0
    private string GetLine(int deviceid,int paramid)
    {
        IList<OriginalDataInfo> orilist = new List<OriginalDataInfo>();
        OriginalData ori = new OriginalData();

        IList<ParamInfo> paramdata = ParamDataProxy.GetParams();


        orilist = ori.GetTopNDatasByDeviceIDAndParamID(20, deviceid, paramid);
        int j = orilist.Count;
        if (j > 0)
        {
            string json = "{\"j\":" + j + ",\"rows\":[";
            double maxitem = 1000;//最多放1000个点在图像上面
            int step = j > maxitem ? (int)(maxitem / j) : 1;

            for (int i = 0; i < orilist.Count; i += step)
            {
                json += "{\"time1\":\"" + (Convert.ToDateTime(orilist[i].InsertTime).AddHours(-8) - new DateTime(1970, 1, 1)).TotalMilliseconds + "\",\"price\":\"" + Convert.ToDecimal(orilist[i].ParamValue) + "\"},";
            }

            json = json.TrimEnd(',');
            json += "]}";
            return json;

        }
        else
        {
            throw new Exception("无数据");
        }
    }
예제 #2
0
        public static IList<ParamAndOneDataInfo> GetParamAndOneData(int deviceid)
        {
            IList<ParamAndOneDataInfo> tempdata = new List<ParamAndOneDataInfo>();
            
            OriginalData ori = new OriginalData();
            IList<OriginalDataInfo> oridata = new List<OriginalDataInfo>();
            oridata = ori.GetTopNDatasByDeviceID(10, 1);
            IList<ParamInfo> paramdata = ParamDataProxy.GetParams();


            foreach (ParamInfo par in paramdata)
            {
                ParamAndOneDataInfo temp = new ParamAndOneDataInfo();
                oridata = ori.GetTopNDatasByDeviceIDAndParamID(1, deviceid, par.ParamID);
                ParamInfo p = ParamDataProxy.GetParamByID(par.ParamID);
                temp.DeviceID = deviceid;
                temp.ParamDesc = p.ParamDesc;
                temp.ParamUnit = p.ParamUnit;
                temp.InsertTime = oridata[0].InsertTime;
                temp.ParamValue = oridata[0].ParamValue;

                tempdata.Add(temp);

            }

            return tempdata;

        }