public void TestLimitCount() { CastDate currentDate = new CastDate { Time = 1484953200000 }; ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator", null, @".\Data\RuleListBCTC.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate, null, null, null, null, null, null); reportData.RuleExplorer = new RuleBLLStub(); reportData.CurrentSnapshot = TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\TechCrit61009Violations.json"); var component = new RulesList(); Dictionary <string, string> config = new Dictionary <string, string> { { "PAR", "60011" }, { "COUNT", "2" } }; var table = component.Content(reportData, config); var expectedData = new List <string>(); expectedData.AddRange(new List <string> { "Criticality", "Weight", "Grade", "Technical Criterion", "Rule Name", "# Viol.", "Successful Checks" }); expectedData.AddRange(new List <string> { "µ", "9", "3.56", "Complexity - Algorithmic and Control Structure Complexity", "Action Mappings should have few forwards", "58", "3,117" }); expectedData.AddRange(new List <string> { "", "45", "3.56", "Complexity - Algorithmic and Control Structure Complexity", "Avoid accessing data by using the position and length", "123", "1,234" }); TestUtility.AssertTableContent(table, expectedData, 7, 3); }
private void ExecuteAddCommand() { var view = new AddRuleView(); view.Show(); Messenger.Default.Send(new NotificationMessageAction <WebRuleItem>(null, item => { DatabaseHelper.Open(); var row = DatabaseHelper.InsertOrIgnore <WebRuleItem>( "Name , Url , CatalogBegin , CatalogEnd , ChapterBegin , ChapterEnd , Replace , AuthorBegin , AuthorEnd , DescriptionBegin , DescriptionEnd , CoverBegin , CoverEnd", "@Name , @Url , @CatalogBegin , @CatalogEnd , @ChapterBegin , @ChapterEnd , @Replace , @AuthorBegin , @AuthorEnd , @DescriptionBegin , @DescriptionEnd , @CoverBegin , @CoverEnd", new SQLiteParameter("@Name", item.Name), new SQLiteParameter("@Url", item.Url), new SQLiteParameter("@CatalogBegin", item.CatalogBegin), new SQLiteParameter("@CatalogEnd", item.CatalogEnd), new SQLiteParameter("@ChapterBegin", item.ChapterBegin), new SQLiteParameter("@ChapterEnd", item.ChapterEnd), new SQLiteParameter("@Replace", item.Replace), new SQLiteParameter("@AuthorBegin", item.AuthorBegin), new SQLiteParameter("@AuthorEnd", item.AuthorEnd), new SQLiteParameter("@DescriptionBegin", item.DescriptionBegin), new SQLiteParameter("@DescriptionEnd", item.DescriptionEnd), new SQLiteParameter("@CoverBegin", item.CoverBegin), new SQLiteParameter("@CoverEnd", item.CoverEnd)); DatabaseHelper.Close(); if (row > 0) { RulesList.Add(item); view.Close(); } }), "rule"); }
/** * Core method for executing rules * It executes rules in the given list and stores attributes */ private Result RunRules(RulesList rulesList, string executionType) { // We need to capture result of each rule in the list var ruleResultAttributesList = new List <RuleResultAttributes>(); // Number of rules executed could be less, due to stoppin on failure int rulesExecutedCount = 0; foreach (var rule in rulesList) { bool runResult = false; Exception exception = null; // We do not want Exception to be propagated to caller, instead will will capture it try { runResult = rule.RuleMethod(EngineAttributes.Component, EngineAttributes.Output); } catch (Exception e) { exception = e; } finally { ruleResultAttributesList.Add(new RuleResultAttributes(rule, runResult, exception)); } rulesExecutedCount++; // Rule may fail due to global option or per-rule option if (exception != null && (EngineAttributes.StopOnException || rule.RuleAttributes.StopOnException)) { return(new Result(EngineAttributes, new RunResultAttributes(rulesList.Count, rulesExecutedCount, executionType, rule.RuleAttributes.Name, "Exception"), ruleResultAttributesList.ToArray())); } if (runResult == false && (EngineAttributes.StopOnRuleFailure || rule.RuleAttributes.StopOnRuleFailure)) { return(new Result(EngineAttributes, new RunResultAttributes(rulesList.Count, rulesExecutedCount, executionType, rule.RuleAttributes.Name, "RuleFailure"), ruleResultAttributesList.ToArray())); } } return(new Result(EngineAttributes, new RunResultAttributes(rulesList.Count, rulesExecutedCount, executionType, null, null), ruleResultAttributesList.ToArray())); }
/* * private void LoadDataAndDataBind(string sortExpression) * { * DataView view = DataSource.Expression.DefaultView; * view.Sort = sortExpression; * MyListView.DataSource = view; * MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("ExpressionId"); * MyListView.DataBind(); * } * */ /// <summary> /// Handles the ItemCommand event of the RulesList control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param> protected void RulesList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (String.Compare(e.CommandName, "DeleteExpression", StringComparison.OrdinalIgnoreCase) == 0) { //Notify RuleEditDialog for deletetion expression // delete expression int exprId = 0; if (Int32.TryParse(e.CommandArgument.ToString(), out exprId)) { if (_expression != null) { ExpressionDto.ExpressionRow expressionRow = _expression.Expression.FindByExpressionId(exprId); if (expressionRow != null) { expressionRow.Delete(); } } } //Delete corresponding FilterExpressionNodeCollection from list serialized collection ExpressionFilters.RemoveAt(e.Item.ItemIndex); } RulesList.DataSource = _expression; RulesList.DataBind(); ExpressionsPanel.Update(); }
private void SearchBySNAction(object o) { RulesList.Clear(); foreach (Rule rule in db.Rules.Where(r => r.RuleYear == SearchRuleYear && r.AnnualSerialNumber == SearchASN)) { RulesList.Add(rule); } }
private void ExecuteDeleteCommand(int index) { if (index < 0 || index >= RulesList.Count) { return; } DatabaseHelper.Open(); var row = DatabaseHelper.Delete <WebRuleItem>($"Id = {RulesList[index].Id}"); DatabaseHelper.Close(); if (row > 0) { RulesList.RemoveAt(index); } }
/// <summary> /// Initializes a new instance of the WebRulesViewModel class. /// </summary> public WebRulesViewModel() { DatabaseHelper.Open(); var reader = DatabaseHelper.Select <WebRuleItem>(); while (reader.Read()) { if (reader.HasRows) { RulesList.Add(new WebRuleItem(reader)); } } reader.Close(); DatabaseHelper.Close(); }
/** * Rule can have a common group and we can run rules part of a group */ public Result RunGroupRules(string groupName) { // Let's not do conversion inside the loop var groupList = new RulesList(); groupName = groupName.Trim().ToLower(); // If the rule's group matches the given group name, add to execution list foreach (var rule in RulesList) { if (rule.RuleAttributes.Group.Trim().ToLower() == groupName) { groupList.Add(rule); } } return(RunRules(groupList, groupName)); }
private void PrepareToAddNew() { Year = null; SelectedNation = null; SelectorName = null; MandatoryEntries = null; HeadquaetersEntries = null; InfantryEntries = null; ArtilleryEntries = null; ArmouredCarsEntries = null; TanksEntries = null; TransportsEntries = null; SelectedSelector = null; NationsList.Clear(); SelectorsList.Clear(); RulesList.Clear(); thisModel.EmptySelector.ResetData(); FunctionOnLoad(); }
private void SearchAction(object o) { RulesList.Clear(); tempList = new ObservableCollection <string>(); SelectedTopics = AddTreeItemsToList(TopicsList); tempList = new ObservableCollection <string>(); SelectedIssuers = AddTreeItemsToList(IssuersList); //foreach (string topic in SelectedTopics) //{ // foreach (Rule rule in db.Rules.Where(r => r.Topic.Equals(topic)).ToList()) // RulesList.Add(rule); //} foreach (Rule rule in db.Rules.Where(r => SelectedTopics.Contains(r.Topic.TopicName) && SelectedIssuers.Contains(r.Issuer.IssuerName))) { RulesList.Add(rule); } }
/** * Run rules with specified names only */ public Result RunNamedRules(string[] ruleNames) { // Convert ruleNames array into trimmed lower case, so that we don't do in inside the loop var namedList = new RulesList(); for (var i = 0; i < ruleNames.Length; i++) { ruleNames[i] = ruleNames[i].Trim().ToLower(); } // If the current rule is listed in the ruleNames array, add to execution list foreach (var rule in RulesList) { if (Array.Exists(ruleNames, name => name == rule.RuleAttributes.Name.Trim().ToLower())) { namedList.Add(rule); } } return(RunRules(namedList, string.Join(", ", ruleNames))); }
static Employee() { Rules = new RulesList<Employee>(); }
public void InitializeInstance() { Instance = new RulesList<Order>(); }
static Order() { Rules = new RulesList <Order>(); }
private void Save() { ObservableCollection <GameRule> SelectedRulesList = new ObservableCollection <GameRule>(RulesList.Where(w => (w.IsSelected == true))); if (SelectedSelector == null) { if (SelectedNation != null) { thisModel.AddSelector(SelectorName, Year, thisModel.MandatoryString, thisModel.HeadquartersString, thisModel.InfantryString, thisModel.ArmouredCarsString, thisModel.ArtilleryString, thisModel.TanksString, thisModel.TransportsString, SelectedNation.ID, SelectedRulesList); } } else { thisModel.UpdateSelector(SelectorName, Year, thisModel.MandatoryString, thisModel.HeadquartersString, thisModel.InfantryString, thisModel.ArmouredCarsString, thisModel.ArtilleryString, thisModel.TanksString, thisModel.TransportsString, SelectedNation.ID, SelectedRulesList); } PrepareToAddNew(); }
static Order() { Rules = new RulesList<Order>(); }
private void ConfirmChanges() { ObservableCollection <GameRule> SelectedRulesList = new ObservableCollection <GameRule>(RulesList.Where(w => (w.IsSelected == true))); thisModel.ConfirmChanges(Name, Range, Shots, Penetration, RequiresLoader, SelectedWeapon, WeaponsList, SelectedRulesList); if (SelectedWeapon != null) { Name = SelectedWeapon.Name; Range = SelectedWeapon.Range; Shots = SelectedWeapon.Shots; Penetration = SelectedWeapon.Penetration; RequiresLoader = SelectedWeapon.RequiresLoader; } else { PrepareToAddNew(); } }
static Employee() { Rules = new RulesList <Employee>(); }
public void InitializeInstance() { Instance = new RulesList <Order>(); }
private void ConfirmChanges() { ObservableCollection <GameRule> SelectedRulesList = new ObservableCollection <GameRule>(RulesList.Where(w => (w.IsSelected == true))); ObservableCollection <Weapon> SelectedWeaponsList = new ObservableCollection <Weapon>(WeaponsList.Where(w => (w.IsSelected == true))); int SelectedNationID = (SelectedNation != null) ? SelectedNation.ID : 0; thisModel.ConfirmChanges(Name, SelectedNationID, Type, Composition, WeaponDescription, ArmourClass, Inexperienced, Regular, Veteran, PointsInexp, PointsReg, PointsVet, BaseSize, MaxSize, SelectedUnit, UnitsList, SelectedRulesList, SelectedWeaponsList); if (SelectedUnit != null) { Name = SelectedUnit.Name; SelectedNation = NationsList.Where(x => x.ID == SelectedUnit.NationID).FirstOrDefault(); Type = SelectedUnit.Type; Composition = SelectedUnit.Composition; WeaponDescription = SelectedUnit.WeaponDescription; ArmourClass = SelectedUnit.ArmourClass; Inexperienced = SelectedUnit.Inexperienced; Regular = SelectedUnit.Regular; Veteran = SelectedUnit.Veteran; PointsInexp = SelectedUnit.PointsInexp; PointsReg = SelectedUnit.PointsReg; PointsVet = SelectedUnit.PointsVet; BaseSize = SelectedUnit.BaseSize; MaxSize = SelectedUnit.MaxSize; } else { PrepareToAddNew(); } }
// GET: Rules/RulesList // Show the list of all rules public ActionResult RulesList() { RulesList rulesList = new RulesList(); return(View(rulesList)); }