示例#1
0
        private void timer_Tick(object sender, EventArgs e)
        {
            string date_time = DateTime.Now.ToString("HH:mm");

            for (int i = 0; i < info_DB.Count; i++)
            {
                if (date_time == info_DB[i].Time_Running)
                {
                    List <string> day_running = info_DB[i].DayOfWeed_Running.Split(',').ToList();

                    for (int j = 0; j < day_running.Count; j++)
                    {
                        if (DateTime.Now.DayOfWeek.ToString().ToLower() == day_running[j].ToLower())
                        {
                            Info_DB infoDB = info_DB[i];
                            new Thread(() => SQLServer_Running(infoDB, _Server)).Start();
                        }
                    }
                }
            }


            for (int i = 0; i < info_JobMySQL.Count; i++)
            {
                for (int k = 0; k < info_JobMySQL[i].ListDB.Count; k++)
                {
                    if (date_time == info_JobMySQL[i].ListDB[k].Time_Running)
                    {
                        List <string> day_running = info_JobMySQL[i].ListDB[k].DayOfWeed_Running.Split(',').ToList();

                        for (int j = 0; j < day_running.Count; j++)
                        {
                            if (DateTime.Now.DayOfWeek.ToString().ToLower() == day_running[j].ToLower())
                            {
                                Info_MySQL_DB        infoDB    = info_JobMySQL[i].ListDB[k];
                                Info_MySQL_Instansce instansce = info_JobMySQL[i].Instances;

                                new Thread(() => MySQL_Running(instansce, infoDB)).Start();
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        bool MySQL_Running(Info_MySQL_Instansce instansce, Info_MySQL_DB DB)
        {
            string    Mess = "";
            Exception er   = null;  //gán cờ er bằng null chỉ thị ko có lỗi

            Thread.CurrentThread.IsBackground = true;

            er = DB.Download_BackupFile(fTPServer);
            if (er != null)
            {
                Mess = er.Message + ": " + ((er.InnerException == null) ? "" : er.InnerException.Message);
                File_Read_Write.Write_File(log_path, DateTime.Now + ": Error - " + DB.DBTarget + ": " + Mess, true);

                SendEmail.Send_Email(DB.Email, null, "[Dashboard - RTS] Clone Database error!", "Server: " + instansce.Server_Name + @"\nDatabase name: " + DB.DBTarget + "\n" + Mess, false);

                return(false);
            }
            else
            {
                File_Read_Write.Write_File(log_path, DateTime.Now + ": Download Backup file " + fTPServer.URL + "BackupDB_zip/" + DB.ServerSource + "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + DB.DBSource + ".zip....done!", true);
            }


            er = DB.Excute_Restore_DB(instansce);
            if (er != null)
            {
                Mess = er.Message + ": " + ((er.InnerException == null) ? "" : er.InnerException.Message);
                File_Read_Write.Write_File(log_path, DateTime.Now + ": Error - " + DB.DBTarget + ": " + Mess, true);

                SendEmail.Send_Email(DB.Email, null, "[Dashboard - RTS] Clone Database error!", "Server: " + instansce.Server_Name + @"\nDatabase name: " + DB.DBTarget + "\n" + Mess, false);

                return(false);
            }
            else
            {
                File_Read_Write.Write_File(log_path, DateTime.Now + ": Restore " + DB.ServerSource + @"\" + DB.DBSource + " to " + instansce.Server_Name + @"\" + DB.DBTarget + " done!", true);
            }

            SendEmail.Send_Email(DB.Email, null, "[Dashboard - RTS] Clone Database succufully!", "Clone Database " + DB.ServerSource + @"\" + DB.DBSource + " to " + instansce.Server_Name + @"\" + DB.DBTarget + " succufully!", false);

            return(true);
        }