Ejemplo n.º 1
0
        private void MenuContextuelCreerEtape_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //On prend la dernière étape du datagrid
                IOrderedEnumerable <CsRAffectationEtapeWorkflow> dtGridRAff = dtgrdParametre.ItemsSource as IOrderedEnumerable <CsRAffectationEtapeWorkflow>;
                CsRAffectationEtapeWorkflow lastStep = null;

                if (null != dtGridRAff)
                {
                    lastStep = dtGridRAff.LastOrDefault();
                }
                CsEtape beforeStep = null;
                if (null != lastStep)
                {
                    beforeStep = _ttsLesEtapes.Where(st => st.PK_ID == lastStep.FK_IDETAPE)
                                 .FirstOrDefault();
                }

                //Appel récursive de cette même fenêtre pour configurer le circuit de détournement
                //causé par la condition sur l'étape courante d'origine
                //Mais pour le moment, pas de condition à un deuxième niveau
                UcWKFSelectEtape uctl = new UcWKFSelectEtape(_ttsLesEtapes, beforeStep, StepAllReadyChoosed, dtgrdParametre, _workingTable,
                                                             _LesGroupesValidation, false);
                uctl.Closing += uctl_Closing;
                uctl.Show();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        void formC_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //On récupère la condition et on affiche la valeur
            CsConditionBranchement condition = ((UcWKFCondition)sender).LaCondition;

            TheCondition = condition;
            //On affiche dans le textbox
            if (null != TheCondition)
            {
                txtCondition.Text = condition.COLONNENAME + " " +
                                    condition.OPERATEUR + " " + condition.VALUE;
            }
            //En créant une condition, on crée un nouveau circuit, donc un nouveau RWORKFLOWCENTRE
            //c'est un détournement de circuit, avec pour origine l'étape actuelle
            _detournement = ((UcWKFCondition)sender).FirstEtapeDetournement;

            //donc lui déjà on l'ajoute dans le ObservableCollection SecondedonnesDatagrid
            if (null == SecondedonnesDatagrid)
            {
                SecondedonnesDatagrid = new ObservableCollection <CsRAffectationEtapeWorkflow>();
            }
            SecondedonnesDatagrid.Add(_detournement);

            dtgrdParametre.ItemsSource = SecondedonnesDatagrid.OrderBy(c => c.ORDRE);
        }
Ejemplo n.º 3
0
        public UcWKFSelectEtape(List <CsEtape> lsEtapes, CsEtape BeforeStep, List <CsEtape> EtapeDejaChoisie, DataGrid pdtGrid, CsTableDeTravail theWorkingTable, List <CsGroupeValidation> grpValidations,
                                KeyValuePair <CsRAffectationEtapeWorkflow, CsConditionBranchement> lEtapeEtCondition, SessionObject.ExecMode execMode,
                                CsRAffectationEtapeWorkflow detournementCircuit)
        {
            try
            {
                InitializeComponent();

                dataGrid = pdtGrid;
                if (dataGrid != null)
                {
                    donnesDatagrid = dataGrid.ItemsSource as ObservableCollection <CsRAffectationEtapeWorkflow>;
                }
                _ttsLesEtapes         = lsEtapes;
                _workingTable         = theWorkingTable;
                _LesGroupesValidation = grpValidations;
                _StepAndCondition     = lEtapeEtCondition;
                _EtapePrecedente      = BeforeStep;
                Step = _StepAndCondition;
                _lesEtapesANePasChoisir = EtapeDejaChoisie;
                _detournement           = detournementCircuit;
                _execMode = execMode;

                SetData();
                ShowDetailEtape();
            }
            catch (Exception ex)
            {
                Message.ShowError(ex.Message, "Configuration Etape");
            }
        }
 private void OKButton_Click(object sender, RoutedEventArgs e)
 {
     if (_execMode == SessionObject.ExecMode.Creation)
     {
         //Création de la condition
         if (!_conditionAction)
         {
             _theCondition = new CsConditionBranchement()
             {
                 PK_ID             = Guid.NewGuid(),
                 COLONNENAME       = _LesColonnes.ToList()[cmbColonne.SelectedIndex],
                 FK_IDETAPEVRAIE   = int.Parse(cmbEtapeConditionVrai.SelectedValue.ToString()),
                 FK_IDTABLETRAVAIL = (null != TableTravailConcernée) ? TableTravailConcernée.PK_ID : 0,
                 NOM = _LesColonnes.ToList()[cmbColonne.SelectedIndex] + " " + Operateurs.ToList()[cmbOperateur.SelectedIndex]
                       + " " + txtValeur.Text,
                 OPERATEUR                = Operateurs.ToList()[cmbOperateur.SelectedIndex],
                 VALUE                    = txtValeur.Text,
                 FK_IDETAPEFAUSE          = null,
                 PEUT_TRANSMETTRE_SI_FAUX = true,
             };
             _rAffDirectementBranchee = new CsRAffectationEtapeWorkflow()
             {
                 PK_ID                  = Guid.NewGuid(),
                 FK_IDETAPE             = _theCondition.FK_IDETAPEVRAIE.Value,
                 FK_IDGROUPEVALIDATIOIN = Guid.Empty,
                 ORDRE                  = 1,
                 FROMCONDITION          = true,
                 CONDITION              = _theCondition.NOM,
                 LIBELLEETAPE           = _lsEtapes.Where(et => et.PK_ID == _theCondition.FK_IDETAPEVRAIE).First()
                                          .NOM
             };
         }
         else
         {
             _theCondition = new CsConditionBranchement()
             {
                 PK_ID             = Guid.NewGuid(),
                 COLONNENAME       = _LesColonnes.ToList()[cmbColonne.SelectedIndex],
                 FK_IDTABLETRAVAIL = (null != TableTravailConcernée) ? TableTravailConcernée.PK_ID : 0,
                 NOM = _LesColonnes.ToList()[cmbColonne.SelectedIndex] + " " + Operateurs.ToList()[cmbOperateur.SelectedIndex]
                       + " " + txtValeur.Text,
                 OPERATEUR                = Operateurs.ToList()[cmbOperateur.SelectedIndex],
                 VALUE                    = txtValeur.Text,
                 FK_IDETAPEFAUSE          = null,
                 PEUT_TRANSMETTRE_SI_FAUX = false
             };
         }
         this.DialogResult = true;
     }
     else if (_execMode == SessionObject.ExecMode.Modification)
     {
     }
 }
