Esempio n. 1
0
        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);
            });
        }
Esempio n. 2
0
        private void button_testconnect_Click(object sender, EventArgs e)
        {
            if (checkBox_DBType.Checked == true)
            {
                VC_DB conn = new VC_DB();
                try
                {
                    conn.connect();
                    var reader = conn.getUser();
                    while (reader.Read())
                    {
                        comboBox_user.Items.Add(reader[0]);
                    }
                    MessageBox.Show("Connect to Database is Complated");
                    conn.getDBlog(richTextBox_log);
                }
                catch (Exception g)
                {
                    MessageBox.Show(g.ToString());
                }
            }
            //update database
            //if (checkBox1.Checked = true)
            //{
            //    string vcenter_ip = textBox_ServerIP.Text;
            //    string vcenter_user = textBox_User.Text;
            //    string vcenter_password = textBox_Password.Text;
            //    string vcenter_port = textBox_port.Text;
            //    string sql = string.Format("update vCenterDB set vcenter_ip='{0}',vcenter_user='******'," +
            //        "vcenter_password='******',vcenter_port='{3}' where id =1", vcenter_ip, vcenter_user, vcenter_password, vcenter_port);
            //    SQLiteOperation update = new SQLiteOperation();
            //    update.query(sql);
            //    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_port.Text = reader[4].ToString();
            //    }
            //    textBox_ServerIP.ReadOnly = true;
            //    textBox_User.ReadOnly = true;
            //    textBox_Password.ReadOnly = true;
            //    textBox_port.ReadOnly = true;
            //    checkBox1.Checked = false;
            //    connectDB();
            //}
            //else
            //{
            //    connectDB();
            //}
        }