Esempio n. 1
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            if (backupSetting == null)
            {
                if (File.Exists(Program.ConfigFile))
                {
                    backupSetting = JsonHelp.FromJson <BackupSetting>(File.ReadAllText(Program.ConfigFile));
                }
                else
                {
                    BackupSetting defaultSetting = new BackupSetting();
                    defaultSetting.SvnAdminCmd    = new FileInfo(@"C:\Program Files\TortoiseSVN\bin\svnadmin.exe");
                    defaultSetting.BackupHome     = new DirectoryInfo(@"D:\backup\svn");
                    defaultSetting.RepositoryHome = new DirectoryInfo(@"D:\repositories");
                    defaultSetting.BackupTime     = "01:00";
                    defaultSetting.BackupRetain   = 7;
                    backupSetting = defaultSetting;
                    // 保存配置文件
                    File.WriteAllText(Program.ConfigFile, JsonHelp.ToJson(backupSetting));
                }
            }

            int index = backupSetting.BackupTime.IndexOf(":");

            settingHour   = Convert.ToInt32(backupSetting.BackupTime.Substring(0, index));
            settingMinute = Convert.ToInt32(backupSetting.BackupTime.Substring(index + 1));

            // Hook up the Elapsed event for the timer.
            timer1.Elapsed  += OnTimedEvent;
            timer1.AutoReset = true;

            taskIsRuning = true;
            SetButtonEnabled();
        }
Esempio n. 2
0
        private void btnSetting_Click(object sender, EventArgs e)
        {
            var frmSetting = new FrmSetting();

            frmSetting.Setting = backupSetting;
            frmSetting.ShowDialog(this);
            this.backupSetting = frmSetting.Setting;

            // 修改计划任务的时间
            int index = backupSetting.BackupTime.IndexOf(":");

            settingHour   = Convert.ToInt32(backupSetting.BackupTime.Substring(0, index));
            settingMinute = Convert.ToInt32(backupSetting.BackupTime.Substring(index + 1));

            // 保存配置文件
            File.WriteAllText(Program.ConfigFile, JsonHelp.ToJson(backupSetting));
        }