コード例 #1
0
        private void LoadData(DateTime dt, int SensorID)
        {
            stackpanel.Children.Clear();
            db = new DbContext();
            EntityQuery<vwSensorValuesAndTC10MinDataLog> qry = from n in db.GetVwSensorValuesAndTC10MinDataLogQuery()
                                                               where n.TIMESTAMP >= dt && n.TIMESTAMP < dt.AddDays(1) && n.SENSOR_ID == SensorID && n.ISVALID == "Y"
                                                               orderby n.TIMESTAMP
                                                               select n;
            //EntityQuery  qry = from n in db.GetTblTC10MinDataLogQuery()
            //                                     join m in db.GetTblSensor_ValuesQuery() on n.SensorID equals m.SensorID
            //                   where n.TIMESTAMP >= dt && n.TIMESTAMP < dt.AddDays(1) && n.SENSOR_ID == SensorID && n.ISVALID == "Y"
            //                   orderby n.TIMESTAMP
            //                   select new { n., m };

            LoadOperation<vwSensorValuesAndTC10MinDataLog> lo = db.Load<vwSensorValuesAndTC10MinDataLog>(qry);

            lo.Completed += (s, a) =>
            {

                if (lo.Error != null)
                {
                    MessageBox.Show(lo.Error.Message);
                    return;
                }

                db.Load<tblSensor>(db.GetTblSensorQuery().Where(dd => dd.SENSOR_ID == SensorID)).Completed += (ss, aa)
                    =>
                {
                    if ((ss as LoadOperation).Error != null)
                    {

                        MessageBox.Show((ss as LoadOperation).Error.Message);
                        return;
                    }

                    //tblTC10MinDataLog data = new tblTC10MinDataLog();
                    //in db.tblTC10MinDataLogs

                    if (db.tblSensors.FirstOrDefault().SENSOR_TYPE == "TILT")
                    {
                        IsTilt = 1;
                        vcnt = 3;
                    }
                    else
                        vcnt = 3;
                    for (int i = 1; i <= vcnt; i++)
                    {
                        CreateChart(i);
                    }
                    //db.Load<tblSensor_Values>(db.GetTblSensor_ValuesQuery().Where(dv => dv.SENSOR_ID == SensorID)).Completed += (sss, aaa)
                    //    =>
                    //    {
                    //        initmean = db.tblSensor_Values.FirstOrDefault().INITMEAN;
                    //        sigma = db.tblSensor_Values.FirstOrDefault().SIGMA;
                    //    };

                };

            };
        }
コード例 #2
0
        //void _timer_Tick(object sender, EventArgs e)
        //{
        //    if (BeginPicker.SelectedDate == DateTime.Today)/////////////102.08.19新增
        //    LoadData(DateTime.Today, sensorID);///////////////102.08.19新增           目的讓每十分鐘自動更新 如果selectdate不是今天則不更新
        //}
        private void LoadData(DateTime stardt, DateTime enddt, int SensorID)
        {
            //qry = null;
            if (status != "Range")
            stackpanel.Children.Clear();
            db = new DbContext();

            Isvalid = "N";
            FunctionLoadSensorTypeGroupID(stardt, enddt,SensorID); // 抓SensorTypeGroup 的 ID
        }