コード例 #1
0
        private void m_mnuStockInVariable_Click(object sender, EventArgs e)
        {
            if (Selection.Count != 1 || AskCreationVariable == null)
            {
                return;
            }
            CRepresentationExpressionGraphique rep = Selection[0] as CRepresentationExpressionGraphique;

            if (rep == null || rep.Formule == null)
            {
                return;
            }
            CTypeResultatExpression typeRes = rep.Formule.TypeDonnee;
            CDefinitionProprieteDynamiqueVariableFormule def = new CDefinitionProprieteDynamiqueVariableFormule(
                "", typeRes, true);

            def = CFormEditVariableFormule.EditeVariable(def);
            if (def != null)
            {
                if (AskCreationVariable(def))
                {
                    C2iExpressionSetVariable exp    = new C2iExpressionSetVariable();
                    C2iExpressionChamp       expVar = new C2iExpressionChamp(def);
                    exp.Parametres.Add(expVar);
                    exp.Parametres.Add(rep.Formule);
                    rep.Formule = exp;
                    Refresh();
                }
            }
        }
コード例 #2
0
        //----------------------------------------------------------------------
        public CResultAErreur Eval(CContexteEvaluationExpression ctxEval, params object[] parametres)
        {
            if (Formule == null)
            {
                return(null);
            }
            int nParametre = 0;
            CContexteEvaluationExpression ctxCopie = new CContexteEvaluationExpression(ctxEval.ObjetSource);

            foreach (CParametreFonctionDynamique parametre in Parametres)
            {
                CDefinitionProprieteDynamiqueVariableFormule def = new CDefinitionProprieteDynamiqueVariableFormule(
                    parametre.Nom,
                    parametre.TypeResultatExpression,
                    true);
                ctxCopie.AddVariable(def);
                if (nParametre < parametres.Length)
                {
                    ctxCopie.SetValeurVariable(def, parametres[nParametre]);
                }
                else
                {
                    ctxCopie.SetValeurVariable(def, null);
                }
                nParametre++;
            }
            CResultAErreur result = Formule.Eval(ctxCopie);

            if (!result)
            {
                result.EmpileErreur(I.T("Error while evaluating method @1|20127"));
            }
            return(result);
        }
コード例 #3
0
        //-----------------------------------------------------------
        private void m_lnkAddVar_LinkClicked(object sender, EventArgs e)
        {
            CDefinitionProprieteDynamiqueVariableFormule variable = CFormEditVariableFormule.EditeVariable(null);

            if (variable != null && RepresentationEditee != null)
            {
                RepresentationEditee.AddVariable(variable);
                UpdateVariables();
            }
        }
コード例 #4
0
 private void m_lnkRemoveVar_LinkClicked(object sender, EventArgs e)
 {
     if (m_wndListeVariables.SelectedItems.Count == 1)
     {
         ListViewItem item = m_wndListeVariables.SelectedItems[0];
         CDefinitionProprieteDynamiqueVariableFormule def = item.Tag as CDefinitionProprieteDynamiqueVariableFormule;
         if (def != null && RepresentationEditee != null)
         {
             RepresentationEditee.RemoveVariable(def);
             UpdateVariables();
         }
     }
 }
コード例 #5
0
 private bool m_editeur_AskCreationVariable(CDefinitionProprieteDynamiqueVariableFormule defACreer)
 {
     foreach (CDefinitionProprieteDynamiqueVariableFormule defExistante in RepresentationEditee.Variables)
     {
         if (defExistante.Nom.ToUpper() == defACreer.Nom.ToUpper())
         {
             MessageBox.Show(I.T("Variable @1 already exists|20018", defACreer.Nom));
             return(false);
         }
     }
     RepresentationEditee.AddVariable(defACreer);
     UpdateVariables();
     return(true);
 }
コード例 #6
0
ファイル: CTrapHandler.cs プロジェクト: ykebaili/Timos
        //------------------------------------------------------------
        private CDefinitionProprieteDynamiqueVariableFormule AssureVariableTrap(C2iExpressionGraphique formule)
        {
            if (formule == null)
            {
                return(null);
            }
            CDefinitionProprieteDynamiqueVariableFormule def = formule.Variables.FirstOrDefault(v => v.Nom == c_strNomVariableTrap);

            if (def == null)
            {
                def = new CDefinitionProprieteDynamiqueVariableFormule("Trap",
                                                                       new CTypeResultatExpression(typeof(CTrapInstance), false), true);
                formule.AddVariable(def);
            }
            return(def);
        }