Ejemplo n.º 5
0
        private void Modifier_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dtgrdParametre.SelectedItem != null)
                {
                    //Appel récursif de la même fenêtre
                    var objetselectionne = (CsRAffectationEtapeWorkflow)dtgrdParametre.SelectedItem;
                    if (null != objetselectionne)
                    {
                        IOrderedEnumerable <CsRAffectationEtapeWorkflow> dtGridRAff = dtgrdParametre.ItemsSource as IOrderedEnumerable <CsRAffectationEtapeWorkflow>;
                        CsRAffectationEtapeWorkflow lastStep = null;

                        if (null != dtGridRAff)
                        {
                            lastStep = dtGridRAff.Where(aff => aff.ORDRE < objetselectionne.ORDRE)
                                       .OrderBy(a => a.ORDRE)
                                       .LastOrDefault();
                        }
                        CsEtape beforeStep = null;
                        if (null != lastStep)
                        {
                            beforeStep = _ttsLesEtapes.Where(st => st.PK_ID == lastStep.FK_IDETAPE)
                                         .FirstOrDefault();
                        }
                        List <CsEtape> IlFautQuandMemeAjouterLaMemeEtapePourQuellePuisseEtreSelecionneeDansLaFenetreDeConfiguration = new List <CsEtape>();
                        StepAllReadyChoosed.ForEach((CsEtape etap) =>
                        {
                            if (etap.PK_ID != objetselectionne.FK_IDETAPE)
                            {
                                IlFautQuandMemeAjouterLaMemeEtapePourQuellePuisseEtreSelecionneeDansLaFenetreDeConfiguration.Add(etap);
                            }
                        });

                        KeyValuePair <CsRAffectationEtapeWorkflow, CsConditionBranchement> leAffChoosed = new KeyValuePair <CsRAffectationEtapeWorkflow, CsConditionBranchement>(
                            objetselectionne, _RelationAffectationEtapeCondition[objetselectionne.PK_ID]);

                        //pour le moment, pas de condition à un deuxième niveau
                        UcWKFSelectEtape form = new UcWKFSelectEtape(_ttsLesEtapes, beforeStep, IlFautQuandMemeAjouterLaMemeEtapePourQuellePuisseEtreSelecionneeDansLaFenetreDeConfiguration,
                                                                     dtgrdParametre, _workingTable, _LesGroupesValidation,
                                                                     leAffChoosed, SessionObject.ExecMode.Modification, false);

                        form.Closing += uctl_Closing;
                        form.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                Message.Show(ex.Message, Languages.FenetreOperation);
            }
        }
        public UcWKFCondition(CsEtape _theStep, List <CsEtape> lsStep, CsTableDeTravail _table, List <CsGroupeValidation> grpValidation,
                              CsConditionBranchement lCondition, SessionObject.ExecMode execMode, CsRAffectationEtapeWorkflow DirectEtapeBranchement)
        {
            try
            {
                InitializeComponent();
                _lsEtapes                = lsStep;
                TableTravailConcernée    = _table;
                OrigineEtape             = _theStep;
                GroupeValidation         = grpValidation;
                _theCondition            = lCondition;
                _rAffDirectementBranchee = DirectEtapeBranchement;
                _execMode                = execMode;

                SetData();
                ShowDetail();
            }
            catch (Exception ex)
            {
                Message.ShowError(ex.Message, "Définition Condition Etape");
            }
        }
