Esempio n. 1
0
        private void btnAplicar_Click(object sender, EventArgs e)
        {
            ConfigMngr config = new ConfigMngr();

            config.BackupFolder = tbDirBack.Text;
            config.BackupTime = nmrHora.Value + ":" + nmrMin.Value;
            config.BackupEnable = cbEnable.Checked;
            config.MysqlFolder = tbMysqlDir.Text;
            config.BackupFrequency = checkFreq();
            config.BackupDay = dtpA.Text.Split('/')[0];
            config.BackupMonth = dtpA.Text.Split('/')[1];
            config.BackupDofW = dtpW.Text;

            try
            {
                config.UpdateFile();
            }
            catch (Exception err)
            {
                MessageBox.Show("Erro: " + err.Message + "\n\nDetalhes:\n" + err, "Erro");
            }
        }
Esempio n. 2
0
        private void tmr_Tick(object sender, EventArgs e)
        {
            ConfigMngr config = new ConfigMngr();

            stslblTime.Text = DateTime.Now.ToLongTimeString();

            if (config.BackupEnable)
            {
                if (config.BackupFrequency.ToString().ToUpper() == "D")
                {
                    if (config.BackupTime == DateTime.Now.ToShortTimeString() && !config.DidHappened)
                    {
                        config.DidHappened = true;
                        config.UpdateFile();
                        BackupMngr backup = new BackupMngr();
                        backup.backupDb();
                    }
                    else if (!(config.BackupTime == DateTime.Now.ToShortTimeString()) && config.DidHappened)
                    {
                        config.DidHappened = false;
                        config.UpdateFile();
                    }
                }
                else if (config.BackupFrequency.ToString().ToUpper() == "S")
                {
                    if (config.BackupDofW == DateTime.Now.DayOfWeek.ToString() && !config.DidHappened)
                    {
                        config.DidHappened = true;
                        config.UpdateFile();
                        BackupMngr backup = new BackupMngr();
                        backup.backupDb();
                    }
                    else if (!(config.BackupDofW == DateTime.Now.DayOfWeek.ToString()) && config.DidHappened)
                    {
                        config.DidHappened = false;
                        config.UpdateFile();
                    }
                }
                else if (config.BackupFrequency.ToString().ToUpper() == "Q")
                {
                    if (config.BackupDofW == DateTime.Now.DayOfWeek.ToString() && !config.DidHappened)
                    {
                        config.DidHappened = true;
                        config.UpdateFile();
                        BackupMngr backup = new BackupMngr();
                        backup.backupDb();
                    }
                    else if (!(config.BackupDofW == DateTime.Now.DayOfWeek.ToString()) && config.DidHappened)
                    {
                        config.DidHappened = false;
                        config.UpdateFile();
                    }
                }
                else if (config.BackupFrequency.ToString().ToUpper() == "M")
                {
                    if (config.BackupDay == DateTime.Now.Day.ToString() && !config.DidHappened)
                    {
                        config.DidHappened = true;
                        config.UpdateFile();
                        BackupMngr backup = new BackupMngr();
                        backup.backupDb();
                    }
                    else if (!(config.BackupDay == DateTime.Now.Day.ToString()) && config.DidHappened)
                    {
                        config.DidHappened = false;
                        config.UpdateFile();
                    }
                }
                else if (config.BackupFrequency.ToString().ToUpper() == "A")
                {
                    if (config.BackupMonth == DateTime.Now.Month.ToString() &&
                        config.BackupDay == DateTime.Now.Day.ToString() &&
                        !config.DidHappened)
                    {
                        config.DidHappened = true;
                        config.UpdateFile();
                        BackupMngr backup = new BackupMngr();
                        backup.backupDb();
                    }
                    else if (!(config.BackupMonth == DateTime.Now.Month.ToString() &&
                             config.BackupDay == DateTime.Now.Day.ToString()) &&
                             config.DidHappened)
                    {
                        config.DidHappened = false;
                        config.UpdateFile();
                    }
                }
            }
        }