private void userLevelTimer_Tick(object sender, EventArgs e) { AsyncStoreHeatnInput(); userLevelTimer.Enabled = false; sw.Reset(); inputStopWatch.Reset(); timer2.Stop(); normalInputSW.Reset(); if (autContrl.isOn) { DBUtils.OpenConection(); int test = DBUtils.ExecuteScalar(autContrl.lastRowIDQuery); int test2 = autContrl.begginingID; if (DBUtils.ExecuteScalar(autContrl.lastRowIDQuery) - autContrl.begginingID > 2500) { timer2.Interval = autContrl.CalculateUserLevel(); //autContrl.isOn = false; } DBUtils.CloseConnection(); } }
private void MistakesSpeed() { mistakesSpeedDict.Clear(); int average = DBUtils.ExecuteScalar(string.Format("SELECT AVG(timestamp) FROM InputsView WHERE timestamp > 5 {0}", whereAnd)); for (int i = 0; i < 10000; i += 50) { string query = string.Format("SELECT AVG(true_typing_speed) FROM MistakesView WHERE typing_speed between {0} and {1} {2}", i + 1, i + 50, whereAnd); int trueTypSpeedAvg = DBUtils.ExecuteScalar(query); if (trueTypSpeedAvg > 9) { mistakesSpeedDict.Add(Math.Round(1000 / (double)(i + 50), 2), Math.Round(1000 / (double)trueTypSpeedAvg, 2)); } } avgTypingSpeed = new double[mistakesSpeedDict.Count]; int k = 0; foreach (var item in mistakesSpeedDict) { avgTypingSpeed[k] = Math.Round(1000 / (double)average * 0.8, 2); k++; } isLoadedMistakesSpeed = true; }
public void WriteToDB(string query) { DBUtils.OpenConection(); DBUtils.ExecuteQueries(query); DBUtils.CloseConnection(); }
private async void TestInsert() { string connectionString = "Data Source=DatabaseLite.sqlite;Version=3;PRAGMA journal_mode=WAL;"; OrmLiteConnectionFactory dbFactory = new OrmLiteConnectionFactory(connectionString, SqliteDialect.Provider); List <int> stList = new List <int>(); Stopwatch st = new Stopwatch(); Heatmap ht = new Heatmap(); ht.date = "2018-06-20 10:06:14"; ht.delay = 500; ht.program_id = 12; ht.input = "Return"; using (IDbConnection db = dbFactory.OpenDbConnection()) { using (IDbTransaction trans = db.OpenTransaction()) { st.Start(); // db.BeginTransaction(); for (int i = 0; i < 500000; i++) { db.Insert(ht); } trans.Commit(); st.Stop(); stList.Add((int)st.ElapsedMilliseconds); }; }; /* using (var db = dbFactory.Open()) * { * for (int i = 0; i < 100; i++) * { * db.ExecuteNonQuery("BEGIN"); * db.Insert(new Heatmap { input = "Return", delay = 500, date = "2018-06-20 10:06:14", program_id = 12 }); * db.ExecuteNonQuery("end"); * } * st.Stop(); * stList.Add((int)st.ElapsedMilliseconds); * }*/ DBUtils.OpenConection(); st.Restart(); for (int i = 0; i < 500000; i++) { query = "INSERT INTO Heatmap (input,delay,date,program_id) " + "VALUES ('Return', 500, '2018-06-20 10:06:1', '12')"; DBUtils.ExecuteQueries(query); } st.Stop(); stList.Add((int)st.ElapsedMilliseconds); DBUtils.CloseConnection(); string t = ""; using (var db = dbFactory.Open()) { } }
public void InitializePrograms() { DBUtils.OpenConection(); programList = DBUtils.ReadPrograms(); DBUtils.CloseConnection(); }