Ejemplo n.º 7
0
        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override bool Execute(CodeActivityContext context)
        {
            bool _result = true;

            try
            {
                //On obtient les valeurs des paramètres
                string pk_IDLine           = context.GetValue <string>(this.PKIDLine);
                int    cId                 = context.GetValue <int>(this.CentreId);
                Guid   _wkfId              = context.GetValue <Guid>(this.WKFId);
                Guid   _opId               = context.GetValue <Guid>(this.OpId);
                string _matUser            = context.GetValue <string>(this.MatriculeUser);
                string _codeDemandeTravail = context.GetValue <string>(this.CodeDemandeTravail);

                //On recherche les infos sur le circuit
                CsRWorkflow rWKFCentre = null;
                rWKFCentre = new DB_WORKFLOW().SelectAllRWorkflowCentre(_wkfId, cId, _opId)
                             .FirstOrDefault();
                if (null != rWKFCentre)
                {
                    //Récupération des infos
                    CsCentre   centre   = new DB_Centre().SelectAllCentre().Where(c => c.PK_ID == cId).FirstOrDefault();
                    CsWorkflow workflow = new DB_WORKFLOW().SelectAllWorkflows().Where(w => w.PK_ID == _wkfId)
                                          .FirstOrDefault();
                    CsOperation operation = new DB_WORKFLOW().SelectAllOperation2().Where(o => o.PK_ID == _opId)
                                            .FirstOrDefault();

                    //Récupération du circuit
                    Dictionary <CsRAffectationEtapeWorkflow, CsConditionBranchement> lsRAffCircuit = new Dictionary <CsRAffectationEtapeWorkflow, CsConditionBranchement>();
                    lsRAffCircuit = new DB_WORKFLOW().SelectAllAffectationEtapeWorkflow(rWKFCentre.PK_ID);

                    List <CsRAffectationEtapeWorkflow> leCircuitNormal = lsRAffCircuit.Keys.Where(aff => !aff.FK_IDRETAPEWORKFLOWORIGINE.HasValue ||
                                                                                                  aff.FK_IDRETAPEWORKFLOWORIGINE.Value == Guid.Empty)
                                                                         .OrderBy(aff => aff.ORDRE)
                                                                         .ToList();

                    CsRAffectationEtapeWorkflow _1sStep  = leCircuitNormal.FirstOrDefault();
                    CsRAffectationEtapeWorkflow _2ndStep = leCircuitNormal.Where(step => step.ORDRE == _1sStep.ORDRE + 1)
                                                           .FirstOrDefault();

                    //Création de la demande
                    CsDemandeWorkflow dmd = new CsDemandeWorkflow()
                    {
                        PK_ID                  = Guid.NewGuid(),
                        DATECREATION           = DateTime.Today.Date,
                        MATRICULEUSERCREATION  = _matUser,
                        ALLCENTRE              = false,
                        FK_IDCENTRE            = cId,
                        FK_IDOPERATION         = _opId,
                        FK_IDRWORKLOW          = rWKFCentre.PK_ID,
                        FK_IDSTATUS            = (int)STATUSDEMANDE.Initiee,
                        FK_IDWORKFLOW          = _wkfId,
                        FK_IDLIGNETABLETRAVAIL = pk_IDLine,
                        FK_IDETAPEPRECEDENTE   = 0,
                        FK_IDETAPEACTUELLE     = _1sStep.FK_IDETAPE,
                        FK_IDETAPESUIVANTE     = _2ndStep.FK_IDETAPE,
                        CODE = centre.CODESITE + centre.CODE + DateTime.Today.Year + DateTime.Today.Month +
                               DateTime.Now.Minute +
                               DateTime.Now.Millisecond,
                        FK_IDTABLETRAVAIL         = workflow.FK_IDTABLE_TRAVAIL.Value,
                        CODE_DEMANDE_TABLETRAVAIL = _codeDemandeTravail,
                        DATEDERNIEREMODIFICATION  = DateTime.Today.Date
                    };


                    _result = new DB_WORKFLOW().InsertDemande(new List <CsDemandeWorkflow>()
                    {
                        dmd
                    });

                    if (_result) /* tout es bon */
                    {
                        CodeDemande.Set(context, dmd.CODE);
                        PKIDDemande.Set(context, dmd.PK_ID);
                        PKRWKF.Set(context, dmd.FK_IDRWORKLOW);

                        //On récupère les emails pour notifier les utilisateurs de l'arrivée de la demande
                        KeyValuePair <CsGroupeValidation, List <CsRHabilitationGrouveValidation> > grpValidation = new DB_WORKFLOW().SelectAllGroupeValidation()
                                                                                                                   .Where(g => g.Key.PK_ID == _1sStep.FK_IDGROUPEVALIDATIOIN)
                                                                                                                   .FirstOrDefault();

                        if (null != grpValidation.Key)
                        {
                            if (string.Empty != grpValidation.Key.EMAILDIFFUSION)
                            {
                                Emails.Set(context, grpValidation.Key.EMAILDIFFUSION + ";");
                            }
                            else
                            {
                                string _email = string.Empty;
                                foreach (var habilUser in grpValidation.Value)
                                {
                                    _email += habilUser.EMAIL + ";";
                                }

                                Emails.Set(context, _email);
                            }
                        }
                    }
                }
                else
                {
                    _result = false;
                    CodeDemande.Set(context, "Aucun circuit n'a été configuré pour cette opération et ce centre");
                    PKIDDemande.Set(context, Guid.Empty);
                    PKRWKF.Set(context, Guid.Empty);
                }
            }
            catch (Exception ex)
            {
                _result = false;
                CodeDemande.Set(context, ex.Message);
            }


            return(_result);
        }
