Пример #1
0
        internal RuleOperation(RuleOperationContext context, RuleAction action)
        {
            Requires.NotNull(context, nameof(context));

            this.Action = action;
            this.Context = context;
        }
Пример #2
0
 public ShowRule(ShowRule O)
 {
     this.DoWhatNow = O.DoWhatNow;
     this.First = O.First;
     this.Second = O.Second;
     this.UserSuppliedText = O.UserSuppliedText;
 }
Пример #3
0
        private SimpleRule(RuleDescriptor ruleDescriptor, RuleOperationContext ruleOperationContext, RuleAction ruleAction)
        {
            Requires.NotNull(ruleDescriptor, nameof(ruleDescriptor));
            Requires.NotNull(ruleOperationContext, nameof(ruleOperationContext));

            this.RuleDescriptor = ruleDescriptor;
            this.RuleOperationContext = new RuleOperation(ruleOperationContext, ruleAction);
        }
Пример #4
0
        internal SimpleRule(RuleDescriptor ruleDescriptor, List<Func<FormattingContext, bool>> contextFilters, RuleAction action)
        {
            Requires.NotNull(ruleDescriptor, nameof(ruleDescriptor));
            Requires.NotNull(contextFilters, nameof(contextFilters));

            this.RuleDescriptor = ruleDescriptor;
            this.RuleOperationContext = new RuleOperation(new RuleOperationContext(contextFilters), action);
        }
Пример #5
0
 /// <summary>
 /// Adds an action which will be execute before an object is moved when the condition is met
 /// </summary>
 /// <param name="condition">A predicate function which takes a
 /// thing and a proposed move as arguments and returns a boolean value.
 /// The rule will fire (will be violated) if the condition returns true</param>
 /// <param name="action">An action which will be invoked when the condition is met</param>
 public void AddAction(Func <ISpatial2D, IEnumerable <Point2D>, bool> condition, Action <UniversalGrid <T>, ISpatial2D> action, int?id = null)
 {
     Write(() =>
     {
         var idv       = id.HasValue ? id.Value : (_actions.Any() ? _actions.Max(r => r.Value.Id) + 1 : 1);
         _actions[idv] = new RuleAction <UniversalGrid <T> >(idv, action, condition);
     });
 }
Пример #6
0
 private void setDefaults()
 {
     rule = Rule.WI_ReplaceInstitution;
     ruleType = RuleType.WISA_Import;
     ruleAction = RuleAction.Modify;
     header = "Vervang Instellingsnummer";
     description = "Vergang het WISA instellingsnummer bij het importeren. Dit kan handig zijn als je accounts wil toevoegen in een niet officiele instelling.";
 }
Пример #7
0
 public void AddRuleAction(RuleAction ruleAction)
 {
     if (ruleAction == null)
     {
         throw new ArgumentException("Rule action must not be null.");
     }
     Actions.Add(ruleAction);
 }
 private void SetDefaults()
 {
     rule        = Rule.WI_MarkAsVirtual;
     ruleType    = RuleType.WISA_Import;
     ruleAction  = RuleAction.WorkDate;
     header      = "Markeer de school als virtueel";
     description = "Virtuele scholen kunnen een aangepaste werkdatum gebruiken. Dit helpt om inschrijvingen voor het volgende schooljaar in orde te brengen.";
 }
Пример #9
0
 public ShowRule()
 {
     DoWhatNow        = RuleAction.kIgnoreEp;
     First            = -1;
     Second           = -1;
     UserSuppliedText = string.Empty;
     RenumberAfter    = true;
 }
 private void SetDefaults()
 {
     rule        = Rule.AD_DontImportUser;
     ruleType    = RuleType.AD_Import;
     ruleAction  = RuleAction.Discard;
     header      = "Account niet Importeren";
     description = "Dit account niet importeren uit Active Directory.";
 }
Пример #11
0
 public static RuleProperties RuleProperties(
     string name,
     RuleFilter filter = default,
     RuleAction action = default) =>
 new RuleProperties(name, filter)
 {
     Action = action
 };
Пример #12
0
        public static Task <IEnumerable <ValidationError> > ValidateAsync(RuleAction action)
        {
            Guard.NotNull(action, nameof(action));

            var visitor = new RuleActionValidator();

            return(action.Accept(visitor));
        }
