コード例 #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);
        }
コード例 #2
0
        public static CasePlanAggregate New(string casePlanId, string name, string description, string caseOwner, string caseFileId, int caseFileVersion, string xmlContent, ICollection <CasePlanRole> roles, ICollection <CasePlanFileItem> files)
        {
            var result = new CasePlanAggregate();
            var evt    = new CasePlanAddedEvent(Guid.NewGuid().ToString(), BuildCasePlanIdentifier(casePlanId, caseFileVersion), caseFileVersion, casePlanId, name, description, caseOwner, caseFileId, DateTime.UtcNow, xmlContent, roles, files);

            result.Handle(evt);
            result.DomainEvents.Add(evt);
            return(result);
        }
コード例 #3
0
        public static CasePlanAggregate New(List <DomainEvent> evts)
        {
            var result = new CasePlanAggregate();

            foreach (var evt in evts)
            {
                result.Handle(evt);
            }

            return(result);
        }
コード例 #4
0
        public static CasePlanInstanceAggregate New(string id, CasePlanAggregate caseplan, ICollection <CasePlanInstanceRole> permissions, Dictionary <string, string> parameters)
        {
            var result = new CasePlanInstanceAggregate();
            var roles  = caseplan.Roles.Select(_ => new CasePlanInstanceRole
            {
                Id   = _.Id,
                Name = _.Name
            }).ToList();
            var files = caseplan.Files.Select(_ => new CaseFileItemInstance
            {
                DefinitionType = _.DefinitionType,
                EltId          = _.Id,
                Id             = CaseFileItemInstance.BuildId(id, _.Id),
                Name           = _.Name
            }).ToList();
            var stage = CMMNParser.ExtractStage(caseplan.XmlContent, id);
            var json  = stage.ToJson();
            var evt   = new CasePlanInstanceCreatedEvent(Guid.NewGuid().ToString(), id, 0, caseplan.CaseOwner, roles, permissions, json, DateTime.UtcNow, caseplan.AggregateId, caseplan.Name, parameters, files);

            result.Handle(evt);
            result.DomainEvents.Add(evt);
            return(result);
        }