コード例 #1
0
        protected override CaseEltInstance InternalBuild()
        {
            var result = new CaseEltInstance
            {
                ManualActivationRule = ManualActivationRule,
                RepetitionRule       = RepetitionRule,
                NbOccurrence         = Version,
                Type = CasePlanElementInstanceTypes.HUMANTASK
            };

            result.UpdatePerformerRef(PerformerRef);
            result.UpdateImplementation(Implementation);
            result.UpdateInputParameters(InputParameters);
            SeedCasePlanItem(result);
            return(result);
        }
コード例 #2
0
        private static CaseEltInstance BuildPlanItem(string id, string name, tPlanItemDefinition planItemDef, string casePlanInstanceId)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = planItemDef.name;
            }

            if (planItemDef is tHumanTask)
            {
                var humanTask = planItemDef as tHumanTask;
                List <tHumanTaskParameter> pars = new List <tHumanTaskParameter>();
                if (humanTask.implementation == CMMNConstants.UserTaskImplementations.WSHUMANTASK)
                {
                    var parameters = humanTask.extensionElements?.Any.FirstOrDefault(_ => _.Name == "cmg:parameters");
                    if (parameters != null)
                    {
                        var xmlSerializer = new XmlSerializer(typeof(tHumanTaskParameter), "https://github.com/simpleidserver/CaseManagement");
                        foreach (XmlNode child in parameters.ChildNodes)
                        {
                            using (var txtReader = new StringReader(child.OuterXml))
                            {
                                pars.Add((tHumanTaskParameter)xmlSerializer.Deserialize(txtReader));
                            }
                        }
                    }
                }

                var result = new CaseEltInstance
                {
                    Id           = CaseEltInstance.BuildId(casePlanInstanceId, id, 0),
                    EltId        = id,
                    NbOccurrence = 0,
                    Name         = name,
                    Type         = CasePlanElementInstanceTypes.HUMANTASK
                };
                result.UpdateFormId(humanTask.formId);
                result.UpdateImplementation(humanTask.implementation);
                result.UpdateInputParameters(pars.ToDictionary(kvp => kvp.key, kvp => kvp.value));
                result.UpdatePerformerRef(humanTask.performerRef);
                return(result);
            }

            if (planItemDef is tTask)
            {
                return(new CaseEltInstance
                {
                    Id = CaseEltInstance.BuildId(casePlanInstanceId, id, 0),
                    EltId = id,
                    NbOccurrence = 0,
                    Name = name,
                    Type = CasePlanElementInstanceTypes.EMPTYTASK
                });
            }

            if (planItemDef is tTimerEventListener)
            {
                var            timer      = planItemDef as tTimerEventListener;
                CMMNExpression expression = new CMMNExpression
                {
                    Body     = timer.timerExpression.Text.First(),
                    Language = timer.timerExpression.language
                };
                var result = new CaseEltInstance
                {
                    Id           = CaseEltInstance.BuildId(casePlanInstanceId, id, 0),
                    EltId        = id,
                    NbOccurrence = 0,
                    Name         = name,
                    Type         = CasePlanElementInstanceTypes.TIMER
                };
                result.UpdateTimerExpression(expression);
                return(result);
            }

            if (planItemDef is tMilestone)
            {
                return(new CaseEltInstance
                {
                    Id = CaseEltInstance.BuildId(casePlanInstanceId, id, 0),
                    EltId = id,
                    NbOccurrence = 0,
                    Name = name,
                    Type = CasePlanElementInstanceTypes.MILESTONE
                });
            }

            if (planItemDef is tStage)
            {
                return(BuildStage(id, planItemDef as tStage, casePlanInstanceId));
            }

            return(null);
        }