Example #1
0
    private String testdata(string id, string num)
    {
        BLL_Document    BLL   = new BLL_Document();
        DataTable       dt    = BLL.GetTestData(id, num);
        List <TestData> cells = new List <TestData>();

        if (dt != null && dt.Rows.Count > 0)
        {
            int      m  = 0;
            DateTime d0 = new DateTime();//第一根开始时间
            foreach (DataRow dr in dt.Rows)
            {
                List <JZTestDataCell> testdatalist;
                try
                {
                    testdatalist = Newtonsoft.Json.JsonConvert.DeserializeObject <List <JZTestDataCell> >(dr["RealTimeData"].ToString());
                }
                catch
                {
                    testdatalist = Newtonsoft.Json.JsonConvert.DeserializeObject <List <JZTestDataCell> >(BizCommon.JZCommonHelper.GZipDecompressString(dr["RealTimeData"].ToString()));
                }



                int n = 0;
                foreach (JZTestDataCell item in testdatalist)
                {
                    if (n == 0)
                    {
                        d0 = testdatalist[0].Time;
                    }
                    TimeSpan span  = (TimeSpan)(item.Time - d0);
                    TestData model = new TestData();

                    model.Time  = Math.Round(span.TotalMilliseconds / 1000, 2);
                    model.Value = item.Value;
                    cells.Add(model);
                    n++;
                }
                m++;
            }
            return(JsonConvert.SerializeObject(cells));
        }
        else
        {
            return("");
        }
    }