Exemplo n.º 1
0
        public void ShowWizard()
        {
            if (InvokeRequired)
            {
                Invoke(new EmptyDelegate(ShowWizard));
                return;
            }

            if (WizardDialog == null || !WizardDialog.Visible)
            {
                WizardDialog = new WizardHandler();
            }

            WizardDialog.Show();
        }
Exemplo n.º 2
0
        private bool HandleCommandlineArguments(string[] _args)
        {
            bool anyUiShown = false;

            List<string> args = new List<string>(_args);
            Dictionary<string, string> options = CommandLine.CommandLineParser.ExtractOptions(args);

            //Backwards compatible options
            if (args.Count == 2 && args[0].ToLower().Trim() == "run-backup")
                options["run-backup"] = args[1].Trim();

            //Backwards compatible options
            if (args.Count == 1 && args[0] == "show-status")
                options["show-status"] = "";

            //Backwards compatible options
            if (args.Count == 2 && args[0].ToLower().Trim() == "run-backup-group")
                options["run-backup-group"] = args[1].Trim();

            //If pause is requested, pause before parsing --run-backup
            if (options.ContainsKey("pause"))
            {
                string period = options["pause"];
                if (string.IsNullOrEmpty(period))
                    Program.LiveControl.Pause();
                else
                {
                    try
                    {
                        Program.LiveControl.Pause(period);
                    }
                    catch (Exception ex)
                    {
                        Program.LiveControl.Pause();
                        MessageBox.Show(this, string.Format(Strings.MainForm.PauseOperationFailed, ex), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                anyUiShown = true;
            }

            if (options.ContainsKey("run-backup"))
            {
                string backupname = options["run-backup"];
                if (string.IsNullOrEmpty(backupname))
                {
                    if (WizardDialog == null || !WizardDialog.Visible)
                    {
                        WizardDialog = new WizardHandler(new System.Windows.Forms.Wizard.IWizardControl[] { new Wizard_pages.SelectBackup(Duplicati.GUI.Wizard_pages.WizardSettingsWrapper.MainAction.RunNow) });
                        WizardDialog.Show();
                        anyUiShown = true;
                    }
                }
                else
                {
                    anyUiShown = true;

                    Datamodel.Schedule[] schedules = Program.DataConnection.GetObjects<Datamodel.Schedule>("Name LIKE ?", backupname.Trim());
                    if (schedules == null || schedules.Length == 0)
                    {
                        MessageBox.Show(string.Format(Strings.MainForm.NamedBackupNotFound, backupname), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (schedules.Length > 1)
                    {
                        MessageBox.Show(string.Format(Strings.MainForm.MultipleNamedBackupsFound, backupname, schedules.Length), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (Library.Utility.Utility.ParseBoolOption(options, "full"))
                            Program.WorkThread.AddTask(new FullBackupTask(schedules[0]));
                        else
                            Program.WorkThread.AddTask(new IncrementalBackupTask(schedules[0]));
                    }
                }
            }

            if (options.ContainsKey("run-backup-group"))
            {
                string groupname = options["run-backup-group"];
                if (string.IsNullOrEmpty(groupname))
                {
                    if (WizardDialog == null || !WizardDialog.Visible)
                    {
                        WizardDialog = new WizardHandler(new System.Windows.Forms.Wizard.IWizardControl[] { new Wizard_pages.SelectBackup(Duplicati.GUI.Wizard_pages.WizardSettingsWrapper.MainAction.RunNow) });
                        WizardDialog.Show();
                        anyUiShown = true;
                    }
                }
                else
                {
                    Datamodel.Schedule[] schedules = Program.DataConnection.GetObjects<Datamodel.Schedule>("Path LIKE ?", groupname.Trim());
                    if (schedules == null || schedules.Length == 0)
                    {
                        MessageBox.Show(string.Format(Strings.MainForm.NamedBackupGroupNotFound, groupname), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        bool full = Library.Utility.Utility.ParseBoolOption(options, "full");

                        foreach(Datamodel.Schedule s in schedules)
                            if (full)
                                Program.WorkThread.AddTask(new FullBackupTask(s));
                            else
                                Program.WorkThread.AddTask(new IncrementalBackupTask(s));
                    }

                    anyUiShown = true;
                }
            }

            if (Library.Utility.Utility.ParseBoolOption(options, "show-status"))
            {
                ShowStatus();
                anyUiShown = true;
            }

            if (Library.Utility.Utility.ParseBoolOption(options, "show-wizard"))
            {
                ShowWizard();
                anyUiShown = true;
            }

            //Resume if requested
            if (Library.Utility.Utility.ParseBoolOption(options, "resume"))
            {
                Program.LiveControl.Resume();
                anyUiShown = true;
            }

            return anyUiShown;
        }
Exemplo n.º 3
0
        public void ShowWizard()
        {
            if (InvokeRequired)
            {
                Invoke(new EmptyDelegate(ShowWizard));
                return;
            }

            if (WizardDialog == null || !WizardDialog.Visible)
                WizardDialog = new WizardHandler();

            WizardDialog.Show();
        }
Exemplo n.º 4
0
        private bool HandleCommandlineArguments(string[] _args)
        {
            bool anyUiShown = false;

            List <string> args = new List <string>(_args);
            Dictionary <string, string> options = CommandLine.CommandLineParser.ExtractOptions(args);

            //Backwards compatible options
            if (args.Count == 2 && args[0].ToLower().Trim() == "run-backup")
            {
                options["run-backup"] = args[1].Trim();
            }

            //Backwards compatible options
            if (args.Count == 1 && args[0] == "show-status")
            {
                options["show-status"] = "";
            }

            //Backwards compatible options
            if (args.Count == 2 && args[0].ToLower().Trim() == "run-backup-group")
            {
                options["run-backup-group"] = args[1].Trim();
            }

            //If pause is requested, pause before parsing --run-backup
            if (options.ContainsKey("pause"))
            {
                string period = options["pause"];
                if (string.IsNullOrEmpty(period))
                {
                    Program.LiveControl.Pause();
                }
                else
                {
                    try
                    {
                        Program.LiveControl.Pause(period);
                    }
                    catch (Exception ex)
                    {
                        Program.LiveControl.Pause();
                        MessageBox.Show(this, string.Format(Strings.MainForm.PauseOperationFailed, ex), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                anyUiShown = true;
            }

            if (options.ContainsKey("run-backup"))
            {
                string backupname = options["run-backup"];
                if (string.IsNullOrEmpty(backupname))
                {
                    if (WizardDialog == null || !WizardDialog.Visible)
                    {
                        WizardDialog = new WizardHandler(new System.Windows.Forms.Wizard.IWizardControl[] { new Wizard_pages.SelectBackup(Duplicati.GUI.Wizard_pages.WizardSettingsWrapper.MainAction.RunNow) });
                        WizardDialog.Show();
                        anyUiShown = true;
                    }
                }
                else
                {
                    anyUiShown = true;

                    Datamodel.Schedule[] schedules = Program.DataConnection.GetObjects <Datamodel.Schedule>("Name LIKE ?", backupname.Trim());
                    if (schedules == null || schedules.Length == 0)
                    {
                        MessageBox.Show(string.Format(Strings.MainForm.NamedBackupNotFound, backupname), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (schedules.Length > 1)
                    {
                        MessageBox.Show(string.Format(Strings.MainForm.MultipleNamedBackupsFound, backupname, schedules.Length), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (Library.Utility.Utility.ParseBoolOption(options, "full"))
                        {
                            Program.WorkThread.AddTask(new FullBackupTask(schedules[0]));
                        }
                        else
                        {
                            Program.WorkThread.AddTask(new IncrementalBackupTask(schedules[0]));
                        }
                    }
                }
            }

            if (options.ContainsKey("run-backup-group"))
            {
                string groupname = options["run-backup-group"];
                if (string.IsNullOrEmpty(groupname))
                {
                    if (WizardDialog == null || !WizardDialog.Visible)
                    {
                        WizardDialog = new WizardHandler(new System.Windows.Forms.Wizard.IWizardControl[] { new Wizard_pages.SelectBackup(Duplicati.GUI.Wizard_pages.WizardSettingsWrapper.MainAction.RunNow) });
                        WizardDialog.Show();
                        anyUiShown = true;
                    }
                }
                else
                {
                    Datamodel.Schedule[] schedules = Program.DataConnection.GetObjects <Datamodel.Schedule>("Path LIKE ?", groupname.Trim());
                    if (schedules == null || schedules.Length == 0)
                    {
                        MessageBox.Show(string.Format(Strings.MainForm.NamedBackupGroupNotFound, groupname), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        bool full = Library.Utility.Utility.ParseBoolOption(options, "full");

                        foreach (Datamodel.Schedule s in schedules)
                        {
                            if (full)
                            {
                                Program.WorkThread.AddTask(new FullBackupTask(s));
                            }
                            else
                            {
                                Program.WorkThread.AddTask(new IncrementalBackupTask(s));
                            }
                        }
                    }

                    anyUiShown = true;
                }
            }

            if (Library.Utility.Utility.ParseBoolOption(options, "show-status"))
            {
                ShowStatus();
                anyUiShown = true;
            }

            if (Library.Utility.Utility.ParseBoolOption(options, "show-wizard"))
            {
                ShowWizard();
                anyUiShown = true;
            }

            //Resume if requested
            if (Library.Utility.Utility.ParseBoolOption(options, "resume"))
            {
                Program.LiveControl.Resume();
                anyUiShown = true;
            }

            return(anyUiShown);
        }