//--------------------------------------------------- public CWorkflow GetOrCreateWorkflowInCurrentContexte(CEtapeWorkflow etape) { CResultAErreur result = CResultAErreur.True; if (DbKeyTypeWorkflow == null) { return(null); } //Lance le démarrage du workflow if (etape.WorkflowLancé != null) { if (etape.WorkflowLancé.IdEtapeAppelante != etape.Id) { etape.WorkflowLancé.EtapeAppelante = etape;//Pour pallier aux soucis d'id négatifs stockés parfois } return(etape.WorkflowLancé); } else { CTypeWorkflow typeWorkflow = new CTypeWorkflow(etape.ContexteDonnee); if (typeWorkflow.ReadIfExists(DbKeyTypeWorkflow)) { CWorkflow workflow = new CWorkflow(etape.ContexteDonnee); workflow.CreateNewInCurrentContexte(); workflow.TypeWorkflow = typeWorkflow; workflow.Libelle = etape.Libelle; workflow.EtapeAppelante = etape; etape.WorkflowLancé = workflow; return(workflow); } } return(null); }
//------------------------------------------------------- private void InitChamps() { if (m_blocWorkflow == null) { return; } m_txtSelectWorkflow.Init(typeof(CTypeWorkflow), "Libelle", false); if (m_blocWorkflow.DbKeyTypeWorkflow != null) { CTypeWorkflow wkf = new CTypeWorkflow(CSc2iWin32DataClient.ContexteCourant); if (wkf.ReadIfExists(m_blocWorkflow.DbKeyTypeWorkflow)) { m_txtSelectWorkflow.ElementSelectionne = wkf; } } m_txtSelectTypeProjet.Init(typeof(CTypeProjet), "Libelle", false); if (m_blocWorkflow.DbKeyTypeProjet != null) { CTypeProjet typeProjet = new CTypeProjet(CSc2iWin32DataClient.ContexteCourant); if (typeProjet.ReadIfExists(m_blocWorkflow.DbKeyTypeProjet)) { m_txtSelectTypeProjet.ElementSelectionne = typeProjet; } } m_cmbProjectField.Init(typeof(CChampCustom), CFiltreData.GetAndFiltre(CChampCustom.GetFiltreChampsForRole(CWorkflow.c_roleChampCustom), new CFiltreData( CChampCustom.c_champTypeObjetDonnee + "=@1", typeof(CProjet).ToString())), "Nom", false); if (m_blocWorkflow.IdChampProjet != null) { CChampCustom champ = new CChampCustom(CSc2iWin32DataClient.ContexteCourant); if (champ.ReadIfExists(m_blocWorkflow.IdChampProjet.Value)) { m_cmbProjectField.ElementSelectionne = champ; } } m_listeAffectations.Clear(); m_listeAffectations.AddRange(m_blocWorkflow.AffectationsCreationEtDemarrage); m_txtFormuleGanttId.Init(new CFournisseurPropDynStd(), typeof(CEtapeWorkflow)); m_txtFormuleGanttId.Formule = m_blocWorkflow.FormuleGanttId; m_chkGererIterations.Checked = m_blocWorkflow.GererIteration; }
//------------------------------------------------------- private void InitChamps() { m_txtSelectWorkflow.InitAvecFiltreDeBase(typeof(CTypeWorkflow), "Libelle", null, false); if (m_blocWorkflow.DbKeyTypeWorkflow != null) { CTypeWorkflow wkf = new CTypeWorkflow(CSc2iWin32DataClient.ContexteCourant); if (wkf.ReadIfExists(m_blocWorkflow.DbKeyTypeWorkflow)) { m_txtSelectWorkflow.ElementSelectionne = wkf; } } m_keyLastIdTypeEtapeSel = m_blocWorkflow.DbKeyTypeEtapeDémarrage; m_txtWorkflowInit.Init(new CFournisseurGeneriqueProprietesDynamiques(), typeof(CEtapeWorkflow)); m_txtWorkflowInit.Formule = m_blocWorkflow.FormuleInitialisationWorkflowLance; InitComboStartStep(); }
//------------------------------------------------------------------- public void InitFromContexte(CContexteFormNavigable ctx) { int?nIdActeur = ctx["FILTRE_ACTEUR"] as int?; if (nIdActeur != null) { CActeur acteur = new CActeur(CSc2iWin32DataClient.ContexteCourant); if (acteur.ReadIfExists(nIdActeur.Value)) { m_txtActeur.ElementSelectionne = acteur; } } else { m_txtActeur.ElementSelectionne = null; } CEtatEtapeWorkflow etat = ctx["FILTRE_ETAT"] as CEtatEtapeWorkflow; if (etat != null) { m_cmbEtats.SelectedValue = etat; } else { m_cmbEtats.SelectedValue = null; } int?nIdType = ctx["FILTRE_TYPE_WKF"] as int?; if (nIdType != null) { CTypeWorkflow type = new CTypeWorkflow(CSc2iWin32DataClient.ContexteCourant); if (type.ReadIfExists(nIdType.Value)) { m_txtTypeWorkflow.ElementSelectionne = type; } } else { m_txtTypeWorkflow.ElementSelectionne = null; } m_txtLabel.Text = ctx["FILTRE_LABEL"] as string; }
//------------------------------------------------------------------ private void m_panelWorkflow_DoubleClicSurElement(object sender, EventArgs e) { if (!LockEdition) { EditeCurrentEtape(); } else { CWorkflowEtapeDessin etape = m_panelWorkflow.EtapeSelectionnee; if (etape == null) { return; } CBlocWorkflow bloc = etape.TypeEtape != null ? etape.TypeEtape.Bloc : null; CBlocWorkflowWorkflow blocWorkflow = bloc as CBlocWorkflowWorkflow; if (blocWorkflow != null && blocWorkflow.DbKeyTypeWorkflow != null) { CTypeWorkflow typeWorkflow = new CTypeWorkflow(CSc2iWin32DataClient.ContexteCourant); if (typeWorkflow.ReadIfExists(blocWorkflow.DbKeyTypeWorkflow)) { CFormNavigateur navigateur = CFormNavigateur.FindNavigateur(this); if (navigateur != null) { CReferenceTypeForm refFrm = CFormFinder.GetRefFormToEdit(typeof(CTypeWorkflow)); if (refFrm != null) { CFormEditionStandard frm = refFrm.GetForm(typeWorkflow) as CFormEditionStandard; if (frm != null) { navigateur.AffichePage(frm); } } } } } } }
//------------------------------------------------------------------- private void m_menuEditWorkflow_Click(object sender, EventArgs e) { CWorkflowEtapeDessin etape = EtapeSelectionnee; if (etape == null) { return; } CBlocWorkflowWorkflow blocwkf = etape != null && etape.TypeEtape != null ? etape.TypeEtape.Bloc as CBlocWorkflowWorkflow : null; if (blocwkf != null) { CReferenceTypeForm refFrm = CFormFinder.GetRefFormToEdit(typeof(CTypeWorkflow)); if (refFrm != null) { CTypeWorkflow typeWorkflow = null; if (blocwkf.DbKeyTypeWorkflow == null) { if (!LockEdition) { typeWorkflow = new CTypeWorkflow(CSc2iWin32DataClient.ContexteCourant); typeWorkflow.CreateNew(); typeWorkflow.Libelle = blocwkf.TypeEtape.Libelle; } } else { typeWorkflow = new CTypeWorkflow(CSc2iWin32DataClient.ContexteCourant); if (!typeWorkflow.ReadIfExists(blocwkf.DbKeyTypeWorkflow)) { typeWorkflow = null; } } if (typeWorkflow != null) { CFormNavigateur navigateur = null; if (LockEdition) { Form frm = FindForm(); if (frm != null) { Control ctrl = frm.Parent; while (ctrl != null && ctrl.Parent != null && !(ctrl is CFormNavigateur)) { ctrl = ctrl.Parent; } if (typeof(CFormNavigateur).IsAssignableFrom(ctrl.GetType())) { navigateur = (CFormNavigateur)ctrl; } } } CFormEditionStandard frmEdition = refFrm.GetForm(typeWorkflow) as CFormEditionStandard; if (navigateur == null && frmEdition != null) { CFormNavigateurPopup.Show(frmEdition); if (!LockEdition && typeWorkflow.IsValide() && typeWorkflow.Id >= 0) { blocwkf.DbKeyTypeWorkflow = typeWorkflow.DbKey; etape.TypeEtape.Bloc = blocwkf; } } else { navigateur.AffichePage(frmEdition); } } } } }
/// //////////////////////////////////////////////////////////////////// public CResultAErreur SerializeFiltre(C2iSerializer serializer) { int nVersion = GetNumVersion(); CResultAErreur result = serializer.TraiteVersion(ref nVersion); if (!result) { return(result); } if (serializer.Mode == ModeSerialisation.Lecture) { InitCombos(); } CActeur acteur = m_txtActeur.ElementSelectionne as CActeur; int? nIdActeur = acteur != null ? (int?)acteur.Id : null; serializer.TraiteIntNullable(ref nIdActeur); if (nIdActeur != null && serializer.Mode == ModeSerialisation.Lecture) { acteur = new CActeur(CSc2iWin32DataClient.ContexteCourant); if (acteur.ReadIfExists(nIdActeur.Value)) { m_txtActeur.ElementSelectionne = acteur; } } CEtatEtapeWorkflow etat = m_cmbEtats.SelectedValue as CEtatEtapeWorkflow; int?nEtat = etat != null?(int?)etat.CodeInt:null; serializer.TraiteIntNullable(ref nEtat); if (serializer.Mode == ModeSerialisation.Lecture && nEtat != null) { etat = new CEtatEtapeWorkflow((EEtatEtapeWorkflow)nEtat.Value); m_cmbEtats.SelectedValue = etat; } CTypeWorkflow type = m_txtTypeWorkflow.ElementSelectionne as CTypeWorkflow; int? nIdType = type != null ? (int?)type.Id : null; serializer.TraiteIntNullable(ref nIdType); if (nIdType != null && serializer.Mode == ModeSerialisation.Lecture) { type = new CTypeWorkflow(CSc2iWin32DataClient.ContexteCourant); if (type.ReadIfExists(nIdType.Value)) { m_txtTypeWorkflow.ElementSelectionne = type; } } string strText = m_txtLabel.Text; serializer.TraiteString(ref strText); if (serializer.Mode == ModeSerialisation.Lecture) { m_txtLabel.Text = strText; } return(result); }