예제 #1
0
        private void archive_Click(object sender, EventArgs e)
        {
            try
            {
                Origin myOrigins = new Origin();
                Exclusion myExclusions = new Exclusion();

                ArchiverChooser chooser = new ArchiverChooser(myOrigins, myExclusions);

                ArchiverConfiguration config = new ArchiverConfiguration();
                Archiver myArchiver = new Archiver(config);

                myArchiver.Archive(chooser.GetProcessedFileSystemInfos());

                myArchiver.CleanOldDirectories();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            bool _logAtctive = false;
            bool _waitKeyPress = false;

            // Interperto as opcoes de rotina
            GetVariables(args, ref _logAtctive, ref _waitKeyPress);

            try
            {
                // Carrego as origens e exclusoes
                Origin myOrigins = new Origin();
                Exclusion myExclusions = new Exclusion();

                // Carrego a classe responsavel por fazer a escolha de arquivos
                ArchiverChooser chooser = new ArchiverChooser(myOrigins, myExclusions);

                // Carrego a configuracao basica de diretorios
                ArchiverConfiguration config = new ArchiverConfiguration();

                // Carrego a classe responsavel pelo arquivamento.
                Archiver myArchiver = new Archiver(config);

                // Arquivo os itens selecionados
                myArchiver.Archive(chooser.GetProcessedFileSystemInfos());

                // Limpo diretorios antigos
                myArchiver.CleanOldDirectories();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (_logAtctive)
                { System.IO.File.WriteAllText("Log_" + DateTime.Now.ToString("yyyy-MM-dd_hhmmss") + ".txt", ex.Message); }
            }

            if (_waitKeyPress)
            { Console.ReadKey(); }
        }
예제 #3
0
        private void saveChanges_Click(object sender, EventArgs e)
        {
            try
            {
                ArchiverConfiguration config = new ArchiverConfiguration();

                config.HistoryDirectoryPath = tb_historyDir.Text;
                config.HistoryDays = Convert.ToInt32(tb_historyTimeDays.Text);

                config.SaveConfiguration();

                LoadSettings();
                btn_Archive.Enabled = true;
                btn_Preview.Enabled = true;
            }
            catch (Exception ex)
            {
                btn_Archive.Enabled = false;
                btn_Preview.Enabled = false;
                MessageBox.Show(ex.Message);
            }
        }
예제 #4
0
 private void LoadSettings()
 {
     ArchiverConfiguration config = new ArchiverConfiguration();
     tb_historyDir.Text = config.HistoryDirectoryPath;
     tb_historyTimeDays.Text = config.HistoryDays.ToString();
 }
예제 #5
0
 /// <summary>
 /// Construtor
 /// </summary>
 public Archiver(ArchiverConfiguration config)
 {
     _config = config;
     LoadDestination();
 }