Exemplo n.º 1
0
 private void StartWorkflow(CTypeEtapeWorkflow typeEtape)
 {
     if (MessageBox.Show(I.T("Start workflow \"@1\"|20571", Workflow.Libelle), "",
                         MessageBoxButtons.YesNo,
                         MessageBoxIcon.Question) == DialogResult.Yes)
     {
         using (CContexteDonnee ctx = new CContexteDonnee(Workflow.ContexteDonnee.IdSession, true, false))
         {
             CWorkflow workflow = Workflow.GetObjetInContexte(ctx) as CWorkflow;
             if (typeEtape != null)
             {
                 typeEtape = typeEtape.GetObjetInContexte(ctx) as CTypeEtapeWorkflow;
             }
             CResultAErreur result = workflow.DémarreWorkflow(typeEtape, true);
             if (!result)
             {
                 CFormAlerte.Afficher(result.Erreur);
             }
             else
             {
                 InitChamps();
             }
         }
     }
 }
Exemplo n.º 2
0
        //---------------------------------------------------
        public override CResultAErreur RunAndSaveIfOk(CEtapeWorkflow etape)
        {
            CResultAErreur result = CResultAErreur.True;

            if (DbKeyTypeWorkflow == null)
            {
                return(EndAndSaveIfOk(etape));
            }
            CTypeEtapeWorkflow typeEtapeDémarrage = null;

            if (m_dbKeyTypeEtapeDemarrage != null)
            {
                typeEtapeDémarrage = new CTypeEtapeWorkflow(etape.ContexteDonnee);
                if (!typeEtapeDémarrage.ReadIfExists(m_dbKeyTypeEtapeDemarrage))
                {
                    typeEtapeDémarrage = null;
                }
            }
            CWorkflow workflow = GetOrCreateWorkflowInCurrentContexte(etape);

            if (workflow != null && !workflow.IsRunning)
            {
                result = PrepareToStartWorkflow(etape);
                if (workflow.TypeWorkflow.Etapes.Count == 0)
                {
                    return(EndAndSaveIfOk(etape));
                }
                result = workflow.DémarreWorkflow(typeEtapeDémarrage, false);
            }
            return(etape.ContexteDonnee.SaveAll(true));
        }