public bool DeleteRule(SnapshotRule rule, bool deleteSnapshots) { rule.Enabled = false; if (deleteSnapshots) { using (var vss = new VssClient(new VssHost())) { vss.Initialize(VssSnapshotContext.All, VssBackupType.Incremental); PruningMgr.Instance.DeleteAllForRule(vss, rule); } } bool ret = RulesMap.TryRemove(rule.Id, out SnapshotRule value); if (!ret) { return(false); } VssScheduler.CreateAllTriggers(Rules); SaveRules(); return(ret); }
public void AddOrUpdateRule(SnapshotRule newRule) { SnapshotRule oldRule = RulesMap.SafeGet(newRule.Id); if (oldRule != null) { newRule.CopyProperties(oldRule); } else { RulesMap[newRule.Id] = newRule; } SaveRules(); VssScheduler.CreateAllTriggers(Rules); }
public void LoadRules(IList <SnapshotRule> rules) { RulesMap = rules.ToConcurrentDictionary(k => k.Id); VssScheduler.CreateAllTriggers(Rules); }