示例#1
0
        void DATABASEF()
        {
            for (; ;)
            {
                int       numParameters = (int)nParameter.Value * (int)nDevice.Value;
                Stopwatch timer         = new Stopwatch();
                timer.Start();
                for (int i = 0; i < numParameters; i++)
                {
                    Random val = new Random((int)DateTime.Now.Ticks);

                    //storedprocedure
                    //Insert_SensorData(2, 13, (decimal)10.005, DateTime.Now, 4);

                    //InsertData(4, 2, 13, (decimal)10.005, DateTime.Now);
                    using (akilliEvDataContext db = new akilliEvDataContext())
                    {
                        tbl_SensorData Newdata = new tbl_SensorData();
                        Newdata.Device_Id = db.tbl_Devices.FirstOrDefault(x => x.Device_Id == new Random().Next(4, 7)).Device_Id;
                        Newdata.Sensor_Id = db.tbl_Sensors.FirstOrDefault(x => x.Sensor_Id == new Random().Next(2, 5)).Sensor_Id;
                        Newdata.SensorTypeParameter_Id = db.tbl_SensorTypeParameters.FirstOrDefault(y => y.SensorTypeParameter_Id == new Random().Next(13, 17)).SensorTypeParameter_Id;
                        double k = Math.Sqrt(val.NextDouble() * val.Next(32000));
                        double l = Math.Sqrt(val.NextDouble() * val.Next(32000));
                        double m = Math.Round(k * l);
                        Newdata.Value      = (decimal)m;
                        Newdata.RecordTime = DateTime.Now;
                        db.tbl_SensorDatas.InsertOnSubmit(Newdata);
                        db.SubmitChanges();
                    }
                }
                timer.Stop();
                lblElapsed.Text      = timer.ElapsedMilliseconds.ToString();
                lblPerParameter.Text = (((double)timer.ElapsedMilliseconds / (double)numParameters)).ToString();
            }
        }
示例#2
0
        void InsertData(int device_Id, int sensor_Id, int sensorTypeParameter_Id, decimal value, DateTime RecordTime)
        {
            Stopwatch timer = new Stopwatch();

            timer.Start();
            using (akilliEvDataContext db = new akilliEvDataContext())
            {
                tbl_SensorData Newdata = new tbl_SensorData();
                Newdata.Device_Id = device_Id;
                Newdata.Sensor_Id = sensor_Id;
                Newdata.SensorTypeParameter_Id = sensorTypeParameter_Id;
                Newdata.Value      = value;
                Newdata.RecordTime = RecordTime;
                db.tbl_SensorDatas.InsertOnSubmit(Newdata);
                db.SubmitChanges();
            }
            timer.Stop();
            lblMinInsertTime.Text = timer.ElapsedMilliseconds.ToString();
        }