예제 #1
0
        /// ////////////////////////////////////////////////////////
        public override CResultAErreur VerifieDonnees()
        {
            CResultAErreur result      = CResultAErreur.True;
            CProcessInDb   processInDB = new CProcessInDb(Process.ContexteDonnee);

            if (!processInDB.ReadIfExists(m_dbKeyProcess))
            {
                result.EmpileErreur(I.T("Invalid action to start|192"));
                return(result);
            }
            //Vérifie le type des variables
            CProcess process = processInDB.Process;

            foreach (string strIdVariable in m_mapVariablesProcessToFormule.Keys)
            {
                IVariableDynamique variable = process.GetVariable(strIdVariable);
                if (variable != null)
                {
                    CTypeResultatExpression typeVariable = variable.TypeDonnee;
                    C2iExpression           expression   = (C2iExpression)m_mapVariablesProcessToFormule[strIdVariable];
                    if (expression != null)
                    {
                        if (!expression.TypeDonnee.Equals(typeVariable))
                        {
                            result.EmpileErreur(I.T("The formula of '@1' variable value must return a @2 type|193", variable.Nom, typeVariable.ToStringConvivial()));
                        }
                    }
                }
            }
            return(result);
        }
예제 #2
0
        /// //////////////////////////////////////////
        public override CResultAErreur MyEval(CContexteEvaluationExpression ctx, object[] valeursParametres)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CContexteDonnee       contexteDonnee = null;
                IObjetAContexteDonnee objAContexte   = ctx.ObjetSource as IObjetAContexteDonnee;
                if (objAContexte != null)
                {
                    contexteDonnee = objAContexte.ContexteDonnee;
                }
                if (valeursParametres.Length > 1 && valeursParametres[1] is IObjetAContexteDonnee)
                {
                    contexteDonnee = ((IObjetAContexteDonnee)valeursParametres[1]).ContexteDonnee;
                }
                if (contexteDonnee == null)
                {
                    contexteDonnee = ctx.GetObjetAttache(typeof(CContexteDonnee)) as CContexteDonnee;
                }

                if (contexteDonnee == null)
                {
                    result.EmpileErreur(I.T("Can not find any context to execute process|20013"));
                    return(result);
                }
                int?nIdProcess = valeursParametres[0] as int?;
                if (nIdProcess == null)
                {
                    result.EmpileErreur(I.T("First parameters of start process should be an integer|20014"));
                    return(result);
                }
                CProcessInDb process = new CProcessInDb(contexteDonnee);
                if (!process.ReadIfExists(nIdProcess.Value))
                {
                    result.EmpileErreur(I.T("Can not find process @1|20015", nIdProcess.Value.ToString()));
                    return(result);
                }
                object target = null;
                if (valeursParametres.Length > 1)
                {
                    target = valeursParametres[1];
                }
                result = CProcessEnExecutionInDb.StartProcessClient(
                    process.Process,
                    target,
                    contexteDonnee,
                    null);
            }
            catch
            {
                result.EmpileErreur(I.T("Error in StartProcess|20016"));
            }
            return(result);
        }
예제 #3
0
        public override bool UtiliseObjet(object objetCherche)
        {
            if (base.UtiliseObjet(objetCherche))
            {
                return(true);
            }
            CProcessInDb pr = objetCherche as CProcessInDb;

            if (pr != null && pr.DbKey == m_dbKeyProcess)
            {
                return(true);
            }
            return(false);
        }