Пример #13
0
 private void setDefaults()
 {
     rule        = Rule.SS_NoSubGroups;
     ruleType    = RuleType.SS_Import;
     ruleAction  = RuleAction.Discard;
     header      = "Negeer Subgroepen";
     description = "Zorgt er voor dat de subgroepen van deze groep niet geimporteerd zal worden.";
 }
Пример #14
0
 private void SetDefaults()
 {
     rule        = Rule.SS_DiscardGroup;
     ruleType    = RuleType.SS_Import;
     ruleAction  = RuleAction.Discard;
     header      = "Negeer Groep";
     description = "Zorgt er voor dat deze groep niet geimporteerd zal worden.";
 }
 private void SetDefaults()
 {
     rule        = Rule.WI_DontImportUser;
     ruleType    = RuleType.WISA_Import;
     ruleAction  = RuleAction.Discard;
     header      = "Account niet Importeren";
     description = "Dit account niet importeren uit Wisa.";
 }
 private void SetDefaults()
 {
     rule        = Rule.WI_DontImportClass;
     ruleType    = RuleType.WISA_Import;
     ruleAction  = RuleAction.Discard;
     header      = "Klas niet Importeren";
     description = "Sla deze klas over bij het importeren uit Wisa.";
 }
Пример #17
0
 protected override void SetItems(IReadOnlyList <byte[]> data)
 {
     RuleId    = new Guid(data[0]);
     Tag       = BitConverter.ToUInt64(data[1], 0);
     KeyId     = new Guid(data[2]);
     Condition = Encoding.UTF8.GetString(data[3]);
     Action    = (RuleAction)BitConverter.ToInt32(data[4], 0);
     OwnerId   = new Guid(data[5]);
 }
Пример #18
0
        protected void Then <T>(Fact <T> fact, Func <FactContext <T>, Task> action)
            where T : class
        {
            var factDeclaration = _declarations.Get <T>(fact.Name);

            var ruleAction = new RuleAction <T>(factDeclaration, action);

            _actions.Add(ruleAction);
        }
Пример #19
0
        private bool IsGeneratingReply()
        {
            Rule       rule        = this.workItem.Rule;
            int        actionIndex = this.workItem.ActionIndex;
            RuleAction ruleAction  = rule.Actions[actionIndex];

            RuleAction.Type actionType = ruleAction.ActionType;
            return(actionType == RuleAction.Type.OP_REPLY || actionType == RuleAction.Type.OP_OOF_REPLY || actionType == RuleAction.Type.OP_DELETE);
        }
Пример #20
0
        internal /*for testing purposes*/ static bool IsBaselineWeakend(RuleAction baselineAction, RuleAction targetAction)
        {
            Debug.Assert(baselineAction != RuleAction.Default, "'Default' is invalid value for rule. RuleSet schema should prevent this");
            Debug.Assert(targetAction != RuleAction.Default, "'Default' is invalid value for rule. RuleSet schema should prevent this");

            int baselineStrictness = Array.IndexOf(ruleActionStrictnessOrder, baselineAction);
            int targetStrictness   = Array.IndexOf(ruleActionStrictnessOrder, targetAction);

            return(baselineStrictness > targetStrictness);
        }
Пример #21
0
        public static RuleDescription GetRuleDescription(AmqpRuleDescription amqpDescription)
        {
            Filter     filter     = MessageConverter.GetFilter(amqpDescription.Filter);
            RuleAction ruleAction = MessageConverter.GetRuleAction(amqpDescription.Action);

            return(new RuleDescription(filter)
            {
                Action = ruleAction
            });
        }
Пример #22
0
 public ShowRule([CanBeNull] XElement xmlSettings)
 {
     SetToDefaults();
     if (xmlSettings != null)
     {
         DoWhatNow        = xmlSettings.ExtractEnum("DoWhatNow", RuleAction.kIgnoreEp);
         First            = xmlSettings.ExtractInt("First", -1);
         Second           = xmlSettings.ExtractInt("Second", -1);
         UserSuppliedText = xmlSettings.ExtractString("Text");
     }
 }
