Beispiel #1
0
 public static void StartBackup()
 {
     if (Application.OpenForms.OfType <BackupWindow>().Count() > 0)
     {
         return;
     }
     bwindow = new BackupWindow();
     bwindow.Show();
 }
Beispiel #2
0
 static void CheckBackupTime(object sender, System.Timers.ElapsedEventArgs e)
 {
     if ((int)DateTime.Now.DayOfWeek != Settings.Default.backupday)
     {
         return;
     }
     backupTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, (int)Settings.Default.backuphour, (int)Settings.Default.backupminute, 0);
     if (backupTime > DateTime.Now)
     {
         if ((int)(backupTime - DateTime.Now).TotalMinutes <= Settings.Default.startcheck)
         {
             foreach (var session in activeusers)
             {
                 if (!Notifications.ContainsKey(session.SessionId))
                 {
                     SendMessage(session.SessionId, Settings.Default.alert1box.Replace("{time}", backupTime.ToString("HH:mm")));
                     Notifications.Add(session.SessionId, DateTime.Now);
                 }
                 else
                 {
                     if ((DateTime.Now - Notifications[session.SessionId]).TotalMinutes >= (int)Settings.Default.alert_interval)
                     {
                         SendMessage(session.SessionId, Settings.Default.alert1box.Replace("{time}", backupTime.ToString("HH:mm")));
                         Notifications[session.SessionId] = DateTime.Now;
                     }
                 }
             }
         }
     }
     else
     {
         if (backupTime < startuptime)
         {
             FinishedBackups.Add(backupTime);
             return;
         }
         if (!FinishedBackups.Contains(backupTime))
         {
             ITerminalServicesManager manager = new TerminalServicesManager();
             using (ITerminalServer server = manager.GetLocalServer())
             {
                 server.Open();
                 foreach (ITerminalServicesSession session in server.GetSessions())
                 {
                     KillParusWithNotifiction(session);
                 }
             }
             if (Settings.Default.backupauto && Application.OpenForms.OfType <BackupWindow>().Count() == 0)
             {
                 bwindow = new BackupWindow();
                 bwindow.ShowDialog();
             }
         }
     }
 }