コード例 #7
0
        private void m_wndListeVariables_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListViewHitTestInfo info = m_wndListeVariables.HitTest(e.X, e.Y);

            if (info != null)
            {
                CDefinitionProprieteDynamiqueVariableFormule def = info.Item.Tag as CDefinitionProprieteDynamiqueVariableFormule;
                if (def != null)
                {
                    CDefinitionProprieteDynamiqueVariableFormule newDef = CFormEditVariableFormule.EditeVariable(def);
                    if (newDef != null)
                    {
                        RepresentationEditee.ReplaceVariable(def, newDef);
                        UpdateVariables();
                    }
                }
            }
        }
コード例 #8
0
        //----------------------------------------------------------------------------
        public CDefinitionProprieteDynamique[] GetDefinitionsChamps(CObjetPourSousProprietes objet, CDefinitionProprieteDynamique defParente)
        {
            List <CDefinitionProprieteDynamique> lst = new List <CDefinitionProprieteDynamique>();

            if (FournisseurPrincipal != null)
            {
                lst.AddRange(FournisseurPrincipal.GetDefinitionsChamps(objet, defParente));
            }
            foreach (CParametreFonctionDynamique parametre in Parametres)
            {
                CDefinitionProprieteDynamiqueVariableFormule def = new CDefinitionProprieteDynamiqueVariableFormule(
                    parametre.Nom,
                    parametre.TypeResultatExpression,
                    true);
                def.Rubrique = I.T("Parameters|20128");
                lst.Add(def);
            }
            return(lst.ToArray());
        }
