Exemplo n.º 1
0
 private void BgwBackupDay_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         CurrentDate = DateTime.Now;
         if (control == false)
         {
             string SettingsDay = FAB.Oku("Day", "Tuned Day");
             Day          = Convert.ToInt16(SettingsDay);
             SettingsDate = CurrentDate.AddDays(Day);
             control      = true;
         }
         TS     = SettingsDate - CurrentDate;
         Day    = TS.Days;
         Hour   = TS.Hours;
         Minute = TS.Minutes;
         Second = TS.Seconds;
         if (CurrentDate.Day == SettingsDate.Day && CurrentDate.Hour == SettingsDate.Hour && CurrentDate.Minute == SettingsDate.Minute && CurrentDate.Second == SettingsDate.Second)
         {
             ReadHourDataBase();
             foreach (string str in this.DataBases)
             {
                 CNB.TxtName      = "Day";
                 CNB.FileName     = "C:/temp/" + str + timeClass.GetServerTime().ToString("yyyy-MM-dd-HH-mm-ss") + ".bak";
                 CNB.DataBaseName = str;
                 if (csTransactions.ServerItems.ConnectName == "Local")
                 {
                     CNB.srv = new Server(csTransactions.ServerItems.svName);
                 }
                 CNB.BackupDb();
             }
             control = false;
         }
     }
     catch (Exception ex)
     {
         if (Second == 0 && Minute == 0)
         {
             string read = FAB.Oku("Day", "Tuned Day");
             Day = Convert.ToInt16(read);
         }
     }
 }
Exemplo n.º 2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            INIKaydet AutoSettings = new INIKaydet(Application.StartupPath + @"\AutoBackup\AutoSettings.ini");
            INIKaydet Auto         = new INIKaydet(Application.StartupPath + @"\AutoBackup\Auto.ini");

            SettingsTime = AutoSettings.Oku("Auto", "Auto Settings");
            switch (SettingsTime)
            {
            case "Minute":
                lblRemTime.Text = MinuteBackup.Minute.ToString() + " : " + MinuteBackup.Second.ToString();
                break;

            case "Hour":
                lblRemTime.Text = HourBackup.Hour.ToString() + " : " + HourBackup.Minute.ToString() + " : " + HourBackup.Second.ToString();
                break;

            case "Day":
                if (changeCheck.Checked == true)
                {
                    if (control == false)
                    {
                        ReadAutoDate = Convert.ToInt16(Auto.Oku("Day", "Tuned Day"));
                        TargetDate   = DateTime.Now.AddDays(ReadAutoDate);
                        control      = true;
                    }
                    if (control == true)
                    {
                        lblRemTime.Text = "Target Date : " + TargetDate.ToString();
                    }
                }
                if (changeCheck.Checked == false)
                {
                    lblRemTime.Text = DayBackup.Day.ToString() + " : " + DayBackup.Hour.ToString() + " : " + DayBackup.Minute.ToString() + " : " + DayBackup.Second.ToString();
                    control         = false;
                }
                break;

            case "Month":
                if (changeCheck.Checked == true)
                {
                    if (control == false)
                    {
                        ReadAutoDate = Convert.ToInt16(Auto.Oku("Month", "Tuned Month"));
                        TargetDate   = DateTime.Now.AddMonths(ReadAutoDate);
                        control      = true;
                    }
                    if (control == true)
                    {
                        lblRemTime.Text = "Target Date : " + TargetDate.ToString();
                    }
                }
                if (changeCheck.Checked == false)
                {
                    lblRemTime.Text = MonthBackup.Day.ToString() + " : " + MonthBackup.Hour.ToString() + " : " + MonthBackup.Minute.ToString() + " : " + MonthBackup.Second.ToString();
                    control         = false;
                }
                break;

            case "Year":
                if (changeCheck.Checked == true)
                {
                    if (control == false)
                    {
                        ReadAutoDate = Convert.ToInt16(Auto.Oku("Year", "Tuned Year"));
                        TargetDate   = DateTime.Now.AddYears(ReadAutoDate);
                        control      = true;
                    }
                    if (control == true)
                    {
                        lblRemTime.Text = "Target Date : " + TargetDate.ToString();
                    }
                }
                if (changeCheck.Checked == false)
                {
                    lblRemTime.Text = YearBackup.Day.ToString() + " : " + YearBackup.Hour.ToString() + " : " + YearBackup.Minute.ToString() + " : " + YearBackup.Second.ToString();
                    control         = false;
                }
                break;
            }
        }