Example #1
0
        private void UpdateTimerInternal(NextBackup nextBackup, bool discardIfDisabled)
        {
            if (Disposed)
            {
                return;
            }

            if (discardIfDisabled && _backupTimer == null)
            {
                return;
            }

            _backupTimer?.Dispose();

            if (_logger.IsOperationsEnabled)
            {
                _logger.Operations($"Next {(nextBackup.IsFull ? "full" : "incremental")} backup is in {nextBackup.TimeSpan.TotalMinutes} minutes.");
            }

            var timer = nextBackup.TimeSpan < _periodicBackupRunner.MaxTimerTimeout
                ? new Timer(_periodicBackupRunner.TimerCallback, nextBackup, nextBackup.TimeSpan, Timeout.InfiniteTimeSpan)
                : new Timer(_periodicBackupRunner.LongPeriodTimerCallback, nextBackup, _periodicBackupRunner.MaxTimerTimeout, Timeout.InfiniteTimeSpan);

            _backupTimer = new BackupTimer
            {
                Timer      = timer,
                CreatedAt  = DateTime.UtcNow,
                NextBackup = nextBackup
            };
        }
Example #2
0
        private void LoadSettings()
        {
            _loadingSettings = true;

            txtSaveLocation.Text          = Settings.Default.SaveFileLocation;
            numBackupInterval.Value       = Settings.Default.BackupInterval;
            BackupTimer.Interval          = (int)(numBackupInterval.Value * 60000);
            chkAutoBackup.Checked         = Settings.Default.AutomaticBackup;
            txtAutoBackupLocation.Text    = Settings.Default.AutomaticBackupDirectory;
            txtBackupDirectory.Text       = Settings.Default.BackupDirectory;
            chkHideRestoreWarning.Checked = Settings.Default.HideRestoreWarning;
            chkTrayMinimize.Checked       = Settings.Default.TrayMinimize;

            if (Settings.Default.AutomaticBackup)
            {
                BackupTimer.Enabled = true;
                BackupTimer.Start();

                Log($"Starting automatic backups every {Settings.Default.BackupInterval} minutes");
            }

            btnBackup.Enabled = Sekiro.IsProfilePathValid(Settings.Default.SaveFileLocation);

            _loadingSettings = false;
        }
Example #3
0
 public App()
 {
     Reset();
     Logger.Info("Starting backup application");
     SetUiCulture();
     InitTrayIcon();
     _backup = new BackupTimer(ShowMessage);
     _backup.Start();
     //var title = Backup.Properties.Resources.StartNotificationTitle;
     //var content = Backup.Properties.Resources.StartNotificationContent;
     //_trayIcon.ShowBalloonTip(5000, title, content, System.Windows.Forms.ToolTipIcon.Info);
 }
Example #4
0
        private void CancelFutureTasks()
        {
            _backupTimer?.Dispose();
            _backupTimer = null;

            try
            {
                CancelToken?.Cancel();
            }
            catch
            {
            }
        }
Example #5
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            _console = new MConsole();
            _console.CreateConsole();

            ColorCodes.Add(ConsoleColor.DarkYellow);
            ColorCodes.Add(ConsoleColor.Green);
            ColorCodes.Add(ConsoleColor.Cyan);
            ColorCodes.Add(ConsoleColor.Gray);
            ColorCodes.Add(ConsoleColor.Red);
            OutputLogLegend();
            Log("AutoStart in 4 Seconds...", MServer.UTILITY);
            _Server = new MServer();

            IPAddressBox.Text = _Server.ServerIPAddress;
            PortBox.Text      = _Server.ServerPort.ToString();

            _Server.Version = MVersion.VERSION.ToString();

            _Server.ZoneChanged     += _Server_ZoneChanged;
            _Server.UniverseChanged += _Server_UniverseChanged;

            _Server.ServerInfo         += _Server_ServerInfo;
            _Server.MetricInfo         += _Server_MetricInfo;
            _Server.ClientConnected    += _Server_ClientConnected;
            _Server.ClientLoggedIn     += _Server_ClientLoggedIn;
            _Server.ClientDisconnected += _Server_ClientDisconnected;

            Log("Created Server Version:" + _Server.Version, MServer.UTILITY);
            Text     += " v" + _Server.Version;
            LocalName = HostInfo.HostName;
            //ConnectionsList.DataSource = MassiveConnections;
            //ZoneList.DataSource = MassiveZones;
            ZoneList.DisplayMember = "Name";


#if DEBUG
            timer1.Interval = 1000;
            Text           += " DEBUG";
#endif
            timer1.Start();
            BackupTimer.Start();
            // NetworkTimer.Start();

