//-------------------------------------------------------
        private void InitChamps()
        {
            CFiltreData filtre = new CFiltreData(CProcessInDb.c_champTypeCible + "=@1",
                                                 typeof(CEtapeWorkflow).ToString());

            m_txtSelectProcess.Init(typeof(CProcessInDb),
                                    filtre,
                                    "Libelle",
                                    true);
            if (m_blocProcess.DbKeyProcess != null)
            {
                CProcessInDb process = new CProcessInDb(CContexteDonneeSysteme.GetInstance());
                if (process.ReadIfExists(m_blocProcess.DbKeyProcess))
                {
                    m_txtSelectProcess.ElementSelectionne = process;
                }
            }
            m_process = m_blocProcess.Process;
            m_txtInstructions.Text   = m_blocProcess.Instructions;
            m_chkManualStart.Checked = m_blocProcess.DemarrageManuel;
            CParametresInitialisationEtape parametres = m_blocProcess.TypeEtape != null ? m_blocProcess.TypeEtape.ParametresInitialisation : new CParametresInitialisationEtape();

            m_panelAffectations.Init(parametres);
            m_chkUtiliserSortieProcessCommeCodeRetour.Checked = m_blocProcess.UtiliserLaValeurDeSortieDeProcessCommeCodeRetour;

            UpdateVisuProcess();
        }