Пример #23
0
 public ShowRule(XElement?xmlSettings) : this()
 {
     if (xmlSettings != null)
     {
         DoWhatNow        = xmlSettings.ExtractEnum("DoWhatNow", RuleAction.kIgnoreEp);
         First            = xmlSettings.ExtractInt("First", -1);
         Second           = xmlSettings.ExtractInt("Second", -1);
         UserSuppliedText = xmlSettings.ExtractString("Text");
         RenumberAfter    = xmlSettings.ExtractBool("RenumberAfter", true);
     }
 }
Пример #24
0
 internal AlertRuleData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, string namePropertiesName, string description, string provisioningState, bool isEnabled, RuleCondition condition, RuleAction action, IList <RuleAction> actions, DateTimeOffset?lastUpdatedOn) : base(id, name, resourceType, systemData, tags, location)
 {
     NamePropertiesName = namePropertiesName;
     Description        = description;
     ProvisioningState  = provisioningState;
     IsEnabled          = isEnabled;
     Condition          = condition;
     Action             = action;
     Actions            = actions;
     LastUpdatedOn      = lastUpdatedOn;
 }
Пример #25
0
        private void AreEqual(RuleAction exp, RuleAction act)
        {
            if (exp is RuleEmailAction)
            {
                var expEmailRuleAction = exp as RuleEmailAction;
                var actEmailRuleAction = act as RuleEmailAction;

                AreEqual(expEmailRuleAction.CustomEmails, actEmailRuleAction.CustomEmails);
                Assert.Equal(expEmailRuleAction.SendToServiceOwners, actEmailRuleAction.SendToServiceOwners);
            }
        }
Пример #26
0
 internal void ApplyRuleChange(RuleAction action)
 {
     if (action.Action == RuleActionType.Add)
     {
         ProgramRules.Add(action.Rule);
     }
     else
     {
         ProgramRules.Remove(action.Rule);
     }
 }
Пример #27
0
        public void Buy(BuyOptions options)
        {
            lock (syncRoot)
            {
                PauseTasks();
                try
                {
                    IRule       rule       = signalsService.Rules.Entries.FirstOrDefault(r => r.Name == options.Metadata.SignalRule);
                    RuleAction  ruleAction = rule?.Action ?? RuleAction.Default;
                    IPairConfig pairConfig = GetPairConfig(options.Pair);

                    bool arbitragePair = pairConfig.ArbitrageEnabled && pairConfig.ArbitrageSignalRules.Contains(options.Metadata.SignalRule);
                    if (arbitragePair)
                    {
                        Arbitrage arbitrage = Exchange.GetArbitrage(options.Pair, Config.Market, pairConfig.ArbitrageMarkets, pairConfig.ArbitrageType);
                        if (arbitrage.IsAssigned)
                        {
                            Arbitrage(new ArbitrageOptions(options.Pair, arbitrage, options.Metadata));
                        }
                    }
                    else
                    {
                        ITradingPair swappedPair = Account.GetTradingPairs().OrderBy(p => p.CurrentMargin).FirstOrDefault(tradingPair =>
                        {
                            IPairConfig tradingPairConfig = GetPairConfig(tradingPair.Pair);
                            return(tradingPairConfig.SellEnabled && tradingPairConfig.SwapEnabled && tradingPairConfig.SwapSignalRules != null &&
                                   tradingPairConfig.SwapSignalRules.Contains(options.Metadata.SignalRule) &&
                                   tradingPairConfig.SwapTimeout < (DateTimeOffset.Now - tradingPair.OrderDates.DefaultIfEmpty().Max()).TotalSeconds);
                        });

                        if (swappedPair != null)
                        {
                            Swap(new SwapOptions(swappedPair.Pair, options.Pair, options.Metadata));
                        }
                        else if (ruleAction == RuleAction.Default)
                        {
                            if (CanBuy(options, out string message))
                            {
                                tradingTimedTask.InitiateBuy(options);
                            }
                            else
                            {
                                loggingService.Debug(message);
                            }
                        }
                    }
                }
                finally
                {
                    ContinueTasks();
                }
            }
        }