Ejemplo n.º 8
0
        void uctl_Closing(object sender, CancelEventArgs e)
        {
            //On récupère l'etape créée
            KeyValuePair <CsRAffectationEtapeWorkflow, CsConditionBranchement> RAffAndCondition = ((UcWKFSelectEtape)sender)
                                                                                                  .Step;

            if (null != RAffAndCondition.Key)
            {
                //On teste d'abord l'existance
                if (null != SecondedonnesDatagrid.Where(c => c.PK_ID == RAffAndCondition.Key.PK_ID).FirstOrDefault() &&
                    _RelationAffectationEtapeCondition.Keys.Contains(RAffAndCondition.Key.PK_ID))
                {
                    //C'est la modification
                    CsRAffectationEtapeWorkflow lAncienAff = SecondedonnesDatagrid.Where(c => c.PK_ID == RAffAndCondition.Key.PK_ID).First();
                    SecondedonnesDatagrid.Remove(lAncienAff);
                    //On remet l'ordre de l'ancien
                    RAffAndCondition.Key.ORDRE = lAncienAff.ORDRE;
                    SecondedonnesDatagrid.Add(RAffAndCondition.Key);

                    //On supprime l'étape qui avait été choisi
                    var toDelete = _ttsLesEtapes.Where(et => et.PK_ID == lAncienAff.FK_IDETAPE).FirstOrDefault();
                    var toAdd    = _ttsLesEtapes.Where(et => et.PK_ID == RAffAndCondition.Key.FK_IDETAPE).FirstOrDefault();
                    StepAllReadyChoosed.Remove(toDelete);
                    //On ajoute l'étape qui vient d'être choisi, si bien sûr elle n'existe pas déjà
                    if (!StepAllReadyChoosed.Contains(toAdd))
                    {
                        StepAllReadyChoosed.Add(toAdd);
                    }

                    //On les supprime pour vider la mémoire
                    GC.SuppressFinalize(toDelete);
                    GC.SuppressFinalize(toAdd);

                    RAffAndCondition.Key.CONDITION = (null != RAffAndCondition.Value) ? RAffAndCondition.Value.NOM
                        : string.Empty;

                    if (_RelationAffectationEtapeCondition.Keys.Contains(RAffAndCondition.Key.PK_ID))
                    {
                        _RelationAffectationEtapeCondition[RAffAndCondition.Key.PK_ID] = RAffAndCondition.Value;
                    }
                    else
                    {
                        _RelationAffectationEtapeCondition.Add(RAffAndCondition.Key.PK_ID, RAffAndCondition.Value);
                    }
                }
                //C'est l'insertion
                else if (null == SecondedonnesDatagrid.Where(c => c.PK_ID == RAffAndCondition.Key.PK_ID).FirstOrDefault() &&
                         !_RelationAffectationEtapeCondition.Keys.Contains(RAffAndCondition.Key.PK_ID))
                {
                    RAffAndCondition.Key.ORDRE = SecondedonnesDatagrid.Count + 1;
                    SecondedonnesDatagrid.Add(RAffAndCondition.Key);
                    //On ajoute l'étape qui a été choisi
                    StepAllReadyChoosed.Add(_ttsLesEtapes.Where(et => et.PK_ID == RAffAndCondition.Key.FK_IDETAPE).FirstOrDefault());
                    //On ajoute la condition
                    RAffAndCondition.Key.CONDITION = (null != RAffAndCondition.Value) ? RAffAndCondition.Value.NOM
                        : string.Empty;

                    _RelationAffectationEtapeCondition.Add(RAffAndCondition.Key.PK_ID, RAffAndCondition.Value);
                }
            }

            if (UseCondition)
            {
                dtgrdParametre.ItemsSource = SecondedonnesDatagrid.OrderBy(aff => aff.ORDRE);
            }
        }
