Exemplo n.º 1
0
        private void RaiseEventObj(EcasEvent e, EcasPropertyDictionary props)
        {
            // if(e == null) throw new ArgumentNullException("e");
            // if(m_bEnabled == false) return;

            if (this.RaisingEvent != null)
            {
                EcasRaisingEventArgs args = new EcasRaisingEventArgs(e, props);
                this.RaisingEvent(this, args);
                if (args.Cancel)
                {
                    return;
                }
            }

            try
            {
                foreach (EcasTrigger t in m_vTriggers)
                {
                    t.RunIfMatching(e, props);
                }
            }
            catch (Exception ex)
            {
                if (!VistaTaskDialog.ShowMessageBox(ex.Message, KPRes.TriggerExecutionFailed,
                                                    PwDefs.ShortProductName, VtdIcon.Warning, null))
                {
                    MessageService.ShowWarning(KPRes.TriggerExecutionFailed + ".", ex);
                }
            }
        }
Exemplo n.º 2
0
        public EcasContext(EcasTriggerSystem coll, EcasTrigger trigger,
                           EcasEvent e, EcasPropertyDictionary props)
        {
            if (coll == null)
            {
                throw new ArgumentNullException("coll");
            }
            if (trigger == null)
            {
                throw new ArgumentNullException("trigger");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            if (props == null)
            {
                throw new ArgumentNullException("props");
            }

            m_coll     = coll;
            m_trigger  = trigger;
            m_eOccured = e;
            m_props    = props;
        }
Exemplo n.º 3
0
        internal void RaiseEvent(PwUuid eventType, string strPropKey,
                                 object oPropValue)
        {
            EcasPropertyDictionary d = new EcasPropertyDictionary();

            d.Set(strPropKey, oPropValue);

            RaiseEvent(eventType, d);
        }
Exemplo n.º 4
0
        public void RunIfMatching(EcasEvent ctxOccured, EcasPropertyDictionary props)
        {
            if (!m_bEnabled || !m_bOn)
            {
                return;
            }

            EcasContext ctx = new EcasContext(Program.TriggerSystem, this,
                                              ctxOccured, props);

            bool bEventMatches = false;

            foreach (EcasEvent e in m_events)
            {
                if (Program.EcasPool.CompareEvents(e, ctx))
                {
                    bEventMatches = true;
                    break;
                }
            }
            if (!bEventMatches)
            {
                return;
            }

            foreach (EcasCondition c in m_conds)
            {
                if (!Program.EcasPool.EvaluateCondition(c, ctx))
                {
                    return;
                }
            }

            foreach (EcasAction a in m_acts)
            {
                if (ctx.Cancel)
                {
                    break;
                }

                Program.EcasPool.ExecuteAction(a, ctx);
            }

            if (m_bTurnOffAfterAction)
            {
                m_bOn = false;
            }
        }
Exemplo n.º 5
0
        public void RaiseEvent(PwUuid eventType, EcasPropertyDictionary props)
        {
            if (eventType == null)
            {
                throw new ArgumentNullException("eventType");
            }
            // if(props == null) throw new ArgumentNullException("props");

            if (!m_bEnabled)
            {
                return;
            }

            EcasEvent e = new EcasEvent();

            e.Type = eventType;

            RaiseEventObj(e, (props ?? new EcasPropertyDictionary()));
        }
Exemplo n.º 6
0
 public EcasRaisingEventArgs(EcasEvent evt, EcasPropertyDictionary props)
 {
     m_evt   = evt;
     m_props = props;
 }