예제 #4
0
        /// ////////////////////////////////////////////////////////
        protected override CResultAErreur MyExecute(CContexteExecutionAction contexte)
        {
            CResultAErreur result      = CResultAErreur.False;
            CProcessInDb   processInDB = new CProcessInDb(contexte.ContexteDonnee);

            if (!processInDB.ReadIfExists(m_dbKeyProcess))
            {
                result.EmpileErreur(I.T("The @1 action doesn't exist|194", m_dbKeyProcess.ToString()));
                result.EmpileErreur(I.T("Error in an action execution from an action|195"));
                return(result);
            }

            string strOldContextuel = contexte.ContexteDonnee.IdModificationContextuelle;

            CContexteDonnee contexteDonneeSousAction = contexte.ContexteDonnee;

            if (ModeAsynchrone || LancerDansUnProcessSepare)
            {
                contexteDonneeSousAction = new CContexteDonnee(contexte.IdSession, true, true);
            }

            //Si synchrone, s'execute dans le même contexte de données
            if (!ModeAsynchrone)
            {
                CProcessEnExecutionInDb processEnExec = new CProcessEnExecutionInDb(contexteDonneeSousAction);

                processEnExec.CreateNewInCurrentContexte();

                CProcess process = processInDB.Process;
                process.ContexteDonnee = contexteDonneeSousAction;

                object elementCible = contexte.ObjetCible;

                //Remplit les variables du process
                foreach (string strIdVariable in m_mapVariablesProcessToFormule.Keys)
                {
                    IVariableDynamique variable = process.GetVariable(strIdVariable);
                    //Evalue la formule
                    C2iExpression expression = (C2iExpression)m_mapVariablesProcessToFormule[strIdVariable];
                    CContexteEvaluationExpression contexteEval = new CContexteEvaluationExpression(Process);
                    contexteEval.AttacheObjet(typeof(CContexteDonnee), contexte.ContexteDonnee);
                    result = expression.Eval(contexteEval);
                    if (!result)
                    {
                        result.EmpileErreur(I.T("Error during the variables assignment in sub action|197"));
                        result.EmpileErreur(I.T("@1 variable error|196", variable.Nom));
                        return(result);
                    }
                    CObjetDonnee objDonnee = result.Data as CObjetDonnee;
                    if (objDonnee != null)
                    {
                        result.Data = objDonnee.GetObjetInContexte(contexteDonneeSousAction);
                    }
                    process.SetValeurChamp(variable.IdVariable, result.Data);
                    if (variable.IdVariable == CProcess.c_strIdVariableElement && result.Data is CObjetDonneeAIdNumerique)
                    {
                        elementCible = result.Data;
                    }
                }

                if (elementCible is CObjetDonneeAIdNumerique)
                {
                    processEnExec.ElementLie = (CObjetDonneeAIdNumerique)elementCible;
                }
                else
                {
                    processEnExec.ElementLie = null;
                }
                processEnExec.Libelle = process.Libelle;

                CBrancheProcess branche = new CBrancheProcess(process);
                branche.IsModeAsynchrone = ModeAsynchrone;
                //TESTDBKEYOK
                branche.KeyUtilisateur          = contexte.Branche.KeyUtilisateur;
                branche.ConfigurationImpression = contexte.Branche.ConfigurationImpression;

                CContexteExecutionAction contexteExecution = new CContexteExecutionAction(
                    processEnExec,
                    branche,
                    elementCible,
                    ModeAsynchrone ? null : contexteDonneeSousAction, contexte.IndicateurProgression);

                CAction pointEntree = null;
                if (IdPointEntree >= 0)
                {
                    pointEntree = process.GetActionFromId(IdPointEntree);
                    if (pointEntree == null)
                    {
                        result.EmpileErreur(I.T("Can not find entry point|20018"));
                        return(result);
                    }
                }
                else
                {
                    pointEntree = process.GetActionDebut();
                }

                if (!ModeAsynchrone)
                {
                    contexteExecution.SauvegardeContexteExterne = !m_bLancerDansContexteSepare;

                    result = branche.ExecuteAction(pointEntree, contexteExecution, elementCible, true);
                    foreach (CContexteExecutionAction.CParametreServiceALancerALaFin s in contexteExecution.ServicesALancerALaFin)
                    {
                        contexte.AddServiceALancerALaFin(s);
                    }
                    contexteExecution.ClearServicesALancerALaFin();
                    if (m_bSansTrace)
                    {
                        processEnExec.Table.Rows.Remove(processEnExec.Row.Row);
                    }
                    if (VariableResultat != null && process.VariableDeRetour != null)
                    {
                        object valeur = process.GetValeurChamp(process.VariableDeRetour);
                        if (valeur != null)
                        {
                            valeur = valeur.ToString();
                        }
                        Process.SetValeurChamp(VariableResultat.IdVariable, valeur.ToString());
                    }
                }
                else
                {
                    //Ouvre une nouvelle session pour éxecuter le process
                    CSessionProcessServeurSuivi sessionAsync = new CSessionProcessServeurSuivi();
                    result = sessionAsync.OpenSession(new CAuthentificationSessionProcess(),
                                                      I.T("Process @1|198", processInDB.Libelle),
                                                      CSessionClient.GetSessionForIdSession(contexte.IdSession));
                    if (!result)
                    {
                        return(result);
                    }
                    contexteExecution.ChangeIdSession(sessionAsync.IdSession);
                    contexteExecution.HasSessionPropre = true;
                    m_brancheToExecute         = branche;
                    m_actionToExecute          = pointEntree;
                    m_elementCible             = elementCible;
                    m_contexteExecutionProcess = contexteExecution;
                    Thread th = new Thread(new ThreadStart(DemarreProcess));
                    th.Start();
                    return(result);
                }
            }
            contexte.ContexteDonnee.IdModificationContextuelle = strOldContextuel;
            return(result);
        }