コード例 #1
0
        /// <summary>
        /// Returns all registered <see cref="IProcessStep"/> items in the system.
        /// </summary>
        /// <param name="executionContext"></param>
        /// <param name="cacheTimeout"></param>
        /// <returns></returns>
        private IList <IProcessStep> getProcessSteps(IProcessExecutionContext executionContext, bool useCache)
        {
            try
            {
                IList <IProcessStep> registeredSteps = new List <IProcessStep>();

                var steps = DataConnector.GetAllProcessSteps(executionContext.DataService);

                var stepChannels = DataConnector.GetAllStepAuthorizedChannels(executionContext.DataService);

                var stepTypes = DataConnector.GetAllStepTypes(executionContext.DataService);


                var stepRequirements = DataConnector.GetAllStepRequirements(executionContext.DataService);

                var alternateBranches = DataConnector.GetAlternateBranches(executionContext.DataService);

                var channels = PlatformService.GetChannels(executionContext, useCache);

                foreach (var step in steps)
                {
                    var stype = stepTypes.Where(r => r.Id == step.ProcessStepTypeId.Id).FirstOrDefault();

                    if (stype == null)
                    {
                        throw TransactionException.BuildException(TransactionException.ErrorCode.ProcessStepTypeNotFound);
                    }

                    var processStepType = this.ProcessStepTypeFactory.CreateStepType(
                        executionContext,
                        stype as IRecordPointer <Guid>,
                        stype.Name,
                        stype.SupportsConditionalBranching ?? false,
                        stype.AssemblyName,
                        stype.ClassName,
                        useCache);

                    var assignedChannels = new List <IChannel>();
                    foreach (var c in stepChannels.Where(r => r.ParentId != null && r.ChannelId != null && r.ParentId.Id == step.Id))
                    {
                        var channel = channels.Where(r => r.Id == c.ChannelId.Id).FirstOrDefault();
                        assignedChannels.Add(channel);
                    }

                    var assignedRequirements = stepRequirements.Where(r => r.ProcessStepId != null && r.ProcessStepId.Id == step.Id);


                    var assignedBranches = new List <IAlternateBranch>();
                    foreach (var b in alternateBranches.Where(r => r.ParentStepId != null && r.ParentStepId.Id == step.Id))
                    {
                        var branch = AlternateBranchFactory.CreateAlternateBranch(
                            executionContext,
                            b as IRecordPointer <Guid>,
                            b.Name,
                            b.EvaluationOrder,
                            b.ParentStepId,
                            b.SubsequentStepId,
                            b.EvaluatorTypeId,
                            b.EvaluationParameters,
                            useCache);
                        assignedBranches.Add(branch);
                    }


                    var processStep = ProcessStepFactory.CreateProcessStep(
                        executionContext,
                        step as IRecordPointer <Guid>,
                        step.Name,
                        step.TransactionProcessId,
                        processStepType,
                        step.StepParameters,
                        step.SubsequentStepId,
                        assignedBranches,
                        assignedChannels,
                        assignedRequirements,
                        useCache);

                    registeredSteps.Add(processStep);
                }

                return(registeredSteps);
            }
            catch (Exception)
            {
                throw;
            }
        }