Esempio n. 1
0
 public bool BoundErrorWithProcess(Entities.User user, Entities.Process process, List <Entities.Error> errors, bool delete = false)
 {
     return(manager.HPService.BoundErrorWithProcess(user, process, errors.ToArray(), delete));
 }
Esempio n. 2
0
 public Entities.Process CreateNewProcess(Entities.User user, Entities.Process process)
 {
     return(manager.HPService.CreateNewProcess(user, process).GetResult());
 }
Esempio n. 3
0
 public bool BoundErrorWithProcess(Entities.User user, Entities.Process process, Entities.Error[] errors, bool delete)
 {
     return(base.Channel.BoundErrorWithProcess(user, process, errors, delete));
 }
Esempio n. 4
0
 public Entities.ResultValue <Entities.Process> CreateNewProcess(Entities.User user, Entities.Process process)
 {
     return(base.Channel.CreateNewProcess(user, process));
 }
        /// <summary>
        /// Execute the process action.
        /// </summary>
        /// <param name="process"></param>
        /// <param name="openingParticipant"></param>
        private void PerformAction(Entities.Process process, Entities.OpeningParticipant openingParticipant)         // TODO: Create custom syntax and parser for actions.
        {
            // Perform any actions based on the event.
            //oLecture.Actions.Add(new OpeningAction(oLecture, OpeningActionEvent.Accept, "Insert(Participant.Answers, Opening.Tags, Question.Caption=\"Title\");"));
            //oLecture.Actions.Add(new OpeningAction(oLecture, OpeningActionEvent.Unapply, "Delete(Opening.Tags, Tag.Key=\"Title\");"));

            var matches = _regex.Matches(process.Action);
            var opening = process.Opening;

            foreach (Match match in matches)
            {
                var method = match.Groups["method"];
                switch (method.Value)
                {
                case ("Add"):
                {
                    var source      = match.Groups["args"]?.Captures[0]?.Value?.Replace(", ", "");
                    var destination = match.Groups["args"]?.Captures[1]?.Value?.Replace(", ", "");
                    var condition   = match.Groups["args"]?.Captures[2]?.Value?.Replace(")", "");

                    if (source == "Participant.Answers")
                    {
                        if (!String.IsNullOrWhiteSpace(condition))
                        {
                            if (condition.StartsWith("Question.Caption"))
                            {
                                var cval    = condition.Substring(18, condition.Length - 19);
                                var answers = (
                                    from p in this.Context.Processes
                                    join oq in this.Context.OpeningQuestions on p.OpeningId equals oq.OpeningId
                                    join op in this.Context.OpeningParticipants on p.OpeningId equals op.OpeningId
                                    join oan in this.Context.OpeningAnswers on new { p.OpeningId, op.ParticipantId, oq.QuestionId } equals new { oan.OpeningId, oan.ParticipantId, oan.QuestionId }
                                    where p.Id == process.Id &&
                                    op.ParticipantId == openingParticipant.ParticipantId &&
                                    oq.Question.Caption == cval
                                    select oan.Text);

                                answers.ForEach(a =>
                                    {
                                        var tag = new Entities.OpeningTag(opening, cval, a);
                                        opening.Tags.Add(tag);
                                        this.Context.OpeningTags.Add(tag);
                                    });
                            }
                        }
                    }
                }
                break;

                case ("Delete"):
                {
                    var source    = match.Groups["args"]?.Captures[0]?.Value?.Replace(", ", "");
                    var condition = match.Groups["args"]?.Captures[1]?.Value?.Replace(")", "");

                    if (source == "Opening.Tags")
                    {
                        if (!String.IsNullOrWhiteSpace(condition))
                        {
                            if (condition.StartsWith("Tag.Key"))
                            {
                                var cval = condition.Substring(9, condition.Length - 10);
                                var tags = this.Context.OpeningTags.Where(ot => ot.OpeningId == opening.Id && ot.Key == cval).ToArray();

                                tags.ForEach(t => {
                                        opening.Tags.Remove(t);
                                        this.Context.OpeningTags.Remove(t);
                                    });
                            }
                        }
                    }
                }
                break;
                }
                match.NextMatch();
            }
        }
 public OpeningAction(Entities.Process process, Entities.OpeningParticipant openingParticipant)
 {
     this.Process            = process;
     this.OpeningParticipant = openingParticipant;
 }