예제 #1
0
 //-------------------------------------------------------------------
 private void m_btnExecuter_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
 {
     if (m_panelListe.ElementSelectionne != null)
     {
         CProcessInDb process = (CProcessInDb)m_panelListe.ElementSelectionne;
         if (CFormAlerte.Afficher(I.T("Execute Action '@1' ?|990", process.Libelle),
                                  EFormAlerteType.Question) == DialogResult.Yes)
         {
             CResultAErreur result = CFormExecuteProcess.StartProcess(
                 process.Process,
                 null,
                 process.ContexteDonnee.IdSession,
                 process.ContexteDonnee.IdVersionDeTravail,
                 false
                 );
             if (!result)
             {
                 CFormAlerte.Afficher(result.Erreur);
             }
             else
             {
                 CFormAlerte.Afficher(I.T("Execution complete|991"));
             }
         }
     }
 }
예제 #2
0
        /// //////////////////////////////////////////////////////////////////
        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);
        }