#if DEBUG
#else
#endif
            MaxConnectionsLabel.Text = "Max Connections" + MServer.MAXCONNECTIONS;
            Log("Backup schedule is: Backup every " + (BackupTimer.Interval / 3600000) + " hour", 3);
            GetPublicIP();
        }
        private void chkAutoBackup_CheckedChanged(object sender, EventArgs e)
        {
            SaveSettings();
            BackupTimer.Enabled = chkAutoBackup.Checked;

            if (chkAutoBackup.Checked)
            {
                BackupTimer.Start();
            }
            else
            {
                BackupTimer.Stop();
            }
        }
Example #7
0
        private void UpdateTimerInternal(Timer newBackupTimer, bool discardIfDisabled)
        {
            if (Disposed)
            {
                newBackupTimer.Dispose();
                return;
            }

            if (discardIfDisabled && BackupTimer == null)
            {
                newBackupTimer.Dispose();
                return;
            }

            BackupTimer?.Dispose();
            BackupTimer = newBackupTimer;
        }
Example #8
0
        public void UpdateTimer(Timer newBackupTimer, bool discardIfDisabled = false)
        {
            using (UpdateBackupTask())
            {
                if (Disposed)
                {
                    return;
                }

                if (discardIfDisabled && BackupTimer == null)
                {
                    return;
                }

                BackupTimer?.Dispose();
                BackupTimer = newBackupTimer;
            }
        }
Example #9
0
        public void UpdateTimer(Timer newBackupTimer, bool discardIfDisabled = false)
        {
            _updateTimerSemaphore.Wait();

            try
            {
                if (discardIfDisabled && BackupTimer == null)
                {
                    return;
                }

                BackupTimer?.Dispose();
                BackupTimer = newBackupTimer;
            }
            finally
            {
                _updateTimerSemaphore.Release();
            }
        }
Example #10
0
        public void DisableFutureBackups()
        {
            _updateTimerSemaphore.Wait();

            try
            {
                BackupTimer?.Dispose();
                BackupTimer = null;

                try
                {
                    CancelToken?.Cancel();
                }
                catch {}
            }
            finally
            {
                _updateTimerSemaphore.Release();
            }
        }
Example #11
0
        private async void Source_Backup_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, double> BackupTimer;
            List <Object> _sourceUIObjects = GetSourceObjects((((System.Windows.Controls.Button)sender).Name).Substring(0, 7));

            SetProgressBar((System.Windows.Controls.ProgressBar)_sourceUIObjects[4], (System.Windows.Controls.TextBox)_sourceUIObjects[5]);
            ((System.Windows.Controls.Button)sender).IsEnabled = false;
            try
            {
                BackupTimer = await AsyncBackup(((System.Windows.Controls.TextBox)_sourceUIObjects[0]).Text, Destination.Text);

                DestinationTotalSize.Text     = @"Total Size: " + string.Format("{0:0.00}", myCopyer.CalculateSourceSize(Destination.Text));
                DestinationNumberOfFiles.Text = @"Number of Files: " + myCopyer.FindNumberOfFiles(Destination.Text).ToString();
                double BackupTimerValue = BackupTimer.Min(t => t.Value);
                string BackupTimerUnits = (from entry in BackupTimer where (entry.Value == BackupTimerValue) select entry.Key).FirstOrDefault();
                ((System.Windows.Controls.TextBox)_sourceUIObjects[5]).Visibility = Visibility.Visible;
                ((System.Windows.Controls.TextBox)_sourceUIObjects[5]).Text       = @"It took: " + String.Format("{0:0.00}", BackupTimerValue) + BackupTimerUnits;
            }
            catch (Exception Ex)
            {
                SetRed((System.Windows.Controls.Button)sender);
                RemoveProgressBar((System.Windows.Controls.ProgressBar)_sourceUIObjects[4], (System.Windows.Controls.TextBox)_sourceUIObjects[5]);
                ((System.Windows.Controls.Button)sender).IsEnabled = true;
                PromptUser(@"Backup Failed, exception is:" + Ex.Message, Ex.StackTrace);
                return;
            }

            RemoveProgressBar((System.Windows.Controls.ProgressBar)_sourceUIObjects[4], (System.Windows.Controls.TextBox)_sourceUIObjects[5]);
            SetGreen((System.Windows.Controls.Button)sender);
            try
            {
                FillDestinationFields();
            }
            catch (Exception Ex)
            {
                PromptUser(@"Backup Succeeded but unable to determine Destination properties" + Ex.Message, Ex.StackTrace);
            }

            ((System.Windows.Controls.Button)sender).IsEnabled = true;
        }
Example #12
0
 public void DisableFutureBackups()
 {
     Disposed = true;
     BackupTimer?.Dispose();
 }