private void button_save_Click(object sender, EventArgs e) { SQLiteOperation conn = new SQLiteOperation(); var check = true; string user = comboBox_user.Text; string time = dateTimePicker1.Text; int autorun_check; if (checkBox_autorun.Checked) { autorun_check = 1; } else { autorun_check = 0; } int day = Convert.ToInt16(comboBox_Day.Text); if (check) { string sql = string.Format("update Scheduler set sc_user = '******',sc_time='{1}',sc_day = {2},sc_autorun={3} where sc_id =1 ;", user, time, day, autorun_check); conn.query(sql); richTextBox_log.Text += DateTime.Now.ToString() + " : update job scheduler is complated \n"; MessageBox.Show("update is complated"); } else { MessageBox.Show("Task insert db"); string sql = string.Format("insert into Scheduler(sc_user,sc_time,sc_day,sc_autorun) values('{0}','{1}',{2},{3});", user, time, day, autorun_check); conn.query(sql); } }
public void deleteEvent() { VC_DB mssql = new VC_DB(); SQLiteOperation sqlite = new SQLiteOperation(); int hour = 0; int minutes = 0; string user = ""; // ลบ log จาก user int day = 24; // เวลาลบลอกที่เก่าเกิน int interval = 24; // ชั้วโมง var reader = sqlite.query("select * from Scheduler where sc_id=1"); while (reader.Read()) { user = reader[1].ToString(); day = Convert.ToInt16(reader[3]); string Date1 = reader[2].ToString(); // split time string[] a = Date1.Split(':'); hour = Convert.ToInt16(a[0]); minutes = Convert.ToInt16(a[1]); } string strPath = AppDomain.CurrentDomain.BaseDirectory + "Log.txt"; System.IO.File.AppendAllLines(strPath, new[] { "Start time" + DateTime.Now.ToString() }); TaskScheduler.Instance.ScheduleTask(hour, minutes, interval, () => { System.IO.File.AppendAllLines(strPath, new[] { "running now : " + DateTime.Now.ToString() }); mssql.delete_event(day, user); }); }
public void setDefault_vCenterDB() { SQLiteOperation setDF = new SQLiteOperation(); SQLiteDataReader reader = setDF.query("select * from vCenterDB"); while (reader.Read()) { textBox_ServerIP.Text = reader[1].ToString(); textBox_User.Text = reader[2].ToString(); textBox_Password.Text = reader[3].ToString(); textBox_dbname.Text = reader[4].ToString(); } DateTime time = DateTime.Now; textBox_ServerIP.ReadOnly = true; textBox_User.ReadOnly = true; textBox_Password.ReadOnly = true; textBox_dbname.ReadOnly = true; setDF.getLogDB(richTextBox_log); }