Exemplo n.º 1
0
 public void Save()
 {
     if (AutoSave)
     {
         triggerFile.Set("contexts", TriggerM.List());
         Trace.TraceInformation("Saved");
     }
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        public void AddTrigger(PXTriggerContext context)
        {
            var trigger = TriggerM.Add(context);

            TriggerM.Start(trigger);
        }