/// <summary> /// Démarre une action /// </summary> /// <param name="process"></param> /// <param name="nIdSession"></param> /// <returns></returns> public static CResultAErreur RunEvent(IDeclencheurAction declencheur, CObjetDonneeAIdNumerique objetCible, bool bHideProgress) { CFormExecuteProcess form = new CFormExecuteProcess(); form.Top = 0; form.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - form.Width / 2; if (declencheur is IDeclencheurActionManuelle) { bHideProgress |= ((IDeclencheurActionManuelle)declencheur).HideProgress; } if (bHideProgress) { CInfoDeclencheurProcess infoDeclencheur = new CInfoDeclencheurProcess(TypeEvenement.Manuel); CAppelleurFonctionAsynchrone appeleur = new CAppelleurFonctionAsynchrone(); CResultAErreur resultDefault = CResultAErreur.True; resultDefault.EmpileErreur(I.T("Asynchronous call error @1|20149", "RunEvent")); return(appeleur.StartFonctionAndWaitAvecCallback(declencheur.GetType(), declencheur, "RunEvent", "", resultDefault, objetCible, infoDeclencheur, null) as CResultAErreur); //return declencheur.RunEvent(objetCible, infoDeclencheur, null); } else { IAsyncResult res = form.m_runEvent.BeginInvoke(declencheur, objetCible, new AsyncCallback(form.OnEndProcess), null); form.ShowDialog(); //Bloque le code ici ! CResultAErreur result = form.m_runEvent.EndInvoke(res); return(result); } }
/// <summary> /// Démarre une action /// </summary> /// <param name="process"></param> /// <param name="nIdSession"></param> /// <returns></returns> public static CResultAErreur StartProcess(CProcess process, CReferenceObjetDonnee refCible, int nIdSession, int?nIdVersion, bool bHideProgress) { CFormExecuteProcess form = new CFormExecuteProcess(); form.Top = 0; form.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - form.Width / 2; if (bHideProgress) { return(CProcessEnExecutionInDb.StartProcess( process, new CInfoDeclencheurProcess(TypeEvenement.Manuel), refCible, nIdSession, nIdVersion, null)); } else { IAsyncResult res = form.m_startProcess.BeginInvoke(process, refCible, nIdSession, nIdVersion, new AsyncCallback(form.OnEndProcess), null); form.ShowDialog(); //Bloque le code ici ! CResultAErreur result = form.m_startProcess.EndInvoke(res); return(result); } }
//------------------------------------------------------------------- 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")); } } } }
/// ///////////////////////////////////////////////////////////////////////// /// <summary> /// Relance une action /// </summary> /// <param name="processEnExec"></param> /// <param name="nIdAction"></param> /// <returns></returns> public static CResultAErreur RepriseAction(CProcessEnExecutionInDb processEnExec, int nIdAction) { CFormExecuteProcess form = new CFormExecuteProcess(); form.Top = 0; form.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - form.Width / 2; IAsyncResult res = form.m_repriseAction.BeginInvoke(processEnExec, nIdAction, new AsyncCallback(form.OnEndProcess), null); form.ShowDialog(); //Bloque le code ici ! CResultAErreur result = form.m_repriseAction.EndInvoke(res); return(result); }
//------------------------------------------------------------------------- private void MenuDeclencheurClick(object sender, EventArgs e) { if (sender is CMenuItemDeclencheur) { IDeclencheurAction declencheur = ((CMenuItemDeclencheur)sender).Declencheur; /*CInfoDeclencheurProcess infoDeclencheur = new CInfoDeclencheurProcess(TypeEvenement.Manuel); * CResultAErreur result = declencheur.RunEventMultiple ( * (CObjetDonneeAIdNumeriqueAuto[])m_panelListe.GetElementsCheckes().ToArray(typeof(CObjetDonneeAIdNumeriqueAuto)), * infoDeclencheur );*/ CResultAErreur result = CFormExecuteProcess.RunEventMultiple( declencheur, (CObjetDonneeAIdNumerique[])m_panelListe.GetElementsCheckes().ToArray(typeof(CObjetDonneeAIdNumerique)), false); m_panelListe.Refresh(); if (!result) { CFormAlerte.Afficher(result.Erreur); } } }
/// <summary> /// Démarre une action /// </summary> /// <param name="process"></param> /// <param name="nIdSession"></param> /// <returns></returns> public static CResultAErreur RunEventMultiple(IDeclencheurAction declencheur, CObjetDonneeAIdNumerique[] objetsCibles, bool bHideProgress) { CFormExecuteProcess form = new CFormExecuteProcess(); form.Top = 0; form.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - form.Width / 2; if (declencheur is IDeclencheurActionManuelle) { bHideProgress |= ((IDeclencheurActionManuelle)declencheur).HideProgress; } if (bHideProgress) { CInfoDeclencheurProcess infoDeclencheur = new CInfoDeclencheurProcess(TypeEvenement.Manuel); return(declencheur.RunEventMultiple(objetsCibles, infoDeclencheur, null)); } else { IAsyncResult res = form.m_runEventMultiples.BeginInvoke(declencheur, objetsCibles, new AsyncCallback(form.OnEndProcess), null); form.ShowDialog(); //Bloque le code ici ! CResultAErreur result = form.m_runEventMultiples.EndInvoke(res); return(result); } }
/// ////////////////////////////////////////////////////////////////// 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); }