Пример #28
0
 public void RemoveRuleAction(RuleAction ruleAction)
 {
     if (ruleAction == null)
     {
         throw new ArgumentException("Rule action must not be null.");
     }
     if (!Actions.Contains(ruleAction))
     {
         throw new ArgumentException("Rule action must already be present in the collection.");
     }
     Actions.Remove(ruleAction);
 }
        private RuleSet CreateVsRuleSet(int rules, string ruleSetFileName, RuleAction defaultAction = RuleAction.Warning)
        {
            RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules);

            ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction);
            ruleSet.FilePath = Path.Combine(this.VsRuleSetsDirectory, ruleSetFileName);
            ruleSet.WriteToFile(ruleSet.FilePath);

            this.temporaryFiles.AddFile(ruleSet.FilePath, false);

            return(ruleSet);
        }
        private RuleSet CreateUserSharedRuleSet(string ruleSetFileName, RuleAction defaultAction = RuleAction.Warning, int rules = DefaultNumberOfRules)
        {
            RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules);

            ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction);
            ruleSet.FilePath = Path.Combine(this.SolutionSharedRuleSetFolder, ruleSetFileName);
            ruleSet.WriteToFile(ruleSet.FilePath);

            this.temporaryFiles.AddFile(ruleSet.FilePath, false);

            return(ruleSet);
        }
Пример #31
0
        public static IRuleAction CompileAction(ActionElement element, IEnumerable <Declaration> declarations, IEnumerable <Declaration> dependencies)
        {
            var optimizer           = new ExpressionMultiParameterOptimizer <Action <IContext, object[]> >();
            var optimizedExpression = optimizer.CompactParameters(element.Expression, 1);
            var @delegate           = optimizedExpression.Compile();
            var fastDelegate        = Create(@delegate, element.Expression.Parameters.Count - 1);
            var tupleFactMap        = IndexMap.CreateMap(element.Imports, declarations);
            var dependencyIndexMap  = IndexMap.CreateMap(element.Imports, dependencies);
            var action = new RuleAction(element.Expression, fastDelegate, tupleFactMap, dependencyIndexMap, element.ActionTrigger);

            return(action);
        }
 public ActionResult Edit([Bind(Include = "Id,ActionName,ErrorMessage,RuleActionID,AssociatedActionTypeID")] RuleAction ruleaction, string UrlReferrer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ruleaction).State = EntityState.Modified;
         db.SaveChanges();
         //,Hash = "Action"
         return(RedirectToAction("Edit", "BusinessRule", new { id = ruleaction.RuleActionID }));
     }
     ViewBag.RuleActionID           = new SelectList(dbRuleAction.BusinessRules, "ID", "DisplayValue", ruleaction.RuleActionID);
     ViewBag.AssociatedActionTypeID = new SelectList(dbAssociatedActionType.ActionTypes, "ID", "DisplayValue", ruleaction.AssociatedActionTypeID);
     return(View(ruleaction));
 }
Пример #33
0
        public static RuleAction FromDomainModel(this RuleAction obj, AddRuleActionDomain domain, UserDomain user)
        {
            if (obj == null)
            {
                obj = new RuleAction();
            }

            obj.ActionId = domain.ActionId;
            obj.DeviceId = domain.DeviceId;
            obj.TenantId = user.TenantId;

            return(obj);
        }
        public static RuleDescription GetRuleDescription(AmqpRuleDescriptionCodec amqpDescription)
        {
            Filter     filter = GetFilter(amqpDescription.Filter);
            RuleAction action = GetRuleAction(amqpDescription.Action);

            RuleDescription description = new RuleDescription(filter)
            {
                Action = action,
                Name   = amqpDescription.RuleName
            };

            return(description);
        }
Пример #35
0
 private static RuleAction GetInverseAction(RuleAction action)
 {
     if (action == RuleAction.Delete)
     {
         return RuleAction.Space;
     }
     else if (action == RuleAction.Space)
     {
         return RuleAction.Delete;
     }
     else
     {
         return action;
     }
 }
