コード例 #1
0
        private IList <IRequirement> getRequirements(IProcessExecutionContext executionContext, bool useCache)
        {
            try
            {
                IList <IRequirement> registeredRequirements = new List <IRequirement>();

                var requirements = DataConnector.GetAllRequirements(executionContext.DataService);

                var waiverRoles = DataConnector.GetAllRequirementWaiverRoles(executionContext.DataService);

                foreach (var requirement in requirements)
                {
                    ILogicEvaluatorType evaluatorType = this.EvaluatorTypeFactory.BuildEvaluatorType(executionContext, requirement.EvaluatorTypeId, useCache);

                    registeredRequirements.Add(
                        RequirementFactory.CreateRequirement(
                            executionContext,
                            requirement as IRecordPointer <Guid>,
                            requirement.Name,
                            requirement.TypeFlag ?? eRequirementTypeFlags.Validation,
                            requirement.TransactionTypeId,
                            evaluatorType,
                            requirement.RequirementParameters,
                            waiverRoles.Where(r => r.TransactionRequirementId != null && r.TransactionRequirementId.Id == requirement.Id).Select(r => r.RoleId),
                            useCache));
                }

                return(registeredRequirements);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ILogicEvaluator CreateEvaluator(IProcessExecutionContext executionContext, IRecordPointer <Guid> evaluatorId, ILogicEvaluatorType evaluatorType, string parameters, bool useCache = true)
        {
            string recordKey = CACHE_KEY + evaluatorId.Id.ToString();

            var cacheTimeout = useCache ? getCacheTimeout(executionContext) : null;

            useCache = useCache && executionContext.Cache != null && cacheTimeout != null;

            if (useCache && executionContext.Cache.Exists(recordKey))
            {
                return(executionContext.Cache.Get <ILogicEvaluator>(recordKey));
            }

            var serializedParameter = ParameterSerializer.CreateParamters(parameters);

            var evaluator = new LogicEvaluator(evaluatorType, serializedParameter);

            if (useCache)
            {
                executionContext.Cache.Add <ILogicEvaluator>(recordKey, evaluator, cacheTimeout.Value);
            }

            return(evaluator);
        }
コード例 #3
0
 public IRequirement CreateEvidenceRequirement(IProcessExecutionContext executionContext, IRecordPointer <Guid> requirementId, string name, eRequirementTypeFlags?requirementType, IRecordPointer <Guid> transactionTypeId, ILogicEvaluatorType evaluatorType, string parameters, IEnumerable <IRecordPointer <Guid> > waiverRoles, bool useCache = true)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
 internal protected LogicEvaluator(ILogicEvaluatorType type, ISerializedParameters parameters)
 {
     Type       = type;
     Parameters = parameters;
 }
コード例 #5
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;
            }
        }