コード例 #1
0
ファイル: PMSRuleService.cs プロジェクト: mehabadi/HPMS
 public RuleWithPolicyData AddRule(string name, string ruleText, RuleType ruleType, PolicyId policyId, int order)
 {
     using (var scope = new TransactionScope())
     {
         var policy = policyRep.GetRuleBasePolicyById(policyId);
         var rule   = ruleService.AddRule(name, ruleText, ruleType, order);
         policy.AssignRule(rule);
         scope.Complete();
         return(new RuleWithPolicyData {
             Policy = policy, Rule = rule
         });;
     }
 }
コード例 #2
0
        public void BuildBulkAccount_Test()
        {
            const int accountCount = 10;

            // Not so random seed =>
            Random random = new Random(314);

            User son = new User {
                Role = UserRole.AccreditedParty, Email = "*****@*****.**", Name = "Sunny Bloggs", Username = "******"
            };
            User daughter = new User {
                Role = UserRole.AccreditedParty, Email = "*****@*****.**", Name = "Dorothy Bloggs", Username = "******"
            };

            List <Account> bulkAccounts = new List <Account>();

            for (int i = 0; i < accountCount; i++)
            {
                List <User> authorisedUsers = new List <User>();
                if (random.NextDouble() > 0.75)
                {
                    authorisedUsers.Add(son);
                }

                if (random.NextDouble() > 0.75)
                {
                    authorisedUsers.Add(daughter);
                }

                bulkAccounts.Add(new AccountFactory().BuildAccount(authorisedUsers, random.NextDouble()));
            }

            IRuleService ruleProcessor = GetInjection <IRuleService>();

            ruleProcessor.AddRule("And(Account.HasFileCount(fileCount:Int32:100),Not(Account.HasAccreditedParties()))=>Message.Publish(message:String:\"Account with large number of files, only Owner defined\")");
            ruleProcessor.AddRule("And(Not(Account.HasFileCount(fileCount:Int32:100)),Account.HasAccreditedParties())=>Message.Publish(message:String:\"Under utilised Account\")");

            ruleProcessor.Process(bulkAccounts);
        }
コード例 #3
0
 public bool Post(SkypeBotRule newRule)
 {
     return(_ruleService.AddRule(newRule));
 }