private void ValidateCodeCannotContain(Rule rule, Project project) { foreach (var codeFile in project.CodeFiles) { var codeFilePath = Path.Combine(Path.GetDirectoryName(project.FilePath), codeFile); if (!File.Exists(codeFilePath)) { continue; } var fileLinesList = File.ReadAllLines(codeFilePath).ToList(); var matchedReferences = GetMatchingStrings(fileLinesList, rule.Reference); foreach (var mr in matchedReferences) { if (rule.ViolationKind == ViolationKind.Violation) { ViolationList.Add(new Rule() { RuleName = rule.RuleName, ProjectToCheck = project.Name, RuleType = RuleType.CodeCannotContain, Reference = rule.Reference }); } else if (rule.ViolationKind == ViolationKind.Warning) { WarningList.Add(new Rule() { RuleName = rule.RuleName, ProjectToCheck = project.Name, RuleType = RuleType.CodeCannotContain, Reference = rule.Reference }); } } } }
public ViolationList GetViolations() { ViolationList violationList = new ViolationList(); try { // Lock the tables. Debug.Assert(!ClientMarketData.AreLocksHeld); ClientMarketData.AccountLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.ObjectLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.PositionLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.RestrictionLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.SecurityLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.ViolationLock.AcquireReaderLock(CommonTimeout.LockWait); // Make sure the restriction exists. We need it to find the default settlement restriction. ClientMarketData.RestrictionRow restrictionRow = ClientMarketData.Restriction.FindByRestrictionId(this.restrictionId); if (restrictionRow == null) { throw new Exception(String.Format("Restriction {0} doesn't exist", restrictionId)); } foreach (ClientMarketData.ViolationRow violationRow in restrictionRow.GetViolationRows()) { violationList.Add(new Violation(violationRow)); } } finally { // Release the table locks. if (ClientMarketData.AccountLock.IsReaderLockHeld) { ClientMarketData.AccountLock.ReleaseReaderLock(); } if (ClientMarketData.ObjectLock.IsReaderLockHeld) { ClientMarketData.ObjectLock.ReleaseReaderLock(); } if (ClientMarketData.PositionLock.IsReaderLockHeld) { ClientMarketData.PositionLock.ReleaseReaderLock(); } if (ClientMarketData.RestrictionLock.IsReaderLockHeld) { ClientMarketData.RestrictionLock.ReleaseReaderLock(); } if (ClientMarketData.SecurityLock.IsReaderLockHeld) { ClientMarketData.SecurityLock.ReleaseReaderLock(); } if (ClientMarketData.ViolationLock.IsReaderLockHeld) { ClientMarketData.ViolationLock.ReleaseReaderLock(); } Debug.Assert(!ClientMarketData.AreLocksHeld); } return(violationList); }
private void btnAddViolation_Click(object sender, EventArgs e) { Violation violation = _car.createViolation(); Violation_AddEdit vAE = new Violation_AddEdit(violation); if (vAE.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _violationList.Add(violation); loadViolation(); } }
private void ValidateNotAllowedReferences(Rule rule, Project project) { var matchedReferences = GetMatchingStrings(project.References, rule.Reference); foreach (var mr in matchedReferences) { if (rule.ViolationKind == ViolationKind.Violation) { ViolationList.Add(new Rule() { RuleName = rule.RuleName, ProjectToCheck = project.Name, RuleType = RuleType.NotAllowed, Reference = mr }); } else if (rule.ViolationKind == ViolationKind.Warning) { WarningList.Add(new Rule() { RuleName = rule.RuleName, ProjectToCheck = project.Name, RuleType = RuleType.NotAllowed, Reference = mr }); } } }
private void ValidateMustIncludeRulesReferences(Rule rule, Project project) { var matchedReferences = GetMatchingStrings(project.References, rule.Reference).ToList(); if (matchedReferences.Count == 0) { if (rule.ViolationKind == ViolationKind.Violation) { ViolationList.Add(new Rule() { RuleName = rule.RuleName, ProjectToCheck = project.Name, RuleType = RuleType.MustInclude, Reference = rule.Reference }); } else if (rule.ViolationKind == ViolationKind.Warning) { WarningList.Add(new Rule() { RuleName = rule.RuleName, ProjectToCheck = project.Name, RuleType = RuleType.MustInclude, Reference = rule.Reference }); } } }