Example #1
0
 public void getTime(Time now, int DisplayInterval)
 {
     datetime[2] = now;
     datetime[1] = now.SubtractMinutes(DisplayInterval / 3);
     datetime[0] = now.SubtractMinutes(DisplayInterval / 3 * 2);
 }
        //public void getData(Time last, ScaleData data, DataSet ds)
        //{
        //    Time first = last.subtractMinutes(_model.DisplayInterval);
        //    data.FirstTime = first;
        //    int diff = last.get_diff_by_minute(first);
        //    data.getTime(last, diff);
        //    int rowCount = ds.Tables[0].Rows.Count;
        //    for (int i = 0; i < 2; ++i)
        //    {
        //        data.Depth[i] = ds.Tables[0].Rows[rowCount / 3 * (i + 1)]["DEPTH"].ToString();
        //        data.Pos[i] = rowCount / 3 * (i + 1);
        //    }
        //    _model.getData(ds);
        //}
        private void getData(object sender, EventArgs args)
        {
            DataSet dataSet = new DataSet();
            dataSet = conn.SelectDataSet("SELECT TOP 1 * FROM " + TableName + " WHERE WELLID = '" + WellID
                                            + "' AND WELLBOREID ='" + WellBoreID + "' ORDER BY TDATE DESC, TTIME DESC");

            if (dataSet.Tables[0].Rows.Count != 0)
            {

                String date = dataSet.Tables[0].Rows[0]["TDATE"].ToString();
                String time = dataSet.Tables[0].Rows[0]["TTIME"].ToString();
                // 数据截止时间
                Time last = new Time(date, time);
                Time first = last.SubtractMinutes(_model.DisplayInterval);
                date = first.ToDateString();
                time = first.ToTimeString();

                dataSet.Clear();
                dataSet.Dispose();

                DataSet ds = new DataSet();

                string str = "SELECT * FROM " + TableName + " Where (TDATE = '" + date + "' And TTime >= '" + time + "') Or (TDate >'" + date + "') AND WELLID = '" + WellID + "' AND WELLBOREID ='" + WellBoreID + "' ORDER BY TDATE asc,TTIME asc";

                //ds = conn.SelectDataSet("SELECT * FROM (SELECT * FROM " + TableName
                //                        + " WHERE TDATE >= '" + date + "') AS TEMP WHERE TEMP.TTIME >= '" + time + "' ORDER BY TEMP.TDATE asc, TEMP.TTIME asc");

                ds = conn.SelectDataSet(str);

                int N = ds.Tables[0].Rows.Count;

                // 数据起始时间
                first = getDateTime(ds.Tables[0].Rows[0]["TDATE"].ToString(),
                                    ds.Tables[0].Rows[0]["TTIME"].ToString());

                data.FirstTime = first;
                // 获取两时间的差值
                int diff = last.GetDiffByMinute(first);
                data.getTime(last, diff);

                int rowCount = ds.Tables[0].Rows.Count;
                for (int i = 0; i < 2; ++i)
                {
                    data.Depth[i] = ds.Tables[0].Rows[rowCount / 3 * (i + 1)]["DEPTMEAS"].ToString();
                    data.Pos[i] = rowCount / 3 * (i + 1);
                }

                _model.getData(ds);
                ds.Clear();
                ds.Dispose();

                adjustHeader();
                foreach (Column col in this.Columns)
                {
                    col.repaint(data);
                }
                Scale.repaintScale(data);
                _timer.Interval = _model.Interval;
            }
        }
Example #3
0
        public void TestSubtractMinutes()
        {
            Time t1 = new Time(2000, 1, 2, 1, 1, 3);
            Time t2 = t1.SubtractMinutes(50);
            Assert.AreEqual(50, t1.GetDiffByMinute(t2));

            t1 = new Time(2000, 1, 2, 0, 1, 3);
            t2 = t1.SubtractMinutes(50);
            Assert.AreEqual(50, t1.GetDiffByMinute(t2));
        }