/// <summary>
        /// Ajoute une action en base, indépendamment d'un workflow.
        /// </summary>
        /// <param name="action">Nouvelle action</param>
        /// <returns>Message de retour</returns>
        public async Task <ENT.Action> AddAction(ENT.Action action)
        {
            if (action == null)
            {
                throw new WrongParameterException("ActionSequenceDomain.AddAction : Action is null.");
            }
            int cnt = await UnitOfWork.GetDbContext().Action
                      .Where(a => a.Name == action.Name)
                      .CountAsync();

            if (cnt > 0)
            {
                throw new WrongParameterException($"ActionSequenceDomain.AddAction : Action ({action.Name}) is already existing.");
            }

            UnitOfWork.ActionRepository.PrepareAddForObject(action);

            int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync();

            if (nbr <= 0)
            {
                throw new DatabaseException("ActionSequenceDomain.AddAction : Impossible to save new Action.");
            }

            return(action);
        }
        /// <summary>
        /// Ajoute une nouvelle action dans une séquence (existante ou non)
        /// </summary>
        /// <param name="actionSequence">Nouvelle ActionSequence</param>
        /// <param name="actionId">Id de l'Action à exécuter</param>
        /// <returns>Message de retour</returns>
        public async Task <ActionSequence> AddActionSequence(ActionSequence actionSequence, long actionId)
        {
            if (actionSequence == null)
            {
                throw new WrongParameterException("ActionSequenceDomain.AddAction : ActionSequence is null.");
            }
            ENT.Action action = await UnitOfWork.GetDbContext().Action
                                .Where(a => a.Id == actionId)
                                .FirstOrDefaultAsync();

            if (action == null)
            {
                throw new WrongParameterException($"ActionSequenceDomain.AddAction : Unknown Action with id = {actionId}.");
            }

            UnitOfWork.ActionSequenceRepository.PrepareAddForObject(actionSequence);
            actionSequence.Action = action;
            int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync();

            if (nbr <= 0)
            {
                throw new DatabaseException("ActionSequenceDomain.AddAction : impossible to save ActionSequence.");
            }

            return(actionSequence);
        }
        /// <summary>
        /// Exécute une action sur un SelectorInstance
        /// </summary>
        /// <param name="action">Action</param>
        /// <param name="referenceSequence">Référence de la séquence d'action</param>
        /// <param name="OrderSequence">Numéro d'ordre de l'action dans la séquence</param>
        /// <param name="selectorInstance">SelectorInstance</param>
        /// <param name="wfInstance">WorkflowInstance</param>
        /// <param name="values">Valeurs à modifier</param>
        /// <returns>Message de retour</returns>
        public async Task <HttpResponseMessageResult> ExecuteAction(ENT.Action action, long referenceSequence, int OrderSequence, SelectorInstance selectorInstance, WorkflowInstance wfInstance, IEnumerable <KeyValuePair <long, double> > values)
        {
            HttpResponseMessageResult res = new HttpResponseMessageResult()
            {
                IsSuccess = true
            };

            if (action.Type == ActionTypeEnum.Hardcode)
            {
                if (action.Name == Constant.ACTION_SPLIT_PRIMEUM)
                {
                    return(await ExecuteSplitPrimeum(referenceSequence, OrderSequence, selectorInstance, wfInstance));
                }
                if (action.Name == Constant.ACTION_SPLIT_COPY)
                {
                    return(await ExecuteSplitCopy(referenceSequence, OrderSequence, selectorInstance, wfInstance));
                }
                if (action.Name == Constant.ACTION_AGREGATE_PRIMEUM)
                {
                    return(await ExecuteAggregatePrimeum(referenceSequence, OrderSequence, selectorInstance, wfInstance));
                }
            }
            if (action.Type == ActionTypeEnum.Dynamic)
            {
                // TODO
            }

            return(res);
        }
Пример #4
0
        /// <summary>
        /// Récupére l'entité désignée par l'id en paramétre.
        /// </summary>
        /// <param name="id">Id de l'entité</param>
        /// <returns>Message de retour avec l'entité</returns>
        public async Task <DTO.Action> GetById(long id)
        {
            ENT.Action action = await ActionSequenceDomain.GetAction(id);

            DTO.Action dtoAction = null;
            if (action != null)
            {
                dtoAction = Mapper.Map <ENT.Action, DTO.Action>(action);
            }

            return(dtoAction);
        }
Пример #5
0
        /// <summary>
        /// Ajoute une action en base, indépendamment d'un workflow.
        /// </summary>
        /// <param name="action">Nouvelle action</param>
        /// <returns>Action enregistrée (avec son id)</returns>
        public async Task <DTO.Action> AddAction(DTO.Action action)
        {
            ENT.Action entAction = Mapper.Map <DTO.Action, ENT.Action>(action);

            return(Mapper.Map <ENT.Action, DTO.Action>(await ActionSequenceDomain.AddAction(entAction)));
        }