示例#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 CasePlanInstanceAggregate New(string id, StageElementInstance stage, ICollection <CaseFileItemInstance> caseFiles)
        {
            var result = new CasePlanInstanceAggregate();
            var evt    = new CasePlanInstanceCreatedEvent(Guid.NewGuid().ToString(), id, 0, null, new List <CasePlanInstanceRole>(), new List <CasePlanInstanceRole>(), stage.ToJson(), DateTime.UtcNow, null, string.Empty, new Dictionary <string, string>(), caseFiles);

            result.Handle(evt);
            result.DomainEvents.Add(evt);
            return(result);
        }
示例#3
0
        public static CasePlanInstanceAggregate New(ICollection <DomainEvent> evts)
        {
            var result = new CasePlanInstanceAggregate();

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

            return(result);
        }
示例#4
0
        public override object Clone()
        {
            var result = new CasePlanInstanceAggregate
            {
                CasePlanId       = CasePlanId,
                AggregateId      = AggregateId,
                CreateDateTime   = CreateDateTime,
                Version          = Version,
                Name             = Name,
                State            = State,
                UpdateDateTime   = UpdateDateTime,
                CaseOwner        = CaseOwner,
                Files            = new ConcurrentBag <CasePlanInstanceFileItem>(Files.Select(_ => (CasePlanInstanceFileItem)_.Clone()).ToList()),
                Roles            = Roles.Select(_ => (CasePlanInstanceRole)_.Clone()).ToList(),
                WorkerTasks      = new ConcurrentBag <CasePlanInstanceWorkerTask>(WorkerTasks.Select(_ => (CasePlanInstanceWorkerTask)_.Clone()).ToArray()),
                ExecutionContext = (CasePlanInstanceExecutionContext)ExecutionContext.Clone(),
                Children         = new ConcurrentBag <BaseCaseEltInstance>(Children.Select(_ => (BaseCaseEltInstance)_.Clone()))
            };

            result.ExecutionContext.CasePlanInstance = result;
            return(result);
        }
示例#5
0
        public override object Clone()
        {
            var result = new CasePlanInstanceAggregate
            {
                CasePlanId                = CasePlanId,
                CaseFileId                = CaseFileId,
                AggregateId               = AggregateId,
                CreateDateTime            = CreateDateTime,
                Version                   = Version,
                Name                      = Name,
                State                     = State,
                UpdateDateTime            = UpdateDateTime,
                NameIdentifier            = NameIdentifier,
                Files                     = Files.Select(_ => (CasePlanInstanceFileItem)_.Clone()).ToList(),
                Roles                     = Roles.Select(_ => (CasePlanInstanceRole)_.Clone()).ToList(),
                WorkerTasks               = WorkerTasks.Select(_ => (CasePlanInstanceWorkerTask)_.Clone()).ToList(),
                ExecutionContextVariables = ExecutionContextVariables.ToDictionary(c => c.Key, c => c.Value),
                Children                  = Children.Select(_ => (CaseEltInstance)_.Clone()).ToList()
            };

            return(result);
        }
示例#6
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);
        }
示例#7
0
 public CasePlanInstanceExecutionContext(CasePlanInstanceAggregate casePlanInstance) : this()
 {
     CasePlanInstance = casePlanInstance;
 }