Example #1
0
        public IAlternateBranch CreateAlternateBranch(IProcessExecutionContext executionContext, IRecordPointer <Guid> alternateBranchId, string name, int evaluationOrder, IRecordPointer <Guid> parentStepId, IRecordPointer <Guid> subsequentStepId, IRecordPointer <Guid> evaluatorTypeId, string parameters, bool useCache = true)
        {
            try
            {
                useCache = useCache && executionContext.Cache != null;

                string cacheKey = null;

                if (useCache)
                {
                    cacheKey = CACHE_KEY + alternateBranchId.ToString();

                    if (executionContext.Cache.Exists(cacheKey))
                    {
                        return(executionContext.Cache.Get <IAlternateBranch>(cacheKey));
                    }
                }

                if (evaluatorTypeId is null)
                {
                    throw new ArgumentNullException("evaluatorTypeId");
                }

                var evaluatorType = EvaluatorTypeFactory.BuildEvaluatorType(executionContext, evaluatorTypeId, useCache);
                var evaluator     = EvaluatorFactory.CreateEvaluator(executionContext, alternateBranchId, evaluatorType, parameters, useCache);

                var alternateBranch = new AlternateBranch(alternateBranchId.RecordType, alternateBranchId.Id, name, evaluationOrder, parentStepId, subsequentStepId, evaluator);

                if (useCache)
                {
                    var settings     = SettingsFactory.CreateSettings(executionContext.Settings);
                    var cacheTimeout = settings.AlternateBranchCacheTimeout;

                    executionContext.Cache.Add <IAlternateBranch>(cacheKey, alternateBranch, cacheTimeout.Value);
                }

                return(alternateBranch);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
        public IRequirement CreateRequirement(IProcessExecutionContext executionContext, IRecordPointer <Guid> requirementId, string name, eRequirementTypeFlags?requirementType, IRecordPointer <Guid> transactionTypeId, ILogicEvaluatorType evaluatorType, string parameters, IEnumerable <IRecordPointer <Guid> > waiverRoles, bool useCache = true)
        {
            try
            {
                useCache = useCache && executionContext.Cache != null;

                string cacheKey = null;

                if (useCache)
                {
                    cacheKey = CACHE_KEY + requirementId.ToString();

                    if (executionContext.Cache.Exists(cacheKey))
                    {
                        return(executionContext.Cache.Get <IRequirement>(cacheKey));
                    }
                }

                var evaluator   = EvaluatorFactory.CreateEvaluator(executionContext, requirementId, evaluatorType, parameters, useCache);
                var requirement = new Requirement(requirementId.RecordType, requirementId.Id, name, requirementType, transactionTypeId, evaluator, waiverRoles);

                if (useCache)
                {
                    var settings     = SettingsFactory.CreateSettings(executionContext.Settings);
                    var cacheTimeout = settings.TransactionRequirementCacheTimeout;

                    executionContext.Cache.Add <IRequirement>(cacheKey, requirement, cacheTimeout.Value);
                }

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