public void Save() { if (AutoSave) { triggerFile.Set("contexts", TriggerM.List()); Trace.TraceInformation("Saved"); } }
public void Start(PXStorage storage) { Trace.TraceInformation("MASTER START"); Storage = storage; triggerFile = Storage.GetConfigLocalStorage(triggerFileName); IEnumerable <PXTriggerContext> contexts = triggerFile.Get <IEnumerable <PXTriggerContext> >("contexts"); TriggerM.OnTrigger += TriggerM_OnTrigger; TriggerM.ContextsChanged += TriggerM_ContextsChanged; if (contexts != null) { Console.WriteLine("RESUME!!!"); TriggerM.Resume(contexts); //TODO: Actions with running status should be set to Error } List <PXPolicy> policies = new List <PXPolicy> { new PXPolicy { Name = "bilibili", UrlPatterns = new string[] { @"bilibili.com/video/(?<avnum>av\d+)" }, PathPattern = "bilibili/{avnum}/{timestamp}", Actions = new string[] { "you-get", "snapshot" }, }, //new PXPolicy //{ // Name = "default", // UrlPatterns = new string[] { @"\s*\S+?" }, // PathPattern = "webpage/{md5url}/{timestamp}", // Actions = new string[] { "snapshot" } //}, }; PolicyM = new PXPolicyManager(policies); ActionM.OnStatusChange += ActionM_OnStatusChange; }
public void AddTrigger(PXTriggerContext context) { var trigger = TriggerM.Add(context); TriggerM.Start(trigger); }