/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator .Eval(Context.Rules.CustomerDivisionAuthorization) .Eval(Context.Rules.IssuerDivisionHasPostingAccount) // Soll auf alle fälle ein Fehler sein! .Eval(Context.Rules.RecipientHasDefaultPostingAccount) // Für DEMO erst mal nur Warnung .Eval(Context.Rules.DocumentType) .Eval(Context.Rules.Voucher) .Eval(Context.Rules.LocalizationLanguageValid) .Eval(Context.Rules.PrintCountValid) .Eval(Context.Rules.BlacklistTerms); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); // Falls ein verletzung der Blacklist Regel vorliegt dann entferne den allgemeinen RuleState für den ResourceName CleanupRuleStateIfExists(BlacklistMessageId, ResourceName); }
protected override void EvaluateInternal() { Context.Rules = new RulesBundle(Context, this); var ruleResult = RulesEvaluator.Create() .Eval(Context.Rules.TransportIdRequired) .Evaluate(); MergeFromResult(ruleResult); if (!ruleResult.IsSuccess) { return; } var repository = ServiceProvider.GetService <IRepository <Olma.Transport> >(); Context.Transport = repository.FindAll() .Where(i => i.Id == Context.TransportId) .Include(i => i.Bids) .SingleOrDefault(); var transportNotFound = Context.Transport == null; AddMessage(transportNotFound, ResourceName, new TransportNotFound()); var transportExist = !transportNotFound; var requested = Context.Transport?.Status == Olma.TransportStatus.Requested; var allocated = Context.Transport?.Status == Olma.TransportStatus.Allocated; var invalid = transportExist && !(requested || allocated); AddMessage(invalid, ResourceName, Message); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator .Eval(Context.Rules.CustomerDivisionAuthorizationRule) .Eval(Context.Rules.DigitalCodePristine) .Eval(Context.Rules.TruckDriverNameRequired) .Eval(Context.Rules.LicensePlateRequired) .Eval(Context.Rules.LicensePlateCountryIdRequired) .Eval(Context.Rules.PositionsValid) .Eval(Context.Rules.MoreInformationValid) .Eval(Context.Rules.BlacklistTerms); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); // Add all Message from ruleResult MergeFromResult(ruleResult); // Add Message if ruleResult is not success AddMessage(!ruleResult.IsSuccess, ResourceName, Message); // Falls ein verletzung der Blacklist Regel vorliegt dann entferne den allgemeinen RuleState für den ResourceName CleanupRuleStateIfExists(BlacklistMessageId, ResourceName); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator // {{TODO}} var transportOffering = Context.TransportOffering; var divisionIds = Context.DivisionIds; if (transportOffering.WinningBid != null && !Context.DivisionIds.Contains(transportOffering.WinningBid.DivisionId)) { transportOffering.WinningBid = null; } transportOffering.Bids = transportOffering.Bids.Where(i => divisionIds.Contains(i.DivisionId)) .ToList(); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator.EvalIf(Context.Rules.DigitalCodeValidationRule, !string.IsNullOrEmpty(Context.Parent.DigitalCode)); rulesEvaluator //TODO AMINE //.Eval(Context.Rules.OrderResourceRule) //.Eval(Context.Rules.AuthorizationRule) .Eval(Context.Rules.RequiredLoadCarrierIdRule) .Eval(Context.Rules.RequiredLoadCarrierQuantityRule) .Eval(Context.Rules.ValidSourceAccountRule) .Eval(Context.Rules.ValidDestinationAccountRule) .Eval(Context.Rules.SufficientBalanceRule); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator .Eval(Context.Rules.VouchersSearchQueryRule) .Eval(Context.Rules.VouchersValidRule); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); // TODO AuthorizationRule // Der QueryFilter sorgt bereits für den einen Datenschutz Filter. // Die DAL Objekte können für die Autorisierung nicht herangezogen werden // foreach (var page in Context.PaginationResult.Data) // { // var getOperatorRule=new GetOperatorRule<ContextModel, Voucher>(Context, model => page); // // var authorizationRule = new AuthorizationRule< // Voucher, // ContextModel, // DivisionPermissionResource, // CanReadVoucherRequirement>(getOperatorRule, this); // // authorizationRule.Validate(RuleState); // } AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); Context.PostingAccountRepository = ServiceProvider.GetService <IRepository <Olma.PostingAccount> >(); Context.LoadCarrierRepository = ServiceProvider.GetService <IRepository <Olma.LoadCarrier> >(); Context.LmsAvail2deliRepository = ServiceProvider.GetService <IRepository <LmsAvail2deli> >(); Context.LmsQuali2palletRepository = ServiceProvider.GetService <IRepository <LmsQuali2pallet> >(); Context.Mapper = ServiceProvider.GetService <IMapper>(); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator // Not things to validate // Evaluate var ruleResult = rulesEvaluator.Evaluate(); Context.ExpressCode = Context.ExpressCodeResult; if (Context.ExpressCode == null) { RuleState.Add(ResourceName, new RuleState(Context.ExpressCode) { RuleStateItems = { new DigitalCodeInvalid() } }); } AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); var transportRepo = ServiceProvider.GetService <IRepository <Olma.Transport> >(); Context.Transport = transportRepo.FindAll() // TODO handle security seperately as we are disabling query filters to get both demand / supply order .IgnoreQueryFilters() .Include(i => i.WinningBid) .Include(i => i.OrderMatch) .Include(i => i.OrderMatch.Demand).ThenInclude(i => i.Detail) .Include(i => i.OrderMatch.Supply).ThenInclude(i => i.Detail) .SingleOrDefault(i => i.Id == Context.TransportId); // Assign rules to the Evaluator rulesEvaluator.Eval(Context.Rules.Required); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator // No need to validate var transportRepo = ServiceProvider.GetService <IRepository <Olma.Transport> >(); Context.Transport = transportRepo.FindAll() .IgnoreQueryFilters() .Include(i => i.WinningBid) .Include(i => i.Bids) .SingleOrDefault(i => i.Id == Context.TransportId); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Assign all values for Context Context.ServiceProvider = ServiceProvider; Context.Mapper = ServiceProvider.GetService <IMapper>(); Context.LmsOrderGroupRepo = ServiceProvider.GetService <IRepository <Olma.LmsOrder> >(); Context.OlmaLoadCarrierRepo = ServiceProvider.GetService <IRepository <Olma.LoadCarrier> >(); Context.AuthData = ServiceProvider.GetService <IAuthorizationDataService>(); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create(); // Assign rules to the Evaluator rulesEvaluator .Eval(Context.Rules.LongitudeValidRule) .Eval(Context.Rules.LatitudeValidRule) .Eval(Context.Rules.RadiusValidRule) .Eval(Context.Rules.MinStackHighValidRule) .Eval(Context.Rules.MaxStackHighValidRule); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); Context.PostingRequestRepository = ServiceProvider.GetService <IRepository <Olma.PostingRequest> >(); Context.BookingsRepository = ServiceProvider.GetService <IRepository <Bookings> >(); Context.LtmsReferenceLookupService = ServiceProvider.GetService <ILtmsReferenceLookupService>(); Context.Mapper = ServiceProvider.GetService <IMapper>(); Context.CacheOptions = ServiceProvider.GetService <IOptions <CacheOptions> >(); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator.Eval(Context.Rules.PostingAccountValidRule); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); AddMessage(Context.Parent.PostingAccountId != null && !Context.PostingAccountsBalances.Any(), ResourceName, new PostingAccountBalanceNotFound()); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); Context.AuthData = ServiceProvider.GetService <IAuthorizationDataService>(); Context.Mapper = ServiceProvider.GetService <IMapper>(); Context.CustomerDivisionRepo = ServiceProvider.GetService <IRepository <Olma.CustomerDivision> >(); Context.CustomerPartnerRepo = ServiceProvider.GetService <IRepository <Olma.CustomerPartner> >(); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator // No need to validate // Evaluate var ruleResult = rulesEvaluator.Evaluate(); var query = Context.VoucherSearchQuery; query = OrderingQuery(Context.VouchersSearchRequest, query); var projectedQuery = query.ProjectTo <Contracts.Models.Voucher>(Context.Mapper.ConfigurationProvider); var paginationResult = projectedQuery.ToPaginationResult(Context.VouchersSearchRequest); Fetch(paginationResult); Context.PaginationResult = paginationResult; AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Get DivisionIds Context.DivisionIds = ServiceProvider .GetService <IAuthorizationDataService>() .GetDivisionIds() .ToArray(); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator .Eval(Context.Rules.TransportValid) .Eval(Context.Rules.ModifyTransportOffering) .Eval(Context.Rules.MaskAddressIfNecessary); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator.Eval(Context.Rules.PostingAccountBalanceRule) .Eval(Context.Rules.PostingAccountConditionRule); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); var postingAccountsConditions = Context.Rules.PostingAccountConditionRule.Context.PostingAccountsConditions; var postingAccountsBalances = Context.Rules.PostingAccountBalanceRule.Context.PostingAccountsBalances; Context.PostingAccountsResult = new List <Contracts.Models.PostingAccount>(); foreach (var postingAccount in Context.PostingAccounts) { postingAccount.PickupConditions = postingAccountsConditions.Where(c => c.RefLtmsAccountId == postingAccount.RefLtmsAccountId && c.Type == PostingAccountConditionType.Pickup).ToList(); postingAccount.DropoffConditions = postingAccountsConditions.Where(c => c.RefLtmsAccountId == postingAccount.RefLtmsAccountId && c.Type == PostingAccountConditionType.DropOff).ToList(); postingAccount.DemandConditions = postingAccountsConditions.Where(c => c.RefLtmsAccountId == postingAccount.RefLtmsAccountId && c.Type == PostingAccountConditionType.Demand).ToList(); postingAccount.SupplyConditions = postingAccountsConditions.Where(c => c.RefLtmsAccountId == postingAccount.RefLtmsAccountId && c.Type == PostingAccountConditionType.Supply).ToList(); postingAccount.TransferConditions = postingAccountsConditions.Where(c => c.RefLtmsAccountId == postingAccount.RefLtmsAccountId && c.Type == PostingAccountConditionType.Transfer).ToList(); postingAccount.VoucherConditions = postingAccountsConditions.Where(c => c.RefLtmsAccountId == postingAccount.RefLtmsAccountId && c.Type == PostingAccountConditionType.Voucher).ToList(); postingAccount.Balances = postingAccountsBalances[postingAccount.Id]; Context.PostingAccountsResult.Add(postingAccount); } AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// First Validate IRule. If the rule is success the execute the action of the command /// </summary> /// <returns></returns> public async Task <IWrappedResponse> Execute() { // Evaluate the Rule when var result = RulesEvaluator.Create().Eval(Rule).Evaluate(); #region Security via Interface -> IValidationWithAuthorizationAbility if (Rule is IRuleWithAuthorizationSkill ruleWithAuthorizationSkill) { var rRule = ruleWithAuthorizationSkill.Authorization.ResourceRule; if (!rRule.IsValid()) { return(await Task.Factory.StartNew(() => new WrappedResponse() { ResultType = ResultType.NotFound, Errors = new[] { string.Empty } })); } var aRule = ruleWithAuthorizationSkill.Authorization.AuthorizationRule; if (!aRule.IsValid()) { return(await Task.Factory.StartNew(() => new WrappedResponse() { ResultType = ResultType.Forbidden, Errors = new[] { string.Empty } })); } } if (Rule is IRuleWithRessourceSkill ruleWithRessourceSkill) { var rRule = ruleWithRessourceSkill.ResourceRule; if (!rRule.IsValid()) { return(await Task.Factory.StartNew(() => new WrappedResponse() { ResultType = ResultType.NotFound, Errors = new[] { string.Empty } })); } } #endregion // if when valid -> return result of then or return the wrapped RuleState of when return(result.IsSuccess ? await Action(Rule) : result.WrappedResponse <TResultOfThen>()); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator .Eval(Context.Rules.BlacklistOther); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); Context.AuthData = ServiceProvider.GetService <IAuthorizationDataService>(); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator .Eval(Context.Rules.ExpressCodeAuthorizationRule); //Check issuer var customerIds = Context.AuthData.GetCustomerIds().ToList(); var divisionIds = Context.AuthData.GetDivisionIds().ToList(); if (customerIds.Count > 0 && Context.ExpressCode.IssuingCustomerId != null && !customerIds.Contains((int)Context.ExpressCode.IssuingCustomerId)) { RuleState.Add(ResourceName, new RuleState(Context.ExpressCode) { RuleStateItems = { new DigitalCodeIssuingCustomerDoesNotMatch() } }); } if (divisionIds.Count > 0 && Context.ExpressCode.IssuingDivisionId != null && !divisionIds.Contains((int)Context.ExpressCode.IssuingDivisionId)) { RuleState.Add(ResourceName, new RuleState(Context.ExpressCode) { RuleStateItems = { new DigitalCodeIssuingDivisionDoesNotMatch() } }); } if (Context.ExpressCode.ValidTo.HasValue && Context.ExpressCode.ValidTo < DateTime.Today) { RuleState.Add(ResourceName, new RuleState(Context.ExpressCode) { RuleStateItems = { new DigitalCodeExpired() } }); } //TODO: implement generic ExpiredRule // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); rulesEvaluator.Eval(Context.Rules.LoadCarrierReceiptResourceRule); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator // No need to validate deeper // Evaluate var ruleResult = rulesEvaluator.Evaluate(); MergeFromResult(ruleResult); }
protected override void EvaluateInternal() { Context.Rules = new RulesBundle(Context, this); var rulesEvaluator = RulesEvaluator.Create().CheckAllRules(); rulesEvaluator.Eval(Context.Rules.CustomerDivisionAuthorizationRule) .Eval(Context.Rules.LoadCarrierIdValidationRule) .Eval(Context.Rules.NumberOfLoadsValidationRule) .Eval(Context.Rules.LoadingLocationIdValidationRule) .Eval(Context.Rules.BaseLoadCarrierValidationRule); var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); Context.Mapper = ServiceProvider.GetService <IMapper>(); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator // Not Things to validate // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator // No need to validate Context.TransportOfferingsPaginationResult = CreateTransportOfferingPaginationResult(); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
public override void Evaluate() { var result = RulesEvaluator.Create() .Eval(new OrderGroupHasOrdersRule(OrderGroup)) .Eval(new OrderGroupHasOpenOrConfirmedOrdersRule(OrderGroup)) .Evaluate(); if (!result.IsSuccess) { RuleState.Add("OrderGroup", new RuleState(OrderGroup) { RuleStateItems = { new OrderGroupCancel() } }); } if (result is RuleWithStateResult stateResult) { RuleState.Merge(stateResult.State); } }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator .Eval(Context.Rules.CustomerDivisionAuthorizationRule) .Eval(Context.Rules.OrderSearchQueryRule) .Eval(Context.Rules.OrderSummaryValidRule); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); var repository = ServiceProvider.GetService <IRepository <Olma.Transport> >(); Context.TransportOffering = repository.GetById <Olma.Transport, TransportOffering>(Context.TransportId, true).Data; // Assign rules to the Evaluator rulesEvaluator.Eval(Context.Rules.Required); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
protected override void EvaluateInternal() { Context.Rules = new RulesBundle(Context, this); var ruleResult = RulesEvaluator.Create() .Eval(Context.Rules.RequiredSourceAccountIdRule) .Evaluate(); MergeFromResult(ruleResult); if (!ruleResult.IsSuccess) { return; } var postingAccountRepository = ServiceProvider.GetService <IRepository <Olma.PostingAccount> >(); Context.SourceAccount = postingAccountRepository.GetByKey(Context.SourceAccountId); AddMessage(Context.SourceAccount == null, ResourceName, Message); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); Context.ExpressCodeRepository = ServiceProvider.GetService <IRepository <Olma.ExpressCode> >(); Context.ExpressCodeUsageConditionRepository = ServiceProvider.GetService <IRepository <Olma.ExpressCodeUsageCondition> >(); Context.Mapper = ServiceProvider.GetService <IMapper>(); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator // Not things to validate // Evaluate var ruleResult = rulesEvaluator.Evaluate(); Context.ExpressCode = Context.ExpressCodeResult; if (Context.ExpressCode == null) { RuleState.Add(ResourceName, new RuleState(Context.ExpressCode) { RuleStateItems = { new DigitalCodeInvalid() } }); } else { if (Context.Parent.PrintType == PrintType.LoadCarrierReceiptDelivery && (Context.ExpressCodeUsageCondition == null || !Context.ExpressCodeUsageCondition.AcceptForDropOff)) { RuleState.Add(ResourceName, new RuleState(Context.ExpressCodeUsageCondition) { RuleStateItems = { new ReceivingUnplannedDeliveriesNotAllowed() } }); } } MergeFromResult(ruleResult); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator rulesEvaluator .Eval(Context.Rules.CustomerNameRequiredRule) .Eval(Context.Rules.PartnerDirectoryResourceRule) .Eval(Context.Rules.BlacklistTermsRule); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); // Falls ein verletzung der Blacklist Regel vorliegt dann entferne den allgemeinen RuleState für den ResourceName CleanupRuleStateIfExists(BlacklistMessageId, ResourceName); }
/// <summary> /// Internal Method for Evaluate /// </summary> protected override void EvaluateInternal() { // Initialized all rules. Instancing only takes place during execution, since otherwise the service scope has not yet been assigned Context.Rules = new RulesBundle(Context, this); // Initialized Evaluator var rulesEvaluator = RulesEvaluator.Create().StopEvaluateOnFirstInvalidRule(); // Assign rules to the Evaluator // No need to validate deeper var dbContext = ServiceProvider.GetService <OlmaDbContext>(); var exists = dbContext.LocalizationLanguages.Count(l => l.Id == Context.LocalizationId) > 0; AddMessage(!exists, ResourceName, Message); // Evaluate var ruleResult = rulesEvaluator.Evaluate(); AddMessage(!ruleResult.IsSuccess, ResourceName, Message); MergeFromResult(ruleResult); }
protected override void EvaluateInternal() { Context.Rules = new RulesBundle(Context, this); var ruleResult = RulesEvaluator.Create() .Eval(Context.Rules.RequiredDestinationAccountIdRule) .Evaluate(); MergeFromResult(ruleResult); if (!ruleResult.IsSuccess) { return; } var postingAccountRepository = ServiceProvider.GetService <IRepository <Olma.PostingAccount> >(); Context.DestinationAccount = postingAccountRepository .FindByCondition(a => a.Id == Context.DestinationAccountId && !a.IsDeleted) .IgnoreQueryFilters().SingleOrDefault(); //HACK to get RefLtmsAccountId of Destination Acccount AddMessage(Context.DestinationAccount == null, ResourceName, Message); }