Beispiel #1
0
 public void InsertOrUpdateRule(int version, RuleDto rule)
 {
     _log.Info(m => m("Updating '{0}' rule", rule.RuleName));
     using (var context = _contextFactory.Create(_repositoryName))
     {
         using (var command = _commandFactory.CreateStoredProcedure("sp_InsertUpdateRule"))
         {
             command.AddParameter("ruleName", rule.RuleName);
             command.AddParameter("version", version);
             command.AddParameter("application", rule.Application);
             command.AddParameter("environment", rule.Environment);
             command.AddParameter("instance", rule.Instance);
             command.AddParameter("machine", rule.Machine);
             command.AddParameter("config", rule.ConfigurationData);
             context.ExecuteNonQuery(command);
         }
         using (var command = _commandFactory.CreateStoredProcedure("sp_DeleteRuleVariables"))
         {
             command.AddParameter("ruleName", rule.RuleName);
             command.AddParameter("version", version);
             context.ExecuteNonQuery(command);
         }
         if (rule.Variables != null && rule.Variables.Count > 0)
         {
             using (var command = _commandFactory.CreateStoredProcedure("sp_InsertRuleVariable"))
             {
                 command.AddParameter("ruleName", rule.RuleName);
                 command.AddParameter("version", version);
                 var variableName = command.AddParameter("variableName", SqlDbType.NVarChar, ParameterDirection.Input);
                 var variableValue = command.AddParameter("variableValue", SqlDbType.NVarChar, ParameterDirection.Input);
                 foreach (var variable in rule.Variables)
                 {
                     variableName.Value = variable.VariableName;
                     variableValue.Value = variable.SubstitutionValue;
                     context.ExecuteNonQuery(command);
                 }
             }
         }
     }
 }
Beispiel #2
0
 private Task CreateRule(IOwinContext context, int version, RuleDto rule)
 {
     var clientCredentials = context.Get<IClientCredentials>("ClientCredentials");
     _ruleData.AddRules(clientCredentials, version, new List<RuleDto> { rule });
     return Json(context, new PostResponseDto { Success = true });
 }
Beispiel #3
0
        public void InsertOrUpdateRule(int version, RuleDto rule)
        {
            CheckForUpdate();

            var ruleVersion = GetVersion(version, true);
            if (ruleVersion == null) return;

            ruleVersion.Rules.RemoveAll(r => string.Equals(r.RuleName, rule.RuleName, StringComparison.InvariantCultureIgnoreCase));
            ruleVersion.Rules.Add(rule);

            SaveChanges();
        }
Beispiel #4
0
        public void InsertOrUpdateRule(int version, RuleDto rule)
        {
            var ruleVersion = _rules.FirstOrDefault(r => r.Version == version);
            if (ruleVersion == null) return;

            ruleVersion.Rules.RemoveAll(r => string.Equals(r.RuleName, rule.RuleName, StringComparison.InvariantCultureIgnoreCase));
            ruleVersion.Rules.Add(rule);
        }
Beispiel #5
0
 private Task UpdateRule(IOwinContext context, int version, string name, RuleDto rule)
 {
     var clientCredentials = context.Get<IClientCredentials>("ClientCredentials");
     _ruleData.UpdateRule(clientCredentials, version, name, rule);
     return Json(context, new PostResponseDto { Success = true });
 }