Ejemplo n.º 9
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            //On crée laffectation
            if (null != cmbEtape.SelectedValue && null != cmbGroupeValidation.SelectedValue)
            {
                if (!VerifierChampDelai())
                {
                    Message.ShowError(new Exception("Veuillez donner une durée d'exécution de l'étape"), "Affectation Etape");
                    return;
                }

                int     PKIDStep = int.Parse(cmbEtape.SelectedValue.ToString());
                CsEtape LEtapeOh = _ttsLesEtapes.Where(et => et.PK_ID == PKIDStep)
                                   .FirstOrDefault();

                Guid GrpPKID = Guid.Parse(cmbGroupeValidation.SelectedValue.ToString());

                if (null != LEtapeOh && Guid.Empty != GrpPKID)
                {
                    if (null == Step.Key)
                    {
                        CsRAffectationEtapeWorkflow affEtape = new CsRAffectationEtapeWorkflow()
                        {
                            PK_ID                  = Guid.NewGuid(),
                            CODEETAPE              = LEtapeOh.CODE,
                            FK_IDETAPE             = PKIDStep,
                            FK_IDGROUPEVALIDATIOIN = GrpPKID,
                            LIBELLEETAPE           = LEtapeOh.NOM,
                            GROUPEVALIDATION       = _LesGroupesValidation.Where(g => g.PK_ID == GrpPKID).FirstOrDefault().GROUPENAME,
                            DUREE                  = int.Parse(txtDelai.Text)
                        };
                        if (null != TheCondition)
                        {
                            affEtape.CONDITION = TheCondition.NOM;
                            TheCondition.FK_IDRAFFECTATIONWKF = affEtape.PK_ID;
                        }

                        Step = new KeyValuePair <CsRAffectationEtapeWorkflow, CsConditionBranchement>(affEtape, TheCondition);
                    }
                    else
                    {
                        CsRAffectationEtapeWorkflow affEtape = new CsRAffectationEtapeWorkflow()
                        {
                            PK_ID                  = Step.Key.PK_ID,
                            CODEETAPE              = LEtapeOh.CODE,
                            FK_IDETAPE             = PKIDStep,
                            FK_IDGROUPEVALIDATIOIN = GrpPKID,
                            LIBELLEETAPE           = LEtapeOh.NOM,
                            ORDRE                  = Step.Key.ORDRE,
                            DUREE                  = int.Parse(txtDelai.Text)
                        };
                        if (null != TheCondition)
                        {
                            affEtape.CONDITION = TheCondition.NOM;
                            TheCondition.FK_IDRAFFECTATIONWKF = affEtape.PK_ID;
                        }

                        Step = new KeyValuePair <CsRAffectationEtapeWorkflow, CsConditionBranchement>(affEtape, TheCondition);
                    }

                    //On va maintenant récupérer les étapes du circuits de détournement
                    LeCircuitDetourne = new List <CsRAffectationEtapeWorkflow>();
                    if (null != SecondedonnesDatagrid)
                    {
                        foreach (CsRAffectationEtapeWorkflow aff in SecondedonnesDatagrid)
                        {
                            aff.FK_IDRETAPEWORKFLOWORIGINE = Step.Key.PK_ID;
                            LeCircuitDetourne.Add(aff);
                        }
                    }
                    this.DialogResult = true;
                }
                else
                {
                    this.DialogResult = false;
                }
            }
            else
            {
                Message.ShowError(new Exception("Veuillez sélectionner une étape et un groupe de validation"),
                                  "Affectation Etape");
            }
        }