Пример #36
0
        public ShowRule(XmlReader reader)
        {
            this.SetToDefaults();
            reader.Read();
            while (reader.Name != "Rule")
                return;

            reader.Read();
            while (reader.Name != "Rule")
            {
                if (reader.Name == "DoWhatNow")
                    this.DoWhatNow = (RuleAction) reader.ReadElementContentAsInt();
                else if (reader.Name == "First")
                    this.First = reader.ReadElementContentAsInt();
                else if (reader.Name == "Second")
                    this.Second = reader.ReadElementContentAsInt();
                else if (reader.Name == "Text")
                    this.UserSuppliedText = reader.ReadElementContentAsString();
                else
                    reader.ReadOuterXml();
            }
        }
 private RuleSet CreateProjectRuleSetWithInclude(int rules, string solutionRuleSetToInclude, IncludeType solutionIncludeType, RuleAction defaultAction)
 {
     return this.CreateProjectRuleSetWithIncludes(rules, solutionRuleSetToInclude, solutionIncludeType, defaultAction);
 }
        private RuleSet CreateUserSharedRuleSet(string ruleSetFileName, RuleAction defaultAction = RuleAction.Warning, int rules = DefaultNumberOfRules)
        {
            RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules);
            ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction);
            ruleSet.FilePath = Path.Combine(this.SolutionSharedRuleSetFolder, ruleSetFileName);
            ruleSet.WriteToFile(ruleSet.FilePath);

            this.temporaryFiles.AddFile(ruleSet.FilePath, false);

            return ruleSet;
        }
        private RuleSet CreateVsRuleSet(int rules, string ruleSetFileName, RuleAction defaultAction = RuleAction.Warning)
        {
            RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules);
            ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction);
            ruleSet.FilePath = Path.Combine(this.VsRuleSetsDirectory, ruleSetFileName);
            ruleSet.WriteToFile(ruleSet.FilePath);

            this.temporaryFiles.AddFile(ruleSet.FilePath, false);

            return ruleSet;
        }
Пример #40
0
 public Rule(string pattern, string scopeName)
 {
     Pattern = new Regex(pattern);
     ScopeName = scopeName;
     action = RuleAction.JustEmit;
 }
Пример #41
0
 public void SetAction(RuleAction action, string actionScopeName)
 {
     this.action = action;
     this.actionScopeName = actionScopeName;
 }
        private RuleSet CreateProjectRuleSetWithIncludes(int rules, string solutionRuleSetToInclude, IncludeType solutionIncludeType, RuleAction defaultAction = RuleAction.Warning, params string[] otherIncludes)
        {
            string projectRuleSetFilePath = Path.Combine(this.ProjectRuleSetFolder, Guid.NewGuid() + ".ruleset");
            string solutionInclude = solutionIncludeType == IncludeType.AsIs ? solutionRuleSetToInclude : PathHelper.CalculateRelativePath(projectRuleSetFilePath, solutionRuleSetToInclude);
            string[] includes = new[] { solutionInclude };
            if ((otherIncludes?.Length ?? 0) > 0)
            {
                includes = includes.Concat(otherIncludes).ToArray();
            }

            RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules, includes);
            ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction);
            ruleSet.FilePath = projectRuleSetFilePath;
            ruleSet.WriteToFile(ruleSet.FilePath);

            this.temporaryFiles.AddFile(ruleSet.FilePath, false);

            return ruleSet;
        }
        internal /*for testing purposes*/ static bool IsBaselineWeakend(RuleAction baselineAction, RuleAction targetAction)
        {
            Debug.Assert(baselineAction != RuleAction.Default, "'Default' is invalid value for rule. RuleSet schema should prevent this");
            Debug.Assert(targetAction != RuleAction.Default, "'Default' is invalid value for rule. RuleSet schema should prevent this");

            int baselineStrictness = Array.IndexOf(ruleActionStrictnessOrder, baselineAction);
            int targetStrictness = Array.IndexOf(ruleActionStrictnessOrder, targetAction);

            return baselineStrictness > targetStrictness;
        }
Пример #44
0
 public void SetToDefaults()
 {
     this.DoWhatNow = RuleAction.kIgnoreEp;
     this.First = this.Second = -1;
     this.UserSuppliedText = "";
 }
Пример #45
0
 public void SetAction(RuleAction action)
 {
     SetAction(action, ScopeName);
 }