示例#2
0
        //-------------------------------------------------------------
        public CResultAErreur StartProcess(CEtapeWorkflow etape)
        {
            CResultAErreur result  = CResultAErreur.True;
            CProcess       process = m_process;

            if (process == null)
            {
                if (m_dbKeyProcess != null)
                {
                    CProcessInDb processInDb = new CProcessInDb(etape.ContexteDonnee);
                    if (processInDb.ReadIfExists(m_dbKeyProcess))
                    {
                        process = processInDb.Process;
                    }
                }
            }
            if (process != null)
            {
                if (process.Libelle.Trim().Length == 0 && etape != null)
                {
                    process.Libelle = I.T("Step @1|20109", etape.Libelle);
                }
                result = CProcessEnExecutionInDb.StartProcess(process, new CInfoDeclencheurProcess(TypeEvenement.Specifique),
                                                              new CReferenceObjetDonnee(etape),
                                                              etape.ContexteDonnee.IdSession,
                                                              null,
                                                              null);
                if (result)
                {
                    etape.Refresh();//Relit l'étape car elle a pu être modifiée par le process
                    if (m_bUtiliserSortieDeProcessCommeCodeRetour && (result.Data is string || result.Data is string[]))
                    {
                        if (result.Data is string)
                        {
                            etape.CodesRetour = new string[] { (string)result.Data }
                        }
                        ;
                        if (result.Data is string[])
                        {
                            etape.CodesRetour = (string[])result.Data;
                        }
                    }
                    result = EndAndSaveIfOk(etape);
                }
            }
            return(result);
        }
    }
        /// //////////////////////////////////////////
        protected override void InitChamps()
        {
            base.InitChamps();
            m_wndAideFormule.FournisseurProprietes = ObjetEdite.Process;
            m_wndAideFormule.ObjetInterroge        = typeof(CProcess);

            m_txtFormuleVariable.Init(m_wndAideFormule.FournisseurProprietes, m_wndAideFormule.ObjetInterroge);

            CListeObjetsDonnees liste = new CListeObjetsDonnees(CSc2iWin32DataClient.ContexteCourant, typeof(CProcessInDb));

            m_cmbProcess.ListDonnees       = liste;
            m_cmbProcess.ProprieteAffichee = "Libelle";
            CProcessInDb processInDB = new CProcessInDb(CSc2iWin32DataClient.ContexteCourant);

            m_tableIdVariableToFormule.Clear();
            CProcess processALancer = null;

            if (processInDB.ReadIfExists(ActionLancerProcess.DbKeyProcess))
            {
                m_cmbProcess.SelectedValue = processInDB;
                processALancer             = processInDB.Process;
                if (processALancer != null)
                {
                    foreach (IVariableDynamique variable in processALancer.ListeVariables)
                    {
                        m_tableIdVariableToFormule[variable.IdVariable] = ActionLancerProcess.GetExpressionForVariableProcess(variable.IdVariable);
                    }
                }
            }
            else
            {
                m_cmbProcess.SelectedValue = null;
            }

            UpdateListeVariables();

            m_chkAsynchrone.Checked     = ActionLancerProcess.ModeAsynchrone;
            m_chkSansTrace.Checked      = ActionLancerProcess.SansTrace;
            m_chkContexteSepare.Checked = ActionLancerProcess.LancerDansUnProcessSepare;

            UpdatePointsEntree();
        }
        /// //////////////////////////////////////////////////////////////////
        protected static CResultAErreur ExecuteActionProcess(CActionSur2iLinkExecuterProcess action, object objetCible)
        {
            CResultAErreur result  = CResultAErreur.True;
            CProcessInDb   process = new CProcessInDb(CSc2iWin32DataClient.ContexteCourant);

            if (process.ReadIfExists(action.IdProcessInDb))
            {
                CProcess processToExecute = process.Process;
                result = AffecteVariablesToProcess(action, processToExecute, objetCible);
                if (!result)
                {
                    return(result);
                }
                CInfoDeclencheurProcess infoDecl = new CInfoDeclencheurProcess(TypeEvenement.Manuel);
                CReferenceObjetDonnee   refObj   = null;
                object cibleProcess = objetCible;
                if (cibleProcess is CDefinitionMultiSourceForExpression)
                {
                    cibleProcess = ((CDefinitionMultiSourceForExpression)cibleProcess).ObjetPrincipal;
                }
                if (cibleProcess != null && process.TypeCible != null)
                {
                    if (cibleProcess.GetType().IsArray)
                    {
                        ArrayList lstRefs = new ArrayList();
                        foreach (object cible in (Array)cibleProcess)
                        {
                            if (process.TypeCible.IsAssignableFrom(cible.GetType()) && cible is CObjetDonnee)
                            {
                                lstRefs.Add(new CReferenceObjetDonnee((CObjetDonnee)cible));
                            }
                        }
                        if (lstRefs.Count == 0)
                        {
                            result.EmpileErreur(I.T("No element selected for requested action|30085"));
                        }
                        else
                        {
                            result = CFormExecuteProcess.StartProcessMultiples(processToExecute,
                                                                               (CReferenceObjetDonnee[])lstRefs.ToArray(typeof(CReferenceObjetDonnee)),
                                                                               CTimosApp.SessionClient.IdSession,
                                                                               CSc2iWin32DataClient.ContexteCourant.IdVersionDeTravail,
                                                                               action.MasquerProgressProcess);
                            return(result);
                        }
                    }
                    else
                    {
                        if (process.TypeCible.IsAssignableFrom(cibleProcess.GetType()) && cibleProcess is CObjetDonnee)
                        {
                            refObj = new CReferenceObjetDonnee((CObjetDonnee)cibleProcess);
                        }
                    }
                }
                result = CFormExecuteProcess.StartProcess(processToExecute,
                                                          refObj,
                                                          CTimosApp.SessionClient.IdSession,
                                                          CSc2iWin32DataClient.ContexteCourant.IdVersionDeTravail,
                                                          action.MasquerProgressProcess);
            }
            else
            {
                CEvenement evt = new CEvenement(CSc2iWin32DataClient.ContexteCourant);
                CInfoDeclencheurProcess infoDecl = new CInfoDeclencheurProcess(TypeEvenement.Manuel);
                object cibleProcess = objetCible;
                if (cibleProcess is CDefinitionMultiSourceForExpression)
                {
                    cibleProcess = ((CDefinitionMultiSourceForExpression)cibleProcess).ObjetPrincipal;
                }
                if (evt.ReadIfExists(action.IdEvenement))
                {
                    if (cibleProcess == null)
                    {
                        result.EmpileErreur(I.T("Impossible to execute the requested event|30086"));
                        return(result);
                    }
                    if (cibleProcess.GetType().IsArray)
                    {
                        ArrayList lstRefs = new ArrayList();
                        foreach (object cible in (Array)cibleProcess)
                        {
                            if (!(cible is CObjetDonneeAIdNumerique) || !evt.ShouldDeclenche((CObjetDonneeAIdNumerique)cible, ref infoDecl))
                            {
                                result.EmpileErreur(I.T("The requested action cannot be executed on at least one of the requested elements|30087"));
                                return(result);
                            }
                            lstRefs.Add(cible);
                        }
                        if (lstRefs.Count == 0)
                        {
                            result.EmpileErreur(I.T("No element selected for execution|30088"));
                            return(result);
                        }
                        result = CFormExecuteProcess.RunEventMultiple(
                            evt,
                            (CObjetDonneeAIdNumeriqueAuto[] )lstRefs.ToArray(typeof(CObjetDonneeAIdNumeriqueAuto)),
                            action.MasquerProgressProcess);
                    }
                    else
                    {
                        if (!evt.ShouldDeclenche((CObjetDonneeAIdNumerique)cibleProcess, ref infoDecl))
                        {
                            result.EmpileErreur(I.T("Impossible to trigger the requested event on this object|30089"));
                            return(result);
                        }
                        result = CFormExecuteProcess.RunEvent(evt, (CObjetDonneeAIdNumerique)cibleProcess, action.MasquerProgressProcess);
                    }
                }
                else
                {
                    result.EmpileErreur(I.T("The requested action does not exist|30090"));
                }
            }
            return(result);
        }
