Exemple #1
0
        //-------------------------------------------------------------------
        /// <summary>
        /// Démarre les étapes suivantes d'une étape
        /// </summary>
        /// <param name="etape"></param>
        /// <returns></returns>
        public CResultAErreur PrépareSuiteEtapeInCurrentContext(CEtapeWorkflow etape)
        {
            CResultAErreur     result    = CResultAErreur.True;
            CTypeEtapeWorkflow typeEtape = etape.TypeEtape;

            if (typeEtape.LiensSortants.Count == 0)
            {
                IsRunning = false;
                if (EtapeAppelante != null)
                {
                    //Fin de l'étape appelante
                    result = EtapeAppelante.EndEtapeNoSave();
                    if (!result)
                    {
                        return(result);
                    }
                }
                return(result);
            }
            foreach (CLienEtapesWorkflow lien in typeEtape.LiensSortants)
            {
                bool          bStartLien  = true;
                C2iExpression formuleLien = lien.Formule;
                if (lien.ActivationCode.Trim().Length > 0)
                {
                    bStartLien = false;
                    foreach (string strCodeRetour in etape.CodesRetour)
                    {
                        if (strCodeRetour.ToUpper() == lien.ActivationCode.ToUpper())
                        {
                            bStartLien = true;
                            break;
                        }
                    }
                }
                if (formuleLien != null && bStartLien && !(formuleLien is C2iExpressionVrai))
                {
                    CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(etape);
                    result = formuleLien.Eval(ctx);
                    if (!result)
                    {
                        result.EmpileErreur(I.T("Error on condition formula on link @1 from step @2|20008",
                                                lien.Libelle, etape.Libelle));
                        return(result);
                    }
                    bStartLien = result.Data != null && CUtilBool.BoolFromString(result.Data.ToString()) == true;
                }
                if (bStartLien)
                {
                    CTypeEtapeWorkflow typeDestination           = lien.EtapeDestination;
                    CResultAErreurType <CEtapeWorkflow> resEtape = etape.Workflow.CreateOrGetEtapeInCurrentContexte(typeDestination);
                    if (!resEtape)
                    {
                        result.EmpileErreur(resEtape.Erreur);
                        return(result);
                    }
                    else
                    {
                        resEtape.DataType.DemandeDemarrageInCurrentContext(etape);
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        public bool StartWorkflowMultiSteps(ArrayList listEtapesToStart)
        {
            CSessionClient   session = CSessionClient.GetSessionForIdSession(ContexteDonnee.IdSession);
            IInfoUtilisateur info    = session != null?session.GetInfoUtilisateur() : null;

            if (info != null)
            {
                KeyManager = info.KeyUtilisateur;
            }
            CResultAErreur result = CResultAErreur.True;

            if (TypeWorkflow.Etapes.Count == 0)
            {
                if (EtapeAppelante != null)
                {
                    EtapeAppelante.EndEtapeNoSave();
                    return(true);
                }
            }
            foreach (object stepsPath in listEtapesToStart)
            {
                if (!(stepsPath is string))
                {
                    throw new Exception(I.T("Invalid parameter for 'StartWorkflowMultiSteps'. Parameter must be an array of steps type path (separated by points).|20106"));
                }
                string strPath      = (string)stepsPath;
                int    nPosPoint    = strPath.IndexOf('.');
                string strStepType  = "";
                string strSuitePath = "";
                if (nPosPoint > 0)
                {
                    strStepType  = strPath.Substring(0, nPosPoint);
                    strSuitePath = strPath.Substring(nPosPoint + 1);
                }
                else
                {
                    strStepType = strPath;
                }
                CTypeEtapeWorkflow typeEtape = null;
                if (strStepType.Trim().Length == 0)
                {
                    typeEtape = TypeWorkflow.EtapeDemarrageDefaut;
                }
                else
                {
                    CListeObjetsDonnees lst = TypeWorkflow.Etapes;
                    lst.Filtre = new CFiltreData(CTypeEtapeWorkflow.c_champIdUniversel + "=@1", strStepType);
                    if (lst.Count > 0)
                    {
                        typeEtape = lst[0] as CTypeEtapeWorkflow;
                    }
                    if (typeEtape == null)
                    {
                        throw new Exception(I.T("Step type @1 can not be found|20107"));
                    }
                }

                CResultAErreurType <CEtapeWorkflow> resEtape = CreateOrGetEtapeInCurrentContexte(typeEtape);
                if (resEtape)
                {
                    CEtapeWorkflow etape = resEtape.DataType;
                    etape.StartWithPath(strSuitePath);
                }
                else
                {
                    result.EmpileErreur(resEtape.Erreur);
                }
                IsRunning = true;
                RunGeneration++;
            }
            return(result);
        }