Exemple #1
0
 private void closeDown(object sender, EventArgs e)
 {
     UserSettings.setSetting("crash-reason", "User Exit");
     notifyIcon1.ShowBalloonTip(10000, "RootBackup", "RootBackup has been shut down and will not be able to backup your files until it is started again.", ToolTipIcon.Info);
     notifyIcon1.Dispose();
     Environment.Exit(0);
 }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();
            G.form1 = this;

            //Reset crash reason
            UserSettings.setSetting("crash-reason", "None");
            new CrashHelper("RootBackup Helper", @"C:\Program Files\RootBackup\RootBackup Helper.exe").start();

            //Enable devmode in title
            if (G.getUsername().Equals("JBlevins") && Debugger.IsAttached)
            {
                this.Text = "DevMode";
            }

            //Notify Icon init
            notifyIcon1.Text    = "RootBackup";
            notifyIcon1.Icon    = Icon;
            notifyIcon1.Visible = true;

            notifyIcon1.ContextMenu = new ContextMenu();
            notifyIcon1.ContextMenu.MenuItems.Add(new MenuItem("Exit", closeDown));

            //Other startup stuff
            UserSettings.setSetting("Version", G.VERSION);

            if (!Visible)
            {
                G.messageBox("RootBackup", "RootBackup is now hidden in your toolbar. You can access it again by clicking on the RootBackup icon.", ToolTipIcon.Info);
            }

            //Auto set next and last backup times
            new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    Thread.Sleep(250);
                    G.setLastBackupTime();
                    G.setNextBackupTime();
                    G.refreshStatus();
                    if (G.timeUntilNextBackup() <= 0 && UserSettings.getSetting("auto-backup").Equals("Yes") && UserSettings.getSetting("source-folders").Length > 3)
                    {
                        bool startBackupBool = true;
                        if (startBackupBool && !G.backingUp)
                        {
                            G.backupThread = new Thread(new ThreadStart(() => {
                                startBackup();
                            }));
                            G.backupThread.Start();
                        }
                    }
                }
            })).Start();

            G.setProgressBar(0, 0);
        }
Exemple #3
0
        private void Schedule_FormClosing(object sender, FormClosingEventArgs e)
        {
            string autoBackup = "Yes";

            if (radioButton2.Checked)
            {
                autoBackup = "No";
            }
            UserSettings.setSetting("auto-backup", autoBackup);
            UserSettings.setSetting("backup-interval", numericUpDown1.Value.ToString());

            G.scheduleForm = null;
        }
Exemple #4
0
        private void Settings_FormClosing(object sender, FormClosingEventArgs e)
        {
            string sourceFolders = "";

            for (int i = 0; i < listBox1.Items.Count; i++)
            {
                if (i == 0)
                {
                    sourceFolders += listBox1.Items[i].ToString();
                }
                else
                {
                    sourceFolders += "*" + listBox1.Items[i].ToString();
                }
            }

            UserSettings.setSetting("source-folders", sourceFolders);
            UserSettings.setSetting("target-folder", textBox1.Text);

            G.settingsForm = null;
        }
Exemple #5
0
        void startBackup()
        {
            G.setProgressBar(0, 0);

            if (!G.backingUp)
            {
                PowerHelper.ForceSystemAwake();
                G.backingUp = true;
                G.setStartBackupOption(false);
                G.setStatus("Analyzing source folders");


                string[] sourceFolders = G.splitString(UserSettings.getSetting("source-folders"), "*");

                //Delete old tmp files
                string[] tmpFiles = Directory.GetFiles(UserSettings.getSetting("target-folder"));
                for (int i = 0; i < tmpFiles.Length && G.backingUp; i++)
                {
                    G.print("Deleteing " + tmpFiles[i]);
                    if (tmpFiles[i].EndsWith(".tmp"))
                    {
                        File.Delete(tmpFiles[i]);
                    }
                }

                //Backup files online
                Thread.Sleep(1000);
                string[] sourcePaths = G.splitString(UserSettings.getSetting("source-folders"), "*");
                //G.connection.sendMessage("beginRevision");
                for (int x = 0; x < sourcePaths.Length && G.backingUp; x++)
                {
                    G.setProgressBar(0, 0);
                    if (!G.replaceAll(sourcePaths[x], " ", "").Equals(""))
                    {
                        string[] sourceFolderNameArgs = G.splitString(sourcePaths[x], @"\");
                        string   sourceFolderName     = sourceFolderNameArgs[sourceFolderNameArgs.Length - 1];
                        G.setStatus("Creating backup for " + sourcePaths[x] + ". This may take a while, please be patient.");
                        G.compressDirectory(sourcePaths[x], UserSettings.getSetting("target-folder") + sourceFolderName + ".zip");
                        //G.setStatus("Uploading backup for " + sourcePaths[x] + ". This may take a while, please be patient.");
                        //G.connection.uploadFile(@"C:\RootBackup\" + sourceFolderName + ".zip");
                        //G.setStatus("Clearing space for next folder backup.");
                        //File.Delete(@"C:\RootBackup\" + sourceFolderName + ".zip");
                    }
                }
                G.handleFinalErrors();
            }
            G.backingUp = false;
            G.messageBox("Backup Finished", "RootBackup has finished backing up your files.", ToolTipIcon.Info);
            G.setStartBackupOption(true);
            G.setProgressBar(0, 0);
            if (G.backupError)
            {
                G.setStatus("Backup finished with errors. Will try again in " + UserSettings.getSetting("backup-interval") + " hours.");
                G.backupError = false;
            }
            else
            {
                G.setStatus("Backup finished");
            }
            PowerHelper.ResetSystemDefault();
            UserSettings.setSetting("last-backup", G.getTimeUTC());
            UserSettings.setSetting("last-backup-millis", "" + G.getTimeMilli());
        }