示例#5
0
        /* les parametres sont passés dans le table de paramètres :
         * Id de la variable, suivi de sa valeur( en texte ),...
         *
         */
        public string StartAction(int nIdAction, string[] strParametres)
        {
            DataSet ds = new DataSet();

            if (!AssureSession())
            {
                return("ERROR : " + I.T("Session error|30002"));
            }
            if ((strParametres.Length % 2) != 0)
            {
                return("ERROR : " + I.T("The parameters are not passed correctly|30003"));
            }

            using (CContexteDonnee contexte = new CContexteDonnee(m_session.IdSession, true, false))
            {
                CProcessInDb processInDb = new CProcessInDb(contexte);
                if (!processInDb.ReadIfExists(nIdAction))
                {
                    return("ERROR : " + I.T("The action @1 does not exist|30004", nIdAction.ToString()));
                }

                CProcess process = processInDb.Process;
                #region Affectation des variables du process
                for (int nVariable = 0; nVariable < strParametres.Length; nVariable += 2)
                {
                    string             strVariable = strParametres[nVariable];
                    IVariableDynamique variable    = null;
                    try
                    {
                        variable = process.GetVariable(strVariable);
                    }
                    catch
                    {
                        foreach (CVariableDynamique varTest in process.ListeVariables)
                        {
                            if (varTest.Nom.ToUpper() == strVariable.ToUpper())
                            {
                                variable = varTest;
                                break;
                            }
                        }
                        if (variable == null)
                        {
                            return("ERROR : " + I.T("@1 is not a valid variable id|30005", strVariable));
                        }
                    }
                    if (!(variable is CVariableDynamiqueSaisie))
                    {
                        return("ERROR : " + I.T("The variable @1 is not valid or does not exist|30006", strVariable));
                    }

                    try
                    {
                        object valeur = ((CVariableDynamiqueSaisie)variable).TypeDonnee2i.StringToType(strParametres[nVariable + 1], null);
                        process.SetValeurChamp(variable, valeur);
                    }
                    catch
                    {
                        return("ERROR : " + I.T("Error in affectation of variable @1|30007", variable.Nom));
                    }
                }
                #endregion

                //Note : le service web ne sait pas lancer un process dans une version
                CResultAErreur result = CProcessEnExecutionInDb.StartProcess(process, new CInfoDeclencheurProcess(TypeEvenement.Manuel), m_session.IdSession, null, null);
                if (!result)
                {
                    return("ERROR : " + result.Erreur.ToString());
                }
                if (result.Data != null)
                {
                    return(result.Data.ToString());
                }
                return(null);
            }
        }
