示例#1
0
		private bool UpdateDataEx(EcasCondition c, bool bGuiToInternal, bool bDxTypeInfo)
		{
			m_bBlockTypeSelectionHandler = true;
			bool bResult = EcasUtil.UpdateDialog(EcasObjectType.Condition, m_cmbConditions,
				m_dgvParams, c, bGuiToInternal, bDxTypeInfo);
			m_bBlockTypeSelectionHandler = false;
			return bResult;
		}
示例#2
0
        private bool UpdateDataEx(EcasCondition c, bool bGuiToInternal, bool bDxTypeInfo)
        {
            m_bBlockTypeSelectionHandler = true;
            bool bResult = EcasUtil.UpdateDialog(EcasObjectType.Condition, m_cmbConditions,
                                                 m_dgvParams, c, bGuiToInternal, bDxTypeInfo);

            m_bBlockTypeSelectionHandler = false;
            return(bResult);
        }
示例#3
0
        public bool Evaluate(EcasCondition c, EcasContext ctx)
        {
            if(c == null) throw new ArgumentNullException("c");

            foreach(EcasConditionType t in m_conditions)
            {
                if(t.Type.EqualsValue(c.Type))
                    return t.EvaluateMethod(c, ctx);
            }

            throw new NotSupportedException();
        }
示例#4
0
        private void OnConditionAdd(object sender, EventArgs e)
        {
            EcasCondition     eNew = new EcasCondition();
            EcasConditionForm dlg  = new EcasConditionForm();

            dlg.InitEx(eNew);
            if (UIUtil.ShowDialogAndDestroy(dlg) == DialogResult.OK)
            {
                m_trigger.ConditionCollection.Add(eNew);
                UpdateConditionListEx(false);
            }
        }
		private static bool IsMatchEnvironmentVar(EcasCondition c, EcasContext ctx)
		{
			string strName = EcasUtil.GetParamString(c.Parameters, 0, true);
			uint uCompareType = EcasUtil.GetParamEnum(c.Parameters, 1,
				EcasUtil.StdStringCompareEquals, EcasUtil.StdStringCompare);
			string strValue = EcasUtil.GetParamString(c.Parameters, 2, true);

			if(string.IsNullOrEmpty(strName) || (strValue == null))
				return false;

			try
			{
				string strVar = Environment.GetEnvironmentVariable(strName);
				if(strVar == null) return false;

				return EcasUtil.CompareStrings(strVar, strValue, uCompareType);
			}
			catch(Exception) { Debug.Assert(false); }

			return false;
		}
        private static bool IsHostReachable(EcasCondition c, EcasContext ctx)
        {
            string strHost = EcasUtil.GetParamString(c.Parameters, 0, true);
            if(string.IsNullOrEmpty(strHost)) return true;

            int[] vTimeOuts = { 250, 1250 };
            const string strBuffer = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
            byte[] pbBuffer = Encoding.ASCII.GetBytes(strBuffer);

            try
            {
                Ping ping = new Ping(); // We have sufficient privileges?
                PingOptions options = new PingOptions(64, true);

                foreach(int nTimeOut in vTimeOuts)
                {
                    PingReply reply = ping.Send(strHost, nTimeOut, pbBuffer, options);
                    if(reply.Status == IPStatus.Success) return true;
                }

                return false;
            }
            catch(Exception) { }

            return false;
        }
 private static bool IsDatabaseModified(EcasCondition c, EcasContext ctx)
 {
     PwDatabase pd = Program.MainForm.ActiveDatabase;
     if((pd == null) || !pd.IsOpen) return false;
     return pd.Modified;
 }
        private static bool IsMatchString(EcasCondition c, EcasContext ctx)
        {
            string str = EcasUtil.GetParamString(c.Parameters, 0, true);
            uint uCompareType = EcasUtil.GetParamEnum(c.Parameters, 1,
                EcasUtil.StdStringCompareEquals, EcasUtil.StdStringCompare);
            string strValue = EcasUtil.GetParamString(c.Parameters, 2, true);

            if((str == null) || (strValue == null)) return false;

            return EcasUtil.CompareStrings(str, strValue, uCompareType);
        }
        private static bool IsMatchFileExists(EcasCondition c, EcasContext ctx)
        {
            string strFile = EcasUtil.GetParamString(c.Parameters, 0, true);
            if(string.IsNullOrEmpty(strFile)) return true;

            try
            {
                // return File.Exists(strFile);

                IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFile);
                return IOConnection.FileExists(ioc);
            }
            catch(Exception) { }

            return false;
        }
示例#10
0
 public void InitEx(EcasCondition e)
 {
     m_conditionInOut = e;
     m_condition      = e.CloneDeep();
 }
示例#11
0
		private static bool EcasConditionEvaluateTrue(EcasCondition c, EcasContext ctx)
		{
			return true;
		}
示例#12
0
 private void OnConditionAdd(object sender, EventArgs e)
 {
     EcasCondition eNew = new EcasCondition();
     EcasConditionForm dlg = new EcasConditionForm();
     dlg.InitEx(eNew);
     if(UIUtil.ShowDialogAndDestroy(dlg) == DialogResult.OK)
     {
         m_trigger.ConditionCollection.Add(eNew);
         UpdateConditionListEx(false);
     }
 }
        private static bool IsMatchFile(EcasCondition c, EcasContext ctx)
        {
            string strFile = EcasUtil.GetParamString(c.Parameters, 0, true);
            if(string.IsNullOrEmpty(strFile)) return true;

            try { return File.Exists(strFile); }
            catch(Exception) { }

            return false;
        }
示例#14
0
        public bool EvaluateCondition(EcasCondition c, EcasContext ctx)
        {
            if(c == null) throw new ArgumentNullException("c");

            foreach(EcasConditionProvider p in m_vConditionProviders)
            {
                if(p.IsSupported(c.Type))
                {
                    bool bResult = p.Evaluate(c, ctx);
                    return (c.Negate ? !bResult : bResult);
                }
            }

            throw new Exception(KPRes.TriggerConditionTypeUnknown + " " +
                KPRes.TypeUnknownHint + MessageService.NewParagraph + c.TypeString);
        }
示例#15
0
		public void InitEx(EcasCondition e)
		{
			m_conditionInOut = e;
			m_condition = e.CloneDeep();
		}
        private static bool IsDatabaseModified(EcasCondition c, EcasContext ctx)
        {
            PwDatabase pd = null;

            uint uSel = EcasUtil.GetParamUInt(c.Parameters, 0, 0);
            if(uSel == 0)
                pd = Program.MainForm.ActiveDatabase;
            else if(uSel == 1)
                pd = ctx.Properties.Get<PwDatabase>(EcasProperty.Database);
            else { Debug.Assert(false); }

            if((pd == null) || !pd.IsOpen) return false;
            return pd.Modified;
        }