Beispiel #1
0
        public static CasePlanInstanceAggregate New(string id, CasePlanAggregate caseplan, string nameIdentifier, Dictionary <string, string> parameters)
        {
            var result = new CasePlanInstanceAggregate();
            var roles  = caseplan.Roles.Select(_ => new CasePlanInstanceRole
            {
                EltId = _.EltId,
                Name  = _.Name
            }).ToList();
            var files = caseplan.Files.Select(_ =>
            {
                var result = new CaseEltInstance
                {
                    EltId = _.EltId,
                    Id    = CaseEltInstance.BuildId(id, _.EltId),
                    Name  = _.Name
                };
                result.UpdateDefinitionType(_.DefinitionType);
                return(result);
            }).ToList();
            var stage = CMMNParser.ExtractStage(caseplan.XmlContent, id);
            var evt   = new CasePlanInstanceCreatedEvent(Guid.NewGuid().ToString(), id, 0, nameIdentifier, roles, stage, DateTime.UtcNow, caseplan.CaseFileId, caseplan.AggregateId, caseplan.Name, parameters, files);

            result.Handle(evt);
            result.DomainEvents.Add(evt);
            return(result);
        }
Beispiel #2
0
        public CaseEltInstance TryCreateInstance(CaseEltInstance elt)
        {
            var evt = new CasePlanItemInstanceCreatedEvent(Guid.NewGuid().ToString(), AggregateId, Version, elt.Id, DateTime.UtcNow);

            Handle(evt);
            DomainEvents.Add(evt);
            var id = CaseEltInstance.BuildId(AggregateId, elt.EltId, elt.NbOccurrence + 1);

            return(GetCasePlanItem(id));
        }