示例#6
0
        //-----------------------------------------------------------
        public static CResultAErreur RunProcess(int nIdProcess, Dictionary <string, string> valeursParametres)
        {
            AssureTimerNettoyage();
            CResultAErreur result = GetSession();

            if (!result)
            {
                return(result);
            }
            CDonneeSessionProcess donneeSession = result.Data as CDonneeSessionProcess;

            result = CResultAErreur.True;
            try
            {
                CSessionClient session = donneeSession.SessionClient;
                using (CContexteDonnee contexte = new CContexteDonnee(session.IdSession, true, false))
                {
                    CProcessInDb processInDb = new CProcessInDb(contexte);
                    if (!processInDb.ReadIfExists(nIdProcess))
                    {
                        result.EmpileErreur(I.T("The process @1 doesn't exist|30008", nIdProcess.ToString()));
                        result.Data = (int)EErreurs.ProcessDoesntExists;
                        return(result);
                    }
                    CProcess process = processInDb.Process;
                    foreach (KeyValuePair <string, string> parametre in valeursParametres)
                    {
                        string strParametre = parametre.Key;
                        string strValeur    = parametre.Value;
                        bool   bTrouvee     = false;
                        foreach (IVariableDynamique variable in process.ListeVariables)
                        {
                            if (strParametre.ToUpper() == variable.Nom.ToUpper())
                            {
                                if (!variable.TypeDonnee.TypeDotNetNatif.IsValueType && variable.TypeDonnee.TypeDotNetNatif != typeof(string))
                                {
                                    result.EmpileErreur(I.T("Variable @1 cannot be set by TimosProcess. Only simple values can be used|30009", variable.Nom));
                                    result.Data = (int)EErreurs.InvalidVariableValueOnlySimpleValuesAreAccepted;
                                    return(result);
                                }
                                try
                                {
                                    object valeur = CUtilTexte.FromUniversalString(strValeur, variable.TypeDonnee.TypeDotNetNatif);
                                }
                                catch
                                {
                                }
                                process.SetValeurChamp(variable.IdVariable, strValeur);
                                bTrouvee = true;
                                break;
                            }
                        }
                        if (!bTrouvee)
                        {
                            result = ShowHelp(process);
                            result.EmpileErreur(I.T("Unknown variable @1|30010", strParametre));
                            result.Data = (int)EErreurs.UnknownVariable;
                            return(result);
                        }
                    }
                    result = CProcessEnExecutionInDb.StartProcess(process, new CInfoDeclencheurProcess(TypeEvenement.Manuel), session.IdSession, null, null);
                    if (!result)
                    {
                        result.Data = (int)EErreurs.ErrorWhileRunningProcess;
                        return(result);
                    }
                    if (result.Data != null)
                    {
                        try
                        {
                            result.Data = Convert.ToInt32(result.Data);
                        }
                        catch
                        {
                        }
                        return(result);
                    }
                    else
                    {
                        result.Data = 0;
                    }
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
                result.Data = (int)EErreurs.ErrorWhileRunningProcess;
                return(result);
            }
            finally
            {
                lock (typeof(CLanceurProcessCommandLine))
                {
                    donneeSession.EndUsing();
                }
            }
            return(result);
        }
        //-----------------------------------------------------------------------------------------------------
        public void InitChamps(CActionSur2iLink action, CObjetPourSousProprietes objetPourSousProprietes)
        {
            m_actionEditee = action as CActionSur2iLinkExecuterProcess;
            if (m_actionEditee == null)
            {
                Visible = false;
                return;
            }
            Visible = true;

            m_objetPourSousProprietes = objetPourSousProprietes;
            CObjetPourSousProprietes            objetPourFiltreActions = m_objetPourSousProprietes;
            CDefinitionMultiSourceForExpression multi = m_objetPourSousProprietes.ElementAVariableInstance as CDefinitionMultiSourceForExpression;

            if (multi != null)
            {
                objetPourFiltreActions = multi.DefinitionObjetPrincipal;
            }
            CFiltreData filtre = null;

            if (objetPourFiltreActions == null || objetPourFiltreActions.TypeAnalyse == null)
            {
                filtre = new CFiltreData(CProcessInDb.c_champTypeCible + "=@1", "");
            }
            else
            {
                filtre = new CFiltreData(CProcessInDb.c_champTypeCible + "=@1 or " +
                                         CProcessInDb.c_champTypeCible + "=@2 or " +
                                         CProcessInDb.c_champTypeCible + "=@3",
                                         "",
                                         objetPourFiltreActions.TypeAnalyse.ToString(),
                                         typeof(CObjetDonneeAIdNumerique).ToString());
            }

            m_selectionneurProcess.InitAvecFiltreDeBase <CProcessInDb>("Libelle", filtre, true);
            CProcessInDb process = new CProcessInDb(CSc2iWin32DataClient.ContexteCourant);
            CProcess     processPourParametres = null;

            if (process.ReadIfExists(((CActionSur2iLinkExecuterProcess)m_actionEditee).IdProcessInDb))
            {
                m_selectionneurProcess.ElementSelectionne = process;
                processPourParametres = process.Process;
            }


            if (objetPourFiltreActions != null && objetPourFiltreActions.TypeAnalyse != null)
            {
                m_panelEvenementManuel.Visible = true;
                CFiltreData filtreDeBase = new CFiltreData(
                    CEvenement.c_champTypeEvenement + "=@1 and " +
                    CEvenement.c_champTypeCible + "=@2",
                    (int)TypeEvenement.Manuel,
                    objetPourFiltreActions.TypeAnalyse.ToString());

                m_selectionneurEvenementManuel.InitAvecFiltreDeBase <CEvenement>(
                    "Libelle",
                    filtreDeBase, true);

                CEvenement evt = new CEvenement(CSc2iWin32DataClient.ContexteCourant);
                if (evt.ReadIfExists(((CActionSur2iLinkExecuterProcess)m_actionEditee).IdEvenement))
                {
                    m_selectionneurEvenementManuel.ElementSelectionne = evt;
                    processPourParametres = null;
                }
            }
            else
            {
                m_panelEvenementManuel.Visible = false;
                m_selectionneurEvenementManuel.ElementSelectionne = null;
            }
            m_chkHideProgress.Checked = ((CActionSur2iLinkExecuterProcess)m_actionEditee).MasquerProgressProcess;
            InitListeFormulesParametres(processPourParametres, m_actionEditee);
        }