コード例 #9
0
        private void m_btnOk_Click(object sender, EventArgs e)
        {
            if (m_txtNom.Text == "")
            {
                MessageBox.Show("Name ?");
                return;
            }
            Type tp = null;

            if (m_variable != null && m_variable.TypeDonnee != null)
            {
                tp = m_variable.TypeDonnee.TypeDotNetNatif;
            }
            if (m_parametre != null && m_parametre.TypeResultatExpression != null)
            {
                tp = m_parametre.TypeResultatExpression.TypeDotNetNatif;
            }
            if (tp == null || m_txtType.Text != DynamicClassAttribute.GetNomConvivial(tp))
            {
                tp = CActivatorSurChaine.GetType(m_txtType.Text, true);
                if (tp == null)
                {
                    MessageBox.Show(I.T("Invalid type|20023"));
                    return;
                }
            }
            if (m_variable != null)
            {
                m_variable = new CDefinitionProprieteDynamiqueVariableFormule(
                    m_txtNom.Text, new CTypeResultatExpression(tp, m_chkArray.Checked), true);
            }
            if (m_parametre != null)
            {
                m_parametre.Nom = m_txtNom.Text;
                m_parametre.TypeResultatExpression = new CTypeResultatExpression(tp, m_chkArray.Checked);
            }
            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #10
0
ファイル: CCreateurAlarmes.cs プロジェクト: ykebaili/Timos
        //------------------------------------------------------------------
        public CResultAErreur FillAlarm(CTrapInstance trap, CLocalAlarme alarme)
        {
            CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(TrapHandler.TypeAgent);
            CDefinitionProprieteDynamiqueVariableFormule def = AssureVariableTrap(FormuleActions);

            if (def != null)
            {
                ctx.SetValeurVariable(def, trap);
            }
            def = AssureVariableAlarme(FormuleActions);
            if (def != null)
            {
                ctx.SetValeurVariable(def, alarme);
            }

            CResultAErreur result = FormuleActions.Eval(ctx);

            if (!result)
            {
                return(result);
            }

            return(result);
        }
コード例 #11
0
        public static CDefinitionProprieteDynamiqueVariableFormule EditeVariable(CDefinitionProprieteDynamiqueVariableFormule variable)
        {
            CFormEditVariableFormule form = new CFormEditVariableFormule();

            if (variable != null)
            {
                form.m_txtNom.Text      = variable.Nom;
                form.m_txtType.Text     = DynamicClassAttribute.GetNomConvivial(variable.TypeDonnee.TypeDotNetNatif);
                form.m_chkArray.Checked = variable.TypeDonnee.IsArrayOfTypeNatif;
            }
            else
            {
                variable = new CDefinitionProprieteDynamiqueVariableFormule();
            }
            form.m_variable = variable;
            CDefinitionProprieteDynamiqueVariableFormule retour = null;

            if (form.ShowDialog() == DialogResult.OK)
            {
                retour = form.m_variable;
            }
            form.Dispose();
            return(retour);
        }
コード例 #12
0
        //-----------------------------------------------------------


        //-----------------------------------------------------------
        private void FillItemVariable(ListViewItem item, CDefinitionProprieteDynamiqueVariableFormule variable)
        {
            item.Text = variable.Nom;
            item.Tag  = variable;
        }
コード例 #13
0
ファイル: CTrapHandler.cs プロジェクト: ykebaili/Timos
        public void CreateAlarmesOnTrap(CTrapInstance trap, CFuturocomTrace trace)
        {
            trap.CurrentTrapHandler = this;
            CDefinitionProprieteDynamiqueVariableFormule def = AssureVariableTrap(FormulePreTraitementTrap);
            CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(TypeAgent);

            if (def != null)
            {
                ctx.SetValeurVariable(def, trap);
            }
            CResultAErreur result = CResultAErreur.True;

            trap.EntiteAssociee = null;
            if (FormuleIndexEntite != null && TypeEntiteAssocie != null)
            {
                CContexteEvaluationExpression ctxSurThis = new CContexteEvaluationExpression(trap);
                result = FormuleIndexEntite.Eval(ctxSurThis);
                if (result && result.Data != null)
                {
                    CListeEntitesDeMemoryDb <CEntiteSnmpPourSupervision> lst = trap.AgentSnmp.Entites;
                    lst.Filtre = new CFiltreMemoryDb(CEntiteSnmpPourSupervision.c_champIndex + "=@1 and " +
                                                     CTypeEntiteSnmpPourSupervision.c_champId + "=@2",
                                                     result.Data.ToString(),
                                                     TypeEntiteAssocie.Id);
                    if (lst.Count() > 0)
                    {
                        trap.EntiteAssociee = lst.ElementAt(0);
                        if (trace != null)
                        {
                            trace.Write(
                                "Trap associated to entity " + trap.EntiteAssociee.Libelle + " (" + trap.EntiteAssociee.TypeEntite.Libelle + ")",
                                ALTRACE.DEBUG);
                        }
                    }
                    else
                    {
                        if (trace != null)
                        {
                            trace.Write(
                                "Associated entity is null (" + TypeEntiteAssocie.Libelle + " " + result.Data.ToString() + ")",
                                ALTRACE.DEBUG);
                        }
                    }
                }
                else
                {
                    if (trace != null)
                    {
                        if (!result)
                        {
                            trace.Write(
                                "Error in associed entity index formula : " + result.Erreur.ToString(),
                                ALTRACE.DEBUG);
                        }
                        else
                        {
                            trace.Write(
                                "Error in associed entity index formula : the formula returned a null result",
                                ALTRACE.DEBUG);
                        }
                    }
                }
            }
            bool bEvalPretraite = true;

            if (FormulePreTraitementTrap is C2iExpressionGraphique &&
                FormulePreTraitementTrap.Parametres.Count == 0)
            {
                bEvalPretraite = false;
            }
            if (bEvalPretraite)
            {
                result = FormulePreTraitementTrap.Eval(ctx);
                if (!result && trace != null)
                {
                    trace.Write(
                        "Error in Pretreatment formula " + result.Erreur.ToString(),
                        ALTRACE.DEBUG);
                }
            }



            foreach (CCreateurAlarme createur in CreateursAlarmes)
            {
                if (trace != null)
                {
                    trace.Write(
                        "Try creator " + createur.Libelle + " (" + createur.Code + ")",
                        ALTRACE.DEBUG);
                }
                bool bCreer = createur.FormuleCondition.GetType() == typeof(C2iExpressionVrai);
                if (!bCreer)
                {
                    ctx    = new CContexteEvaluationExpression(trap);
                    result = createur.FormuleCondition.Eval(ctx);
                    if (result && result.Data is bool && (bool)result.Data)
                    {
                        bCreer = true;
                    }
                    else if (trace != null)
                    {
                        if (!result)
                        {
                            trace.Write(
                                "Creator " + createur.Libelle + " condition error : " + result.Erreur.ToString(),
                                ALTRACE.DEBUG);
                        }
                        else
                        {
                            trace.Write(
                                "Create " + createur.Libelle + " condition returned false",
                                ALTRACE.DEBUG);
                        }
                    }
                }
                if (bCreer)
                {
                    if (trace != null)
                    {
                        trace.Write(
                            "Creator " + createur.Libelle + " condition returned true",
                            ALTRACE.DEBUG);
                    }
                    trap.AddAlarm(createur.Code, 0, trace);
                }
            }
        }