Example #1
0
        bool MySQL_Running(Info_MySQL_Instansce instansce, Info_MySQL_Jobs job)
        {
            string        Mess = "";
            Exception     er   = null; //gán cờ er bằng null chỉ thị ko có lỗi
            List <string> logs = new List <string>();

            Thread.CurrentThread.IsBackground = true;

            er = job.Execute_DB(instansce);
            if (er != null)
            {
                Mess = er.Message + ": " + ((er.InnerException == null) ? "" : er.InnerException.Message);

                logs.Add(DateTime.Now + ": Error - " + instansce.DB_Name + ": " + Mess);
                File_Read_Write.Write_File(DateTime.Now + ": Error - " + instansce.DB_Name + ": " + Mess, true);

                SendEmail.Send_Email(instansce.To_Email, null, "Execute SQL File(s) error!", "Server: " + instansce.Server_Name + @"\nDatabase name: " + instansce.DB_Name + "\n" + Mess + "\nLog:\n" + string.Join(Environment.NewLine, logs), false);

                return(false);
            }
            else
            {
                logs.Add(DateTime.Now + ": Execute SQL File(s) " + instansce.Server_Name + @"\" + instansce.DB_Name + " done!");
                File_Read_Write.Write_File(DateTime.Now + ": Execute SQL File(s) " + instansce.Server_Name + @"\" + instansce.DB_Name + " done!", true);
            }

            try
            {
                string t = new SSHClient().SSH_Exec("cd /root/Audition/ && ./client_master restoreMetaCache");

                logs.Add(DateTime.Now + ": Restore metaCache succufully! Result: " + t);
                File_Read_Write.Write_File(DateTime.Now + ": Restore metaCache succufully! Result: " + t, true);
            }
            catch (Exception io)
            {
                logs.Add(DateTime.Now + ": Error - " + io.Message);
                File_Read_Write.Write_File(DateTime.Now + ": Error - " + io.Message, true);

                return(false);
            }

            SendEmail.Send_Email(instansce.To_Email, null, "Execute SQL File(s) succufully!", "Applied SQL File(s) to " + instansce.Server_Name + @"\" + instansce.DB_Name + " succufully!\n" + "\nLog:\n" + string.Join(Environment.NewLine, logs), false);

            logs.Clear();

            return(true);
        }
Example #2
0
        private void timer_Tick(object sender, EventArgs e)
        {
            string date_time = DateTime.Now.ToString("dd-MM-yyyy HH:mm");

            for (int i = 0; i < info_MySQL.Count; i++)
            {
                for (int k = 0; k < info_MySQL[i].ListJob.Count; k++)
                {
                    if (date_time == info_MySQL[i].ListJob[k].Time_Running)
                    {
                        Info_MySQL_Jobs      infoJob   = info_MySQL[i].ListJob[k];
                        Info_MySQL_Instansce instansce = info_MySQL[i].Instances;

                        File_Read_Write.Write_File(DateTime.Now + ": Start Execute - " + infoJob.Files.Count + " file(s): " + string.Join(",", infoJob.Files) + " on " + instansce.DB_Name + @"\" + instansce.DB_Name, true);

                        new Thread(() => MySQL_Running(instansce, infoJob)).Start();
                    }
                }
            }
        }